]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/UefiApplicationEntryPoint/ApplicationEntryPoint.c
Checked in part of MDE library instances following PI and UEFI. It includes:
[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 // The package level header files this module uses
17 //
18 #include <Uefi.h>
19 //
20 // The protocols, PPI and GUID defintions for this module
21 //
22 //
23 // The Library classes this module consumes
24 //
25 #include <Library/UefiApplicationEntryPoint.h>
26 #include <Library/UefiBootServicesTableLib.h>
27
28 /**
29 Enrty point to UEFI application.
30
31 @param ImageHandle ImageHandle of the loaded driver.
32 @param SystemTable Pointer to the EFI System Table.
33
34 @retval EFI_SUCCESS One or more of the drivers returned a success code.
35 @retval !EFI_SUCESS The return status from the last driver entry point in the list.
36
37 **/
38 EFI_STATUS
39 EFIAPI
40 _ModuleEntryPoint (
41 IN EFI_HANDLE ImageHandle,
42 IN EFI_SYSTEM_TABLE *SystemTable
43 )
44 {
45 EFI_STATUS Status;
46
47 if (_gUefiDriverRevision != 0) {
48 //
49 // Make sure that the EFI/UEFI spec revision of the platform is >= EFI/UEFI spec revision of the application.
50 //
51 if (SystemTable->Hdr.Revision < _gUefiDriverRevision) {
52 return EFI_INCOMPATIBLE_VERSION;
53 }
54 }
55
56 //
57 // Call constructor for all libraries.
58 //
59 ProcessLibraryConstructorList (ImageHandle, SystemTable);
60
61 //
62 // Call the module's entry point
63 //
64 Status = ProcessModuleEntryPointList (ImageHandle, SystemTable);
65
66 //
67 // Process destructor for all libraries.
68 //
69 ProcessLibraryDestructorList (ImageHandle, SystemTable);
70
71 //
72 // Return the return status code from the driver entry point
73 //
74 return Status;
75 }
76
77 /**
78 Invoke the destuctors of all libraries and call gBS->Exit
79 to return control to firmware core.
80
81 @param Status Status returned by the application that is exiting.
82
83 @retval VOID
84
85 **/
86 VOID
87 EFIAPI
88 Exit (
89 IN EFI_STATUS Status
90 )
91
92 {
93 ProcessLibraryDestructorList (gImageHandle, gST);
94
95 gBS->Exit (gImageHandle, Status, 0, NULL);
96 }
97
98 /**
99 Enrty point wrapper of UEFI Application.
100
101 @param ImageHandle ImageHandle of the loaded driver.
102 @param SystemTable Pointer to the EFI System Table.
103
104 @retval EFI_SUCCESS One or more of the drivers returned a success code.
105 @retval !EFI_SUCESS The return status from the last driver entry point in the list.
106
107 **/
108 EFI_STATUS
109 EFIAPI
110 EfiMain (
111 IN EFI_HANDLE ImageHandle,
112 IN EFI_SYSTEM_TABLE *SystemTable
113 )
114 {
115 return _ModuleEntryPoint (ImageHandle, SystemTable);
116 }