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