]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/UefiApplicationEntryPoint/ApplicationEntryPoint.c
Code Scrub the common includes in 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 #include <Uefi.h>
16 #include <Library/UefiApplicationEntryPoint.h>
17 #include <Library/UefiBootServicesTableLib.h>
18
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 **/
76 VOID
77 EFIAPI
78 Exit (
79 IN EFI_STATUS Status
80 )
81
82 {
83 ProcessLibraryDestructorList (gImageHandle, gST);
84
85 gBS->Exit (gImageHandle, Status, 0, NULL);
86 }
87
88 /**
89 Enrty point wrapper of UEFI Application.
90
91 @param ImageHandle ImageHandle of the loaded driver.
92 @param SystemTable Pointer to the EFI System Table.
93
94 @retval EFI_SUCCESS One or more of the drivers returned a success code.
95 @retval !EFI_SUCESS The return status from the last driver entry point in the list.
96
97 **/
98 EFI_STATUS
99 EFIAPI
100 EfiMain (
101 IN EFI_HANDLE ImageHandle,
102 IN EFI_SYSTEM_TABLE *SystemTable
103 )
104 {
105 return _ModuleEntryPoint (ImageHandle, SystemTable);
106 }