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