ArmPlatformPkg/NorFlashDxe: initialize varstore headers eagerly
The lazy initialization of the varstore FVB makes no longer sense at this point: - "mNorFlashInstanceTemplate.Initialize" is NULL; - in NorFlashCreateInstance(), we only set Instance->Initialize to non-NULL -- namely NorFlashFvbInitialize() -- if the FVB stands for the variable store (see "ContainVariableStorage" / "SupportFvb"); - we call Instance->Initialize() from three places: - from NorFlashWriteSingleBlock(), which is too late for the variable read service ("variable write" depends on "variable read"); - from InitializeFvAndVariableStoreHeaders(), but that is only reachable from NorFlashFvbInitialize(), i.e. recursively from Instance->Initialize() itself; - and from FvbRead(), which is never called by the variable driver, only by the FTW driver. However, the variable driver may read (not write) the memory-mapped varstore flash chip before the FTW driver is dispatched. Therefore the lazy initialization is both superfluous and insufficient. Initialize the varstore headers eagerly, before we install the FVB protocol interface. Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Leif Lindholm <leif.lindholm@linaro.org> Cc: Steve Capper <steve.capper@linaro.org> Cc: Supreeth Venkatesh <Supreeth.Venkatesh@arm.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Tested-by: Steve Capper <steve.capper@linaro.org> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
This commit is contained in:
@@ -32,9 +32,6 @@ NOR_FLASH_INSTANCE mNorFlashInstanceTemplate = {
|
||||
NOR_FLASH_SIGNATURE, // Signature
|
||||
NULL, // Handle ... NEED TO BE FILLED
|
||||
|
||||
FALSE, // Initialized
|
||||
NULL, // Initialize
|
||||
|
||||
0, // DeviceBaseAddress ... NEED TO BE FILLED
|
||||
0, // RegionBaseAddress ... NEED TO BE FILLED
|
||||
0, // Size ... NEED TO BE FILLED
|
||||
@@ -69,7 +66,6 @@ NOR_FLASH_INSTANCE mNorFlashInstanceTemplate = {
|
||||
NorFlashDiskIoWriteDisk // WriteDisk
|
||||
},
|
||||
|
||||
FALSE, // SupportFvb ... NEED TO BE FILLED
|
||||
{
|
||||
FvbGetAttributes, // GetAttributes
|
||||
FvbSetAttributes, // SetAttributes
|
||||
@@ -137,8 +133,7 @@ NorFlashCreateInstance (
|
||||
}
|
||||
|
||||
if (SupportFvb) {
|
||||
Instance->SupportFvb = TRUE;
|
||||
Instance->Initialize = NorFlashFvbInitialize;
|
||||
NorFlashFvbInitialize (Instance);
|
||||
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
&Instance->Handle,
|
||||
@@ -152,8 +147,6 @@ NorFlashCreateInstance (
|
||||
return Status;
|
||||
}
|
||||
} else {
|
||||
Instance->Initialized = TRUE;
|
||||
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
&Instance->Handle,
|
||||
&gEfiDevicePathProtocolGuid, &Instance->DevicePath,
|
||||
@@ -924,10 +917,6 @@ NorFlashWriteSingleBlock (
|
||||
|
||||
PrevBlockAddress = 0;
|
||||
|
||||
if (!Instance->Initialized && Instance->Initialize) {
|
||||
Instance->Initialize(Instance);
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_BLKIO, "NorFlashWriteSingleBlock(Parameters: Lba=%ld, Offset=0x%x, *NumBytes=0x%x, Buffer @ 0x%08x)\n", Lba, Offset, *NumBytes, Buffer));
|
||||
|
||||
// Detect WriteDisabled state
|
||||
|
Reference in New Issue
Block a user