public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Pete Batard" <pete@akeo.ie>
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	[thread overview]
Message-ID: <20191119113809.2472-7-pete@akeo.ie> (raw)
In-Reply-To: <20191119113809.2472-1-pete@akeo.ie>

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 <pete@akeo.ie>
---
 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 <pete@akeo.ie>
  *  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 <IndustryStandard/Bcm2836.h>
 #include <Library/PcdLib.h>
 
+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


  parent reply	other threads:[~2019-11-19 11:38 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-19 11:38 [edk2-platforms][PATCH v2 0/7] Platform/RPi: Early Raspberry Pi 4 groundwork Pete Batard
2019-11-19 11:38 ` [edk2-platforms][PATCH v2 1/7] Platform/RPi: Add missing model name Pete Batard
2019-11-19 12:02   ` Philippe Mathieu-Daudé
2019-11-19 12:14     ` [edk2-devel] " Leif Lindholm
2019-11-19 12:25       ` Philippe Mathieu-Daudé
2019-11-19 12:50         ` Leif Lindholm
2019-11-19 12:25     ` Pete Batard
2019-11-19 11:38 ` [edk2-platforms][PATCH v2 2/7] Platform/RPi: Add model family detection Pete Batard
2019-11-19 11:38 ` [edk2-platforms][PATCH v2 3/7] Platform/RPi: Replace Bcm283x SoC base register address with a PCD Pete Batard
2019-11-19 11:43   ` Philippe Mathieu-Daudé
2019-11-19 11:57     ` Pete Batard
2019-11-19 12:16       ` Philippe Mathieu-Daudé
2019-11-19 12:44         ` Leif Lindholm
2019-11-19 12:51           ` Ard Biesheuvel
2019-11-19 11:38 ` [edk2-platforms][PATCH v2 4/7] Platform/RPi: Use offsets for Bcm238x SoC register addresses Pete Batard
2019-11-19 11:46   ` Philippe Mathieu-Daudé
2019-11-19 11:38 ` [edk2-platforms][PATCH v2 5/7] Silicon/Broadcom: Add Bcm2711 header Pete Batard
2019-11-19 11:51   ` Philippe Mathieu-Daudé
2019-11-19 11:38 ` Pete Batard [this message]
2019-11-19 11:38 ` [edk2-platforms][PATCH v2 7/7] Platform/RPi: Clean up and improve early memory init Pete Batard
2019-11-19 18:20 ` [edk2-platforms][PATCH v2 0/7] Platform/RPi: Early Raspberry Pi 4 groundwork Leif Lindholm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191119113809.2472-7-pete@akeo.ie \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox