From nobody Mon Feb 9 19:52:32 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+50693+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+50693+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1573747682; cv=none; d=zoho.com; s=zohoarc; b=leLsnmy6EavEV+ziVO+NEQ8VlI9zBn/iC5zW2gXZfESL85MqLHZzyEke43O1REBRAhEkxy0UExThal6Xce68v8MgTJNIo10F/dhzVPBIcZoHMJkvDB1hcqFiCycTHDyeZgec3d1FV82lItqhgHMAt0+Vvj/9LBUJH/ukDQKlDzk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573747682; 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=Nwhju36h2Tz6jUsz48NdFpwVMdasEdjWyKBhUXoPPcM=; b=cMLnvEIhsP1l2pgamMuWcPpTh1wc07kj590R35/otsZtQOZHYwMybB82Os2Z+OaS428mgGgGQajVsfAkG0UJ23ve6KYZ5oH5wMxlWUT7NmpnYAUJH3qh2gxZ2Mso2+f2M//Ww16abn1KLniwE8fSnncsltqipKRRfTYQN5duB7M= 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+50693+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1573747682148655.0028626298421; Thu, 14 Nov 2019 08:08:02 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 4xABYY1788612x6cCLkiNfEp; Thu, 14 Nov 2019 08:08:01 -0800 X-Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by mx.groups.io with SMTP id smtpd.web11.6520.1573747679927292720 for ; Thu, 14 Nov 2019 08:08:00 -0800 X-Received: by mail-wr1-f65.google.com with SMTP id s5so7125377wrw.2 for ; Thu, 14 Nov 2019 08:07:59 -0800 (PST) X-Gm-Message-State: 3kr29lGH2oeXRsmPKBbwKQGcx1787277AA= X-Google-Smtp-Source: APXvYqzHa12PV7ySOOm7UwUrJNGL07ZKMSI8wk7M6bg2Q8cl02B0yBqbfurPPZZni0BZR+4RHwRfOQ== X-Received: by 2002:a5d:4412:: with SMTP id z18mr8713276wrq.149.1573747678238; Thu, 14 Nov 2019 08:07:58 -0800 (PST) X-Received: from localhost.localdomain ([84.203.67.47]) by smtp.gmail.com with ESMTPSA id a16sm6793088wmd.11.2019.11.14.08.07.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Nov 2019 08:07:57 -0800 (PST) From: "Pete Batard" To: devel@edk2.groups.io Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org, philmd@redhat.com Subject: [edk2-devel] [edk2-platforms][PATCH 4/8] Platform/RPi: Read more variables from VideoCore during early init Date: Thu, 14 Nov 2019 16:07:36 +0000 Message-Id: <20191114160740.10072-5-pete@akeo.ie> In-Reply-To: <20191114160740.10072-1-pete@akeo.ie> References: <20191114160740.10072-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=1573747681; bh=IuYsJeEX3F2gqtt0eYaRXpHkidS6+s0zUgcX+yd9VHY=; h=Cc:Date:From:Reply-To:Subject:To; b=O5BByBPgMKhr3Zd0+9qS6f2FJ+UxUQLtrUzytxALuAgUf7RN4ohMhng2xpl5/guRo5k pkJSJ9ST5/AvxYCs2us8GFsZ0dJXn0ltOBIgNVt0bLebLaZw3mOICvZENRDmcl4FFUYYq uP8TlQ91DGG2VKmuZc2wItswCnQL9H4AkLY= 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 | 75 = ++++++++++++++++++-- Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c | 14 = +++- 3 files changed, 84 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..49a132c722f1 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. * @@ -52,24 +53,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 (#50693): https://edk2.groups.io/g/devel/message/50693 Mute This Topic: https://groups.io/mt/57792566/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-