]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.c
add meta-data to describe module behavior
[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
21#include <Library/DebugLib.h>\r
22\r
23INT32 \r
24EFIAPI \r
25main(\r
26 UINTN Argc, \r
27 CHAR16 **Argv\r
28);\r
29\r
30EFI_STATUS\r
31EFIAPI\r
32ShellCEntryLib(\r
33 IN EFI_HANDLE ImageHandle,\r
34 IN EFI_SYSTEM_TABLE *SystemTable\r
35 ){\r
36 INT32 ReturnFromMain;\r
37 EFI_SHELL_PARAMETERS_PROTOCOL *EfiShellParametersProtocol;\r
38 EFI_SHELL_INTERFACE *EfiShellInterface;\r
39 EFI_STATUS Status;\r
40\r
41 ReturnFromMain = -1;\r
42 EfiShellParametersProtocol = NULL;\r
43 EfiShellInterface = NULL;\r
44\r
45 Status = SystemTable->BootServices->OpenProtocol(ImageHandle, \r
46 &gEfiShellParametersProtocolGuid,\r
47 (VOID **)&EfiShellParametersProtocol,\r
48 ImageHandle,\r
49 NULL,\r
50 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
51 );\r
52 if (!EFI_ERROR(Status)) {\r
53 //\r
54 // use shell 2.0 interface\r
55 //\r
56 ReturnFromMain = main(EfiShellInterface->Argc, EfiShellInterface->Argv);\r
57 } else {\r
58 //\r
59 // try to get shell 1.0 interface instead.\r
60 //\r
61 Status = SystemTable->BootServices->OpenProtocol(ImageHandle, \r
62 &gEfiShellInterfaceGuid,\r
63 (VOID **)&EfiShellInterface,\r
64 ImageHandle,\r
65 NULL,\r
66 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
67 );\r
68 if (!EFI_ERROR(Status)) {\r
69 //\r
70 // use shell 1.0 interface\r
71 // \r
72 ReturnFromMain = main(EfiShellParametersProtocol->Argc, EfiShellParametersProtocol->Argv);\r
73 } else {\r
74 ASSERT(FALSE);\r
75 }\r
76 }\r
77 if (ReturnFromMain == 0) {\r
78 return (EFI_SUCCESS);\r
79 } else {\r
80 return (EFI_UNSUPPORTED);\r
81 }\r
82}\r