TianoCore EDK2 master
Loading...
Searching...
No Matches
UefiDriverEntryPointFwCfgOverrideLib.c
Go to the documentation of this file.
1
12#include <Uefi.h>
13
15
16#include <Library/BaseLib.h>
17#include <Library/DebugLib.h>
21
35EFIAPI
37 EFI_HANDLE ImageHandle
38 )
39{
40 EFI_STATUS Status;
41
42 //
43 // If an UnloadImage() handler is specified, then call it
44 //
45 Status = ProcessModuleUnloadList (ImageHandle);
46
47 //
48 // If the driver specific unload handler does not return an error, then call
49 // all of the library destructors. If the unload handler returned an error,
50 // then the driver can not be unloaded, and the library destructors should
51 // not be called
52 //
53 if (!EFI_ERROR (Status)) {
54 ProcessLibraryDestructorList (ImageHandle, gST);
55 }
56
57 //
58 // Return the status from the driver specific unload handler
59 //
60 return Status;
61}
62
80EFIAPI
82 IN EFI_HANDLE ImageHandle,
83 IN EFI_SYSTEM_TABLE *SystemTable
84 )
85{
86 EFI_STATUS Status;
87 EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
88 RETURN_STATUS RetStatus;
89 BOOLEAN Enabled;
90
91 if (_gUefiDriverRevision != 0) {
92 //
93 // Make sure that the EFI/UEFI spec revision of the platform is >= EFI/UEFI
94 // spec revision of the driver
95 //
96 if (SystemTable->Hdr.Revision < _gUefiDriverRevision) {
97 return EFI_INCOMPATIBLE_VERSION;
98 }
99 }
100
101 //
102 // Call constructor for all libraries
103 //
104 ProcessLibraryConstructorList (ImageHandle, SystemTable);
105
106 //
107 // Install unload handler...
108 //
109 if (_gDriverUnloadImageCount != 0) {
110 Status = gBS->HandleProtocol (
111 ImageHandle,
112 &gEfiLoadedImageProtocolGuid,
113 (VOID **)&LoadedImage
114 );
115 ASSERT_EFI_ERROR (Status);
116 LoadedImage->Unload = _DriverUnloadHandler;
117 }
118
119 RetStatus = QemuFwCfgParseBool (
120 FixedPcdGetPtr (PcdEntryPointOverrideFwCfgVarName),
121 &Enabled
122 );
123 if (!RETURN_ERROR (RetStatus) && !Enabled) {
124 //
125 // The QEMU fw_cfg variable tells us not to load this image. So abort.
126 //
127 Status = EFI_ABORTED;
128 } else {
129 //
130 // Call the driver entry point
131 //
132 Status = ProcessModuleEntryPointList (ImageHandle, SystemTable);
133 }
134
135 //
136 // If all of the drivers returned errors, or we if are aborting, then invoke
137 // all of the library destructors
138 //
139 if (EFI_ERROR (Status)) {
140 ProcessLibraryDestructorList (ImageHandle, SystemTable);
141 }
142
143 //
144 // Return the cumulative return status code from all of the driver entry
145 // points
146 //
147 return Status;
148}
VOID EFIAPI ProcessModuleEntryPointList(IN VOID *HobStart)
#define STATIC
Definition: Base.h:264
#define RETURN_ERROR(StatusCode)
Definition: Base.h:1061
#define IN
Definition: Base.h:279
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
#define FixedPcdGetPtr(TokenName)
Definition: PcdLib.h:134
RETURN_STATUS EFIAPI QemuFwCfgParseBool(IN CONST CHAR8 *FileName, OUT BOOLEAN *Value)
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
STATIC EFI_STATUS EFIAPI _DriverUnloadHandler(EFI_HANDLE ImageHandle)
EFI_STATUS EFIAPI _ModuleEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)