MdeModulePkg Variable: Align TPL level for (Smm)EndOfDxe callback
[mirror_edk2.git] / MdeModulePkg / Universal / Variable / RuntimeDxe / VariableDxe.c
CommitLineData
e4b7e2c9 1/** @file\r
e4b7e2c9
RN
2 Implement all four UEFI Runtime Variable services for the nonvolatile\r
3 and volatile storage space and install variable architecture protocol.\r
fa0737a8 4\r
328e5d8c 5Copyright (C) 2013, Red Hat, Inc.\r
3d7ebd64 6Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
9b18845a 7(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
fa0737a8
SZ
8This program and the accompanying materials\r
9are licensed and made available under the terms and conditions of the BSD License\r
10which accompanies this distribution. The full text of the license may be found at\r
11http://opensource.org/licenses/bsd-license.php\r
e4b7e2c9 12\r
fa0737a8
SZ
13THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
14WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
e4b7e2c9
RN
15\r
16**/\r
17\r
18#include "Variable.h"\r
19\r
9b18845a
DL
20extern VARIABLE_STORE_HEADER *mNvVariableCache;\r
21extern EFI_FIRMWARE_VOLUME_HEADER *mNvFvHeaderCache;\r
22extern VARIABLE_INFO_ENTRY *gVariableInfo;\r
23EFI_HANDLE mHandle = NULL;\r
24EFI_EVENT mVirtualAddressChangeEvent = NULL;\r
25EFI_EVENT mFtwRegistration = NULL;\r
26extern BOOLEAN mEndOfDxe;\r
27VOID ***mVarCheckAddressPointer = NULL;\r
28UINTN mVarCheckAddressPointerCount = 0;\r
29EDKII_VARIABLE_LOCK_PROTOCOL mVariableLock = { VariableLockRequestToLock };\r
30EDKII_VAR_CHECK_PROTOCOL mVarCheck = { VarCheckRegisterSetVariableCheckHandler,\r
31 VarCheckVariablePropertySet,\r
32 VarCheckVariablePropertyGet };\r
e4b7e2c9 33\r
dc9bd6ed
ZC
34/**\r
35 Some Secure Boot Policy Variable may update following other variable changes(SecureBoot follows PK change, etc).\r
36 Record their initial State when variable write service is ready.\r
37\r
38**/\r
39VOID\r
40EFIAPI\r
41RecordSecureBootPolicyVarData(\r
42 VOID\r
43 );\r
44\r
e4b7e2c9
RN
45/**\r
46 Return TRUE if ExitBootServices () has been called.\r
fa0737a8 47\r
e4b7e2c9
RN
48 @retval TRUE If ExitBootServices () has been called.\r
49**/\r
50BOOLEAN\r
51AtRuntime (\r
52 VOID\r
53 )\r
54{\r
55 return EfiAtRuntime ();\r
56}\r
57\r
58\r
59/**\r
60 Initializes a basic mutual exclusion lock.\r
61\r
fa0737a8
SZ
62 This function initializes a basic mutual exclusion lock to the released state\r
63 and returns the lock. Each lock provides mutual exclusion access at its task\r
e4b7e2c9
RN
64 priority level. Since there is no preemption or multiprocessor support in EFI,\r
65 acquiring the lock only consists of raising to the locks TPL.\r
66 If Lock is NULL, then ASSERT().\r
67 If Priority is not a valid TPL value, then ASSERT().\r
68\r
69 @param Lock A pointer to the lock data structure to initialize.\r
70 @param Priority EFI TPL is associated with the lock.\r
71\r
72 @return The lock.\r
73\r
74**/\r
75EFI_LOCK *\r
76InitializeLock (\r
77 IN OUT EFI_LOCK *Lock,\r
78 IN EFI_TPL Priority\r
79 )\r
80{\r
81 return EfiInitializeLock (Lock, Priority);\r
82}\r
83\r
84\r
85/**\r
86 Acquires lock only at boot time. Simply returns at runtime.\r
87\r
88 This is a temperary function that will be removed when\r
89 EfiAcquireLock() in UefiLib can handle the call in UEFI\r
90 Runtimer driver in RT phase.\r
91 It calls EfiAcquireLock() at boot time, and simply returns\r
92 at runtime.\r
93\r
94 @param Lock A pointer to the lock to acquire.\r
95\r
96**/\r
97VOID\r
98AcquireLockOnlyAtBootTime (\r
99 IN EFI_LOCK *Lock\r
100 )\r
101{\r
102 if (!AtRuntime ()) {\r
103 EfiAcquireLock (Lock);\r
104 }\r
105}\r
106\r
107\r
108/**\r
109 Releases lock only at boot time. Simply returns at runtime.\r
110\r
111 This is a temperary function which will be removed when\r
112 EfiReleaseLock() in UefiLib can handle the call in UEFI\r
113 Runtimer driver in RT phase.\r
114 It calls EfiReleaseLock() at boot time and simply returns\r
115 at runtime.\r
116\r
117 @param Lock A pointer to the lock to release.\r
118\r
119**/\r
120VOID\r
121ReleaseLockOnlyAtBootTime (\r
122 IN EFI_LOCK *Lock\r
123 )\r
124{\r
125 if (!AtRuntime ()) {\r
126 EfiReleaseLock (Lock);\r
127 }\r
128}\r
129\r
130/**\r
0a18956d 131 Retrieve the Fault Tolerent Write protocol interface.\r
e4b7e2c9
RN
132\r
133 @param[out] FtwProtocol The interface of Ftw protocol\r
134\r
135 @retval EFI_SUCCESS The FTW protocol instance was found and returned in FtwProtocol.\r
136 @retval EFI_NOT_FOUND The FTW protocol instance was not found.\r
137 @retval EFI_INVALID_PARAMETER SarProtocol is NULL.\r
138\r
139**/\r
140EFI_STATUS\r
141GetFtwProtocol (\r
142 OUT VOID **FtwProtocol\r
143 )\r
144{\r
145 EFI_STATUS Status;\r
146\r
147 //\r
148 // Locate Fault Tolerent Write protocol\r
149 //\r
150 Status = gBS->LocateProtocol (\r
151 &gEfiFaultTolerantWriteProtocolGuid,\r
152 NULL,\r
153 FtwProtocol\r
fa0737a8 154 );\r
e4b7e2c9
RN
155 return Status;\r
156}\r
157\r
158/**\r
0a18956d 159 Retrieve the FVB protocol interface by HANDLE.\r
e4b7e2c9
RN
160\r
161 @param[in] FvBlockHandle The handle of FVB protocol that provides services for\r
162 reading, writing, and erasing the target block.\r
163 @param[out] FvBlock The interface of FVB protocol\r
164\r
165 @retval EFI_SUCCESS The interface information for the specified protocol was returned.\r
166 @retval EFI_UNSUPPORTED The device does not support the FVB protocol.\r
167 @retval EFI_INVALID_PARAMETER FvBlockHandle is not a valid EFI_HANDLE or FvBlock is NULL.\r
fa0737a8 168\r
e4b7e2c9
RN
169**/\r
170EFI_STATUS\r
171GetFvbByHandle (\r
172 IN EFI_HANDLE FvBlockHandle,\r
173 OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL **FvBlock\r
174 )\r
175{\r
176 //\r
177 // To get the FVB protocol interface on the handle\r
178 //\r
179 return gBS->HandleProtocol (\r
180 FvBlockHandle,\r
181 &gEfiFirmwareVolumeBlockProtocolGuid,\r
182 (VOID **) FvBlock\r
183 );\r
184}\r
185\r
186\r
187/**\r
188 Function returns an array of handles that support the FVB protocol\r
fa0737a8 189 in a buffer allocated from pool.\r
e4b7e2c9
RN
190\r
191 @param[out] NumberHandles The number of handles returned in Buffer.\r
192 @param[out] Buffer A pointer to the buffer to return the requested\r
193 array of handles that support FVB protocol.\r
194\r
195 @retval EFI_SUCCESS The array of handles was returned in Buffer, and the number of\r
196 handles in Buffer was returned in NumberHandles.\r
197 @retval EFI_NOT_FOUND No FVB handle was found.\r
198 @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the matching results.\r
199 @retval EFI_INVALID_PARAMETER NumberHandles is NULL or Buffer is NULL.\r
fa0737a8 200\r
e4b7e2c9
RN
201**/\r
202EFI_STATUS\r
203GetFvbCountAndBuffer (\r
204 OUT UINTN *NumberHandles,\r
205 OUT EFI_HANDLE **Buffer\r
206 )\r
207{\r
208 EFI_STATUS Status;\r
209\r
210 //\r
211 // Locate all handles of Fvb protocol\r
212 //\r
213 Status = gBS->LocateHandleBuffer (\r
214 ByProtocol,\r
215 &gEfiFirmwareVolumeBlockProtocolGuid,\r
216 NULL,\r
217 NumberHandles,\r
218 Buffer\r
219 );\r
220 return Status;\r
221}\r
222\r
223\r
224/**\r
225 Notification function of EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE.\r
226\r
227 This is a notification function registered on EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.\r
228 It convers pointer to new virtual address.\r
229\r
230 @param Event Event whose notification function is being invoked.\r
231 @param Context Pointer to the notification function's context.\r
232\r
233**/\r
234VOID\r
235EFIAPI\r
236VariableClassAddressChangeEvent (\r
237 IN EFI_EVENT Event,\r
238 IN VOID *Context\r
239 )\r
240{\r
efb01a10 241 UINTN Index;\r
328e5d8c 242\r
e4b7e2c9
RN
243 EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->FvbInstance->GetBlockSize);\r
244 EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->FvbInstance->GetPhysicalAddress);\r
245 EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->FvbInstance->GetAttributes);\r
246 EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->FvbInstance->SetAttributes);\r
247 EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->FvbInstance->Read);\r
248 EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->FvbInstance->Write);\r
249 EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->FvbInstance->EraseBlocks);\r
250 EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->FvbInstance);\r
251 EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->PlatformLangCodes);\r
252 EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->LangCodes);\r
253 EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->PlatformLang);\r
254 EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase);\r
255 EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->VariableGlobal.VolatileVariableBase);\r
256 EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->VariableGlobal.HobVariableBase);\r
257 EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal);\r
fa0737a8 258 EfiConvertPointer (0x0, (VOID **) &mNvVariableCache);\r
9b18845a 259 EfiConvertPointer (0x0, (VOID **) &mNvFvHeaderCache);\r
efb01a10 260\r
8021f4c7
SZ
261 if (mAuthContextOut.AddressPointer != NULL) {\r
262 for (Index = 0; Index < mAuthContextOut.AddressPointerCount; Index++) {\r
263 EfiConvertPointer (0x0, (VOID **) mAuthContextOut.AddressPointer[Index]);\r
264 }\r
265 }\r
fa0737a8 266\r
8021f4c7
SZ
267 if (mVarCheckAddressPointer != NULL) {\r
268 for (Index = 0; Index < mVarCheckAddressPointerCount; Index++) {\r
269 EfiConvertPointer (0x0, (VOID **) mVarCheckAddressPointer[Index]);\r
fa0737a8
SZ
270 }\r
271 }\r
e4b7e2c9
RN
272}\r
273\r
274\r
275/**\r
276 Notification function of EVT_GROUP_READY_TO_BOOT event group.\r
277\r
278 This is a notification function registered on EVT_GROUP_READY_TO_BOOT event group.\r
279 When the Boot Manager is about to load and execute a boot option, it reclaims variable\r
280 storage if free size is below the threshold.\r
281\r
282 @param Event Event whose notification function is being invoked.\r
283 @param Context Pointer to the notification function's context.\r
284\r
285**/\r
286VOID\r
287EFIAPI\r
288OnReadyToBoot (\r
289 EFI_EVENT Event,\r
290 VOID *Context\r
291 )\r
292{\r
8021f4c7 293 if (!mEndOfDxe) {\r
f1304280 294 MorLockInitAtEndOfDxe ();\r
8021f4c7
SZ
295 //\r
296 // Set the End Of DXE bit in case the EFI_END_OF_DXE_EVENT_GROUP_GUID event is not signaled.\r
297 //\r
298 mEndOfDxe = TRUE;\r
299 mVarCheckAddressPointer = VarCheckLibInitializeAtEndOfDxe (&mVarCheckAddressPointerCount);\r
300 //\r
301 // The initialization for variable quota.\r
302 //\r
303 InitializeVariableQuota ();\r
304 }\r
e4b7e2c9
RN
305 ReclaimForOS ();\r
306 if (FeaturePcdGet (PcdVariableCollectStatistics)) {\r
fa0737a8
SZ
307 if (mVariableModuleGlobal->VariableGlobal.AuthFormat) {\r
308 gBS->InstallConfigurationTable (&gEfiAuthenticatedVariableGuid, gVariableInfo);\r
309 } else {\r
310 gBS->InstallConfigurationTable (&gEfiVariableGuid, gVariableInfo);\r
311 }\r
e4b7e2c9 312 }\r
fa0737a8
SZ
313\r
314 gBS->CloseEvent (Event);\r
e4b7e2c9
RN
315}\r
316\r
317/**\r
318 Notification function of EFI_END_OF_DXE_EVENT_GROUP_GUID event group.\r
319\r
320 This is a notification function registered on EFI_END_OF_DXE_EVENT_GROUP_GUID event group.\r
321\r
322 @param Event Event whose notification function is being invoked.\r
323 @param Context Pointer to the notification function's context.\r
324\r
325**/\r
326VOID\r
327EFIAPI\r
328OnEndOfDxe (\r
329 EFI_EVENT Event,\r
330 VOID *Context\r
331 )\r
332{\r
8021f4c7 333 DEBUG ((EFI_D_INFO, "[Variable]END_OF_DXE is signaled\n"));\r
f1304280 334 MorLockInitAtEndOfDxe ();\r
e4b7e2c9 335 mEndOfDxe = TRUE;\r
8021f4c7 336 mVarCheckAddressPointer = VarCheckLibInitializeAtEndOfDxe (&mVarCheckAddressPointerCount);\r
4edb1866
SZ
337 //\r
338 // The initialization for variable quota.\r
339 //\r
340 InitializeVariableQuota ();\r
0fb5e515
SZ
341 if (PcdGetBool (PcdReclaimVariableSpaceAtEndOfDxe)) {\r
342 ReclaimForOS ();\r
343 }\r
fa0737a8
SZ
344\r
345 gBS->CloseEvent (Event);\r
e4b7e2c9
RN
346}\r
347\r
348/**\r
349 Fault Tolerant Write protocol notification event handler.\r
350\r
fa0737a8 351 Non-Volatile variable write may needs FTW protocol to reclaim when\r
e4b7e2c9
RN
352 writting variable.\r
353\r
354 @param[in] Event Event whose notification function is being invoked.\r
355 @param[in] Context Pointer to the notification function's context.\r
fa0737a8 356\r
e4b7e2c9
RN
357**/\r
358VOID\r
359EFIAPI\r
360FtwNotificationEvent (\r
361 IN EFI_EVENT Event,\r
362 IN VOID *Context\r
363 )\r
364{\r
365 EFI_STATUS Status;\r
366 EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol;\r
367 EFI_FAULT_TOLERANT_WRITE_PROTOCOL *FtwProtocol;\r
368 EFI_PHYSICAL_ADDRESS NvStorageVariableBase;\r
369 EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor;\r
370 EFI_PHYSICAL_ADDRESS BaseAddress;\r
371 UINT64 Length;\r
372 EFI_PHYSICAL_ADDRESS VariableStoreBase;\r
373 UINT64 VariableStoreLength;\r
2c4b18e0 374 UINTN FtwMaxBlockSize;\r
e4b7e2c9
RN
375\r
376 //\r
377 // Ensure FTW protocol is installed.\r
378 //\r
379 Status = GetFtwProtocol ((VOID**) &FtwProtocol);\r
380 if (EFI_ERROR (Status)) {\r
381 return ;\r
382 }\r
2c4b18e0
SZ
383\r
384 Status = FtwProtocol->GetMaxBlockSize (FtwProtocol, &FtwMaxBlockSize);\r
385 if (!EFI_ERROR (Status)) {\r
386 ASSERT (PcdGet32 (PcdFlashNvStorageVariableSize) <= FtwMaxBlockSize);\r
387 }\r
388\r
e4b7e2c9
RN
389 //\r
390 // Find the proper FVB protocol for variable.\r
391 //\r
392 NvStorageVariableBase = (EFI_PHYSICAL_ADDRESS) PcdGet64 (PcdFlashNvStorageVariableBase64);\r
393 if (NvStorageVariableBase == 0) {\r
394 NvStorageVariableBase = (EFI_PHYSICAL_ADDRESS) PcdGet32 (PcdFlashNvStorageVariableBase);\r
395 }\r
396 Status = GetFvbInfoByAddress (NvStorageVariableBase, NULL, &FvbProtocol);\r
397 if (EFI_ERROR (Status)) {\r
398 return ;\r
399 }\r
400 mVariableModuleGlobal->FvbInstance = FvbProtocol;\r
401\r
402 //\r
403 // Mark the variable storage region of the FLASH as RUNTIME.\r
404 //\r
e7bafeb9 405 VariableStoreBase = NvStorageVariableBase + (((EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)(NvStorageVariableBase))->HeaderLength);\r
e4b7e2c9
RN
406 VariableStoreLength = ((VARIABLE_STORE_HEADER *)(UINTN)VariableStoreBase)->Size;\r
407 BaseAddress = VariableStoreBase & (~EFI_PAGE_MASK);\r
408 Length = VariableStoreLength + (VariableStoreBase - BaseAddress);\r
409 Length = (Length + EFI_PAGE_SIZE - 1) & (~EFI_PAGE_MASK);\r
410\r
411 Status = gDS->GetMemorySpaceDescriptor (BaseAddress, &GcdDescriptor);\r
412 if (EFI_ERROR (Status)) {\r
e7bafeb9 413 DEBUG ((DEBUG_WARN, "Variable driver failed to get flash memory attribute.\n"));\r
e4b7e2c9
RN
414 } else {\r
415 Status = gDS->SetMemorySpaceAttributes (\r
416 BaseAddress,\r
417 Length,\r
418 GcdDescriptor.Attributes | EFI_MEMORY_RUNTIME\r
419 );\r
420 if (EFI_ERROR (Status)) {\r
421 DEBUG ((DEBUG_WARN, "Variable driver failed to add EFI_MEMORY_RUNTIME attribute to Flash.\n"));\r
422 }\r
423 }\r
fa0737a8 424\r
e4b7e2c9 425 Status = VariableWriteServiceInitialize ();\r
fa0737a8
SZ
426 if (EFI_ERROR (Status)) {\r
427 DEBUG ((DEBUG_ERROR, "Variable write service initialization failed. Status = %r\n", Status));\r
428 }\r
429\r
dc9bd6ed
ZC
430 //\r
431 // Some Secure Boot Policy Var (SecureBoot, etc) updates following other\r
432 // Secure Boot Policy Variable change. Record their initial value.\r
433 //\r
434 RecordSecureBootPolicyVarData();\r
435\r
e4b7e2c9
RN
436 //\r
437 // Install the Variable Write Architectural protocol.\r
438 //\r
439 Status = gBS->InstallProtocolInterface (\r
440 &mHandle,\r
fa0737a8 441 &gEfiVariableWriteArchProtocolGuid,\r
e4b7e2c9
RN
442 EFI_NATIVE_INTERFACE,\r
443 NULL\r
444 );\r
445 ASSERT_EFI_ERROR (Status);\r
fa0737a8 446\r
e4b7e2c9
RN
447 //\r
448 // Close the notify event to avoid install gEfiVariableWriteArchProtocolGuid again.\r
449 //\r
450 gBS->CloseEvent (Event);\r
451\r
452}\r
453\r
454\r
455/**\r
456 Variable Driver main entry point. The Variable driver places the 4 EFI\r
fa0737a8
SZ
457 runtime services in the EFI System Table and installs arch protocols\r
458 for variable read and write services being available. It also registers\r
e4b7e2c9
RN
459 a notification function for an EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.\r
460\r
fa0737a8 461 @param[in] ImageHandle The firmware allocated handle for the EFI image.\r
e4b7e2c9 462 @param[in] SystemTable A pointer to the EFI System Table.\r
fa0737a8 463\r
e4b7e2c9
RN
464 @retval EFI_SUCCESS Variable service successfully initialized.\r
465\r
466**/\r
467EFI_STATUS\r
468EFIAPI\r
469VariableServiceInitialize (\r
470 IN EFI_HANDLE ImageHandle,\r
471 IN EFI_SYSTEM_TABLE *SystemTable\r
472 )\r
473{\r
474 EFI_STATUS Status;\r
475 EFI_EVENT ReadyToBootEvent;\r
476 EFI_EVENT EndOfDxeEvent;\r
477\r
478 Status = VariableCommonInitialize ();\r
479 ASSERT_EFI_ERROR (Status);\r
480\r
481 Status = gBS->InstallMultipleProtocolInterfaces (\r
482 &mHandle,\r
483 &gEdkiiVariableLockProtocolGuid,\r
484 &mVariableLock,\r
efb01a10
SZ
485 NULL\r
486 );\r
487 ASSERT_EFI_ERROR (Status);\r
488\r
489 Status = gBS->InstallMultipleProtocolInterfaces (\r
490 &mHandle,\r
491 &gEdkiiVarCheckProtocolGuid,\r
492 &mVarCheck,\r
e4b7e2c9
RN
493 NULL\r
494 );\r
495 ASSERT_EFI_ERROR (Status);\r
496\r
497 SystemTable->RuntimeServices->GetVariable = VariableServiceGetVariable;\r
498 SystemTable->RuntimeServices->GetNextVariableName = VariableServiceGetNextVariableName;\r
499 SystemTable->RuntimeServices->SetVariable = VariableServiceSetVariable;\r
500 SystemTable->RuntimeServices->QueryVariableInfo = VariableServiceQueryVariableInfo;\r
fa0737a8 501\r
e4b7e2c9
RN
502 //\r
503 // Now install the Variable Runtime Architectural protocol on a new handle.\r
504 //\r
505 Status = gBS->InstallProtocolInterface (\r
506 &mHandle,\r
fa0737a8 507 &gEfiVariableArchProtocolGuid,\r
e4b7e2c9
RN
508 EFI_NATIVE_INTERFACE,\r
509 NULL\r
510 );\r
511 ASSERT_EFI_ERROR (Status);\r
512\r
513 //\r
514 // Register FtwNotificationEvent () notify function.\r
fa0737a8 515 //\r
e4b7e2c9
RN
516 EfiCreateProtocolNotifyEvent (\r
517 &gEfiFaultTolerantWriteProtocolGuid,\r
518 TPL_CALLBACK,\r
519 FtwNotificationEvent,\r
520 (VOID *)SystemTable,\r
521 &mFtwRegistration\r
522 );\r
523\r
524 Status = gBS->CreateEventEx (\r
525 EVT_NOTIFY_SIGNAL,\r
526 TPL_NOTIFY,\r
527 VariableClassAddressChangeEvent,\r
528 NULL,\r
529 &gEfiEventVirtualAddressChangeGuid,\r
530 &mVirtualAddressChangeEvent\r
531 );\r
532 ASSERT_EFI_ERROR (Status);\r
533\r
534 //\r
535 // Register the event handling function to reclaim variable for OS usage.\r
536 //\r
537 Status = EfiCreateEventReadyToBootEx (\r
fa0737a8
SZ
538 TPL_NOTIFY,\r
539 OnReadyToBoot,\r
540 NULL,\r
e4b7e2c9
RN
541 &ReadyToBootEvent\r
542 );\r
543 ASSERT_EFI_ERROR (Status);\r
544\r
545 //\r
546 // Register the event handling function to set the End Of DXE flag.\r
547 //\r
548 Status = gBS->CreateEventEx (\r
549 EVT_NOTIFY_SIGNAL,\r
3d7ebd64 550 TPL_CALLBACK,\r
e4b7e2c9
RN
551 OnEndOfDxe,\r
552 NULL,\r
553 &gEfiEndOfDxeEventGroupGuid,\r
554 &EndOfDxeEvent\r
555 );\r
556 ASSERT_EFI_ERROR (Status);\r
557\r
558 return EFI_SUCCESS;\r
559}\r
560\r