2 Provides application point extension for "C" style main funciton
4 Copyright (c) 2009, Intel Corporation
5 All rights reserved. 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/EfiShellInterface.h>
19 #include <Protocol/EfiShellParameters.h>
21 #include <Library/ShellCEntryLib.h>
22 #include <Library/DebugLib.h>
32 UEFI entry point for an application that will in turn call the
33 ShellAppMain function which has parameters similar to a standard C
36 An application that uses UefiShellCEntryLib must have a ShellAppMain
37 function as prototyped in Include/Library/ShellCEntryLib.h.
39 @param ImageHandle The image handle of the UEFI Application.
40 @param SystemTable A pointer to the EFI System Table.
42 @retval EFI_SUCCESS The application exited normally.
43 @retval Other An error occurred.
49 IN EFI_HANDLE ImageHandle
,
50 IN EFI_SYSTEM_TABLE
*SystemTable
54 EFI_SHELL_PARAMETERS_PROTOCOL
*EfiShellParametersProtocol
;
55 EFI_SHELL_INTERFACE
*EfiShellInterface
;
59 EfiShellParametersProtocol
= NULL
;
60 EfiShellInterface
= NULL
;
62 Status
= SystemTable
->BootServices
->OpenProtocol(ImageHandle
,
63 &gEfiShellParametersProtocolGuid
,
64 (VOID
**)&EfiShellParametersProtocol
,
67 EFI_OPEN_PROTOCOL_GET_PROTOCOL
69 if (!EFI_ERROR(Status
)) {
71 // use shell 2.0 interface
73 ReturnFromMain
= ShellAppMain (
74 EfiShellParametersProtocol
->Argc
,
75 EfiShellParametersProtocol
->Argv
79 // try to get shell 1.0 interface instead.
81 Status
= SystemTable
->BootServices
->OpenProtocol(ImageHandle
,
82 &gEfiShellInterfaceGuid
,
83 (VOID
**)&EfiShellInterface
,
86 EFI_OPEN_PROTOCOL_GET_PROTOCOL
88 if (!EFI_ERROR(Status
)) {
90 // use shell 1.0 interface
92 ReturnFromMain
= ShellAppMain (
93 EfiShellInterface
->Argc
,
94 EfiShellInterface
->Argv
100 if (ReturnFromMain
== 0) {
101 return (EFI_SUCCESS
);
103 return (EFI_UNSUPPORTED
);