2009-06-16 02:23:19 +02:00
|
|
|
/** @file
|
2010-01-25 21:05:08 +01:00
|
|
|
Provides application point extension for "C" style main funciton
|
2009-06-16 02:23:19 +02:00
|
|
|
|
2013-05-15 22:39:04 +02:00
|
|
|
Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
|
2010-01-25 21:05:08 +01:00
|
|
|
This program and the accompanying materials
|
|
|
|
are licensed and made available under the terms and conditions of the BSD License
|
|
|
|
which accompanies this distribution. The full text of the license may be found at
|
|
|
|
http://opensource.org/licenses/bsd-license.php
|
2009-06-16 02:23:19 +02:00
|
|
|
|
2010-01-25 21:05:08 +01:00
|
|
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
2009-06-16 02:23:19 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
#include <Base.h>
|
|
|
|
|
|
|
|
#include <Protocol/SimpleFileSystem.h>
|
2010-01-11 22:49:04 +01:00
|
|
|
#include <Protocol/LoadedImage.h>
|
2009-06-16 02:23:19 +02:00
|
|
|
#include <Protocol/EfiShellInterface.h>
|
|
|
|
#include <Protocol/EfiShellParameters.h>
|
|
|
|
|
2009-06-23 23:40:29 +02:00
|
|
|
#include <Library/ShellCEntryLib.h>
|
2009-06-16 02:23:19 +02:00
|
|
|
#include <Library/DebugLib.h>
|
|
|
|
|
2009-06-17 10:02:21 +02:00
|
|
|
/**
|
2009-06-23 23:40:29 +02:00
|
|
|
UEFI entry point for an application that will in turn call the
|
|
|
|
ShellAppMain function which has parameters similar to a standard C
|
|
|
|
main function.
|
2009-06-17 10:02:21 +02:00
|
|
|
|
2009-06-23 23:40:29 +02:00
|
|
|
An application that uses UefiShellCEntryLib must have a ShellAppMain
|
|
|
|
function as prototyped in Include/Library/ShellCEntryLib.h.
|
|
|
|
|
2013-05-15 22:39:04 +02:00
|
|
|
Note that the Shell uses POSITIVE integers for error values, while UEFI
|
|
|
|
uses NEGATIVE values. If the application is to be used within a script,
|
|
|
|
it needs to return one of the SHELL_STATUS values defined in ShellBase.h.
|
|
|
|
|
2009-06-23 23:40:29 +02:00
|
|
|
@param ImageHandle The image handle of the UEFI Application.
|
|
|
|
@param SystemTable A pointer to the EFI System Table.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The application exited normally.
|
|
|
|
@retval Other An error occurred.
|
2009-06-17 10:02:21 +02:00
|
|
|
|
|
|
|
**/
|
2009-06-16 02:23:19 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
2009-06-17 10:02:21 +02:00
|
|
|
ShellCEntryLib (
|
2009-06-16 02:23:19 +02:00
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
2009-06-17 10:02:21 +02:00
|
|
|
)
|
|
|
|
{
|
2009-07-08 19:26:58 +02:00
|
|
|
INTN ReturnFromMain;
|
2009-06-16 02:23:19 +02:00
|
|
|
EFI_SHELL_PARAMETERS_PROTOCOL *EfiShellParametersProtocol;
|
|
|
|
EFI_SHELL_INTERFACE *EfiShellInterface;
|
|
|
|
EFI_STATUS Status;
|
|
|
|
|
|
|
|
ReturnFromMain = -1;
|
|
|
|
EfiShellParametersProtocol = NULL;
|
|
|
|
EfiShellInterface = NULL;
|
|
|
|
|
2010-01-25 21:05:08 +01:00
|
|
|
Status = SystemTable->BootServices->OpenProtocol(ImageHandle,
|
2009-06-16 02:23:19 +02:00
|
|
|
&gEfiShellParametersProtocolGuid,
|
|
|
|
(VOID **)&EfiShellParametersProtocol,
|
|
|
|
ImageHandle,
|
|
|
|
NULL,
|
|
|
|
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
2010-09-14 07:18:09 +02:00
|
|
|
);
|
2009-06-16 02:23:19 +02:00
|
|
|
if (!EFI_ERROR(Status)) {
|
|
|
|
//
|
|
|
|
// use shell 2.0 interface
|
|
|
|
//
|
2009-06-17 10:02:21 +02:00
|
|
|
ReturnFromMain = ShellAppMain (
|
2009-06-17 18:39:35 +02:00
|
|
|
EfiShellParametersProtocol->Argc,
|
|
|
|
EfiShellParametersProtocol->Argv
|
2010-09-14 07:18:09 +02:00
|
|
|
);
|
2009-06-16 02:23:19 +02:00
|
|
|
} else {
|
|
|
|
//
|
|
|
|
// try to get shell 1.0 interface instead.
|
|
|
|
//
|
2010-01-25 21:05:08 +01:00
|
|
|
Status = SystemTable->BootServices->OpenProtocol(ImageHandle,
|
2009-06-16 02:23:19 +02:00
|
|
|
&gEfiShellInterfaceGuid,
|
|
|
|
(VOID **)&EfiShellInterface,
|
|
|
|
ImageHandle,
|
|
|
|
NULL,
|
|
|
|
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
2010-09-14 07:18:09 +02:00
|
|
|
);
|
2009-06-16 02:23:19 +02:00
|
|
|
if (!EFI_ERROR(Status)) {
|
|
|
|
//
|
|
|
|
// use shell 1.0 interface
|
2010-01-25 21:05:08 +01:00
|
|
|
//
|
2009-06-17 10:02:21 +02:00
|
|
|
ReturnFromMain = ShellAppMain (
|
2009-06-17 18:39:35 +02:00
|
|
|
EfiShellInterface->Argc,
|
|
|
|
EfiShellInterface->Argv
|
2010-09-14 07:18:09 +02:00
|
|
|
);
|
2009-06-16 02:23:19 +02:00
|
|
|
} else {
|
|
|
|
ASSERT(FALSE);
|
|
|
|
}
|
|
|
|
}
|
2013-05-15 22:39:04 +02:00
|
|
|
return ReturnFromMain;
|
2009-06-16 02:23:19 +02:00
|
|
|
}
|