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