2 Provides application point extension for "C" style main funciton
4 Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include <Protocol/SimpleFileSystem.h>
18 #include <Protocol/LoadedImage.h>
19 #include <Protocol/EfiShellInterface.h>
20 #include <Protocol/EfiShellParameters.h>
22 #include <Library/ShellCEntryLib.h>
23 #include <Library/DebugLib.h>
26 UEFI entry point for an application that will in turn call the
27 ShellAppMain function which has parameters similar to a standard C
30 An application that uses UefiShellCEntryLib must have a ShellAppMain
31 function as prototyped in Include/Library/ShellCEntryLib.h.
33 Note that the Shell uses POSITIVE integers for error values, while UEFI
34 uses NEGATIVE values. If the application is to be used within a script,
35 it needs to return one of the SHELL_STATUS values defined in ShellBase.h.
37 @param ImageHandle The image handle of the UEFI Application.
38 @param SystemTable A pointer to the EFI System Table.
40 @retval EFI_SUCCESS The application exited normally.
41 @retval Other An error occurred.
47 IN EFI_HANDLE ImageHandle
,
48 IN EFI_SYSTEM_TABLE
*SystemTable
52 EFI_SHELL_PARAMETERS_PROTOCOL
*EfiShellParametersProtocol
;
53 EFI_SHELL_INTERFACE
*EfiShellInterface
;
57 EfiShellParametersProtocol
= NULL
;
58 EfiShellInterface
= NULL
;
60 Status
= SystemTable
->BootServices
->OpenProtocol(ImageHandle
,
61 &gEfiShellParametersProtocolGuid
,
62 (VOID
**)&EfiShellParametersProtocol
,
65 EFI_OPEN_PROTOCOL_GET_PROTOCOL
67 if (!EFI_ERROR(Status
)) {
69 // use shell 2.0 interface
71 ReturnFromMain
= ShellAppMain (
72 EfiShellParametersProtocol
->Argc
,
73 EfiShellParametersProtocol
->Argv
77 // try to get shell 1.0 interface instead.
79 Status
= SystemTable
->BootServices
->OpenProtocol(ImageHandle
,
80 &gEfiShellInterfaceGuid
,
81 (VOID
**)&EfiShellInterface
,
84 EFI_OPEN_PROTOCOL_GET_PROTOCOL
86 if (!EFI_ERROR(Status
)) {
88 // use shell 1.0 interface
90 ReturnFromMain
= ShellAppMain (
91 EfiShellInterface
->Argc
,
92 EfiShellInterface
->Argv
98 return ReturnFromMain
;