Browse Source

Platform/RPi: Don't describe MMIO regions as memory

When using ACPI OpRegions to poke device registers, Linux will use
the UEFI memory map to decide which memory attributes to use, and
so they should not be described as cacheable memory.

Since MMIO regions that don't require an OS virtual mapping at runtime
don't really belong in the UEFI memory map to begin with, omit them
entirely.

Signed-off-by: Pete Batard <pete@akeo.ie>
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
Ard Biesheuvel 4 years ago
parent
commit
70a8cb5933

+ 4 - 3
Platform/RaspberryPi/Include/Library/RPiMem.h

@@ -9,9 +9,10 @@
 #ifndef RPI_MEM_H__
 #define RPI_MEM_H__
 
-#define RPI_MEM_BASIC_REGION    0
-#define RPI_MEM_RUNTIME_REGION  1
-#define RPI_MEM_RESERVED_REGION 2
+#define RPI_MEM_UNMAPPED_REGION 0
+#define RPI_MEM_BASIC_REGION    1
+#define RPI_MEM_RUNTIME_REGION  2
+#define RPI_MEM_RESERVED_REGION 3
 
 typedef struct {
   CONST CHAR16*                 Name;

+ 10 - 0
Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.c

@@ -72,6 +72,15 @@ AddRuntimeServicesRegion (
   );
 }
 
+STATIC
+VOID
+AddUnmappedMemoryRegion (
+  IN ARM_MEMORY_REGION_DESCRIPTOR *Desc
+  )
+{
+  // Do nothing
+}
+
 STATIC
 VOID
 AddReservedMemoryRegion (
@@ -88,6 +97,7 @@ AddReservedMemoryRegion (
 }
 
 void (*AddRegion[]) (IN ARM_MEMORY_REGION_DESCRIPTOR *Desc) = {
+  AddUnmappedMemoryRegion,
   AddBasicMemoryRegion,
   AddRuntimeServicesRegion,
   AddReservedMemoryRegion,

+ 3 - 3
Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c

@@ -117,7 +117,7 @@ ArmPlatformGetVirtualMemoryMap (
   VirtualMemoryTable[Index].VirtualBase     = VirtualMemoryTable[Index].PhysicalBase;
   VirtualMemoryTable[Index].Length          = mVideoCoreSize;
   VirtualMemoryTable[Index].Attributes      = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
-  VirtualMemoryInfo[Index].Type             = RPI_MEM_RESERVED_REGION;
+  VirtualMemoryInfo[Index].Type             = RPI_MEM_UNMAPPED_REGION;
   VirtualMemoryInfo[Index++].Name           = L"GPU Reserved";
 
   // Compute the total RAM size available on this platform
@@ -139,7 +139,7 @@ ArmPlatformGetVirtualMemoryMap (
     VirtualMemoryTable[Index].VirtualBase   = VirtualMemoryTable[Index].PhysicalBase;
     VirtualMemoryTable[Index].Length        = BCM2711_SOC_REGISTER_LENGTH;
     VirtualMemoryTable[Index].Attributes    = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
-    VirtualMemoryInfo[Index].Type           = RPI_MEM_RESERVED_REGION;
+    VirtualMemoryInfo[Index].Type           = RPI_MEM_UNMAPPED_REGION;
     VirtualMemoryInfo[Index++].Name         = L"SoC Reserved (27xx)";
   }
 
@@ -152,7 +152,7 @@ ArmPlatformGetVirtualMemoryMap (
   VirtualMemoryTable[Index].VirtualBase     = VirtualMemoryTable[Index].PhysicalBase;
   VirtualMemoryTable[Index].Length          = BCM2836_SOC_REGISTER_LENGTH;
   VirtualMemoryTable[Index].Attributes      = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
-  VirtualMemoryInfo[Index].Type             = RPI_MEM_RESERVED_REGION;
+  VirtualMemoryInfo[Index].Type             = RPI_MEM_UNMAPPED_REGION;
   VirtualMemoryInfo[Index++].Name           = L"SoC Reserved (283x)";
 
   // If we have RAM above the 1 GB mark, declare it