mirror of https://github.com/acidanthera/audk.git
1. Invoke InstallConfigurationTable () in OnReadyToBoot() to avoid the new registered table may be NULL.
2. For SMM variable driver, it doesn’t need to mark the variable storage region of the FLASH as RUNTIME, so only keep it for non-SMM variable driver. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11212 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
9969fde78d
commit
9ae0edbfa9
|
@ -2259,9 +2259,6 @@ VariableWriteServiceInitialize (
|
||||||
VARIABLE_STORE_HEADER *VariableStoreHeader;
|
VARIABLE_STORE_HEADER *VariableStoreHeader;
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
UINT8 Data;
|
UINT8 Data;
|
||||||
EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor;
|
|
||||||
EFI_PHYSICAL_ADDRESS BaseAddress;
|
|
||||||
UINT64 Length;
|
|
||||||
EFI_PHYSICAL_ADDRESS VariableStoreBase;
|
EFI_PHYSICAL_ADDRESS VariableStoreBase;
|
||||||
UINT64 VariableStoreLength;
|
UINT64 VariableStoreLength;
|
||||||
|
|
||||||
|
@ -2291,26 +2288,6 @@ VariableWriteServiceInitialize (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Mark the variable storage region of the FLASH as RUNTIME.
|
|
||||||
//
|
|
||||||
BaseAddress = VariableStoreBase & (~EFI_PAGE_MASK);
|
|
||||||
Length = VariableStoreLength + (VariableStoreBase - BaseAddress);
|
|
||||||
Length = (Length + EFI_PAGE_SIZE - 1) & (~EFI_PAGE_MASK);
|
|
||||||
|
|
||||||
Status = gDS->GetMemorySpaceDescriptor (BaseAddress, &GcdDescriptor);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
DEBUG ((DEBUG_WARN, "Variable driver failed to add EFI_MEMORY_RUNTIME attribute to Flash.\n"));
|
|
||||||
} else {
|
|
||||||
Status = gDS->SetMemorySpaceAttributes (
|
|
||||||
BaseAddress,
|
|
||||||
Length,
|
|
||||||
GcdDescriptor.Attributes | EFI_MEMORY_RUNTIME
|
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
DEBUG ((DEBUG_WARN, "Variable driver failed to add EFI_MEMORY_RUNTIME attribute to Flash.\n"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -255,6 +255,9 @@ OnReadyToBoot (
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ReclaimForOS ();
|
ReclaimForOS ();
|
||||||
|
if (FeaturePcdGet (PcdVariableCollectStatistics)) {
|
||||||
|
gBS->InstallConfigurationTable (&gEfiVariableGuid, gVariableInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -279,6 +282,11 @@ FtwNotificationEvent (
|
||||||
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol;
|
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol;
|
||||||
EFI_FAULT_TOLERANT_WRITE_PROTOCOL *FtwProtocol;
|
EFI_FAULT_TOLERANT_WRITE_PROTOCOL *FtwProtocol;
|
||||||
EFI_PHYSICAL_ADDRESS NvStorageVariableBase;
|
EFI_PHYSICAL_ADDRESS NvStorageVariableBase;
|
||||||
|
EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor;
|
||||||
|
EFI_PHYSICAL_ADDRESS BaseAddress;
|
||||||
|
UINT64 Length;
|
||||||
|
EFI_PHYSICAL_ADDRESS VariableStoreBase;
|
||||||
|
UINT64 VariableStoreLength;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Ensure FTW protocol is installed.
|
// Ensure FTW protocol is installed.
|
||||||
|
@ -300,6 +308,29 @@ FtwNotificationEvent (
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
mVariableModuleGlobal->FvbInstance = FvbProtocol;
|
mVariableModuleGlobal->FvbInstance = FvbProtocol;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Mark the variable storage region of the FLASH as RUNTIME.
|
||||||
|
//
|
||||||
|
VariableStoreBase = mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase;
|
||||||
|
VariableStoreLength = ((VARIABLE_STORE_HEADER *)(UINTN)VariableStoreBase)->Size;
|
||||||
|
BaseAddress = VariableStoreBase & (~EFI_PAGE_MASK);
|
||||||
|
Length = VariableStoreLength + (VariableStoreBase - BaseAddress);
|
||||||
|
Length = (Length + EFI_PAGE_SIZE - 1) & (~EFI_PAGE_MASK);
|
||||||
|
|
||||||
|
Status = gDS->GetMemorySpaceDescriptor (BaseAddress, &GcdDescriptor);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
DEBUG ((DEBUG_WARN, "Variable driver failed to add EFI_MEMORY_RUNTIME attribute to Flash.\n"));
|
||||||
|
} else {
|
||||||
|
Status = gDS->SetMemorySpaceAttributes (
|
||||||
|
BaseAddress,
|
||||||
|
Length,
|
||||||
|
GcdDescriptor.Attributes | EFI_MEMORY_RUNTIME
|
||||||
|
);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
DEBUG ((DEBUG_WARN, "Variable driver failed to add EFI_MEMORY_RUNTIME attribute to Flash.\n"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Status = VariableWriteServiceInitialize ();
|
Status = VariableWriteServiceInitialize ();
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
@ -395,9 +426,6 @@ VariableServiceInitialize (
|
||||||
&ReadyToBootEvent
|
&ReadyToBootEvent
|
||||||
);
|
);
|
||||||
|
|
||||||
if (FeaturePcdGet (PcdVariableCollectStatistics)) {
|
|
||||||
gBS->InstallConfigurationTable (&gEfiVariableGuid, gVariableInfo);
|
|
||||||
}
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue