mirror of https://github.com/acidanthera/audk.git
ArmPlatformPkg/NorFlashDxe: Change Flash memory attributes before writes
In NorFlashFvbInitialize() if a valid Firmware Volume header is not found at the start of NOR Flash, the Flash memory is written before it has been remapped with EFI_MEMORY_UC attributes to allow write commands. Since the flash memory was previously mapped with Normal and possibly cacheable memory attributes, the Flash commands might never reach the device. This patch fixes this issue by remapping the Flash memory region with correct memory attributes before writing to it. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Achin Gupta <achin.gupta@arm.com> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
This commit is contained in:
parent
9c8fe63c15
commit
90d1f671cd
|
@ -719,6 +719,29 @@ NorFlashFvbInitialize (
|
||||||
UINTN RuntimeMmioRegionSize;
|
UINTN RuntimeMmioRegionSize;
|
||||||
|
|
||||||
DEBUG((DEBUG_BLKIO,"NorFlashFvbInitialize\n"));
|
DEBUG((DEBUG_BLKIO,"NorFlashFvbInitialize\n"));
|
||||||
|
ASSERT((Instance != NULL));
|
||||||
|
|
||||||
|
//
|
||||||
|
// Declare the Non-Volatile storage as EFI_MEMORY_RUNTIME
|
||||||
|
//
|
||||||
|
|
||||||
|
// Note: all the NOR Flash region needs to be reserved into the UEFI Runtime memory;
|
||||||
|
// even if we only use the small block region at the top of the NOR Flash.
|
||||||
|
// The reason is when the NOR Flash memory is set into program mode, the command
|
||||||
|
// is written as the base of the flash region (ie: Instance->DeviceBaseAddress)
|
||||||
|
RuntimeMmioRegionSize = (Instance->RegionBaseAddress - Instance->DeviceBaseAddress) + Instance->Size;
|
||||||
|
|
||||||
|
Status = gDS->AddMemorySpace (
|
||||||
|
EfiGcdMemoryTypeMemoryMappedIo,
|
||||||
|
Instance->DeviceBaseAddress, RuntimeMmioRegionSize,
|
||||||
|
EFI_MEMORY_UC | EFI_MEMORY_RUNTIME
|
||||||
|
);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
Status = gDS->SetMemorySpaceAttributes (
|
||||||
|
Instance->DeviceBaseAddress, RuntimeMmioRegionSize,
|
||||||
|
EFI_MEMORY_UC | EFI_MEMORY_RUNTIME);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
Instance->Initialized = TRUE;
|
Instance->Initialized = TRUE;
|
||||||
mFlashNvStorageVariableBase = FixedPcdGet32 (PcdFlashNvStorageVariableBase);
|
mFlashNvStorageVariableBase = FixedPcdGet32 (PcdFlashNvStorageVariableBase);
|
||||||
|
@ -756,28 +779,6 @@ NorFlashFvbInitialize (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Declare the Non-Volatile storage as EFI_MEMORY_RUNTIME
|
|
||||||
//
|
|
||||||
|
|
||||||
// Note: all the NOR Flash region needs to be reserved into the UEFI Runtime memory;
|
|
||||||
// even if we only use the small block region at the top of the NOR Flash.
|
|
||||||
// The reason is when the NOR Flash memory is set into program mode, the command
|
|
||||||
// is written as the base of the flash region (ie: Instance->DeviceBaseAddress)
|
|
||||||
RuntimeMmioRegionSize = (Instance->RegionBaseAddress - Instance->DeviceBaseAddress) + Instance->Size;
|
|
||||||
|
|
||||||
Status = gDS->AddMemorySpace (
|
|
||||||
EfiGcdMemoryTypeMemoryMappedIo,
|
|
||||||
Instance->DeviceBaseAddress, RuntimeMmioRegionSize,
|
|
||||||
EFI_MEMORY_UC | EFI_MEMORY_RUNTIME
|
|
||||||
);
|
|
||||||
ASSERT_EFI_ERROR (Status);
|
|
||||||
|
|
||||||
Status = gDS->SetMemorySpaceAttributes (
|
|
||||||
Instance->DeviceBaseAddress, RuntimeMmioRegionSize,
|
|
||||||
EFI_MEMORY_UC | EFI_MEMORY_RUNTIME);
|
|
||||||
ASSERT_EFI_ERROR (Status);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Register for the virtual address change event
|
// Register for the virtual address change event
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue