]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
Add SMM Variable implementation.
[mirror_edk2.git] / MdeModulePkg / Universal / Variable / RuntimeDxe / VariableSmm.c
CommitLineData
8a2d4996 1/** @file\r
2\r
3 The sample implementation for SMM variable protocol. And this driver \r
4 implements an SMI handler to communicate with the DXE runtime driver \r
5 to provide variable services.\r
6\r
7Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
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
12\r
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
15\r
16**/\r
17#include <Protocol/SmmFaultTolerantWrite.h>\r
18#include <Library/SmmServicesTableLib.h>\r
19\r
20#include "Variable.h"\r
21#include "VariableSmmCommon.h"\r
22\r
23extern SMM_VARIABLE_COMMUNICATE_VARIABLE_INFO_ENTRY *gVariableInfo;\r
24EFI_HANDLE mSmmVariableHandle = NULL;\r
25EFI_HANDLE mVariableHandle = NULL;\r
26BOOLEAN mAtRuntime = FALSE;\r
27EFI_GUID mZeroGuid = {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}};\r
28EFI_GUID mSmmVariableWriteGuid = EFI_SMM_VARIABLE_WRITE_GUID;\r
29 \r
30EFI_SMM_VARIABLE_PROTOCOL gSmmVariable = {\r
31 VariableServiceGetVariable,\r
32 VariableServiceGetNextVariableName,\r
33 VariableServiceSetVariable,\r
34 VariableServiceQueryVariableInfo\r
35};\r
36\r
37\r
38/**\r
39 Return TRUE if ExitBootServices () has been called.\r
40 \r
41 @retval TRUE If ExitBootServices () has been called.\r
42**/\r
43BOOLEAN\r
44AtRuntime (\r
45 VOID\r
46 )\r
47{\r
48 return mAtRuntime;\r
49}\r
50\r
51/**\r
52 Initializes a basic mutual exclusion lock.\r
53\r
54 This function initializes a basic mutual exclusion lock to the released state \r
55 and returns the lock. Each lock provides mutual exclusion access at its task \r
56 priority level. Since there is no preemption or multiprocessor support in EFI,\r
57 acquiring the lock only consists of raising to the locks TPL.\r
58 If Lock is NULL, then ASSERT().\r
59 If Priority is not a valid TPL value, then ASSERT().\r
60\r
61 @param Lock A pointer to the lock data structure to initialize.\r
62 @param Priority EFI TPL is associated with the lock.\r
63\r
64 @return The lock.\r
65\r
66**/\r
67EFI_LOCK *\r
68InitializeLock (\r
69 IN OUT EFI_LOCK *Lock,\r
70 IN EFI_TPL Priority\r
71 )\r
72{\r
73 return Lock;\r
74}\r
75\r
76/**\r
77 Acquires lock only at boot time. Simply returns at runtime.\r
78\r
79 This is a temperary function that will be removed when\r
80 EfiAcquireLock() in UefiLib can handle the call in UEFI\r
81 Runtimer driver in RT phase.\r
82 It calls EfiAcquireLock() at boot time, and simply returns\r
83 at runtime.\r
84\r
85 @param Lock A pointer to the lock to acquire.\r
86\r
87**/\r
88VOID\r
89AcquireLockOnlyAtBootTime (\r
90 IN EFI_LOCK *Lock\r
91 )\r
92{\r
93\r
94}\r
95\r
96\r
97/**\r
98 Releases lock only at boot time. Simply returns at runtime.\r
99\r
100 This is a temperary function which will be removed when\r
101 EfiReleaseLock() in UefiLib can handle the call in UEFI\r
102 Runtimer driver in RT phase.\r
103 It calls EfiReleaseLock() at boot time and simply returns\r
104 at runtime.\r
105\r
106 @param Lock A pointer to the lock to release.\r
107\r
108**/\r
109VOID\r
110ReleaseLockOnlyAtBootTime (\r
111 IN EFI_LOCK *Lock\r
112 )\r
113{\r
114\r
115}\r
116\r
117/**\r
118 Retrive the SMM Fault Tolerent Write protocol interface.\r
119\r
120 @param[out] FtwProtocol The interface of SMM Ftw protocol\r
121\r
122 @retval EFI_SUCCESS The SMM FTW protocol instance was found and returned in FtwProtocol.\r
123 @retval EFI_NOT_FOUND The SMM FTW protocol instance was not found.\r
124 @retval EFI_INVALID_PARAMETER SarProtocol is NULL.\r
125\r
126**/\r
127EFI_STATUS\r
128GetFtwProtocol (\r
129 OUT VOID **FtwProtocol\r
130 )\r
131{\r
132 EFI_STATUS Status;\r
133\r
134 //\r
135 // Locate Smm Fault Tolerent Write protocol\r
136 //\r
137 Status = gSmst->SmmLocateProtocol (\r
138 &gEfiSmmFaultTolerantWriteProtocolGuid, \r
139 NULL, \r
140 FtwProtocol\r
141 );\r
142 return Status;\r
143}\r
144\r
145\r
146/**\r
147 Retrive the SMM FVB protocol interface by HANDLE.\r
148\r
149 @param[in] FvBlockHandle The handle of SMM FVB protocol that provides services for\r
150 reading, writing, and erasing the target block.\r
151 @param[out] FvBlock The interface of SMM FVB protocol\r
152\r
153 @retval EFI_SUCCESS The interface information for the specified protocol was returned.\r
154 @retval EFI_UNSUPPORTED The device does not support the SMM FVB protocol.\r
155 @retval EFI_INVALID_PARAMETER FvBlockHandle is not a valid EFI_HANDLE or FvBlock is NULL.\r
156\r
157**/\r
158EFI_STATUS\r
159GetFvbByHandle (\r
160 IN EFI_HANDLE FvBlockHandle,\r
161 OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL **FvBlock\r
162 )\r
163{\r
164 //\r
165 // To get the SMM FVB protocol interface on the handle\r
166 //\r
167 return gSmst->SmmHandleProtocol (\r
168 FvBlockHandle,\r
169 &gEfiSmmFirmwareVolumeBlockProtocolGuid,\r
170 (VOID **) FvBlock\r
171 );\r
172}\r
173\r
174\r
175/**\r
176 Function returns an array of handles that support the SMM FVB protocol\r
177 in a buffer allocated from pool. \r
178\r
179 @param[out] NumberHandles The number of handles returned in Buffer.\r
180 @param[out] Buffer A pointer to the buffer to return the requested\r
181 array of handles that support SMM FVB protocol.\r
182\r
183 @retval EFI_SUCCESS The array of handles was returned in Buffer, and the number of\r
184 handles in Buffer was returned in NumberHandles.\r
185 @retval EFI_NOT_FOUND No SMM FVB handle was found.\r
186 @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the matching results.\r
187 @retval EFI_INVALID_PARAMETER NumberHandles is NULL or Buffer is NULL.\r
188\r
189**/\r
190EFI_STATUS\r
191GetFvbCountAndBuffer (\r
192 OUT UINTN *NumberHandles,\r
193 OUT EFI_HANDLE **Buffer\r
194 )\r
195{\r
196 EFI_STATUS Status;\r
197 UINTN BufferSize;\r
198\r
199 if ((NumberHandles == NULL) || (Buffer == NULL)) {\r
200 return EFI_INVALID_PARAMETER;\r
201 }\r
202\r
203 BufferSize = 0;\r
204 *NumberHandles = 0;\r
205 *Buffer = NULL;\r
206 Status = gSmst->SmmLocateHandle (\r
207 ByProtocol,\r
208 &gEfiSmmFirmwareVolumeBlockProtocolGuid,\r
209 NULL,\r
210 &BufferSize,\r
211 *Buffer\r
212 );\r
213 if (EFI_ERROR(Status) && Status != EFI_BUFFER_TOO_SMALL) {\r
214 return EFI_NOT_FOUND;\r
215 }\r
216\r
217 *Buffer = AllocatePool (BufferSize);\r
218 if (*Buffer == NULL) {\r
219 return EFI_OUT_OF_RESOURCES;\r
220 }\r
221\r
222 Status = gSmst->SmmLocateHandle (\r
223 ByProtocol,\r
224 &gEfiSmmFirmwareVolumeBlockProtocolGuid,\r
225 NULL,\r
226 &BufferSize,\r
227 *Buffer\r
228 );\r
229\r
230 *NumberHandles = BufferSize / sizeof(EFI_HANDLE);\r
231 if (EFI_ERROR(Status)) {\r
232 *NumberHandles = 0;\r
233 }\r
234\r
235 return Status;\r
236}\r
237\r
238\r
239/**\r
240 Get the variable statistics information from the information buffer pointed by gVariableInfo.\r
241\r
242 @param[in, out] InfoEntry A pointer to the buffer of variable information entry.\r
243 On input, point to the variable information returned last time. if \r
244 InfoEntry->VendorGuid is zero, return the first information.\r
245 On output, point to the next variable information.\r
246 @param[in, out] InfoSize On input, the size of the variable information buffer.\r
247 On output, the returned variable information size.\r
248\r
249 @retval EFI_SUCCESS The variable information is found and returned successfully.\r
250 @retval EFI_UNSUPPORTED No variable inoformation exists in variable driver. The \r
251 PcdVariableCollectStatistics should be set TRUE to support it.\r
252 @retval EFI_BUFFER_TOO_SMALL The buffer is too small to hold the next variable information.\r
253\r
254**/\r
255EFI_STATUS\r
256SmmVariableGetStatistics (\r
257 IN OUT SMM_VARIABLE_COMMUNICATE_VARIABLE_INFO_ENTRY *InfoEntry,\r
258 IN OUT UINTN *InfoSize\r
259 )\r
260{\r
261 SMM_VARIABLE_COMMUNICATE_VARIABLE_INFO_ENTRY *VariableInfo;\r
262 UINTN NameLength;\r
263 UINTN StatisticsInfoSize;\r
264 CHAR16 *InfoName;\r
265 \r
266 ASSERT (InfoEntry != NULL);\r
267 VariableInfo = gVariableInfo; \r
268 if (VariableInfo == NULL) {\r
269 return EFI_UNSUPPORTED;\r
270 }\r
271\r
272 StatisticsInfoSize = sizeof (SMM_VARIABLE_COMMUNICATE_VARIABLE_INFO_ENTRY) + StrSize (VariableInfo->Name);\r
273 if (*InfoSize < sizeof (SMM_VARIABLE_COMMUNICATE_VARIABLE_INFO_ENTRY)) {\r
274 *InfoSize = StatisticsInfoSize;\r
275 return EFI_BUFFER_TOO_SMALL;\r
276 }\r
277 InfoName = (CHAR16 *)(InfoEntry + 1);\r
278\r
279 if (CompareGuid (&InfoEntry->VendorGuid, &mZeroGuid)) {\r
280 //\r
281 // Return the first variable info\r
282 //\r
283 CopyMem (InfoEntry, VariableInfo, sizeof (SMM_VARIABLE_COMMUNICATE_VARIABLE_INFO_ENTRY));\r
284 CopyMem (InfoName, VariableInfo->Name, StrSize (VariableInfo->Name));\r
285 *InfoSize = StatisticsInfoSize;\r
286 return EFI_SUCCESS;\r
287 }\r
288\r
289 //\r
290 // Get the next variable info\r
291 //\r
292 while (VariableInfo != NULL) {\r
293 if (CompareGuid (&VariableInfo->VendorGuid, &InfoEntry->VendorGuid)) {\r
294 NameLength = StrSize (VariableInfo->Name);\r
295 if (NameLength == StrSize (InfoName)) {\r
296 if (CompareMem (VariableInfo->Name, InfoName, NameLength) == 0) {\r
297 //\r
298 // Find the match one\r
299 //\r
300 VariableInfo = VariableInfo->Next;\r
301 break;\r
302 }\r
303 }\r
304 }\r
305 VariableInfo = VariableInfo->Next;\r
306 };\r
307 \r
308 if (VariableInfo == NULL) {\r
309 *InfoSize = 0;\r
310 return EFI_SUCCESS;\r
311 }\r
312\r
313 //\r
314 // Output the new variable info\r
315 //\r
316 StatisticsInfoSize = sizeof (SMM_VARIABLE_COMMUNICATE_VARIABLE_INFO_ENTRY) + StrSize (VariableInfo->Name);\r
317 if (*InfoSize < StatisticsInfoSize) {\r
318 *InfoSize = StatisticsInfoSize;\r
319 return EFI_BUFFER_TOO_SMALL;\r
320 }\r
321\r
322 CopyMem (InfoEntry, VariableInfo, sizeof (SMM_VARIABLE_COMMUNICATE_VARIABLE_INFO_ENTRY));\r
323 CopyMem (InfoName, VariableInfo->Name, StrSize (VariableInfo->Name));\r
324 *InfoSize = StatisticsInfoSize;\r
325 \r
326 return EFI_SUCCESS;\r
327}\r
328\r
329\r
330/**\r
331 Communication service SMI Handler entry.\r
332\r
333 This SMI handler provides services for the variable wrapper driver.\r
334\r
335 @param[in] DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().\r
336 @param[in] RegisterContext Points to an optional handler context which was specified when the\r
337 handler was registered.\r
338 @param[in, out] CommBuffer A pointer to a collection of data in memory that will\r
339 be conveyed from a non-SMM environment into an SMM environment.\r
340 @param[in, out] CommBufferSize The size of the CommBuffer.\r
341\r
342 @retval EFI_SUCCESS The interrupt was handled and quiesced. No other handlers \r
343 should still be called.\r
344 @retval EFI_WARN_INTERRUPT_SOURCE_QUIESCED The interrupt has been quiesced but other handlers should \r
345 still be called.\r
346 @retval EFI_WARN_INTERRUPT_SOURCE_PENDING The interrupt is still pending and other handlers should still \r
347 be called.\r
348 @retval EFI_INTERRUPT_PENDING The interrupt could not be quiesced.\r
349**/\r
350EFI_STATUS\r
351EFIAPI\r
352SmmVariableHandler (\r
353 IN EFI_HANDLE DispatchHandle,\r
354 IN CONST VOID *RegisterContext,\r
355 IN OUT VOID *CommBuffer,\r
356 IN OUT UINTN *CommBufferSize\r
357 )\r
358{\r
359 EFI_STATUS Status;\r
360 SMM_VARIABLE_COMMUNICATE_HEADER *SmmVariableFunctionHeader;\r
361 SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE *SmmVariableHeader;\r
362 SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME *GetNextVariableName;\r
363 SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO *QueryVariableInfo;\r
364 SMM_VARIABLE_COMMUNICATE_VARIABLE_INFO_ENTRY *VariableInfo;\r
365 UINTN InfoSize;\r
366\r
367 ASSERT (CommBuffer != NULL);\r
368\r
369 SmmVariableFunctionHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *)CommBuffer;\r
370 switch (SmmVariableFunctionHeader->Function) {\r
371 case SMM_VARIABLE_FUNCTION_GET_VARIABLE:\r
372 SmmVariableHeader = (SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE *) SmmVariableFunctionHeader->Data; \r
373 Status = VariableServiceGetVariable (\r
374 SmmVariableHeader->Name,\r
375 &SmmVariableHeader->Guid,\r
376 &SmmVariableHeader->Attributes,\r
377 &SmmVariableHeader->DataSize,\r
378 (UINT8 *)SmmVariableHeader->Name + SmmVariableHeader->NameSize\r
379 );\r
380 break;\r
381 \r
382 case SMM_VARIABLE_FUNCTION_GET_NEXT_VARIABLE_NAME:\r
383 GetNextVariableName = (SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME *) SmmVariableFunctionHeader->Data;\r
384 Status = VariableServiceGetNextVariableName (\r
385 &GetNextVariableName->NameSize,\r
386 GetNextVariableName->Name,\r
387 &GetNextVariableName->Guid\r
388 );\r
389 break;\r
390 \r
391 case SMM_VARIABLE_FUNCTION_SET_VARIABLE:\r
392 SmmVariableHeader = (SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE *) SmmVariableFunctionHeader->Data;\r
393 Status = VariableServiceSetVariable (\r
394 SmmVariableHeader->Name,\r
395 &SmmVariableHeader->Guid,\r
396 SmmVariableHeader->Attributes,\r
397 SmmVariableHeader->DataSize,\r
398 (UINT8 *)SmmVariableHeader->Name + SmmVariableHeader->NameSize\r
399 );\r
400 break;\r
401 \r
402 case SMM_VARIABLE_FUNCTION_QUERY_VARIABLE_INFO:\r
403 QueryVariableInfo = (SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO *) SmmVariableFunctionHeader->Data;\r
404 Status = VariableServiceQueryVariableInfo (\r
405 QueryVariableInfo->Attributes,\r
406 &QueryVariableInfo->MaximumVariableStorageSize,\r
407 &QueryVariableInfo->RemainingVariableStorageSize,\r
408 &QueryVariableInfo->MaximumVariableSize\r
409 );\r
410 break;\r
411\r
412 case SMM_VARIABLE_FUNCTION_READY_TO_BOOT:\r
413 ReclaimForOS ();\r
414 Status = EFI_SUCCESS;\r
415 break;\r
416 \r
417 case SMM_VARIABLE_FUNCTION_EXIT_BOOT_SERVICE:\r
418 mAtRuntime = TRUE;\r
419 Status = EFI_SUCCESS;\r
420 break;\r
421\r
422 case SMM_VARIABLE_FUNCTION_GET_STATISTICS:\r
423 VariableInfo = (SMM_VARIABLE_COMMUNICATE_VARIABLE_INFO_ENTRY *) SmmVariableFunctionHeader->Data;\r
424 InfoSize = *CommBufferSize - OFFSET_OF (SMM_VARIABLE_COMMUNICATE_HEADER, Data);\r
425 Status = SmmVariableGetStatistics (VariableInfo, &InfoSize);\r
426 *CommBufferSize = InfoSize + OFFSET_OF (SMM_VARIABLE_COMMUNICATE_HEADER, Data);\r
427 break;\r
428\r
429 default:\r
430 ASSERT (FALSE);\r
431 Status = EFI_UNSUPPORTED;\r
432 }\r
433\r
434 SmmVariableFunctionHeader->ReturnStatus = Status;\r
435\r
436 return EFI_SUCCESS;\r
437}\r
438\r
439\r
440/**\r
441 SMM Fault Tolerant Write protocol notification event handler.\r
442\r
443 Non-Volatile variable write may needs FTW protocol to reclaim when \r
444 writting variable.\r
445 \r
446 @param Protocol Points to the protocol's unique identifier\r
447 @param Interface Points to the interface instance\r
448 @param Handle The handle on which the interface was installed\r
449\r
450 @retval EFI_SUCCESS SmmEventCallback runs successfully\r
451 @retval EFI_NOT_FOUND The Fvb protocol for variable is not found.\r
452 \r
453 **/\r
454EFI_STATUS\r
455EFIAPI\r
456SmmFtwNotificationEvent (\r
457 IN CONST EFI_GUID *Protocol,\r
458 IN VOID *Interface,\r
459 IN EFI_HANDLE Handle\r
460 )\r
461{\r
462 EFI_STATUS Status;\r
463 EFI_SMM_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol;\r
464 EFI_SMM_FAULT_TOLERANT_WRITE_PROTOCOL *FtwProtocol;\r
465 EFI_PHYSICAL_ADDRESS NvStorageVariableBase;\r
466 \r
467 if (mVariableModuleGlobal->FvbInstance != NULL) {\r
468 return EFI_SUCCESS;\r
469 }\r
470\r
471 //\r
472 // Ensure SMM FTW protocol is installed.\r
473 //\r
474 Status = GetFtwProtocol (&FtwProtocol);\r
475 if (EFI_ERROR (Status)) {\r
476 return Status;\r
477 }\r
478\r
479 //\r
480 // Find the proper FVB protocol for variable.\r
481 //\r
482 NvStorageVariableBase = (EFI_PHYSICAL_ADDRESS) PcdGet64 (PcdFlashNvStorageVariableBase64);\r
483 if (NvStorageVariableBase == 0) {\r
484 NvStorageVariableBase = (EFI_PHYSICAL_ADDRESS) PcdGet32 (PcdFlashNvStorageVariableBase);\r
485 }\r
486 Status = GetFvbInfoByAddress (NvStorageVariableBase, NULL, &FvbProtocol);\r
487 if (EFI_ERROR (Status)) {\r
488 return EFI_NOT_FOUND;\r
489 }\r
490\r
491 mVariableModuleGlobal->FvbInstance = FvbProtocol;\r
492 \r
493 Status = VariableWriteServiceInitialize ();\r
494 ASSERT_EFI_ERROR (Status);\r
495 \r
496 //\r
497 // Notify the variable wrapper driver the variable write service is ready\r
498 //\r
499 Status = gBS->InstallProtocolInterface (\r
500 &mSmmVariableHandle,\r
501 &mSmmVariableWriteGuid,\r
502 EFI_NATIVE_INTERFACE,\r
503 NULL\r
504 );\r
505 ASSERT_EFI_ERROR (Status);\r
506 \r
507 return EFI_SUCCESS;\r
508}\r
509\r
510\r
511/**\r
512 Variable Driver main entry point. The Variable driver places the 4 EFI\r
513 runtime services in the EFI System Table and installs arch protocols \r
514 for variable read and write services being availible. It also registers\r
515 a notification function for an EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.\r
516\r
517 @param[in] ImageHandle The firmware allocated handle for the EFI image. \r
518 @param[in] SystemTable A pointer to the EFI System Table.\r
519 \r
520 @retval EFI_SUCCESS Variable service successfully initialized.\r
521\r
522**/\r
523EFI_STATUS\r
524EFIAPI\r
525VariableServiceInitialize (\r
526 IN EFI_HANDLE ImageHandle,\r
527 IN EFI_SYSTEM_TABLE *SystemTable\r
528 )\r
529{\r
530 EFI_STATUS Status;\r
531 EFI_HANDLE VariableHandle;\r
532 VOID *SmmFtwRegistration;\r
533 \r
534 //\r
535 // Variable initialize.\r
536 //\r
537 Status = VariableCommonInitialize ();\r
538 ASSERT_EFI_ERROR (Status);\r
539\r
540 //\r
541 // Install the Smm Variable Protocol on a new handle.\r
542 //\r
543 VariableHandle = NULL;\r
544 Status = gSmst->SmmInstallProtocolInterface (\r
545 &VariableHandle,\r
546 &gEfiSmmVariableProtocolGuid,\r
547 EFI_NATIVE_INTERFACE,\r
548 &gSmmVariable\r
549 );\r
550 ASSERT_EFI_ERROR (Status);\r
551\r
552 ///\r
553 /// Register SMM variable SMI handler\r
554 ///\r
555 VariableHandle = NULL;\r
556 Status = gSmst->SmiHandlerRegister (SmmVariableHandler, &gEfiSmmVariableProtocolGuid, &VariableHandle);\r
557 ASSERT_EFI_ERROR (Status);\r
558 \r
559 //\r
560 // Notify the variable wrapper driver the variable service is ready\r
561 //\r
562 Status = SystemTable->BootServices->InstallProtocolInterface (\r
563 &mVariableHandle,\r
564 &gEfiSmmVariableProtocolGuid,\r
565 EFI_NATIVE_INTERFACE,\r
566 &gSmmVariable\r
567 );\r
568 ASSERT_EFI_ERROR (Status);\r
569 \r
570 //\r
571 // Register FtwNotificationEvent () notify function.\r
572 // \r
573 Status = gSmst->SmmRegisterProtocolNotify (\r
574 &gEfiSmmFaultTolerantWriteProtocolGuid,\r
575 SmmFtwNotificationEvent,\r
576 &SmmFtwRegistration\r
577 );\r
578 ASSERT_EFI_ERROR (Status);\r
579\r
580 SmmFtwNotificationEvent (NULL, NULL, NULL);\r
581 \r
582 return EFI_SUCCESS;\r
583}\r
584\r
585\r