ArmPkg/CpuDxe: set DmaBufferAlignment according to CWG

The DmaBufferAlignment currently defaults to 4, which is dangerously
small and may result in lost data on platforms that perform non-coherent
DMA. So instead, take the CWG value from the cache info registers.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
This commit is contained in:
Ard Biesheuvel 2016-10-31 15:43:49 +00:00
parent a8f37449c7
commit 756a514aa4
1 changed files with 12 additions and 1 deletions

View File

@ -225,9 +225,18 @@ EFI_CPU_ARCH_PROTOCOL mCpu = {
CpuGetTimerValue,
CpuSetMemoryAttributes,
0, // NumberOfTimers
4, // DmaBufferAlignment
2048, // DmaBufferAlignment
};
STATIC
VOID
InitializeDma (
IN OUT EFI_CPU_ARCH_PROTOCOL *CpuArchProtocol
)
{
CpuArchProtocol->DmaBufferAlignment = ArmCacheWritebackGranule ();
}
EFI_STATUS
CpuDxeInitialize (
IN EFI_HANDLE ImageHandle,
@ -239,6 +248,8 @@ CpuDxeInitialize (
InitializeExceptions (&mCpu);
InitializeDma (&mCpu);
Status = gBS->InstallMultipleProtocolInterfaces (
&mCpuHandle,
&gEfiCpuArchProtocolGuid, &mCpu,