From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by mx.groups.io with SMTP id smtpd.web11.8640.1574098734157138361 for ; Mon, 18 Nov 2019 09:38:54 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=Me19FW8B; spf=pass (domain: linaro.org, ip: 209.85.128.67, mailfrom: leif.lindholm@linaro.org) Received: by mail-wm1-f67.google.com with SMTP id a17so431778wmb.0 for ; Mon, 18 Nov 2019 09:38:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=re1T7mwozUg32RA0xRc6TUkDdIJOb8OyJ7o4/GBPCfc=; b=Me19FW8BH+SKVwC9K3duH005RuJz8Wgop2xqRhBRVbBMvixRHC5msahdFSbJWDPbFz B0oO9Gj2Dv9DiBamYZirIETqtmqmD518eZIPo5tt/sn884qaHoadT5J070DIse2BjRPh 5/Hh91PB4fxAUhqoAo7T58IMb0ZkEGQo0+S5gb6YYtkmE3EsXI4s2EgzmJhimFp8JBM1 olE22vsUNTVD99xT9h22WQauTHD2nFvlTHSJb9iv4vkzRlukLRUGj8uD6HYjHggEG3nP Y3aixikWLkhkdQzu5V/FKmnbcYXw/ba/aK04P3AJU0i2LgWLp+OrrKm7q4C32CeN4cfU zraw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=re1T7mwozUg32RA0xRc6TUkDdIJOb8OyJ7o4/GBPCfc=; b=hiCnO114mFncsIkSuIreJqO61K67oGoL8DjEvCW+OLEgUUdrGB0efE8mIGEkOA7Rzv bytqueDLUgBiSA4S8D66yMvUvml1/CVxcSNeCs/g+8H3ogESWeuCgXrJVYLvYEorj1n6 yvHRGG6Rl+CrketMXLcoYR2QRylRxNBHCmgIYGG8S1dprX1SOlml/kcn8DlriQ2XMvd8 8bb6XjheLRIIsGrgQLMSu7rZdRlmi8h2u/KHiKf6s5wMmH8MwCsl6pigNtMkJQ6NNyKz HouaNHxDrI5nKh1Gb4i+UxJBZnir3S+YJsTVAN3HYNS5VSM/gcc/LL+81GCPcFL6Saa/ I2QQ== X-Gm-Message-State: APjAAAVU2KE5I2MnAEtWNzxlXeulR6wSvxqPmzHZKOEkPw1EDglO4EBO uCTeAXyVVywEU9EFnKNBb/quyQ== X-Google-Smtp-Source: APXvYqwM+wPVzTfOTIvsIjjljUulOOJL735WwSVTt5s0DUomaDEyofpiH8qsifcc3dkFHcypddi00w== X-Received: by 2002:a1c:e157:: with SMTP id y84mr188296wmg.59.1574098732455; Mon, 18 Nov 2019 09:38:52 -0800 (PST) Return-Path: Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id w13sm23243194wrm.8.2019.11.18.09.38.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Nov 2019 09:38:51 -0800 (PST) Date: Mon, 18 Nov 2019 17:38:50 +0000 From: "Leif Lindholm" To: Pete Batard Cc: devel@edk2.groups.io, ard.biesheuvel@linaro.org, philmd@redhat.com Subject: Re: [edk2-platforms][PATCH 5/8] Platform/RPi: Clean up and improve early memory init Message-ID: <20191118173850.GW7323@bivouac.eciton.net> References: <20191114160740.10072-1-pete@akeo.ie> <20191114160740.10072-6-pete@akeo.ie> <20191118172059.GT7323@bivouac.eciton.net> <3f9be1ea-db97-1ca8-ed20-e0b3fa211825@akeo.ie> MIME-Version: 1.0 In-Reply-To: <3f9be1ea-db97-1ca8-ed20-e0b3fa211825@akeo.ie> User-Agent: Mutt/1.10.1 (2018-07-13) Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Nov 18, 2019 at 05:34:25PM +0000, Pete Batard wrote: > Hi Leif, > > On 2019.11.18 17:20, Leif Lindholm wrote: > > On Thu, Nov 14, 2019 at 04:07:37PM +0000, Pete Batard wrote: > > > This patch improves memory initialization for the Raspberry Pi Platform by: > > > > > > Using VideoCore mailbox data to reserve only the regions that are actually > > > mapped. Especially, besides the base RAM size, which was already set using > > > VideoCore data, we can set the GPU/VideoCore base address as well as the > > > extended RAM, which is the memory beyond 1 GB that is available on models > > > such as the Raspberry Pi 4 (for the 2GB or 4GB versions). > > > > > > Introducing a new PcdExtendedMemoryBase PCD for the base address of the > > > extended memory region, which currently cannot be retrieved from VideoCore > > > (MBOX_GET_ARM_MEMSIZE still only returns a single region on Bcm2711). > > > > > > Introducing a new RpiPlatformGetVirtualMemoryInfo() companion call to > > > ArmPlatformGetVirtualMemoryMap() that allows us greatly simplify the > > > registration of each segment in MemoryPeim() as well as making it easier > > > to maintain for future models. > > > > > > We also fix SoC register space that should have been marked as reserved > > > but wasn't until now and remove the unreferenced mSystemMemoryEnd extern > > > in MemoryInitPeiLib.c. > > > > Minor style comments and one copyright question below. > > > > > Signed-off-by: Pete Batard > > > --- > > > Platform/RaspberryPi/Include/Library/RPiMem.h | 26 +++ > > > Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.c | 94 ++++---- > > > Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.inf | 1 + > > > Platform/RaspberryPi/Library/PlatformLib/PlatformLib.inf | 3 + > > > Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c | 242 +++++++++++--------- > > > Platform/RaspberryPi/RaspberryPi.dec | 1 + > > > 6 files changed, 210 insertions(+), 157 deletions(-) > > > > > > diff --git a/Platform/RaspberryPi/Include/Library/RPiMem.h b/Platform/RaspberryPi/Include/Library/RPiMem.h > > > new file mode 100644 > > > index 000000000000..0bfc697ed094 > > > --- /dev/null > > > +++ b/Platform/RaspberryPi/Include/Library/RPiMem.h > > > @@ -0,0 +1,26 @@ > > > +/** @file > > > + * > > > + * Copyright (c) 2019, Pete Batard > > > + * > > > + * SPDX-License-Identifier: BSD-2-Clause-Patent > > > + * > > > + **/ > > > + > > > +#ifndef __RPI_MEM_H__ > > > +#define __RPI_MEM_H__ > > > > As mentioned for earlier patch, please drop leading __. > > Will do. I assume this applies to trailing __ as well. Thanks! Amusingly not. There are some toolchains that complain about leading __, but none I am aware of that complain about trailing ones. I think they may even be mandated by the coding style :) / Leif > > > > + > > > +#define RPI_MEM_BASIC_REGION 0 > > > +#define RPI_MEM_RUNTIME_REGION 1 > > > +#define RPI_MEM_RESERVED_REGION 2 > > > + > > > +typedef struct { > > > + CONST CHAR16* Name; > > > + UINTN Type; > > > +} RPI_MEMORY_REGION_INFO; > > > + > > > +VOID > > > +RpiPlatformGetVirtualMemoryInfo ( > > > + IN RPI_MEMORY_REGION_INFO** MemoryInfo > > > + ); > > > + > > > +#endif /* __RPI_MEM_H__ */ > > > diff --git a/Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.c b/Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.c > > > index 60cf397f8baa..3a0f7e19e993 100644 > > > --- a/Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.c > > > +++ b/Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.c > > > @@ -15,8 +15,7 @@ > > > #include > > > #include > > > #include > > > - > > > -extern UINT64 mSystemMemoryEnd; > > > +#include > > > VOID > > > BuildMemoryTypeInformationHob ( > > > @@ -39,23 +38,32 @@ InitMmu ( > > > } > > > } > > > +STATIC > > > +VOID > > > +AddBasicMemoryRegion ( > > > + IN ARM_MEMORY_REGION_DESCRIPTOR *Desc > > > +) > > > +{ > > > + BuildResourceDescriptorHob ( > > > + EFI_RESOURCE_SYSTEM_MEMORY, > > > + EFI_RESOURCE_ATTRIBUTE_PRESENT | > > > + EFI_RESOURCE_ATTRIBUTE_INITIALIZED | > > > + EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE | > > > + EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE | > > > + EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE | > > > + EFI_RESOURCE_ATTRIBUTE_TESTED, > > > + Desc->PhysicalBase, > > > + Desc->Length > > > + ); > > > +} > > > + > > > STATIC > > > VOID > > > AddRuntimeServicesRegion ( > > > IN ARM_MEMORY_REGION_DESCRIPTOR *Desc > > > ) > > > { > > > - BuildResourceDescriptorHob ( > > > - EFI_RESOURCE_SYSTEM_MEMORY, > > > - EFI_RESOURCE_ATTRIBUTE_PRESENT | > > > - EFI_RESOURCE_ATTRIBUTE_INITIALIZED | > > > - EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE | > > > - EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE | > > > - EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE | > > > - EFI_RESOURCE_ATTRIBUTE_TESTED, > > > - Desc->PhysicalBase, > > > - Desc->Length > > > - ); > > > + AddBasicMemoryRegion (Desc); > > > BuildMemoryAllocationHob ( > > > Desc->PhysicalBase, > > > @@ -70,17 +78,7 @@ AddReservedMemoryRegion ( > > > IN ARM_MEMORY_REGION_DESCRIPTOR *Desc > > > ) > > > { > > > - BuildResourceDescriptorHob ( > > > - EFI_RESOURCE_SYSTEM_MEMORY, > > > - EFI_RESOURCE_ATTRIBUTE_PRESENT | > > > - EFI_RESOURCE_ATTRIBUTE_INITIALIZED | > > > - EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE | > > > - EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE | > > > - EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE | > > > - EFI_RESOURCE_ATTRIBUTE_TESTED, > > > - Desc->PhysicalBase, > > > - Desc->Length > > > - ); > > > + AddBasicMemoryRegion (Desc); > > > BuildMemoryAllocationHob ( > > > Desc->PhysicalBase, > > > @@ -89,6 +87,12 @@ AddReservedMemoryRegion ( > > > ); > > > } > > > +void (*AddRegion[]) (IN ARM_MEMORY_REGION_DESCRIPTOR *Desc) = { > > > + AddBasicMemoryRegion, > > > + AddRuntimeServicesRegion, > > > + AddReservedMemoryRegion, > > > + }; > > > + > > > /*++ > > > Routine Description: > > > @@ -113,36 +117,28 @@ MemoryPeim ( > > > ) > > > { > > > ARM_MEMORY_REGION_DESCRIPTOR *MemoryTable; > > > + RPI_MEMORY_REGION_INFO *MemoryInfo; > > > + UINTN Index; > > > // Get Virtual Memory Map from the Platform Library > > > ArmPlatformGetVirtualMemoryMap (&MemoryTable); > > > - // Ensure PcdSystemMemorySize has been set > > > - ASSERT (PcdGet64 (PcdSystemMemorySize) != 0); > > > + // Get additional info not provided by MemoryTable > > > + RpiPlatformGetVirtualMemoryInfo (&MemoryInfo); > > > - // FD without variable store > > > - AddReservedMemoryRegion (&MemoryTable[0]); > > > - > > > - // Variable store. > > > - AddRuntimeServicesRegion (&MemoryTable[1]); > > > - > > > - // Trusted Firmware region > > > - AddReservedMemoryRegion (&MemoryTable[2]); > > > - > > > - // Usable memory. > > > - BuildResourceDescriptorHob ( > > > - EFI_RESOURCE_SYSTEM_MEMORY, > > > - EFI_RESOURCE_ATTRIBUTE_PRESENT | > > > - EFI_RESOURCE_ATTRIBUTE_INITIALIZED | > > > - EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE | > > > - EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE | > > > - EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE | > > > - EFI_RESOURCE_ATTRIBUTE_TESTED, > > > - MemoryTable[3].PhysicalBase, > > > - MemoryTable[3].Length > > > - ); > > > - > > > - AddReservedMemoryRegion (&MemoryTable[4]); > > > + // Register each memory region > > > + for (Index = 0; MemoryTable[Index].Length != 0; Index++) { > > > + ASSERT (MemoryInfo[Index].Type < ARRAY_SIZE (AddRegion)); > > > + DEBUG ((DEBUG_INFO, "%s:\n" > > > + "\tPhysicalBase: 0x%lX\n" > > > + "\tVirtualBase: 0x%lX\n" > > > + "\tLength: 0x%lX\n", > > > + MemoryInfo[Index].Name, > > > + MemoryTable[Index].PhysicalBase, > > > + MemoryTable[Index].VirtualBase, > > > + MemoryTable[Index].Length)); > > > + AddRegion[MemoryInfo[Index].Type] (&MemoryTable[Index]); > > > + } > > > // Build Memory Allocation Hob > > > InitMmu (MemoryTable); > > > diff --git a/Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.inf b/Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.inf > > > index 0084c010936d..d39210c7a4f1 100644 > > > --- a/Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.inf > > > +++ b/Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.inf > > > @@ -24,6 +24,7 @@ [Packages] > > > EmbeddedPkg/EmbeddedPkg.dec > > > ArmPkg/ArmPkg.dec > > > ArmPlatformPkg/ArmPlatformPkg.dec > > > + Platform/RaspberryPi/RaspberryPi.dec > > > [LibraryClasses] > > > DebugLib > > > diff --git a/Platform/RaspberryPi/Library/PlatformLib/PlatformLib.inf b/Platform/RaspberryPi/Library/PlatformLib/PlatformLib.inf > > > index 85462febdd8d..c0e2a75451c3 100644 > > > --- a/Platform/RaspberryPi/Library/PlatformLib/PlatformLib.inf > > > +++ b/Platform/RaspberryPi/Library/PlatformLib/PlatformLib.inf > > > @@ -22,6 +22,7 @@ [Packages] > > > EmbeddedPkg/EmbeddedPkg.dec > > > ArmPkg/ArmPkg.dec > > > ArmPlatformPkg/ArmPlatformPkg.dec > > > + Silicon/Broadcom/Bcm27xx/Bcm27xx.dec > > > Silicon/Broadcom/Bcm283x/Bcm283x.dec > > > Platform/RaspberryPi/RaspberryPi.dec > > > @@ -50,10 +51,12 @@ [FixedPcd] > > > gEmbeddedTokenSpaceGuid.PcdDmaDeviceOffset > > > gArmTokenSpaceGuid.PcdSystemMemoryBase > > > gArmTokenSpaceGuid.PcdSystemMemorySize > > > + gRaspberryPiTokenSpaceGuid.PcdExtendedMemoryBase > > > gRaspberryPiTokenSpaceGuid.PcdNvStorageEventLogSize > > > gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize > > > gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize > > > gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize > > > + gBcm27xxTokenSpaceGuid.PcdBcm27xxRegistersAddress > > > gBcm283xTokenSpaceGuid.PcdBcm283xRegistersAddress > > > [Ppis] > > > diff --git a/Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c b/Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c > > > index 2bfd3f020a6e..1a6a13b9591b 100644 > > > --- a/Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c > > > +++ b/Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c > > > @@ -1,7 +1,9 @@ > > > /** @file > > > * > > > + * Copyright (c) 2019, Pete Batard > > > * Copyright (c) 2017-2018, Andrey Warkentin > > > * Copyright (c) 2014, Linaro Limited. All rights reserved. > > > + * Copyright (c) 2013-2018, ARM Limited. All rights reserved. > > > > This confuses me slightly - is it an indication that some code has > > been copied from a file including this copyright? > > It is. I copy/pasted some code from ArmJunoMem.c that had this copyright, > which I then proceeded to modify. Hence the reason why you find the > copyright notice. Sure, that's fine. Could you add a line about that in commit message though? (Literally just "incorporates some code from ArmJunoMem.c" would suffice.) > > > > > * > > > * SPDX-License-Identifier: BSD-2-Clause-Patent > > > * > > > @@ -9,8 +11,11 @@ > > > #include > > > #include > > > -#include > > > #include > > > +#include > > > +#include > > > > Could you move MemoryAllocationLib.h above PcdLib.h? > > Will do. > > I will also take into account comments for the other patches wrt to > alphabetical order for the PCDs as well as the additional comment for x1 in > the assembly before submitting a v2. Thanks! / LEif > Regards, > > /Pete > > > > > / > > Leif > > > > > +#include > > > +#include > > > UINT64 mSystemMemoryBase; > > > extern UINT64 mSystemMemoryEnd; > > > @@ -18,6 +23,13 @@ UINT64 mVideoCoreBase; > > > UINT64 mVideoCoreSize; > > > UINT32 mBoardRevision; > > > + > > > +// The total number of descriptors, including the final "end-of-table" descriptor. > > > +#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS 10 > > > + > > > +STATIC BOOLEAN VirtualMemoryInfoInitialized = FALSE; > > > +STATIC RPI_MEMORY_REGION_INFO VirtualMemoryInfo[MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS]; > > > + > > > #define VariablesSize (FixedPcdGet32(PcdFlashNvStorageVariableSize) + \ > > > FixedPcdGet32(PcdFlashNvStorageFtwWorkingSize) + \ > > > FixedPcdGet32(PcdFlashNvStorageFtwSpareSize) + \ > > > @@ -29,49 +41,6 @@ UINT32 mBoardRevision; > > > #define ATFBase (FixedPcdGet64(PcdFdBaseAddress) + FixedPcdGet32(PcdFdSize)) > > > -STATIC ARM_MEMORY_REGION_DESCRIPTOR RaspberryPiMemoryRegionDescriptor[] = { > > > - { > > > - /* Firmware Volume. */ > > > - FixedPcdGet64 (PcdFdBaseAddress), FixedPcdGet64 (PcdFdBaseAddress), > > > - FixedPcdGet32 (PcdFdSize) - VariablesSize, > > > - ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK > > > - }, > > > - { > > > - /* Variables Volume. */ > > > - VariablesBase, VariablesBase, > > > - VariablesSize, > > > - ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK > > > - }, > > > - { > > > - /* ATF reserved RAM. */ > > > - ATFBase, ATFBase, > > > - FixedPcdGet64 (PcdSystemMemoryBase) - ATFBase, > > > - ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK > > > - }, > > > - { > > > - /* System RAM. */ > > > - FixedPcdGet64 (PcdSystemMemoryBase), FixedPcdGet64 (PcdSystemMemoryBase), > > > - 0, > > > - ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK > > > - }, > > > - { > > > - /* Reserved GPU RAM. */ > > > - 0, > > > - 0, > > > - 0, > > > - ARM_MEMORY_REGION_ATTRIBUTE_DEVICE > > > - }, > > > - { > > > - /* SOC registers. */ > > > - BCM2836_SOC_REGISTERS, > > > - BCM2836_SOC_REGISTERS, > > > - BCM2836_SOC_REGISTER_LENGTH, > > > - ARM_MEMORY_REGION_ATTRIBUTE_DEVICE > > > - }, > > > - { > > > - } > > > -}; > > > - > > > /** > > > Return the Virtual Memory Map of your platform > > > @@ -89,6 +58,11 @@ ArmPlatformGetVirtualMemoryMap ( > > > IN ARM_MEMORY_REGION_DESCRIPTOR** VirtualMemoryMap > > > ) > > > { > > > + UINTN Index = 0; > > > + UINTN GpuIndex; > > > + INT64 ExtendedMemorySize; > > > + ARM_MEMORY_REGION_DESCRIPTOR *VirtualMemoryTable; > > > + > > > // Early output of the info we got from VideoCore can prove valuable. > > > DEBUG ((DEBUG_INFO, "Board Rev: 0x%lX\n", mBoardRevision)); > > > DEBUG ((DEBUG_INFO, "Base RAM : 0x%ll08X (Size 0x%ll08X)\n", mSystemMemoryBase, mSystemMemoryEnd + 1)); > > > @@ -97,68 +71,120 @@ ArmPlatformGetVirtualMemoryMap ( > > > ASSERT (mSystemMemoryBase == 0); > > > ASSERT (VirtualMemoryMap != NULL); > > > - RaspberryPiMemoryRegionDescriptor[3].Length = mSystemMemoryEnd + 1 - > > > - FixedPcdGet64 (PcdSystemMemoryBase); > > > - > > > - RaspberryPiMemoryRegionDescriptor[4].PhysicalBase = > > > - RaspberryPiMemoryRegionDescriptor[3].PhysicalBase + > > > - RaspberryPiMemoryRegionDescriptor[3].Length; > > > - > > > - RaspberryPiMemoryRegionDescriptor[4].VirtualBase = > > > - RaspberryPiMemoryRegionDescriptor[4].PhysicalBase; > > > - > > > - RaspberryPiMemoryRegionDescriptor[4].Length = > > > - RaspberryPiMemoryRegionDescriptor[5].PhysicalBase - > > > - RaspberryPiMemoryRegionDescriptor[4].PhysicalBase; > > > - > > > - DEBUG ((DEBUG_INFO, "FD:\n" > > > - "\tPhysicalBase: 0x%lX\n" > > > - "\tVirtualBase: 0x%lX\n" > > > - "\tLength: 0x%lX\n", > > > - RaspberryPiMemoryRegionDescriptor[0].PhysicalBase, > > > - RaspberryPiMemoryRegionDescriptor[0].VirtualBase, > > > - RaspberryPiMemoryRegionDescriptor[0].Length + > > > - RaspberryPiMemoryRegionDescriptor[1].Length)); > > > - > > > - DEBUG ((DEBUG_INFO, "Variables (part of FD):\n" > > > - "\tPhysicalBase: 0x%lX\n" > > > - "\tVirtualBase: 0x%lX\n" > > > - "\tLength: 0x%lX\n", > > > - RaspberryPiMemoryRegionDescriptor[1].PhysicalBase, > > > - RaspberryPiMemoryRegionDescriptor[1].VirtualBase, > > > - RaspberryPiMemoryRegionDescriptor[1].Length)); > > > - > > > - DEBUG ((DEBUG_INFO, "ATF RAM:\n" > > > - "\tPhysicalBase: 0x%lX\n" > > > - "\tVirtualBase: 0x%lX\n" > > > - "\tLength: 0x%lX\n", > > > - RaspberryPiMemoryRegionDescriptor[2].PhysicalBase, > > > - RaspberryPiMemoryRegionDescriptor[2].VirtualBase, > > > - RaspberryPiMemoryRegionDescriptor[2].Length)); > > > - > > > - DEBUG ((DEBUG_INFO, "System RAM:\n" > > > - "\tPhysicalBase: 0x%lX\n" > > > - "\tVirtualBase: 0x%lX\n" > > > - "\tLength: 0x%lX\n", > > > - RaspberryPiMemoryRegionDescriptor[3].PhysicalBase, > > > - RaspberryPiMemoryRegionDescriptor[3].VirtualBase, > > > - RaspberryPiMemoryRegionDescriptor[3].Length)); > > > - > > > - DEBUG ((DEBUG_INFO, "GPU Reserved:\n" > > > - "\tPhysicalBase: 0x%lX\n" > > > - "\tVirtualBase: 0x%lX\n" > > > - "\tLength: 0x%lX\n", > > > - RaspberryPiMemoryRegionDescriptor[4].PhysicalBase, > > > - RaspberryPiMemoryRegionDescriptor[4].VirtualBase, > > > - RaspberryPiMemoryRegionDescriptor[4].Length)); > > > - > > > - DEBUG ((DEBUG_INFO, "SoC reserved:\n" > > > - "\tPhysicalBase: 0x%lX\n" > > > - "\tVirtualBase: 0x%lX\n" > > > - "\tLength: 0x%lX\n", > > > - RaspberryPiMemoryRegionDescriptor[5].PhysicalBase, > > > - RaspberryPiMemoryRegionDescriptor[5].VirtualBase, > > > - RaspberryPiMemoryRegionDescriptor[5].Length)); > > > - > > > - *VirtualMemoryMap = RaspberryPiMemoryRegionDescriptor; > > > + VirtualMemoryTable = (ARM_MEMORY_REGION_DESCRIPTOR*)AllocatePages > > > + (EFI_SIZE_TO_PAGES (sizeof (ARM_MEMORY_REGION_DESCRIPTOR) * > > > + MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS)); > > > + if (VirtualMemoryTable == NULL) { > > > + return; > > > + } > > > + > > > + > > > + // Firmware Volume > > > + VirtualMemoryTable[Index].PhysicalBase = FixedPcdGet64 (PcdFdBaseAddress); > > > + VirtualMemoryTable[Index].VirtualBase = VirtualMemoryTable[Index].PhysicalBase; > > > + VirtualMemoryTable[Index].Length = FixedPcdGet32 (PcdFdSize) - VariablesSize; > > > + VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK; > > > + VirtualMemoryInfo[Index].Type = RPI_MEM_RESERVED_REGION; > > > + VirtualMemoryInfo[Index++].Name = L"FD"; > > > + > > > + // Variable Volume > > > + VirtualMemoryTable[Index].PhysicalBase = VariablesBase; > > > + VirtualMemoryTable[Index].VirtualBase = VirtualMemoryTable[Index].PhysicalBase; > > > + VirtualMemoryTable[Index].Length = VariablesSize; > > > + VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK; > > > + VirtualMemoryInfo[Index].Type = RPI_MEM_RUNTIME_REGION; > > > + VirtualMemoryInfo[Index++].Name = L"FD Variables"; > > > + > > > + // TF-A reserved RAM > > > + VirtualMemoryTable[Index].PhysicalBase = ATFBase; > > > + VirtualMemoryTable[Index].VirtualBase = VirtualMemoryTable[Index].PhysicalBase; > > > + VirtualMemoryTable[Index].Length = FixedPcdGet64 (PcdSystemMemoryBase) - ATFBase; > > > + VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK; > > > + VirtualMemoryInfo[Index].Type = RPI_MEM_RESERVED_REGION; > > > + VirtualMemoryInfo[Index++].Name = L"TF-A RAM"; > > > + > > > + // Base System RAM > > > + VirtualMemoryTable[Index].PhysicalBase = FixedPcdGet64 (PcdSystemMemoryBase); > > > + VirtualMemoryTable[Index].VirtualBase = VirtualMemoryTable[Index].PhysicalBase; > > > + VirtualMemoryTable[Index].Length = mSystemMemoryEnd + 1 - FixedPcdGet64 (PcdSystemMemoryBase); > > > + VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK; > > > + VirtualMemoryInfo[Index].Type = RPI_MEM_BASIC_REGION; > > > + VirtualMemoryInfo[Index++].Name = L"Base System RAM"; > > > + > > > + // GPU Reserved > > > + GpuIndex = Index; > > > + VirtualMemoryTable[Index].PhysicalBase = mVideoCoreBase; > > > + 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++].Name = L"GPU Reserved"; > > > + > > > + // Compute the amount of extended RAM available on this platform > > > + ExtendedMemorySize = SIZE_256MB; > > > + ExtendedMemorySize <<= (mBoardRevision >> 20) & 0x07; > > > + ExtendedMemorySize -= SIZE_1GB; > > > + if (ExtendedMemorySize > 0) { > > > + VirtualMemoryTable[Index].PhysicalBase = FixedPcdGet64 (PcdExtendedMemoryBase); > > > + VirtualMemoryTable[Index].VirtualBase = VirtualMemoryTable[Index].PhysicalBase; > > > + VirtualMemoryTable[Index].Length = ExtendedMemorySize; > > > + VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK; > > > + VirtualMemoryInfo[Index].Type = RPI_MEM_BASIC_REGION; > > > + VirtualMemoryInfo[Index++].Name = L"Extended System RAM"; > > > + } > > > + > > > + // Extended SoC registers (PCIe, genet, ...) > > > + if (BCM2711_SOC_REGISTERS > 0) { > > > + VirtualMemoryTable[Index].PhysicalBase = BCM2711_SOC_REGISTERS; > > > + 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++].Name = L"SoC Reserved (27xx)"; > > > + } > > > + > > > + // Base SoC registers > > > + VirtualMemoryTable[Index].PhysicalBase = BCM2836_SOC_REGISTERS; > > > + // On the Pi 3 the SoC registers may overlap VideoCore => fix this > > > + if (VirtualMemoryTable[GpuIndex].PhysicalBase + VirtualMemoryTable[GpuIndex].Length > VirtualMemoryTable[Index].PhysicalBase) { > > > + VirtualMemoryTable[GpuIndex].Length = VirtualMemoryTable[Index].PhysicalBase - VirtualMemoryTable[GpuIndex].PhysicalBase; > > > + } > > > + 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++].Name = L"SoC Reserved (283x)"; > > > + > > > + // End of Table > > > + VirtualMemoryTable[Index].PhysicalBase = 0; > > > + VirtualMemoryTable[Index].VirtualBase = 0; > > > + VirtualMemoryTable[Index].Length = 0; > > > + VirtualMemoryTable[Index++].Attributes = (ARM_MEMORY_REGION_ATTRIBUTES)0; > > > + > > > + ASSERT(Index <= MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS); > > > + > > > + *VirtualMemoryMap = VirtualMemoryTable; > > > + VirtualMemoryInfoInitialized = TRUE; > > > +} > > > + > > > +/** > > > + Return additional memory info not populated by the above call. > > > + > > > + This call should follow the one to ArmPlatformGetVirtualMemoryMap (). > > > + > > > +**/ > > > +VOID > > > +RpiPlatformGetVirtualMemoryInfo ( > > > + IN RPI_MEMORY_REGION_INFO** MemoryInfo > > > + ) > > > +{ > > > + ASSERT (VirtualMemoryInfo != NULL); > > > + > > > + if (!VirtualMemoryInfoInitialized) { > > > + DEBUG ((DEBUG_ERROR, > > > + "ArmPlatformGetVirtualMemoryMap must be called before RpiPlatformGetVirtualMemoryInfo.\n")); > > > + return; > > > + } > > > + > > > + *MemoryInfo = VirtualMemoryInfo; > > > } > > > diff --git a/Platform/RaspberryPi/RaspberryPi.dec b/Platform/RaspberryPi/RaspberryPi.dec > > > index 3e9171eccb13..c7e17350544a 100644 > > > --- a/Platform/RaspberryPi/RaspberryPi.dec > > > +++ b/Platform/RaspberryPi/RaspberryPi.dec > > > @@ -42,6 +42,7 @@ [PcdsFixedAtBuild.common] > > > gRaspberryPiTokenSpaceGuid.PcdNvStorageVariableBase|0x0|UINT32|0x00000005 > > > gRaspberryPiTokenSpaceGuid.PcdNvStorageFtwSpareBase|0x0|UINT32|0x00000006 > > > gRaspberryPiTokenSpaceGuid.PcdNvStorageFtwWorkingBase|0x0|UINT32|0x00000007 > > > + gRaspberryPiTokenSpaceGuid.PcdExtendedMemoryBase|0x0|UINT32|0x00000008 > > > [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx] > > > gRaspberryPiTokenSpaceGuid.PcdCpuClock|0|UINT32|0x0000000d > > > -- > > > 2.21.0.windows.1 > > > >