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