2 Provides application point extension for "C" style main funciton
4 Copyright (c) 2009 - 2010, 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 @param ImageHandle The image handle of the UEFI Application.
34 @param SystemTable A pointer to the EFI System Table.
36 @retval EFI_SUCCESS The application exited normally.
37 @retval Other An error occurred.
43 IN EFI_HANDLE ImageHandle
,
44 IN EFI_SYSTEM_TABLE
*SystemTable
48 EFI_SHELL_PARAMETERS_PROTOCOL
*EfiShellParametersProtocol
;
49 EFI_SHELL_INTERFACE
*EfiShellInterface
;
53 EfiShellParametersProtocol
= NULL
;
54 EfiShellInterface
= NULL
;
56 Status
= SystemTable
->BootServices
->OpenProtocol(ImageHandle
,
57 &gEfiShellParametersProtocolGuid
,
58 (VOID
**)&EfiShellParametersProtocol
,
61 EFI_OPEN_PROTOCOL_GET_PROTOCOL
63 if (!EFI_ERROR(Status
)) {
65 // use shell 2.0 interface
67 ReturnFromMain
= ShellAppMain (
68 EfiShellParametersProtocol
->Argc
,
69 EfiShellParametersProtocol
->Argv
73 // try to get shell 1.0 interface instead.
75 Status
= SystemTable
->BootServices
->OpenProtocol(ImageHandle
,
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
94 if (ReturnFromMain
== 0) {
97 return (EFI_UNSUPPORTED
);