]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/UefiApplicationEntryPoint/ApplicationEntryPoint.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdePkg / Library / UefiApplicationEntryPoint / ApplicationEntryPoint.c
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 Entry point to UEFI Application.
17
18 This function is the entry point for a UEFI Application. This function must call
19 ProcessLibraryConstructorList(), ProcessModuleEntryPointList(), and ProcessLibraryDestructorList().
20 The return value from ProcessModuleEntryPointList() is returned.
21 If _gUefiDriverRevision is not zero and SystemTable->Hdr.Revision is less than _gUefiDriverRevison,
22 then return EFI_INCOMPATIBLE_VERSION.
23
24 @param ImageHandle The image handle of the UEFI Application.
25 @param SystemTable A pointer to the EFI System Table.
26
27 @retval EFI_SUCCESS The UEFI Application exited normally.
28 @retval EFI_INCOMPATIBLE_VERSION _gUefiDriverRevision is greater than SystemTable->Hdr.Revision.
29 @retval Other Return value from ProcessModuleEntryPointList().
30
31 **/
32 EFI_STATUS
33 EFIAPI
34 _ModuleEntryPoint (
35 IN EFI_HANDLE ImageHandle,
36 IN EFI_SYSTEM_TABLE *SystemTable
37 )
38 {
39 EFI_STATUS Status;
40
41 if (_gUefiDriverRevision != 0) {
42 //
43 // Make sure that the EFI/UEFI spec revision of the platform is >= EFI/UEFI spec revision of the application.
44 //
45 if (SystemTable->Hdr.Revision < _gUefiDriverRevision) {
46 return EFI_INCOMPATIBLE_VERSION;
47 }
48 }
49
50 //
51 // Call constructor for all libraries.
52 //
53 ProcessLibraryConstructorList (ImageHandle, SystemTable);
54
55 //
56 // Call the module's entry point
57 //
58 Status = ProcessModuleEntryPointList (ImageHandle, SystemTable);
59
60 //
61 // Process destructor for all libraries.
62 //
63 ProcessLibraryDestructorList (ImageHandle, SystemTable);
64
65 //
66 // Return the return status code from the driver entry point
67 //
68 return Status;
69 }
70
71 /**
72 Invokes the library destructors for all dependent libraries and terminates
73 the UEFI Application.
74
75 This function calls ProcessLibraryDestructorList() and the EFI Boot Service Exit()
76 with a status specified by Status.
77
78 @param Status Status returned by the application that is exiting.
79
80 **/
81 VOID
82 EFIAPI
83 Exit (
84 IN EFI_STATUS Status
85 )
86
87 {
88 ProcessLibraryDestructorList (gImageHandle, gST);
89
90 gBS->Exit (gImageHandle, Status, 0, NULL);
91 }
92
93 /**
94 Required by the EBC compiler and identical in functionality to _ModuleEntryPoint().
95
96 @param ImageHandle The image handle of the UEFI Application.
97 @param SystemTable A pointer to the EFI System Table.
98
99 @retval EFI_SUCCESS The UEFI Application exited normally.
100 @retval EFI_INCOMPATIBLE_VERSION _gUefiDriverRevision is greater than SystemTable->Hdr.Revision.
101 @retval Other Return value from ProcessModuleEntryPointList().
102
103 **/
104 EFI_STATUS
105 EFIAPI
106 EfiMain (
107 IN EFI_HANDLE ImageHandle,
108 IN EFI_SYSTEM_TABLE *SystemTable
109 )
110 {
111 return _ModuleEntryPoint (ImageHandle, SystemTable);
112 }