From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by mx.groups.io with SMTP id smtpd.web12.1927.1583231636183589883 for ; Tue, 03 Mar 2020 02:33:56 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@akeo-ie.20150623.gappssmtp.com header.s=20150623 header.b=pKtdO1YZ; spf=none, err=permanent DNS error (domain: akeo.ie, ip: 209.85.221.68, mailfrom: pete@akeo.ie) Received: by mail-wr1-f68.google.com with SMTP id q8so3667849wrm.4 for ; Tue, 03 Mar 2020 02:33:55 -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=QYq9KoIzQPsRN+x7DOWDy7RrF0BWpzsIy7xJHparV6E=; b=pKtdO1YZICNBqMkwBt2yFiDf4tD2v1gM2VvSjbVo016iLQJDdeERH23FtZtGdhk2NM NO2UlU7otvqrNkl1uGnHPtL10DNtDd5CiXYOBT03jn+sm3h3fmvdmltnv6oPP40+8PF3 ndTj5ZIqqw/+zP84Z5Zc4qv0L+gcWlV9LMXYSPQGPbYpbtoHrr4cVWcisWDZZedzQDPt PbKjgjrj/WL6uw1PEPUhiE3q9V9dwanSK/UVa4U6RT9OBWLkrk44Gug9jkrVQLVUIu5M BfCYm4rnobrTjD5RI0qk+9WiTpL5TPMr8GpC/TYj0cTJnH1C2sU1/Vzdipy953wBhuLf 4J7Q== 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=QYq9KoIzQPsRN+x7DOWDy7RrF0BWpzsIy7xJHparV6E=; b=gmYgrecDa3LTeo4O/L18xFjOWoQGiqhONFkk/I6zJluI+BJBAhE6pZueUu5ZzPMXoW vW47rzBqU8OZlznd0HM8BARJ2ShzcD/ZqirRkIigaR8zv3KpMTI6nyEfJ7G8aiL3A3E6 gv3Oro6DqCdkS09Wq7Zy33Osj51Oh66xPFG/DOUuCVeAGizXVzGiId/6MrvLBcsKxYzw htutW6tGLJeSR3JyG0w3Mu2GhFV6RRPwiQN0UFnneX1ltRMgXxyd1WYwtdNI5W6szxZz So/rCbj7zbJxOmU91pmfBu4JXSqTaLL59LjusbG2c1qQ+X6W4GUeCmrmvWoDyGq7ISLO 9IhA== X-Gm-Message-State: ANhLgQ2eOPOnNqky66pby7anzTRazj6XDVbNa/FrGlfW476JZsX2RAuu q4p/aAS0uFBCWZzEYBbQh+RhNbmzisM= X-Google-Smtp-Source: ADFU+vt2AwDhBUf+OlUYEnCVVnF2K+Ez8J6WZmiqQDD4xZVkatAz5zxH07gZpgIpCYeu7mfzuh03BA== X-Received: by 2002:a5d:4ac8:: with SMTP id y8mr4791546wrs.272.1583231634312; Tue, 03 Mar 2020 02:33:54 -0800 (PST) Return-Path: Received: from localhost.localdomain ([84.203.56.244]) by smtp.gmail.com with ESMTPSA id c4sm3255193wml.7.2020.03.03.02.33.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Mar 2020 02:33:53 -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 2/5] Platform/RPi: Separate RAM descriptors between 0-3 GB and 3+ GB Date: Tue, 3 Mar 2020 10:33:36 +0000 Message-Id: <20200303103339.7468-3-pete@akeo.ie> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20200303103339.7468-1-pete@akeo.ie> References: <20200303103339.7468-1-pete@akeo.ie> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Andrei Warkentin This 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 | 33 ++++++++++++++------ 2 files changed, 23 insertions(+), 13 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..3f257d4fa528 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; @@ -78,7 +79,6 @@ ArmPlatformGetVirtualMemoryMap ( return; } - // Firmware Volume VirtualMemoryTable[Index].PhysicalBase = FixedPcdGet64 (PcdFdBaseAddress); VirtualMemoryTable[Index].VirtualBase = VirtualMemoryTable[Index].PhysicalBase; @@ -155,13 +155,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 4GB, and the additional 1GB is added by ConfigDxe. + // + OrigMemorySize = SystemMemorySize; + SystemMemorySize = MIN(SystemMemorySize, 3U * SIZE_1GB); // If we have RAM above the 1 GB mark, declare it if (SystemMemorySize - SIZE_1GB > 0) { @@ -170,7 +170,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 3GB"; + } + + // + // 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 3GB"; } // End of Table -- 2.21.0.windows.1