• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /** @file
2   Entry point library instance to a UEFI application.
3 
4 Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
5 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/BaseLib.h>
18 #include <Library/DebugLib.h>
19 #include <Library/UefiBootServicesTableLib.h>
20 
21 
22 /**
23   Entry point to UEFI Application.
24 
25   This function is the entry point for a UEFI Application. This function must call
26   ProcessLibraryConstructorList(), ProcessModuleEntryPointList(), and ProcessLibraryDestructorList().
27   The return value from ProcessModuleEntryPointList() is returned.
28   If _gUefiDriverRevision is not zero and SystemTable->Hdr.Revision is less than _gUefiDriverRevison,
29   then return EFI_INCOMPATIBLE_VERSION.
30 
31   @param  ImageHandle                The image handle of the UEFI Application.
32   @param  SystemTable                A pointer to the EFI System Table.
33 
34   @retval  EFI_SUCCESS               The UEFI Application exited normally.
35   @retval  EFI_INCOMPATIBLE_VERSION  _gUefiDriverRevision is greater than SystemTable->Hdr.Revision.
36   @retval  Other                     Return value from ProcessModuleEntryPointList().
37 
38 **/
39 EFI_STATUS
40 EFIAPI
_ModuleEntryPoint(IN EFI_HANDLE ImageHandle,IN EFI_SYSTEM_TABLE * SystemTable)41 _ModuleEntryPoint (
42   IN EFI_HANDLE        ImageHandle,
43   IN EFI_SYSTEM_TABLE  *SystemTable
44   )
45 {
46   EFI_STATUS                 Status;
47 
48   if (_gUefiDriverRevision != 0) {
49     //
50     // Make sure that the EFI/UEFI spec revision of the platform is >= EFI/UEFI spec revision of the application.
51     //
52     if (SystemTable->Hdr.Revision < _gUefiDriverRevision) {
53       return EFI_INCOMPATIBLE_VERSION;
54     }
55   }
56 
57   //
58   // Call constructor for all libraries.
59   //
60   ProcessLibraryConstructorList (ImageHandle, SystemTable);
61 
62   //
63   // Call the module's entry point
64   //
65   Status = ProcessModuleEntryPointList (ImageHandle, SystemTable);
66 
67   //
68   // Process destructor for all libraries.
69   //
70   ProcessLibraryDestructorList (ImageHandle, SystemTable);
71 
72   //
73   // Return the return status code from the driver entry point
74   //
75   return Status;
76 }
77 
78 
79 /**
80   Invokes the library destructors for all dependent libraries and terminates
81   the UEFI Application.
82 
83   This function calls ProcessLibraryDestructorList() and the EFI Boot Service Exit()
84   with a status specified by Status.
85 
86   @param  Status  Status returned by the application that is exiting.
87 
88 **/
89 VOID
90 EFIAPI
Exit(IN EFI_STATUS Status)91 Exit (
92   IN EFI_STATUS  Status
93   )
94 
95 {
96   ProcessLibraryDestructorList (gImageHandle, gST);
97 
98   gBS->Exit (gImageHandle, Status, 0, NULL);
99 }
100 
101 
102 /**
103   Required by the EBC compiler and identical in functionality to _ModuleEntryPoint().
104 
105   @param  ImageHandle  The image handle of the UEFI Application.
106   @param  SystemTable  A pointer to the EFI System Table.
107 
108   @retval  EFI_SUCCESS               The UEFI Application exited normally.
109   @retval  EFI_INCOMPATIBLE_VERSION  _gUefiDriverRevision is greater than SystemTable->Hdr.Revision.
110   @retval  Other                     Return value from ProcessModuleEntryPointList().
111 
112 **/
113 EFI_STATUS
114 EFIAPI
EfiMain(IN EFI_HANDLE ImageHandle,IN EFI_SYSTEM_TABLE * SystemTable)115 EfiMain (
116   IN EFI_HANDLE        ImageHandle,
117   IN EFI_SYSTEM_TABLE  *SystemTable
118   )
119 {
120   return _ModuleEntryPoint (ImageHandle, SystemTable);
121 }
122