]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/UefiApplicationEntryPoint/ApplicationEntryPoint.c
MdePkg: Clean up source files
[mirror_edk2.git] / MdePkg / Library / UefiApplicationEntryPoint / ApplicationEntryPoint.c
CommitLineData
e386b444 1/** @file\r
2 Entry point library instance to a UEFI application.\r
3\r
9095d37b 4Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
19388d29 5This program and the accompanying materials\r
e386b444 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
58380e9c 8http://opensource.org/licenses/bsd-license.php.\r
e386b444 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
c7d265a9 15#include <Uefi.h>\r
c7d265a9 16#include <Library/UefiApplicationEntryPoint.h>\r
6517edbe
LG
17#include <Library/BaseLib.h>\r
18#include <Library/DebugLib.h>\r
c7d265a9 19#include <Library/UefiBootServicesTableLib.h>\r
e386b444 20\r
f734a10a 21\r
e386b444 22/**\r
28d3e14f 23 Entry point to UEFI Application.\r
e386b444 24\r
71871514 25 This function is the entry point for a UEFI Application. This function must call\r
26 ProcessLibraryConstructorList(), ProcessModuleEntryPointList(), and ProcessLibraryDestructorList().\r
27 The return value from ProcessModuleEntryPointList() is returned.\r
28 If _gUefiDriverRevision is not zero and SystemTable->Hdr.Revision is less than _gUefiDriverRevison,\r
29 then return EFI_INCOMPATIBLE_VERSION.\r
e386b444 30\r
58380e9c 31 @param ImageHandle The image handle of the UEFI Application.\r
32 @param SystemTable A pointer to the EFI System Table.\r
71871514 33\r
34 @retval EFI_SUCCESS The UEFI Application exited normally.\r
35 @retval EFI_INCOMPATIBLE_VERSION _gUefiDriverRevision is greater than SystemTable->Hdr.Revision.\r
36 @retval Other Return value from ProcessModuleEntryPointList().\r
e386b444 37\r
38**/\r
39EFI_STATUS\r
40EFIAPI\r
41_ModuleEntryPoint (\r
42 IN EFI_HANDLE ImageHandle,\r
43 IN EFI_SYSTEM_TABLE *SystemTable\r
44 )\r
45{\r
46 EFI_STATUS Status;\r
47\r
48 if (_gUefiDriverRevision != 0) {\r
49 //\r
50 // Make sure that the EFI/UEFI spec revision of the platform is >= EFI/UEFI spec revision of the application.\r
51 //\r
52 if (SystemTable->Hdr.Revision < _gUefiDriverRevision) {\r
53 return EFI_INCOMPATIBLE_VERSION;\r
54 }\r
55 }\r
56\r
57 //\r
58 // Call constructor for all libraries.\r
59 //\r
60 ProcessLibraryConstructorList (ImageHandle, SystemTable);\r
61\r
62 //\r
63 // Call the module's entry point\r
64 //\r
65 Status = ProcessModuleEntryPointList (ImageHandle, SystemTable);\r
66\r
67 //\r
68 // Process destructor for all libraries.\r
69 //\r
70 ProcessLibraryDestructorList (ImageHandle, SystemTable);\r
71\r
72 //\r
73 // Return the return status code from the driver entry point\r
74 //\r
75 return Status;\r
76}\r
77\r
71871514 78\r
e386b444 79/**\r
2281e7a9 80 Invokes the library destructors for all dependent libraries and terminates\r
9095d37b 81 the UEFI Application.\r
e386b444 82\r
71871514 83 This function calls ProcessLibraryDestructorList() and the EFI Boot Service Exit()\r
84 with a status specified by Status.\r
85\r
86 @param Status Status returned by the application that is exiting.\r
9095d37b 87\r
e386b444 88**/\r
89VOID\r
90EFIAPI\r
91Exit (\r
92 IN EFI_STATUS Status\r
93 )\r
94\r
95{\r
96 ProcessLibraryDestructorList (gImageHandle, gST);\r
97\r
98 gBS->Exit (gImageHandle, Status, 0, NULL);\r
99}\r
100\r
71871514 101\r
e386b444 102/**\r
9095d37b 103 Required by the EBC compiler and identical in functionality to _ModuleEntryPoint().\r
e386b444 104\r
71871514 105 @param ImageHandle The image handle of the UEFI Application.\r
106 @param SystemTable A pointer to the EFI System Table.\r
e386b444 107\r
71871514 108 @retval EFI_SUCCESS The UEFI Application exited normally.\r
109 @retval EFI_INCOMPATIBLE_VERSION _gUefiDriverRevision is greater than SystemTable->Hdr.Revision.\r
110 @retval Other Return value from ProcessModuleEntryPointList().\r
e386b444 111\r
112**/\r
113EFI_STATUS\r
114EFIAPI\r
115EfiMain (\r
116 IN EFI_HANDLE ImageHandle,\r
117 IN EFI_SYSTEM_TABLE *SystemTable\r
118 )\r
119{\r
120 return _ModuleEntryPoint (ImageHandle, SystemTable);\r
121}\r