2 Provides application point extension for "C" style main function
4 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include <Protocol/SimpleFileSystem.h>
12 #include <Protocol/LoadedImage.h>
13 #include <Protocol/EfiShellInterface.h>
14 #include <Protocol/ShellParameters.h>
16 #include <Library/ShellCEntryLib.h>
17 #include <Library/DebugLib.h>
20 UEFI entry point for an application that will in turn call the
21 ShellAppMain function which has parameters similar to a standard C
24 An application that uses UefiShellCEntryLib must have a ShellAppMain
25 function as prototyped in Include/Library/ShellCEntryLib.h.
27 Note that the Shell uses POSITIVE integers for error values, while UEFI
28 uses NEGATIVE values. If the application is to be used within a script,
29 it needs to return one of the SHELL_STATUS values defined in Protocol/Shell.h.
31 @param ImageHandle The image handle of the UEFI Application.
32 @param SystemTable A pointer to the EFI System Table.
34 @retval EFI_SUCCESS The application exited normally.
35 @retval Other An error occurred.
41 IN EFI_HANDLE ImageHandle
,
42 IN EFI_SYSTEM_TABLE
*SystemTable
46 EFI_SHELL_PARAMETERS_PROTOCOL
*EfiShellParametersProtocol
;
47 EFI_SHELL_INTERFACE
*EfiShellInterface
;
51 EfiShellParametersProtocol
= NULL
;
52 EfiShellInterface
= NULL
;
54 Status
= SystemTable
->BootServices
->OpenProtocol (
56 &gEfiShellParametersProtocolGuid
,
57 (VOID
**)&EfiShellParametersProtocol
,
60 EFI_OPEN_PROTOCOL_GET_PROTOCOL
62 if (!EFI_ERROR (Status
)) {
64 // use shell 2.0 interface
66 ReturnFromMain
= ShellAppMain (
67 EfiShellParametersProtocol
->Argc
,
68 EfiShellParametersProtocol
->Argv
72 // try to get shell 1.0 interface instead.
74 Status
= SystemTable
->BootServices
->OpenProtocol (
76 &gEfiShellInterfaceGuid
,
77 (VOID
**)&EfiShellInterface
,
80 EFI_OPEN_PROTOCOL_GET_PROTOCOL
82 if (!EFI_ERROR (Status
)) {
84 // use shell 1.0 interface
86 ReturnFromMain
= ShellAppMain (
87 EfiShellInterface
->Argc
,
88 EfiShellInterface
->Argv
95 return ReturnFromMain
;