TianoCore EDK2 master
Loading...
Searching...
No Matches
RedfishConfigHandlerCommon.c
Go to the documentation of this file.
1
12
13REDFISH_CONFIG_DRIVER_DATA gRedfishConfigData; // Only one Redfish service supported
14 // on platform for the BIOS
15 // Redfish configuration.
16EFI_EVENT gEndOfDxeEvent = NULL;
17EFI_EVENT gExitBootServiceEvent = NULL;
19
27VOID
28EFIAPI
30 IN EFI_EVENT Event,
31 OUT VOID *Context
32 )
33{
34 EFI_STATUS Status;
35
36 Status = gCredential->StopService (gCredential, ServiceStopTypeSecureBootDisabled);
37 if (EFI_ERROR (Status) && (Status != EFI_UNSUPPORTED)) {
38 DEBUG ((DEBUG_ERROR, "Redfish credential protocol failed to stop service on EndOfDxe: %r", Status));
39 }
40
41 //
42 // Close event, so it will not be invoked again.
43 //
44 gBS->CloseEvent (gEndOfDxeEvent);
45 gEndOfDxeEvent = NULL;
46}
47
55VOID
56EFIAPI
58 IN EFI_EVENT Event,
59 OUT VOID *Context
60 )
61{
62 EFI_STATUS Status;
63
64 Status = gCredential->StopService (gCredential, ServiceStopTypeExitBootService);
65 if (EFI_ERROR (Status) && (Status != EFI_UNSUPPORTED)) {
66 DEBUG ((DEBUG_ERROR, "Redfish credential protocol failed to stop service on ExitBootService: %r", Status));
67 }
68}
69
80 IN EFI_HANDLE ImageHandle
81 )
82{
83 if (gEndOfDxeEvent != NULL) {
84 gBS->CloseEvent (gEndOfDxeEvent);
85 gEndOfDxeEvent = NULL;
86 }
87
88 if (gExitBootServiceEvent != NULL) {
89 gBS->CloseEvent (gExitBootServiceEvent);
90 gExitBootServiceEvent = NULL;
91 }
92
93 if (gRedfishConfigData.Event != NULL) {
94 gBS->CloseEvent (gRedfishConfigData.Event);
95 gRedfishConfigData.Event = NULL;
96 }
97
98 return EFI_SUCCESS;
99}
100
113 IN EFI_HANDLE ImageHandle,
114 IN EFI_SYSTEM_TABLE *SystemTable
115 )
116{
117 EFI_STATUS Status;
118
119 //
120 // Locate Redfish Credential Protocol to get credential for
121 // accessing to Redfish service.
122 //
123 Status = gBS->LocateProtocol (&gEdkIIRedfishCredentialProtocolGuid, NULL, (VOID **)&gCredential);
124 if (EFI_ERROR (Status)) {
125 DEBUG ((DEBUG_ERROR, "%a: No Redfish Credential Protocol is installed on system.", __func__));
126 return Status;
127 }
128
129 //
130 // Create EndOfDxe Event.
131 //
132 Status = gBS->CreateEventEx (
133 EVT_NOTIFY_SIGNAL,
134 TPL_CALLBACK,
136 NULL,
137 &gEfiEndOfDxeEventGroupGuid,
138 &gEndOfDxeEvent
139 );
140 if (EFI_ERROR (Status)) {
141 DEBUG ((DEBUG_ERROR, "%a: Fail to register End Of DXE event.", __func__));
142 return Status;
143 }
144
145 //
146 // Create Exit Boot Service event.
147 //
148 Status = gBS->CreateEventEx (
149 EVT_NOTIFY_SIGNAL,
150 TPL_CALLBACK,
152 NULL,
153 &gEfiEventExitBootServicesGuid,
154 &gExitBootServiceEvent
155 );
156 if (EFI_ERROR (Status)) {
157 gBS->CloseEvent (gEndOfDxeEvent);
158 gEndOfDxeEvent = NULL;
159 DEBUG ((DEBUG_ERROR, "%a: Fail to register Exit Boot Service event.", __func__));
160 return Status;
161 }
162
163 return EFI_SUCCESS;
164}
165
175 VOID
176 )
177{
178 EFI_STATUS Status;
179 EFI_HANDLE *HandleBuffer;
180 UINTN NumberOfHandles;
181 UINTN Index;
183
184 Status = gBS->LocateHandleBuffer (
186 &gEdkIIRedfishConfigHandlerProtocolGuid,
187 NULL,
188 &NumberOfHandles,
189 &HandleBuffer
190 );
191 if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
192 return Status;
193 }
194
195 Status = EFI_SUCCESS;
196 for (Index = 0; Index < NumberOfHandles; Index++) {
197 Status = gBS->HandleProtocol (
198 HandleBuffer[Index],
199 &gEdkIIRedfishConfigHandlerProtocolGuid,
200 (VOID **)&ConfigHandler
201 );
202 ASSERT_EFI_ERROR (Status);
203
204 Status = ConfigHandler->Stop (ConfigHandler);
205 if (EFI_ERROR (Status) && (Status != EFI_UNSUPPORTED)) {
206 DEBUG ((DEBUG_ERROR, "ERROR: Failed to stop Redfish config handler %p.\n", ConfigHandler));
207 break;
208 }
209 }
210
211 return Status;
212}
213
219VOID
221 VOID
222 )
223{
224 EFI_STATUS Status;
225 EFI_HANDLE *HandleBuffer;
226 UINTN NumberOfHandles;
228 UINTN Index;
229 UINT32 *Id;
230
231 Status = gBS->LocateHandleBuffer (
233 &gEdkIIRedfishConfigHandlerProtocolGuid,
234 NULL,
235 &NumberOfHandles,
236 &HandleBuffer
237 );
238 if (EFI_ERROR (Status)) {
239 return;
240 }
241
242 for (Index = 0; Index < NumberOfHandles; Index++) {
243 Status = gBS->HandleProtocol (
244 HandleBuffer[Index],
245 &gEfiCallerIdGuid,
246 (VOID **)&Id
247 );
248 if (!EFI_ERROR (Status)) {
249 continue;
250 }
251
252 Status = gBS->HandleProtocol (
253 HandleBuffer[Index],
254 &gEdkIIRedfishConfigHandlerProtocolGuid,
255 (VOID **)&ConfigHandler
256 );
257 ASSERT_EFI_ERROR (Status);
258 Status = ConfigHandler->Init (ConfigHandler, &gRedfishConfigData.RedfishServiceInfo);
259 if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {
260 DEBUG ((DEBUG_ERROR, "ERROR: Failed to init Redfish config handler %p.\n", ConfigHandler));
261 continue;
262 }
263
264 //
265 // Install caller ID to indicate Redfish Configure Handler is initialized.
266 //
267 Status = gBS->InstallProtocolInterface (
268 &HandleBuffer[Index],
269 &gEfiCallerIdGuid,
271 (VOID *)&gRedfishConfigData.CallerId
272 );
273 ASSERT_EFI_ERROR (Status);
274 }
275}
UINT64 UINTN
@ ServiceStopTypeSecureBootDisabled
@ ServiceStopTypeExitBootService
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
#define DEBUG(Expression)
Definition: DebugLib.h:434
VOID RedfishConfigHandlerInitialization(VOID)
EFI_STATUS RedfishConfigDriverCommonUnload(IN EFI_HANDLE ImageHandle)
VOID EFIAPI RedfishConfigOnExitBootService(IN EFI_EVENT Event, OUT VOID *Context)
VOID EFIAPI RedfishConfigOnEndOfDxe(IN EFI_EVENT Event, OUT VOID *Context)
EFI_STATUS RedfishConfigCommonInit(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS RedfishConfigCommonStop(VOID)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_EVENT
Definition: UefiBaseType.h:37
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS
@ EFI_NATIVE_INTERFACE
Definition: UefiSpec.h:1193
@ ByProtocol
Definition: UefiSpec.h:1518
EFI_EVENT Event
Event for the notification of EFI_REDFISH_CONFIG_HANDLER_PROTOCOL.