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