\r
#include "Variable.h"\r
\r
-extern VARIABLE_STORE_HEADER *mNvVariableCache;\r
-extern EFI_FIRMWARE_VOLUME_HEADER *mNvFvHeaderCache;\r
-extern VARIABLE_INFO_ENTRY *gVariableInfo;\r
EFI_HANDLE mHandle = NULL;\r
EFI_EVENT mVirtualAddressChangeEvent = NULL;\r
EFI_EVENT mFtwRegistration = NULL;\r
-extern BOOLEAN mEndOfDxe;\r
VOID ***mVarCheckAddressPointer = NULL;\r
UINTN mVarCheckAddressPointerCount = 0;\r
EDKII_VARIABLE_LOCK_PROTOCOL mVariableLock = { VariableLockRequestToLock };\r
gBS->CloseEvent (Event);\r
}\r
\r
+/**\r
+ Initializes variable write service for DXE.\r
+\r
+**/\r
+VOID\r
+VariableWriteServiceInitializeDxe (\r
+ VOID\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ Status = VariableWriteServiceInitialize ();\r
+ if (EFI_ERROR (Status)) {\r
+ DEBUG ((DEBUG_ERROR, "Variable write service initialization failed. Status = %r\n", Status));\r
+ }\r
+\r
+ //\r
+ // Some Secure Boot Policy Var (SecureBoot, etc) updates following other\r
+ // Secure Boot Policy Variable change. Record their initial value.\r
+ //\r
+ RecordSecureBootPolicyVarData();\r
+\r
+ //\r
+ // Install the Variable Write Architectural protocol.\r
+ //\r
+ Status = gBS->InstallProtocolInterface (\r
+ &mHandle,\r
+ &gEfiVariableWriteArchProtocolGuid,\r
+ EFI_NATIVE_INTERFACE,\r
+ NULL\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+}\r
+\r
/**\r
Fault Tolerant Write protocol notification event handler.\r
\r
ASSERT (PcdGet32 (PcdFlashNvStorageVariableSize) <= FtwMaxBlockSize);\r
}\r
\r
+ NvStorageVariableBase = NV_STORAGE_VARIABLE_BASE;\r
+ VariableStoreBase = NvStorageVariableBase + mNvFvHeaderCache->HeaderLength;\r
+\r
+ //\r
+ // Let NonVolatileVariableBase point to flash variable store base directly after FTW ready.\r
+ //\r
+ mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase = VariableStoreBase;\r
+\r
//\r
// Find the proper FVB protocol for variable.\r
//\r
- NvStorageVariableBase = (EFI_PHYSICAL_ADDRESS) PcdGet64 (PcdFlashNvStorageVariableBase64);\r
- if (NvStorageVariableBase == 0) {\r
- NvStorageVariableBase = (EFI_PHYSICAL_ADDRESS) PcdGet32 (PcdFlashNvStorageVariableBase);\r
- }\r
Status = GetFvbInfoByAddress (NvStorageVariableBase, NULL, &FvbProtocol);\r
if (EFI_ERROR (Status)) {\r
return ;\r
//\r
// Mark the variable storage region of the FLASH as RUNTIME.\r
//\r
- VariableStoreBase = NvStorageVariableBase + mNvFvHeaderCache->HeaderLength;\r
VariableStoreLength = mNvVariableCache->Size;\r
BaseAddress = VariableStoreBase & (~EFI_PAGE_MASK);\r
Length = VariableStoreLength + (VariableStoreBase - BaseAddress);\r
}\r
}\r
\r
- Status = VariableWriteServiceInitialize ();\r
- if (EFI_ERROR (Status)) {\r
- DEBUG ((DEBUG_ERROR, "Variable write service initialization failed. Status = %r\n", Status));\r
- }\r
-\r
//\r
- // Some Secure Boot Policy Var (SecureBoot, etc) updates following other\r
- // Secure Boot Policy Variable change. Record their initial value.\r
- //\r
- RecordSecureBootPolicyVarData();\r
-\r
+ // Initializes variable write service after FTW was ready.\r
//\r
- // Install the Variable Write Architectural protocol.\r
- //\r
- Status = gBS->InstallProtocolInterface (\r
- &mHandle,\r
- &gEfiVariableWriteArchProtocolGuid,\r
- EFI_NATIVE_INTERFACE,\r
- NULL\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
+ VariableWriteServiceInitializeDxe ();\r
\r
//\r
// Close the notify event to avoid install gEfiVariableWriteArchProtocolGuid again.\r