Implement all four UEFI Runtime Variable services for the nonvolatile\r
and volatile storage space and install variable architecture protocol.\r
\r
-Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
+Copyright (C) 2013, Red Hat, Inc.\r
+Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials \r
are licensed and made available under the terms and conditions of the BSD License \r
which accompanies this distribution. The full text of the license may be found at \r
EFI_HANDLE mHandle = NULL;\r
EFI_EVENT mVirtualAddressChangeEvent = NULL;\r
EFI_EVENT mFtwRegistration = NULL;\r
+extern LIST_ENTRY mLockedVariableList;\r
+extern LIST_ENTRY mVarCheckVariableList;\r
+extern UINT32 mNumberOfHandler;\r
+extern VAR_CHECK_SET_VARIABLE_CHECK_HANDLER *mHandlerTable;\r
extern BOOLEAN mEndOfDxe;\r
EDKII_VARIABLE_LOCK_PROTOCOL mVariableLock = { VariableLockRequestToLock };\r
+EDKII_VAR_CHECK_PROTOCOL mVarCheck = { VarCheckRegisterSetVariableCheckHandler,\r
+ VarCheckVariablePropertySet,\r
+ VarCheckVariablePropertyGet };\r
\r
/**\r
Return TRUE if ExitBootServices () has been called.\r
IN VOID *Context\r
)\r
{\r
+ EFI_STATUS Status;\r
+ UINTN Index;\r
+\r
EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->FvbInstance->GetBlockSize);\r
EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->FvbInstance->GetPhysicalAddress);\r
EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->FvbInstance->GetAttributes);\r
EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->VariableGlobal.HobVariableBase);\r
EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal);\r
EfiConvertPointer (0x0, (VOID **) &mNvVariableCache); \r
+ EfiConvertPointer (0x0, (VOID **) &mHandlerTable);\r
+ for (Index = 0; Index < mNumberOfHandler; Index++) {\r
+ EfiConvertPointer (0x0, (VOID **) &mHandlerTable[Index]);\r
+ }\r
+\r
+ Status = EfiConvertList (0x0, &mLockedVariableList);\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ Status = EfiConvertList (0x0, &mVarCheckVariableList);\r
+ ASSERT_EFI_ERROR (Status);\r
}\r
\r
\r
// Set the End Of DXE bit in case the EFI_END_OF_DXE_EVENT_GROUP_GUID event is not signaled.\r
//\r
mEndOfDxe = TRUE;\r
+ //\r
+ // The initialization for variable quota.\r
+ //\r
+ InitializeVariableQuota ();\r
ReclaimForOS ();\r
if (FeaturePcdGet (PcdVariableCollectStatistics)) {\r
gBS->InstallConfigurationTable (&gEfiVariableGuid, gVariableInfo);\r
)\r
{\r
mEndOfDxe = TRUE;\r
+ //\r
+ // The initialization for variable quota.\r
+ //\r
+ InitializeVariableQuota ();\r
+ if (PcdGetBool (PcdReclaimVariableSpaceAtEndOfDxe)) {\r
+ ReclaimForOS ();\r
+ }\r
}\r
\r
/**\r
UINT64 Length;\r
EFI_PHYSICAL_ADDRESS VariableStoreBase;\r
UINT64 VariableStoreLength;\r
+ UINTN FtwMaxBlockSize;\r
\r
//\r
// Ensure FTW protocol is installed.\r
if (EFI_ERROR (Status)) {\r
return ;\r
}\r
- \r
+\r
+ Status = FtwProtocol->GetMaxBlockSize (FtwProtocol, &FtwMaxBlockSize);\r
+ if (!EFI_ERROR (Status)) {\r
+ ASSERT (PcdGet32 (PcdFlashNvStorageVariableSize) <= FtwMaxBlockSize);\r
+ }\r
+\r
//\r
// Find the proper FVB protocol for variable.\r
//\r
//\r
// Mark the variable storage region of the FLASH as RUNTIME.\r
//\r
- VariableStoreBase = mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase;\r
+ VariableStoreBase = NvStorageVariableBase + (((EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)(NvStorageVariableBase))->HeaderLength);\r
VariableStoreLength = ((VARIABLE_STORE_HEADER *)(UINTN)VariableStoreBase)->Size;\r
BaseAddress = VariableStoreBase & (~EFI_PAGE_MASK);\r
Length = VariableStoreLength + (VariableStoreBase - BaseAddress);\r
\r
Status = gDS->GetMemorySpaceDescriptor (BaseAddress, &GcdDescriptor);\r
if (EFI_ERROR (Status)) {\r
- DEBUG ((DEBUG_WARN, "Variable driver failed to add EFI_MEMORY_RUNTIME attribute to Flash.\n"));\r
+ DEBUG ((DEBUG_WARN, "Variable driver failed to get flash memory attribute.\n"));\r
} else {\r
Status = gDS->SetMemorySpaceAttributes (\r
BaseAddress,\r
);\r
ASSERT_EFI_ERROR (Status);\r
\r
+ Status = gBS->InstallMultipleProtocolInterfaces (\r
+ &mHandle,\r
+ &gEdkiiVarCheckProtocolGuid,\r
+ &mVarCheck,\r
+ NULL\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
SystemTable->RuntimeServices->GetVariable = VariableServiceGetVariable;\r
SystemTable->RuntimeServices->GetNextVariableName = VariableServiceGetNextVariableName;\r
SystemTable->RuntimeServices->SetVariable = VariableServiceSetVariable;\r