[edk2-devel] [edk2-platforms][PATCH 2/5] Platform/RPi: Don't describe MMIO regions as memory

Philippe Mathieu-Daudé philmd at redhat.com
Wed Dec 11 12:22:37 UTC 2019


On 12/11/19 12:25 PM, Pete Batard wrote:
> From: Ard Biesheuvel <ard.biesheuvel at linaro.org>
> 
> 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 at akeo.ie>
> ---
>   Platform/RaspberryPi/Include/Library/RPiMem.h                    |  7 ++++---
>   Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.c | 10 ++++++++++
>   Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c        |  6 +++---
>   3 files changed, 17 insertions(+), 6 deletions(-)
> 
> diff --git a/Platform/RaspberryPi/Include/Library/RPiMem.h b/Platform/RaspberryPi/Include/Library/RPiMem.h
> index 9d38e4b6cfb3..a033af369bb0 100644
> --- a/Platform/RaspberryPi/Include/Library/RPiMem.h
> +++ b/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;
> diff --git a/Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.c b/Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.c
> index 3a0f7e19e993..7ba1cc5602d2 100644
> --- a/Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.c
> +++ b/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,
> diff --git a/Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c b/Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c
> index 781cf78b83d3..f8223d1b94e8 100644
> --- a/Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c
> +++ b/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
> 

Reviewed-by: Philippe Mathieu-Daude <philmd at redhat.com>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#52120): https://edk2.groups.io/g/devel/message/52120
Mute This Topic: https://groups.io/mt/68147483/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-





More information about the edk2-devel-archive mailing list