]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | Implement all four UEFI Runtime Variable services for the nonvolatile\r | |
3 | and volatile storage space and install variable architecture protocol.\r | |
4 | \r | |
5 | Copyright (C) 2013, Red Hat, Inc.\r | |
6 | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r | |
7 | (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r | |
8 | This program and the accompanying materials\r | |
9 | are licensed and made available under the terms and conditions of the BSD License\r | |
10 | which accompanies this distribution. The full text of the license may be found at\r | |
11 | http://opensource.org/licenses/bsd-license.php\r | |
12 | \r | |
13 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
14 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
15 | \r | |
16 | **/\r | |
17 | \r | |
18 | #include "Variable.h"\r | |
19 | \r | |
20 | extern VARIABLE_STORE_HEADER *mNvVariableCache;\r | |
21 | extern EFI_FIRMWARE_VOLUME_HEADER *mNvFvHeaderCache;\r | |
22 | extern VARIABLE_INFO_ENTRY *gVariableInfo;\r | |
23 | EFI_HANDLE mHandle = NULL;\r | |
24 | EFI_EVENT mVirtualAddressChangeEvent = NULL;\r | |
25 | EFI_EVENT mFtwRegistration = NULL;\r | |
26 | extern BOOLEAN mEndOfDxe;\r | |
27 | VOID ***mVarCheckAddressPointer = NULL;\r | |
28 | UINTN mVarCheckAddressPointerCount = 0;\r | |
29 | EDKII_VARIABLE_LOCK_PROTOCOL mVariableLock = { VariableLockRequestToLock };\r | |
30 | EDKII_VAR_CHECK_PROTOCOL mVarCheck = { VarCheckRegisterSetVariableCheckHandler,\r | |
31 | VarCheckVariablePropertySet,\r | |
32 | VarCheckVariablePropertyGet };\r | |
33 | \r | |
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 | |
39 | VOID\r | |
40 | EFIAPI\r | |
41 | RecordSecureBootPolicyVarData(\r | |
42 | VOID\r | |
43 | );\r | |
44 | \r | |
45 | /**\r | |
46 | Return TRUE if ExitBootServices () has been called.\r | |
47 | \r | |
48 | @retval TRUE If ExitBootServices () has been called.\r | |
49 | **/\r | |
50 | BOOLEAN\r | |
51 | AtRuntime (\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 | |
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 | |
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 | |
75 | EFI_LOCK *\r | |
76 | InitializeLock (\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 | |
97 | VOID\r | |
98 | AcquireLockOnlyAtBootTime (\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 | |
120 | VOID\r | |
121 | ReleaseLockOnlyAtBootTime (\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 | |
131 | Retrieve the Fault Tolerent Write protocol interface.\r | |
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 | |
140 | EFI_STATUS\r | |
141 | GetFtwProtocol (\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 | |
154 | );\r | |
155 | return Status;\r | |
156 | }\r | |
157 | \r | |
158 | /**\r | |
159 | Retrieve the FVB protocol interface by HANDLE.\r | |
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 | |
168 | \r | |
169 | **/\r | |
170 | EFI_STATUS\r | |
171 | GetFvbByHandle (\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 | |
189 | in a buffer allocated from pool.\r | |
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 | |
200 | \r | |
201 | **/\r | |
202 | EFI_STATUS\r | |
203 | GetFvbCountAndBuffer (\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 | |
234 | VOID\r | |
235 | EFIAPI\r | |
236 | VariableClassAddressChangeEvent (\r | |
237 | IN EFI_EVENT Event,\r | |
238 | IN VOID *Context\r | |
239 | )\r | |
240 | {\r | |
241 | UINTN Index;\r | |
242 | \r | |
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 | |
258 | EfiConvertPointer (0x0, (VOID **) &mNvVariableCache);\r | |
259 | EfiConvertPointer (0x0, (VOID **) &mNvFvHeaderCache);\r | |
260 | \r | |
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 | |
266 | \r | |
267 | if (mVarCheckAddressPointer != NULL) {\r | |
268 | for (Index = 0; Index < mVarCheckAddressPointerCount; Index++) {\r | |
269 | EfiConvertPointer (0x0, (VOID **) mVarCheckAddressPointer[Index]);\r | |
270 | }\r | |
271 | }\r | |
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 | |
286 | VOID\r | |
287 | EFIAPI\r | |
288 | OnReadyToBoot (\r | |
289 | EFI_EVENT Event,\r | |
290 | VOID *Context\r | |
291 | )\r | |
292 | {\r | |
293 | if (!mEndOfDxe) {\r | |
294 | MorLockInitAtEndOfDxe ();\r | |
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 | |
305 | ReclaimForOS ();\r | |
306 | if (FeaturePcdGet (PcdVariableCollectStatistics)) {\r | |
307 | if (mVariableModuleGlobal->VariableGlobal.AuthFormat) {\r | |
308 | gBS->InstallConfigurationTable (&gEfiAuthenticatedVariableGuid, gVariableInfo);\r | |
309 | } else {\r | |
310 | gBS->InstallConfigurationTable (&gEfiVariableGuid, gVariableInfo);\r | |
311 | }\r | |
312 | }\r | |
313 | \r | |
314 | gBS->CloseEvent (Event);\r | |
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 | |
326 | VOID\r | |
327 | EFIAPI\r | |
328 | OnEndOfDxe (\r | |
329 | EFI_EVENT Event,\r | |
330 | VOID *Context\r | |
331 | )\r | |
332 | {\r | |
333 | DEBUG ((EFI_D_INFO, "[Variable]END_OF_DXE is signaled\n"));\r | |
334 | MorLockInitAtEndOfDxe ();\r | |
335 | mEndOfDxe = TRUE;\r | |
336 | mVarCheckAddressPointer = VarCheckLibInitializeAtEndOfDxe (&mVarCheckAddressPointerCount);\r | |
337 | //\r | |
338 | // The initialization for variable quota.\r | |
339 | //\r | |
340 | InitializeVariableQuota ();\r | |
341 | if (PcdGetBool (PcdReclaimVariableSpaceAtEndOfDxe)) {\r | |
342 | ReclaimForOS ();\r | |
343 | }\r | |
344 | \r | |
345 | gBS->CloseEvent (Event);\r | |
346 | }\r | |
347 | \r | |
348 | /**\r | |
349 | Fault Tolerant Write protocol notification event handler.\r | |
350 | \r | |
351 | Non-Volatile variable write may needs FTW protocol to reclaim when\r | |
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 | |
356 | \r | |
357 | **/\r | |
358 | VOID\r | |
359 | EFIAPI\r | |
360 | FtwNotificationEvent (\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 | |
374 | UINTN FtwMaxBlockSize;\r | |
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 | |
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 | |
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 | |
405 | VariableStoreBase = NvStorageVariableBase + (((EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)(NvStorageVariableBase))->HeaderLength);\r | |
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 | |
413 | DEBUG ((DEBUG_WARN, "Variable driver failed to get flash memory attribute.\n"));\r | |
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 | |
424 | \r | |
425 | Status = VariableWriteServiceInitialize ();\r | |
426 | if (EFI_ERROR (Status)) {\r | |
427 | DEBUG ((DEBUG_ERROR, "Variable write service initialization failed. Status = %r\n", Status));\r | |
428 | }\r | |
429 | \r | |
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 | |
436 | //\r | |
437 | // Install the Variable Write Architectural protocol.\r | |
438 | //\r | |
439 | Status = gBS->InstallProtocolInterface (\r | |
440 | &mHandle,\r | |
441 | &gEfiVariableWriteArchProtocolGuid,\r | |
442 | EFI_NATIVE_INTERFACE,\r | |
443 | NULL\r | |
444 | );\r | |
445 | ASSERT_EFI_ERROR (Status);\r | |
446 | \r | |
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 | |
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 | |
459 | a notification function for an EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.\r | |
460 | \r | |
461 | @param[in] ImageHandle The firmware allocated handle for the EFI image.\r | |
462 | @param[in] SystemTable A pointer to the EFI System Table.\r | |
463 | \r | |
464 | @retval EFI_SUCCESS Variable service successfully initialized.\r | |
465 | \r | |
466 | **/\r | |
467 | EFI_STATUS\r | |
468 | EFIAPI\r | |
469 | VariableServiceInitialize (\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 | |
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 | |
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 | |
501 | \r | |
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 | |
507 | &gEfiVariableArchProtocolGuid,\r | |
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 | |
515 | //\r | |
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 | |
538 | TPL_NOTIFY,\r | |
539 | OnReadyToBoot,\r | |
540 | NULL,\r | |
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 | |
550 | TPL_CALLBACK,\r | |
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 |