]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/UefiApplicationEntryPoint/ApplicationEntryPoint.c
Import some Pei and Dxe related instances for MdePkg.
[mirror_edk2.git] / MdePkg / Library / UefiApplicationEntryPoint / ApplicationEntryPoint.c
1 /** @file
2 Entry point library instance to a UEFI application.
3
4 Copyright (c) 2007, Intel Corporation<BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 //
16 // Include common header file for this module.
17 //
18 #include "CommonHeader.h"
19
20 /**
21 Enrty point to UEFI application.
22
23 @param ImageHandle ImageHandle of the loaded driver.
24 @param SystemTable Pointer to the EFI System Table.
25
26 @retval EFI_SUCCESS One or more of the drivers returned a success code.
27 @retval !EFI_SUCESS The return status from the last driver entry point in the list.
28
29 **/
30 EFI_STATUS
31 EFIAPI
32 _ModuleEntryPoint (
33 IN EFI_HANDLE ImageHandle,
34 IN EFI_SYSTEM_TABLE *SystemTable
35 )
36 {
37 EFI_STATUS Status;
38
39 if (_gUefiDriverRevision != 0) {
40 //
41 // Make sure that the EFI/UEFI spec revision of the platform is >= EFI/UEFI spec revision of the application.
42 //
43 if (SystemTable->Hdr.Revision < _gUefiDriverRevision) {
44 return EFI_INCOMPATIBLE_VERSION;
45 }
46 }
47
48 //
49 // Call constructor for all libraries.
50 //
51 ProcessLibraryConstructorList (ImageHandle, SystemTable);
52
53 //
54 // Call the module's entry point
55 //
56 Status = ProcessModuleEntryPointList (ImageHandle, SystemTable);
57
58 //
59 // Process destructor for all libraries.
60 //
61 ProcessLibraryDestructorList (ImageHandle, SystemTable);
62
63 //
64 // Return the return status code from the driver entry point
65 //
66 return Status;
67 }
68
69 /**
70 Invoke the destuctors of all libraries and call gBS->Exit
71 to return control to firmware core.
72
73 @param Status Status returned by the application that is exiting.
74
75 @retval VOID
76
77 **/
78 VOID
79 EFIAPI
80 Exit (
81 IN EFI_STATUS Status
82 )
83
84 {
85 ProcessLibraryDestructorList (gImageHandle, gST);
86
87 gBS->Exit (gImageHandle, Status, 0, NULL);
88 }
89
90 /**
91 Enrty point wrapper of UEFI Application.
92
93 @param ImageHandle ImageHandle of the loaded driver.
94 @param SystemTable Pointer to the EFI System Table.
95
96 @retval EFI_SUCCESS One or more of the drivers returned a success code.
97 @retval !EFI_SUCESS The return status from the last driver entry point in the list.
98
99 **/
100 EFI_STATUS
101 EFIAPI
102 EfiMain (
103 IN EFI_HANDLE ImageHandle,
104 IN EFI_SYSTEM_TABLE *SystemTable
105 )
106 {
107 return _ModuleEntryPoint (ImageHandle, SystemTable);
108 }