Replace the uncached memory mapping of the framebuffer with a write-
combining one. This improves performance, and avoids issues with
unaligned accesses and DC ZVA instructions performed by the accelerated
memcpy/memset routines.
Instead of manipulating the memory attributes directly, use the
SetMemorySpaceAttributes() DXE services, which validates the attributes
against the capabilities of the region before making the actual change.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Jeremy Linton <jeremy.linton@arm.com>
Tested-by: Ryan Harkin <ryan.harkin@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
#include <Library/IoLib.h>\r
#include <Library/PcdLib.h>\r
#include <Library/DebugLib.h>\r
#include <Library/IoLib.h>\r
#include <Library/PcdLib.h>\r
#include <Library/DebugLib.h>\r
+#include <Library/DxeServicesTableLib.h>\r
#include <Library/LcdPlatformLib.h>\r
#include <Library/UefiBootServicesTableLib.h>\r
\r
#include <Library/LcdPlatformLib.h>\r
#include <Library/UefiBootServicesTableLib.h>\r
\r
-#include <Protocol/Cpu.h>\r
#include <Protocol/EdidDiscovered.h>\r
#include <Protocol/EdidActive.h>\r
\r
#include <Protocol/EdidDiscovered.h>\r
#include <Protocol/EdidActive.h>\r
\r
)\r
{\r
EFI_STATUS Status;\r
)\r
{\r
EFI_STATUS Status;\r
- EFI_CPU_ARCH_PROTOCOL *Cpu;\r
\r
Status = EFI_SUCCESS;\r
\r
\r
Status = EFI_SUCCESS;\r
\r
- // Ensure the Cpu architectural protocol is already installed\r
- Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **)&Cpu);\r
- ASSERT_EFI_ERROR(Status);\r
-\r
- // Mark the VRAM as un-cachable. The VRAM is inside the DRAM, which is cachable.\r
- Status = Cpu->SetMemoryAttributes(Cpu, *VramBaseAddress, *VramSize, EFI_MEMORY_UC);\r
+ // Mark the VRAM as write-combining. The VRAM is inside the DRAM, which is cacheable.\r
+ Status = gDS->SetMemorySpaceAttributes (*VramBaseAddress, *VramSize,\r
+ EFI_MEMORY_WC);\r
ASSERT_EFI_ERROR(Status);\r
if (EFI_ERROR(Status)) {\r
gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES(*VramSize));\r
ASSERT_EFI_ERROR(Status);\r
if (EFI_ERROR(Status)) {\r
gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES(*VramSize));\r
ArmPlatformPkg/ArmPlatformPkg.dec\r
\r
[LibraryClasses]\r
ArmPlatformPkg/ArmPlatformPkg.dec\r
\r
[LibraryClasses]\r
ArmPlatformSysConfigLib\r
ArmPlatformSysConfigLib\r
+ BaseLib\r
+ DxeServicesTableLib\r
\r
[Protocols]\r
gEfiEdidDiscoveredProtocolGuid # Produced\r
\r
[Protocols]\r
gEfiEdidDiscoveredProtocolGuid # Produced\r