]>
Commit | Line | Data |
---|---|---|
b1f95a06 | 1 | /** @file\r |
2 | Provides application point extension for "C" style main funciton \r | |
3 | \r | |
a31bd33c | 4 | Copyright (c) 2009, Intel Corporation<BR>\r |
b1f95a06 | 5 | All rights reserved. This program and the accompanying materials\r |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT 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 | 39 | EFI_STATUS\r |
40 | EFIAPI\r | |
39157531 | 41 | ShellCEntryLib (\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 |