]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.c
comment repairs.
[mirror_edk2.git] / ShellPkg / Library / UefiShellCEntryLib / UefiShellCEntryLib.c
... / ...
CommitLineData
1/** @file\r
2 Provides application point extension for "C" style main funciton \r
3\r
4Copyright (c) 2009, Intel Corporation<BR>\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
21#include <Library/ShellCEntryLib.h>\r
22#include <Library/DebugLib.h>\r
23\r
24/**\r
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
28\r
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
37\r
38**/\r
39EFI_STATUS\r
40EFIAPI\r
41ShellCEntryLib (\r
42 IN EFI_HANDLE ImageHandle,\r
43 IN EFI_SYSTEM_TABLE *SystemTable\r
44 )\r
45{\r
46 INTN ReturnFromMain;\r
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
66 ReturnFromMain = ShellAppMain (\r
67 EfiShellParametersProtocol->Argc,\r
68 EfiShellParametersProtocol->Argv\r
69 );\r
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
85 ReturnFromMain = ShellAppMain (\r
86 EfiShellInterface->Argc,\r
87 EfiShellInterface->Argv\r
88 );\r
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