]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.c
comment repairs.
[mirror_edk2.git] / ShellPkg / Library / UefiShellCEntryLib / UefiShellCEntryLib.c
CommitLineData
b1f95a06 1/** @file\r
2 Provides application point extension for "C" style main funciton \r
3\r
a31bd33c 4Copyright (c) 2009, Intel Corporation<BR>\r
b1f95a06 5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include <Base.h>\r
16\r
17#include <Protocol/SimpleFileSystem.h>\r
18#include <Protocol/EfiShellInterface.h>\r
19#include <Protocol/EfiShellParameters.h>\r
20\r
322016e5 21#include <Library/ShellCEntryLib.h>\r
b1f95a06 22#include <Library/DebugLib.h>\r
23\r
39157531 24/**\r
322016e5 25 UEFI entry point for an application that will in turn call the\r
26 ShellAppMain function which has parameters similar to a standard C\r
27 main function.\r
39157531 28\r
322016e5 29 An application that uses UefiShellCEntryLib must have a ShellAppMain\r
30 function as prototyped in Include/Library/ShellCEntryLib.h.\r
31\r
32 @param ImageHandle The image handle of the UEFI Application.\r
33 @param SystemTable A pointer to the EFI System Table.\r
34\r
35 @retval EFI_SUCCESS The application exited normally.\r
36 @retval Other An error occurred.\r
39157531 37\r
39157531 38**/\r
b1f95a06 39EFI_STATUS\r
40EFIAPI\r
39157531 41ShellCEntryLib (\r
b1f95a06 42 IN EFI_HANDLE ImageHandle,\r
43 IN EFI_SYSTEM_TABLE *SystemTable\r
39157531 44 )\r
45{\r
9eb53ac3 46 INTN ReturnFromMain;\r
b1f95a06 47 EFI_SHELL_PARAMETERS_PROTOCOL *EfiShellParametersProtocol;\r
48 EFI_SHELL_INTERFACE *EfiShellInterface;\r
49 EFI_STATUS Status;\r
50\r
51 ReturnFromMain = -1;\r
52 EfiShellParametersProtocol = NULL;\r
53 EfiShellInterface = NULL;\r
54\r
55 Status = SystemTable->BootServices->OpenProtocol(ImageHandle, \r
56 &gEfiShellParametersProtocolGuid,\r
57 (VOID **)&EfiShellParametersProtocol,\r
58 ImageHandle,\r
59 NULL,\r
60 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
61 );\r
62 if (!EFI_ERROR(Status)) {\r
63 //\r
64 // use shell 2.0 interface\r
65 //\r
39157531 66 ReturnFromMain = ShellAppMain (\r
92fbbb5d 67 EfiShellParametersProtocol->Argc,\r
68 EfiShellParametersProtocol->Argv\r
39157531 69 );\r
b1f95a06 70 } else {\r
71 //\r
72 // try to get shell 1.0 interface instead.\r
73 //\r
74 Status = SystemTable->BootServices->OpenProtocol(ImageHandle, \r
75 &gEfiShellInterfaceGuid,\r
76 (VOID **)&EfiShellInterface,\r
77 ImageHandle,\r
78 NULL,\r
79 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
80 );\r
81 if (!EFI_ERROR(Status)) {\r
82 //\r
83 // use shell 1.0 interface\r
84 // \r
39157531 85 ReturnFromMain = ShellAppMain (\r
92fbbb5d 86 EfiShellInterface->Argc,\r
87 EfiShellInterface->Argv\r
39157531 88 );\r
b1f95a06 89 } else {\r
90 ASSERT(FALSE);\r
91 }\r
92 }\r
93 if (ReturnFromMain == 0) {\r
94 return (EFI_SUCCESS);\r
95 } else {\r
96 return (EFI_UNSUPPORTED);\r
97 }\r
98}\r