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.19884.1574163513040597955 for ; Tue, 19 Nov 2019 03:38:33 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@akeo-ie.20150623.gappssmtp.com header.s=20150623 header.b=vA3uN6ow; 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 r10so23419171wrx.3 for ; Tue, 19 Nov 2019 03:38: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=W3zcJ8NnHqDdQsnhScmUTgPSZz0NMiqXR+R/KvdqWMA=; b=vA3uN6owqrE/stHXRp0COerCik74qArjH9C7fMs1kFGIKLUzOOGEK/SsGwumyWXp9R qbI58JQhmnUSoHn3TCAd+ugA9m4zBSrk7u5fT3giaVcVoqODbSVZuVrmxTEhwkV4FzH1 /eichncdZjWlmJkqonb3A2hfS0PHwYRkukS4Ojk+IwnttS0QwDTxLMbfkS3MNUfo219H Pp2ctYCtBn0sKY4feD7ljKASa4IHVO7ifyhJ/Z+iMKTINfPfQiyeV9dGhXz5aKi0LX/O 8qlSHLM2sutQimKFLD5RFXkmH1N7AUqMZWM10C+ESYRxDLtXnOfJQpHBInXGSzfmDSjU RicQ== 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=W3zcJ8NnHqDdQsnhScmUTgPSZz0NMiqXR+R/KvdqWMA=; b=j8f+Oak4cxcXvyzlDOOd2TzKQJ+FlnTGTmWNXWqfGDEqboSDFZgr8QXRUb1U8jeuUW rgOBntqLNyJUTtWecKE+4mt8QGwv1NFpYJ/ELAhg/7897dhMvOoUTPjuDs0OShz4HyzF 6dEoodcHufJ57XjGnye3/z0OkcOFRLOmzs20so4sD498NVEuTflZ1IlNDE4/ouWv2fNP JQBMuQcsEiNDmtOBiZzz6vcMdJxXp7PoBBm7NSZuBdoFb/Ush8dgZGs2EsHHxm1IfzDn MkTbcd8XbCg1kBjo+sXR9d5JxLatBe+4vaarCA+SzQsgSO2VSNycqFeh3uZfsJ11s6Q9 nX3g== X-Gm-Message-State: APjAAAXiUJ9I8YBzlrE6SFIBd8368Qh+1fGIvpapV0XlCAPGDqP8Y8/k vQrd9JwEbZkMKX0UmYZGJ8AuoYov/Y4= 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) Return-Path: 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-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> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20191119113809.2472-1-pete@akeo.ie> References: <20191119113809.2472-1-pete@akeo.ie> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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/Platform/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 #define RPI_MBOX_SET_POWER_STATE 0x00028001 diff --git a/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.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 MOV32 (x4, BCM2836_MBOX_BASE_ADDRESS) @@ -52,24 +54,90 @@ ASM_FUNC (ArmPlatformPeiBootAction) ldr wzr, [x4, #BCM2836_MBOX_READ_OFFSET] dmb ld + 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 .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 //UINTN //ArmPlatformGetPrimaryCoreMpId ( diff --git a/Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c b/Platform/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 +UINT64 mSystemMemoryBase; extern UINT64 mSystemMemoryEnd; -extern UINT64 mGPUMemoryBase; -extern UINT64 mGPUMemoryLength; +UINT64 mVideoCoreBase; +UINT64 mVideoCoreSize; +UINT32 mBoardRevision; #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", mSystemMemoryBase, mSystemMemoryEnd + 1)); + DEBUG ((DEBUG_INFO, "VideoCore: 0x%ll08X (Size 0x%ll08X)\n", mVideoCoreBase, mVideoCoreSize)); + + ASSERT (mSystemMemoryBase == 0); + ASSERT (VirtualMemoryMap != NULL); + RaspberryPiMemoryRegionDescriptor[3].Length = mSystemMemoryEnd + 1 - FixedPcdGet64 (PcdSystemMemoryBase); -- 2.21.0.windows.1