TianoCore EDK2 master
Loading...
Searching...
No Matches
DriverEntryPoint.c
Go to the documentation of this file.
1
9#include <Uefi.h>
10
12
14#include <Library/BaseLib.h>
15#include <Library/DebugLib.h>
17
30EFIAPI
32 EFI_HANDLE ImageHandle
33 )
34{
35 EFI_STATUS Status;
36
37 //
38 // If an UnloadImage() handler is specified, then call it
39 //
40 Status = ProcessModuleUnloadList (ImageHandle);
41
42 //
43 // If the driver specific unload handler does not return an error, then call all of the
44 // library destructors. If the unload handler returned an error, then the driver can not be
45 // unloaded, and the library destructors should not be called
46 //
47 if (!EFI_ERROR (Status)) {
48 ProcessLibraryDestructorList (ImageHandle, gST);
49 }
50
51 //
52 // Return the status from the driver specific unload handler
53 //
54 return Status;
55}
56
84EFIAPI
86 IN EFI_HANDLE ImageHandle,
87 IN EFI_SYSTEM_TABLE *SystemTable
88 )
89{
90 EFI_STATUS Status;
91 EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
92
93 if (_gUefiDriverRevision != 0) {
94 //
95 // Make sure that the EFI/UEFI spec revision of the platform is >= EFI/UEFI spec revision of the driver
96 //
97 if (SystemTable->Hdr.Revision < _gUefiDriverRevision) {
98 return EFI_INCOMPATIBLE_VERSION;
99 }
100 }
101
102 //
103 // Call constructor for all libraries
104 //
105 ProcessLibraryConstructorList (ImageHandle, SystemTable);
106
107 //
108 // Install unload handler...
109 //
110 if (_gDriverUnloadImageCount != 0) {
111 Status = gBS->HandleProtocol (
112 ImageHandle,
113 &gEfiLoadedImageProtocolGuid,
114 (VOID **)&LoadedImage
115 );
116 ASSERT_EFI_ERROR (Status);
117 LoadedImage->Unload = _DriverUnloadHandler;
118 }
119
120 //
121 // Call the driver entry point
122 //
123 Status = ProcessModuleEntryPointList (ImageHandle, SystemTable);
124
125 //
126 // If all of the drivers returned errors, then invoke all of the library destructors
127 //
128 if (EFI_ERROR (Status)) {
129 ProcessLibraryDestructorList (ImageHandle, SystemTable);
130 }
131
132 //
133 // Return the cummalative return status code from all of the driver entry points
134 //
135 return Status;
136}
137
155EFIAPI
157 IN EFI_HANDLE ImageHandle,
158 IN EFI_SYSTEM_TABLE *SystemTable
159 )
160{
161 return _ModuleEntryPoint (ImageHandle, SystemTable);
162}
EFI_STATUS EFIAPI _DriverUnloadHandler(EFI_HANDLE ImageHandle)
EFI_STATUS EFIAPI _ModuleEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS EFIAPI EfiMain(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
VOID EFIAPI ProcessModuleEntryPointList(IN VOID *HobStart)
#define IN
Definition: Base.h:279
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
CONST UINT8 _gDriverUnloadImageCount
VOID EFIAPI ProcessLibraryDestructorList(IN EFI_HANDLE ImageHandle, IN EFI_MM_SYSTEM_TABLE *MmSystemTable)
EFI_STATUS EFIAPI ProcessModuleUnloadList(IN EFI_HANDLE ImageHandle)
CONST UINT32 _gUefiDriverRevision
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
EFI_SYSTEM_TABLE * gST
EFI_BOOT_SERVICES * gBS