From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by mx.groups.io with SMTP id smtpd.web09.8208.1574097120275825654 for ; Mon, 18 Nov 2019 09:12:00 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=N5ie+ehr; spf=pass (domain: linaro.org, ip: 209.85.221.66, mailfrom: leif.lindholm@linaro.org) Received: by mail-wr1-f66.google.com with SMTP id l7so20433436wrp.6 for ; Mon, 18 Nov 2019 09:11:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=07i1UbgsUu6QoRNyEFfr3Kler6/t6hG82iRxFTjVkUk=; b=N5ie+ehrEX6MtcplW3WICFlq8TtiIaDhQxEXQK1vb8N8+UAms9d9qonjQaJMhlEDdd XmAm27K4CFylTpIif8MwVaJJKXRXmb6DJGFC/uQ9wWRqOEOetxWdNnZQv3QezIu8mYpj MS2+Lh4JNfMZF+OWepsP28DXMse8kv13CWSRytZXLN9UtUVoD9iyhhNZCCyIOISbzLdc cisAmj8JH2ik5SpwwIFmYKGErAMuM2hRA99f3T+4zcVZbv4Zlghh1r5NBbpUvDwyBi38 LGZKAEluyTW4WoySBr/a57HGUt83QChpw4cYqCvVbW5uk7NJcK4uBZpi0J8+VN9PMURp N+2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=07i1UbgsUu6QoRNyEFfr3Kler6/t6hG82iRxFTjVkUk=; b=CVaRQ/qst1N7rjpwXgvQVxIbcN6+jVBNmzyXTW3kXPbKFS4ydhM846c/w5z1C4WR5K 7T37z/B4Ppqw7DTPVb4DqAR2UJRZNV95NPb1xL/wAXA9dmOeUptsDTVm3NpLRKY7C+qc FiCeVj+eJJSovJfhmrd1jO4THsdnlqLM1Bi2DDTtjqtRzSVmskwyZYKkkCk4IHAeAwDE En6jqfpLMfuBElQRl5IjHBm7YfMQKsW1/W653y70aE6QIM247Un6UMCZLs/9ETXmvtSa RPMuJN6SVFgMJUQb2n8+XO8+NbyeT1VRfZOIcVJHIxc3rRFOr+x9iTsIKbnjARyb2gsu GMyA== X-Gm-Message-State: APjAAAU2IE+P65wBjIRbccrFbVqMCDRJNtQ7hz7JwxcrumjhUALOIaU+ DH86Loz6MCWuuAz9Zbo/3OtJ0w== X-Google-Smtp-Source: APXvYqxeOh8hl+g/gld91QIIIBnPlpReKxB9k1+D+LMGb5Q6BAyHUSi3wUq3XJ02Eqy7oOVIyw4g+A== X-Received: by 2002:adf:f388:: with SMTP id m8mr2615441wro.18.1574097118673; Mon, 18 Nov 2019 09:11:58 -0800 (PST) Return-Path: Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id a15sm23575215wrw.10.2019.11.18.09.11.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Nov 2019 09:11:57 -0800 (PST) Date: Mon, 18 Nov 2019 17:11:56 +0000 From: "Leif Lindholm" To: Pete Batard Cc: devel@edk2.groups.io, ard.biesheuvel@linaro.org, philmd@redhat.com Subject: Re: [edk2-platforms][PATCH 4/8] Platform/RPi: Read more variables from VideoCore during early init Message-ID: <20191118171156.GS7323@bivouac.eciton.net> References: <20191114160740.10072-1-pete@akeo.ie> <20191114160740.10072-5-pete@akeo.ie> MIME-Version: 1.0 In-Reply-To: <20191114160740.10072-5-pete@akeo.ie> User-Agent: Mutt/1.10.1 (2018-07-13) Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Nov 14, 2019 at 04:07:36PM +0000, Pete Batard wrote: > 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/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..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) Before this change, x1 is initialized once, used immediately, and later corrupted. After this change it becomes effectively a variable, used several times throughout the function. This is all fine, but I think it deserves adding a comment to the assignment along the lines of // x1 holds the value of PcdDmaDeviceOffset throughout the function / Leif > 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 >