]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPlatformPkg/HdLcdArmVExpressLib: use write-combine mapping for VRAM
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Thu, 6 Apr 2017 11:59:38 +0000 (12:59 +0100)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Thu, 6 Apr 2017 20:31:48 +0000 (21:31 +0100)
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>
ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf

index 67b2f14beee3b42dbb59a14d93cdb145f34bdad2..b1106ee19b98cebac01820924514eac79b97d0d5 100644 (file)
 #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/MemoryAllocationLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
 \r
-#include <Protocol/Cpu.h>\r
 #include <Protocol/EdidDiscovered.h>\r
 #include <Protocol/EdidActive.h>\r
 \r
@@ -119,7 +119,6 @@ LcdPlatformGetVram (
   )\r
 {\r
   EFI_STATUS              Status;\r
-  EFI_CPU_ARCH_PROTOCOL  *Cpu;\r
   EFI_ALLOCATE_TYPE       AllocationType;\r
 \r
   // Set the vram size\r
@@ -138,12 +137,9 @@ LcdPlatformGetVram (
     return Status;\r
   }\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-cacheable. The VRAM is inside the DRAM, which is cacheable.\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
index 7807247379295238972aec36f04794726407729d..dff17e86fd3e563b38318f696a94f2c75276b31f 100644 (file)
@@ -32,8 +32,9 @@ HdLcdArmVExpress.c
   ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec\r
 \r
 [LibraryClasses]\r
-  BaseLib\r
   ArmPlatformSysConfigLib\r
+  BaseLib\r
+  DxeServicesTableLib\r
 \r
 [Protocols]\r
   gEfiEdidDiscoveredProtocolGuid                # Produced\r