]>
Commit | Line | Data |
---|---|---|
b1f95a06 | 1 | /** @file\r |
1e6e84c7 | 2 | Provides application point extension for "C" style main funciton\r |
b1f95a06 | 3 | \r |
3a888f2a | 4 | Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r |
1e6e84c7 | 5 | 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 | |
b1f95a06 | 9 | \r |
1e6e84c7 | 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 | |
b1f95a06 | 12 | \r |
13 | **/\r | |
14 | \r | |
15 | #include <Base.h>\r | |
16 | \r | |
17 | #include <Protocol/SimpleFileSystem.h>\r | |
b3011f40 | 18 | #include <Protocol/LoadedImage.h>\r |
b1f95a06 | 19 | #include <Protocol/EfiShellInterface.h>\r |
20 | #include <Protocol/EfiShellParameters.h>\r | |
21 | \r | |
322016e5 | 22 | #include <Library/ShellCEntryLib.h>\r |
b1f95a06 | 23 | #include <Library/DebugLib.h>\r |
24 | \r | |
39157531 | 25 | /**\r |
322016e5 | 26 | UEFI entry point for an application that will in turn call the\r |
27 | ShellAppMain function which has parameters similar to a standard C\r | |
28 | main function.\r | |
39157531 | 29 | \r |
322016e5 | 30 | An application that uses UefiShellCEntryLib must have a ShellAppMain\r |
31 | function as prototyped in Include/Library/ShellCEntryLib.h.\r | |
32 | \r | |
33 | @param ImageHandle The image handle of the UEFI Application.\r | |
34 | @param SystemTable A pointer to the EFI System Table.\r | |
35 | \r | |
36 | @retval EFI_SUCCESS The application exited normally.\r | |
37 | @retval Other An error occurred.\r | |
39157531 | 38 | \r |
39157531 | 39 | **/\r |
b1f95a06 | 40 | EFI_STATUS\r |
41 | EFIAPI\r | |
39157531 | 42 | ShellCEntryLib (\r |
b1f95a06 | 43 | IN EFI_HANDLE ImageHandle,\r |
44 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
39157531 | 45 | )\r |
46 | {\r | |
9eb53ac3 | 47 | INTN ReturnFromMain;\r |
b1f95a06 | 48 | EFI_SHELL_PARAMETERS_PROTOCOL *EfiShellParametersProtocol;\r |
49 | EFI_SHELL_INTERFACE *EfiShellInterface;\r | |
50 | EFI_STATUS Status;\r | |
51 | \r | |
52 | ReturnFromMain = -1;\r | |
53 | EfiShellParametersProtocol = NULL;\r | |
54 | EfiShellInterface = NULL;\r | |
55 | \r | |
1e6e84c7 | 56 | Status = SystemTable->BootServices->OpenProtocol(ImageHandle,\r |
b1f95a06 | 57 | &gEfiShellParametersProtocolGuid,\r |
58 | (VOID **)&EfiShellParametersProtocol,\r | |
59 | ImageHandle,\r | |
60 | NULL,\r | |
61 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
a405b86d | 62 | );\r |
b1f95a06 | 63 | if (!EFI_ERROR(Status)) {\r |
64 | //\r | |
65 | // use shell 2.0 interface\r | |
66 | //\r | |
39157531 | 67 | ReturnFromMain = ShellAppMain (\r |
92fbbb5d | 68 | EfiShellParametersProtocol->Argc,\r |
69 | EfiShellParametersProtocol->Argv\r | |
a405b86d | 70 | );\r |
b1f95a06 | 71 | } else {\r |
72 | //\r | |
73 | // try to get shell 1.0 interface instead.\r | |
74 | //\r | |
1e6e84c7 | 75 | Status = SystemTable->BootServices->OpenProtocol(ImageHandle,\r |
b1f95a06 | 76 | &gEfiShellInterfaceGuid,\r |
77 | (VOID **)&EfiShellInterface,\r | |
78 | ImageHandle,\r | |
79 | NULL,\r | |
80 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
a405b86d | 81 | );\r |
b1f95a06 | 82 | if (!EFI_ERROR(Status)) {\r |
83 | //\r | |
84 | // use shell 1.0 interface\r | |
1e6e84c7 | 85 | //\r |
39157531 | 86 | ReturnFromMain = ShellAppMain (\r |
92fbbb5d | 87 | EfiShellInterface->Argc,\r |
88 | EfiShellInterface->Argv\r | |
a405b86d | 89 | );\r |
b1f95a06 | 90 | } else {\r |
91 | ASSERT(FALSE);\r | |
92 | }\r | |
93 | }\r | |
94 | if (ReturnFromMain == 0) {\r | |
95 | return (EFI_SUCCESS);\r | |
96 | } else {\r | |
97 | return (EFI_UNSUPPORTED);\r | |
98 | }\r | |
99 | }\r |