]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.c
Fix the issue that accessing for unaligned address break IPF
[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
a31bd33c 4Copyright (c) 2009, Intel Corporation<BR>\r
b1f95a06 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
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 40EFI_STATUS\r
41EFIAPI\r
39157531 42ShellCEntryLib (\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
56 Status = SystemTable->BootServices->OpenProtocol(ImageHandle, \r
57 &gEfiShellParametersProtocolGuid,\r
58 (VOID **)&EfiShellParametersProtocol,\r
59 ImageHandle,\r
60 NULL,\r
61 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
62 );\r
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
39157531 70 );\r
b1f95a06 71 } else {\r
72 //\r
73 // try to get shell 1.0 interface instead.\r
74 //\r
75 Status = SystemTable->BootServices->OpenProtocol(ImageHandle, \r
76 &gEfiShellInterfaceGuid,\r
77 (VOID **)&EfiShellInterface,\r
78 ImageHandle,\r
79 NULL,\r
80 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
81 );\r
82 if (!EFI_ERROR(Status)) {\r
83 //\r
84 // use shell 1.0 interface\r
85 // \r
39157531 86 ReturnFromMain = ShellAppMain (\r
92fbbb5d 87 EfiShellInterface->Argc,\r
88 EfiShellInterface->Argv\r
39157531 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