From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by mx.groups.io with SMTP id smtpd.web12.3386.1583240913040008858 for ; Tue, 03 Mar 2020 05:08:33 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@akeo-ie.20150623.gappssmtp.com header.s=20150623 header.b=gRp4mOyv; spf=none, err=permanent DNS error (domain: akeo.ie, ip: 209.85.128.66, mailfrom: pete@akeo.ie) Received: by mail-wm1-f66.google.com with SMTP id a141so2779465wme.2 for ; Tue, 03 Mar 2020 05:08:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akeo-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Pc/R2wEietdNwOlJcEe23my0e9mp+Qi5rCGWyisDcuk=; b=gRp4mOyvPSes8u27q77SRCKrY+yCO1pkTgQtkTMsibEBCTkT39tHwht61NA3YdbXyj IE3S5oWYuj3aP/WtSeThpW+gw12hGMh/8Gxc9Dgrn09ErcQKOvZNg0181I61Dr3sJZ5g 4FXn47+w9tgtFFUtdwQc4E4UbohmcPxhWbTE+8AUgDzdiPuZkLB3THNgHx+mbeHCBB/d EdIPrNzfDoEP6uV0mh/GgW8YwhzY41B03ORWRp8O+Qvfv8Jv5OzsxlgioWC5yJ9/+WXc XOaADkpFenZjLiYIGFJxobONmYmZK2eFMx/LGDjRm14WipMjQu6ot3GLRsK0FQZAY2tE U7Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Pc/R2wEietdNwOlJcEe23my0e9mp+Qi5rCGWyisDcuk=; b=jm715Xntr0oWetulE1SgWhHVRmrXunkNjgkrfR2vowbl14QoWz5k855Fjz5+oUL7/F 2lV2yiE7XZLkjPVteOjlf7+IbXvA95Di0BqDqDLXKgX6UhI62u2AOqhbOL2fNqhvW7/T sCTycaI04NSb6JR4wevqbK+udsH9KCG3/LlaJJYHF7Htt/MI+qgDaQMj3d0LJwFqRcH+ a3JxMAfbH6HBqAany6h2D7cvbfQ0bd9rwLH9J9URNzv4B191uUmWqnQN0Q+ZiiLaCigT Tv8WfzKdWl89slcP7WI8LTqblc0cp2wNWk3ZcTJY0x8OiywfuBR8aFJDD4iU1S7U5Cxw zMmQ== X-Gm-Message-State: ANhLgQ0LAB03SiM0G8nrouI1iEI21iFyMpROpA2FoHt56UxHvJnTwqpQ v18Idd4zdwZqxnCEyR4WbovMXWsx9lk= X-Google-Smtp-Source: ADFU+vsGN3WxM7CYs0fJb8fA/+DGBpJ4Re+/cY0papgmES5GtHZqBM/YjZZPm8fkrHCny1uIc0V5xw== X-Received: by 2002:a7b:cf39:: with SMTP id m25mr4237796wmg.146.1583240911174; Tue, 03 Mar 2020 05:08:31 -0800 (PST) Return-Path: Received: from localhost.localdomain ([84.203.56.244]) by smtp.gmail.com with ESMTPSA id j5sm3907620wmi.33.2020.03.03.05.08.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Mar 2020 05:08:30 -0800 (PST) From: "Pete Batard" To: devel@edk2.groups.io Cc: ard.biesheuvel@linaro.org, leif@nuviainc.com, philmd@redhat.com, awarkentin@vmware.com Subject: [edk2-devel][PATCH v2 3/6] Platform/RPi: Separate RAM descriptors between 0-3 GB and 3+ GB Date: Tue, 3 Mar 2020 13:08:11 +0000 Message-Id: <20200303130814.3092-4-pete@akeo.ie> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20200303130814.3092-1-pete@akeo.ie> References: <20200303130814.3092-1-pete@akeo.ie> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Andrei Warkentin Splitting the RAM descriptors is required so that we can make the 3 to 4 GB segment of the Raspberry Pi 4 a user-configurable option. This also removes the need for the PcdAcpiBasicMode PCD. Signed-off-by: Pete Batard --- Platform/RaspberryPi/Library/PlatformLib/PlatformLib.inf | 3 -- Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c | 32 ++++++++++++++------ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/Platform/RaspberryPi/Library/PlatformLib/PlatformLib.inf b/Platform/RaspberryPi/Library/PlatformLib/PlatformLib.inf index 9abcc2cc0075..77cdbe399a06 100644 --- a/Platform/RaspberryPi/Library/PlatformLib/PlatformLib.inf +++ b/Platform/RaspberryPi/Library/PlatformLib/PlatformLib.inf @@ -59,8 +59,5 @@ [FixedPcd] gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize -[FeaturePcd] - gRaspberryPiTokenSpaceGuid.PcdAcpiBasicMode - [Ppis] gArmMpCoreInfoPpiGuid diff --git a/Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c b/Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c index 4b388465cdde..901e5e3ee924 100644 --- a/Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c +++ b/Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c @@ -25,7 +25,7 @@ UINT32 mBoardRevision; // The total number of descriptors, including the final "end-of-table" descriptor. -#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS 10 +#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS 11 STATIC BOOLEAN VirtualMemoryInfoInitialized = FALSE; STATIC RPI_MEMORY_REGION_INFO VirtualMemoryInfo[MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS]; @@ -60,6 +60,7 @@ ArmPlatformGetVirtualMemoryMap ( { UINTN Index = 0; UINTN GpuIndex; + INT64 OrigMemorySize; INT64 SystemMemorySize; ARM_MEMORY_REGION_DESCRIPTOR *VirtualMemoryTable; @@ -155,13 +156,13 @@ ArmPlatformGetVirtualMemoryMap ( VirtualMemoryInfo[Index].Type = RPI_MEM_UNMAPPED_REGION; VirtualMemoryInfo[Index++].Name = L"SoC Reserved (283x)"; - if (FeaturePcdGet (PcdAcpiBasicMode)) { - // - // Limit the memory to 3 GB to work around the DMA bugs in the SoC without - // having to rely on IORT or _DMA descriptions. - // - SystemMemorySize = MIN(SystemMemorySize, 3U * SIZE_1GB); - } + // + // By default we limit the memory to 3 GB to work around the DMA bugs in the SoC, + // for OSes that don't support _DMA range descriptors. On 4GB boards, it's runtime + // setting to boot with 4 GB, and the additional 1 GB is added by ConfigDxe. + // + OrigMemorySize = SystemMemorySize; + SystemMemorySize = MIN(SystemMemorySize, 3UL * SIZE_1GB); // If we have RAM above the 1 GB mark, declare it if (SystemMemorySize - SIZE_1GB > 0) { @@ -170,7 +171,20 @@ ArmPlatformGetVirtualMemoryMap ( VirtualMemoryTable[Index].Length = SystemMemorySize - SIZE_1GB; VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK; VirtualMemoryInfo[Index].Type = RPI_MEM_BASIC_REGION; - VirtualMemoryInfo[Index++].Name = L"Extended System RAM"; + VirtualMemoryInfo[Index++].Name = L"Extended System RAM below 3 GB"; + } + + // + // If we have RAM above 3 GB mark, declare it so it's mapped, but + // don't add it to the memory map. This is done later by ConfigDxe if necessary. + // + if (OrigMemorySize > (3UL * SIZE_1GB)) { + VirtualMemoryTable[Index].PhysicalBase = 3UL * SIZE_1GB; + VirtualMemoryTable[Index].VirtualBase = VirtualMemoryTable[Index].PhysicalBase; + VirtualMemoryTable[Index].Length = OrigMemorySize - VirtualMemoryTable[Index].PhysicalBase; + VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK; + VirtualMemoryInfo[Index].Type = RPI_MEM_UNMAPPED_REGION; + VirtualMemoryInfo[Index++].Name = L"Extended System RAM above 3 GB"; } // End of Table -- 2.21.0.windows.1