]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.c
Restore Include/Library/ShellCEntryLib.h. Cleanup function and
[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
4Copyright (c) 2009, Intel Corporation\r
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 24INTN\r
b1f95a06 25EFIAPI \r
39157531 26ShellAppMain (\r
27 IN INTN Argc, \r
28 IN CHAR16 **Argv\r
29 );\r
b1f95a06 30\r
39157531 31/**\r
322016e5 32 UEFI entry point for an application that will in turn call the\r
33 ShellAppMain function which has parameters similar to a standard C\r
34 main function.\r
39157531 35\r
322016e5 36 An application that uses UefiShellCEntryLib must have a ShellAppMain\r
37 function as prototyped in Include/Library/ShellCEntryLib.h.\r
38\r
39 @param ImageHandle The image handle of the UEFI Application.\r
40 @param SystemTable A pointer to the EFI System Table.\r
41\r
42 @retval EFI_SUCCESS The application exited normally.\r
43 @retval Other An error occurred.\r
39157531 44\r
39157531 45**/\r
b1f95a06 46EFI_STATUS\r
47EFIAPI\r
39157531 48ShellCEntryLib (\r
b1f95a06 49 IN EFI_HANDLE ImageHandle,\r
50 IN EFI_SYSTEM_TABLE *SystemTable\r
39157531 51 )\r
52{\r
b1f95a06 53 INT32 ReturnFromMain;\r
54 EFI_SHELL_PARAMETERS_PROTOCOL *EfiShellParametersProtocol;\r
55 EFI_SHELL_INTERFACE *EfiShellInterface;\r
56 EFI_STATUS Status;\r
57\r
58 ReturnFromMain = -1;\r
59 EfiShellParametersProtocol = NULL;\r
60 EfiShellInterface = NULL;\r
61\r
62 Status = SystemTable->BootServices->OpenProtocol(ImageHandle, \r
63 &gEfiShellParametersProtocolGuid,\r
64 (VOID **)&EfiShellParametersProtocol,\r
65 ImageHandle,\r
66 NULL,\r
67 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
68 );\r
69 if (!EFI_ERROR(Status)) {\r
70 //\r
71 // use shell 2.0 interface\r
72 //\r
39157531 73 ReturnFromMain = ShellAppMain (\r
92fbbb5d 74 EfiShellParametersProtocol->Argc,\r
75 EfiShellParametersProtocol->Argv\r
39157531 76 );\r
b1f95a06 77 } else {\r
78 //\r
79 // try to get shell 1.0 interface instead.\r
80 //\r
81 Status = SystemTable->BootServices->OpenProtocol(ImageHandle, \r
82 &gEfiShellInterfaceGuid,\r
83 (VOID **)&EfiShellInterface,\r
84 ImageHandle,\r
85 NULL,\r
86 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
87 );\r
88 if (!EFI_ERROR(Status)) {\r
89 //\r
90 // use shell 1.0 interface\r
91 // \r
39157531 92 ReturnFromMain = ShellAppMain (\r
92fbbb5d 93 EfiShellInterface->Argc,\r
94 EfiShellInterface->Argv\r
39157531 95 );\r
b1f95a06 96 } else {\r
97 ASSERT(FALSE);\r
98 }\r
99 }\r
100 if (ReturnFromMain == 0) {\r
101 return (EFI_SUCCESS);\r
102 } else {\r
103 return (EFI_UNSUPPORTED);\r
104 }\r
105}\r