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
Subject: [edk2-platforms][PATCH v2 5/5] Platform/RPi3/PlatformSmbiosDxe: Derive RAM size from board revision
Date: Tue,  8 Oct 2019 13:38:41 +0100	[thread overview]
Message-ID: <20191008123841.12952-6-pete@akeo.ie> (raw)
In-Reply-To: <20191008123841.12952-1-pete@akeo.ie>

The board revision is the proper channel to use to detect the amount of
RAM available as bits [20-22] report the effective RAM size for the board
starting with 256 MB (000b) and doubling in size for each value.

Signed-off-by: Pete Batard <pete@akeo.ie>
---
 Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c
index 66ffadd0cade..540e3fd61f25 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c
+++ b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c
@@ -863,16 +863,22 @@ MemArrMapInfoUpdateSmbiosType19 (
   )
 {
   EFI_STATUS Status;
-  UINT32 Base;
-  UINT32 Size;
+  UINT32 BoardRevision = 0;
 
-  Status = mFwProtocol->GetArmMem (&Base, &Size);
+  // Note: Type 19 addresses are expressed in KB, not bytes
+  mMemArrMapInfoType19.StartingAddress = 0;
+  // The minimum RAM size used on any Raspberry Pi model is 256 MB
+  mMemArrMapInfoType19.EndingAddress = 256 * 1024;
+  Status = mFwProtocol->GetModelRevision (&BoardRevision);
   if (Status != EFI_SUCCESS) {
-    DEBUG ((DEBUG_ERROR, "Couldn't get the ARM memory size: %r\n", Status));
+    DEBUG ((DEBUG_WARNING, "Couldn't get the board memory size - defaulting to 256 MB: %r\n", Status));
   } else {
-    mMemArrMapInfoType19.StartingAddress = Base / 1024;
-    mMemArrMapInfoType19.EndingAddress = (Base + Size - 1) / 1024;
+    // www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md
+    // Bits [20-22] indicate the amount of memory starting with 256MB (000b)
+    // and doubling in size for each value (001b = 512 MB, 010b = 1GB, etc.)
+    mMemArrMapInfoType19.EndingAddress <<= (BoardRevision >> 20) & 0x07;
   }
+  mMemArrMapInfoType19.EndingAddress -= 1;
 
   LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mMemArrMapInfoType19, mMemArrMapInfoType19Strings, NULL);
 }
-- 
2.21.0.windows.1


  parent reply	other threads:[~2019-10-08 12:39 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-08 12:38 [edk2-platforms][PATCH v2 0/5] Platform/RPi3: Various SMBIOS improvements Pete Batard
2019-10-08 12:38 ` [edk2-platforms][PATCH v2 1/5] Platform/RPi3/RpiFirmwareDxe: Add more query functions Pete Batard
2019-10-10  8:39   ` Leif Lindholm
2019-10-10 12:41     ` Pete Batard
2019-10-10 16:43       ` Leif Lindholm
2019-10-10 17:27         ` Pete Batard
2019-10-08 12:38 ` [edk2-platforms][PATCH v2 2/5] Platform/RPi3/RpiFirmwareDxe: Improve serial number population Pete Batard
2019-10-10  8:43   ` Leif Lindholm
2019-10-10 12:41     ` Pete Batard
2019-10-10 16:49       ` Leif Lindholm
2019-10-10 17:28         ` Pete Batard
2019-10-08 12:38 ` [edk2-platforms][PATCH v2 3/5] Platform/RPi3/PlatformSmbiosDxe: Improve population of SMBIOS entries Pete Batard
2019-10-10  8:59   ` Leif Lindholm
2019-10-08 12:38 ` [edk2-platforms][PATCH v2 4/5] Platform/RPi3/PlatformSmbiosDxe: Populate BIOS major/minor from PCD Pete Batard
2019-10-10  9:01   ` Leif Lindholm
2019-10-08 12:38 ` Pete Batard [this message]
2019-10-10  9:03   ` [edk2-platforms][PATCH v2 5/5] Platform/RPi3/PlatformSmbiosDxe: Derive RAM size from board revision 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=20191008123841.12952-6-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