From nobody Mon Feb 9 16:02:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+50886+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+50886+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1574163514; cv=none; d=zoho.com; s=zohoarc; b=T1NuZkIfaQL1qqdDk6dXzJ/nzGXuYHdnn+Fz5PxRR6pajDKM9eFOEJzjHjUqAUqfqoRIwrnZBnvBr8GER3U99bKE2xhsfBhWZDZKd5jkmV7gtiHPvRyNwUSC46/q2fBFauTcXfLXQKYMFJiZXRNeZkLOVh+PROMJuaPp8tLJSKk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574163514; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=bIkc4niKiYV+JjV8TOJ5ecXOTeWc7u8wC31v1fdhHVo=; b=b6cEfOGQ/cqOuwWC6+jGYQZziIm8Jk8t9iQGhAfmOj8kKzQxci+EuFnRcj/WTl+B3KaYu3Ew/ut60JY0b/qp934ii4GNZu2L00KWHxyAszcWCQxhUjZc15PZE/lL4KCg/nV4Q01nECwok1PELIJ/pljSA4AyeXX3xidemGK895I= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+50886+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1574163514696440.2985553593893; Tue, 19 Nov 2019 03:38:34 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id aaaaYY1788612xaaaaaaaaaa; Tue, 19 Nov 2019 03:38:34 -0800 X-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.19884.1574163513040597955 for ; Tue, 19 Nov 2019 03:38:33 -0800 X-Received: by mail-wr1-f68.google.com with SMTP id r10so23419171wrx.3 for ; Tue, 19 Nov 2019 03:38:32 -0800 (PST) X-Gm-Message-State: aaaaaaaaaaaaaaaaaaaaaaaax1787277AA= X-Google-Smtp-Source: APXvYqwDESSUhfw+tXZl1N7SRH9hoJQYk/v+O4DTdcMnyzSjzWJNvQj4SLqaVyrqT9CoBsAGTdSznw== X-Received: by 2002:adf:f308:: with SMTP id i8mr23524273wro.319.1574163511205; Tue, 19 Nov 2019 03:38:31 -0800 (PST) X-Received: from localhost.localdomain ([84.203.67.47]) by smtp.gmail.com with ESMTPSA id j66sm2608273wma.19.2019.11.19.03.38.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Nov 2019 03:38:30 -0800 (PST) From: "Pete Batard" To: devel@edk2.groups.io Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org, philmd@redhat.com, samer.el-haj-mahmoud@arm.com Subject: [edk2-devel] [edk2-platforms][PATCH v2 6/7] Platform/RPi: Read more variables from VideoCore during early init Date: Tue, 19 Nov 2019 11:38:08 +0000 Message-Id: <20191119113809.2472-7-pete@akeo.ie> In-Reply-To: <20191119113809.2472-1-pete@akeo.ie> References: <20191119113809.2472-1-pete@akeo.ie> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pete@akeo.ie Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1574163514; bh=fW/B0mrsfFC/ltXzBJkOymsZu8+JFa1AA3yEeyPd4EM=; h=Cc:Date:From:Reply-To:Subject:To; b=oFqoESmqTFbZETE1BuA/+50BYnQH6e6xAFpAJv7StJ4TMWFTf681AC4s9ZXSyzvkIZI feGB8b3fiVveF7TujHBsrKtMBEeuiRAZWWgeIV5v122+r/woIrwo5+EUdbZgfSpdJt09H jBvB1YdWY81Hv96brcflhnVsXtpei7j98UM= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Besides the base memory size, we can read the GPU/VideoCore base as well as the model during early init, which we'll need for improving the memory mapping. This patch adds the retrieval of these variables, as well as some early debug display of their values (which can be useful) and also removes unused variables such as mGPUMemoryBase and mGPUMemoryLength. Signed-off-by: Pete Batard --- Platform/RaspberryPi/Include/IndustryStandard/RpiMbox.h | 1 + Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S | 76 = ++++++++++++++++++-- Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c | 14 = +++- 3 files changed, 85 insertions(+), 6 deletions(-) diff --git a/Platform/RaspberryPi/Include/IndustryStandard/RpiMbox.h b/Plat= form/RaspberryPi/Include/IndustryStandard/RpiMbox.h index d3b6f117cfdf..584786a61dfd 100644 --- a/Platform/RaspberryPi/Include/IndustryStandard/RpiMbox.h +++ b/Platform/RaspberryPi/Include/IndustryStandard/RpiMbox.h @@ -34,6 +34,7 @@ #define RPI_MBOX_GET_MAC_ADDRESS 0x00010003 #define RPI_MBOX_GET_BOARD_SERIAL 0x00010004 #define RPI_MBOX_GET_ARM_MEMSIZE 0x00010005 +#define RPI_MBOX_GET_VC_MEMSIZE 0x00010006 =20 #define RPI_MBOX_SET_POWER_STATE 0x00028001 =20 diff --git a/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHe= lper.S b/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper= .S index 36af208d12d8..cc58406e1bfc 100644 --- a/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S +++ b/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S @@ -1,5 +1,6 @@ /** @file * + * Copyright (c) 2019, Pete Batard * Copyright (c) 2016, Linaro Limited. All rights reserved. * Copyright (c) 2011-2013, ARM Limited. All rights reserved. * @@ -39,6 +40,7 @@ ASM_FUNC (ArmPlatformPeiBootAction) adr x0, .Lmeminfo_buffer mov x1, #FixedPcdGet64 (PcdDmaDeviceOffset) orr x0, x0, #RPI_MBOX_VC_CHANNEL + // x1 holds the value of PcdDmaDeviceOffset throughout this function add x0, x0, x1 =20 MOV32 (x4, BCM2836_MBOX_BASE_ADDRESS) @@ -52,24 +54,90 @@ ASM_FUNC (ArmPlatformPeiBootAction) ldr wzr, [x4, #BCM2836_MBOX_READ_OFFSET] dmb ld =20 + ldr w0, .Lmembase + adr x2, mSystemMemoryBase + str x0, [x2] + ldr w0, .Lmemsize sub x0, x0, #1 - adr x1, mSystemMemoryEnd - str x0, [x1] + adr x2, mSystemMemoryEnd + str x0, [x2] + + adr x0, .Lvcinfo_buffer + orr x0, x0, #RPI_MBOX_VC_CHANNEL + add x0, x0, x1 + + poll BCM2836_MBOX_STATUS_FULL + str w0, [x4, #BCM2836_MBOX_WRITE_OFFSET] + dmb sy + poll BCM2836_MBOX_STATUS_EMPTY + dmb sy + ldr wzr, [x4, #BCM2836_MBOX_READ_OFFSET] + dmb ld + + ldr w0, .Lvcbase + adr x2, mVideoCoreBase + str x0, [x2] + + ldr w0, .Lvcsize + adr x2, mVideoCoreSize + str x0, [x2] + + adr x0, .Lrevinfo_buffer + orr x0, x0, #RPI_MBOX_VC_CHANNEL + add x0, x0, x1 + + poll BCM2836_MBOX_STATUS_FULL + str w0, [x4, #BCM2836_MBOX_WRITE_OFFSET] + dmb sy + poll BCM2836_MBOX_STATUS_EMPTY + dmb sy + ldr wzr, [x4, #BCM2836_MBOX_READ_OFFSET] + dmb ld + + ldr w0, .Lrevision + adr x2, mBoardRevision + str w0, [x2] + ret =20 .align 4 .Lmeminfo_buffer: - .long .Lbuffer_size + .long .Lmeminfo_size .long 0x0 .long RPI_MBOX_GET_ARM_MEMSIZE .long 8 // buf size .long 0 // input len +.Lmembase: .long 0 // mem base .Lmemsize: .long 0 // mem size .long 0 // end tag - .set .Lbuffer_size, . - .Lmeminfo_buffer + .set .Lmeminfo_size, . - .Lmeminfo_buffer + +.Lvcinfo_buffer: + .long .Lvcinfo_size + .long 0x0 + .long RPI_MBOX_GET_VC_MEMSIZE + .long 8 // buf size + .long 0 // input len +.Lvcbase: + .long 0 // videocore base +.Lvcsize: + .long 0 // videocore size + .long 0 // end tag + .set .Lvcinfo_size, . - .Lvcinfo_buffer + +.Lrevinfo_buffer: + .long .Lrevinfo_size + .long 0x0 + .long RPI_MBOX_GET_BOARD_REVISION + .long 4 // buf size + .long 0 // input len +.Lrevision: + .long 0 // revision + .long 0 // end tag + .set .Lrevinfo_size, . - .Lrevinfo_buffer =20 //UINTN //ArmPlatformGetPrimaryCoreMpId ( diff --git a/Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c b/Pl= atform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c index 97d5af5260c6..2bfd3f020a6e 100644 --- a/Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c +++ b/Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c @@ -12,9 +12,11 @@ #include #include =20 +UINT64 mSystemMemoryBase; extern UINT64 mSystemMemoryEnd; -extern UINT64 mGPUMemoryBase; -extern UINT64 mGPUMemoryLength; +UINT64 mVideoCoreBase; +UINT64 mVideoCoreSize; +UINT32 mBoardRevision; =20 #define VariablesSize (FixedPcdGet32(PcdFlashNvStorageVariableSize) + \ FixedPcdGet32(PcdFlashNvStorageFtwWorkingSize) + \ @@ -87,6 +89,14 @@ ArmPlatformGetVirtualMemoryMap ( IN ARM_MEMORY_REGION_DESCRIPTOR** VirtualMemoryMap ) { + // 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", mSystemMemo= ryBase, mSystemMemoryEnd + 1)); + DEBUG ((DEBUG_INFO, "VideoCore: 0x%ll08X (Size 0x%ll08X)\n", mVideoCoreB= ase, mVideoCoreSize)); + + ASSERT (mSystemMemoryBase =3D=3D 0); + ASSERT (VirtualMemoryMap !=3D NULL); + RaspberryPiMemoryRegionDescriptor[3].Length =3D mSystemMemoryEnd + 1 - FixedPcdGet64 (PcdSystemMemoryBase); =20 --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#50886): https://edk2.groups.io/g/devel/message/50886 Mute This Topic: https://groups.io/mt/60553577/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-