]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.c
fix swap of pointers
[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
39157531 23INTN\r
b1f95a06 24EFIAPI \r
39157531 25ShellAppMain (\r
26 IN INTN Argc, \r
27 IN CHAR16 **Argv\r
28 );\r
b1f95a06 29\r
39157531 30/**\r
31 UEFI entry point for an application that will in turn call a C \r
32 style ShellAppMain function.\r
33\r
34 This application must have a function defined as follows:\r
35\r
36 INTN\r
37 EFIAPI\r
38 ShellAppMain (\r
39 IN INTN Argc, \r
40 IN CHAR16 **Argv\r
41 );\r
42**/\r
b1f95a06 43EFI_STATUS\r
44EFIAPI\r
39157531 45ShellCEntryLib (\r
b1f95a06 46 IN EFI_HANDLE ImageHandle,\r
47 IN EFI_SYSTEM_TABLE *SystemTable\r
39157531 48 )\r
49{\r
b1f95a06 50 INT32 ReturnFromMain;\r
51 EFI_SHELL_PARAMETERS_PROTOCOL *EfiShellParametersProtocol;\r
52 EFI_SHELL_INTERFACE *EfiShellInterface;\r
53 EFI_STATUS Status;\r
54\r
55 ReturnFromMain = -1;\r
56 EfiShellParametersProtocol = NULL;\r
57 EfiShellInterface = NULL;\r
58\r
59 Status = SystemTable->BootServices->OpenProtocol(ImageHandle, \r
60 &gEfiShellParametersProtocolGuid,\r
61 (VOID **)&EfiShellParametersProtocol,\r
62 ImageHandle,\r
63 NULL,\r
64 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
65 );\r
66 if (!EFI_ERROR(Status)) {\r
67 //\r
68 // use shell 2.0 interface\r
69 //\r
39157531 70 ReturnFromMain = ShellAppMain (\r
92fbbb5d 71 EfiShellParametersProtocol->Argc,\r
72 EfiShellParametersProtocol->Argv\r
39157531 73 );\r
b1f95a06 74 } else {\r
75 //\r
76 // try to get shell 1.0 interface instead.\r
77 //\r
78 Status = SystemTable->BootServices->OpenProtocol(ImageHandle, \r
79 &gEfiShellInterfaceGuid,\r
80 (VOID **)&EfiShellInterface,\r
81 ImageHandle,\r
82 NULL,\r
83 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
84 );\r
85 if (!EFI_ERROR(Status)) {\r
86 //\r
87 // use shell 1.0 interface\r
88 // \r
39157531 89 ReturnFromMain = ShellAppMain (\r
92fbbb5d 90 EfiShellInterface->Argc,\r
91 EfiShellInterface->Argv\r
39157531 92 );\r
b1f95a06 93 } else {\r
94 ASSERT(FALSE);\r
95 }\r
96 }\r
97 if (ReturnFromMain == 0) {\r
98 return (EFI_SUCCESS);\r
99 } else {\r
100 return (EFI_UNSUPPORTED);\r
101 }\r
102}\r