From: "Ard Biesheuvel" <ard.biesheuvel@linaro.org>
To: Pete Batard <pete@akeo.ie>
Cc: edk2-devel-groups-io <devel@edk2.groups.io>,
"Leif Lindholm" <leif@nuviainc.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>,
"Andrei Warkentin" <awarkentin@vmware.com>
Subject: Re: [edk2-devel][PATCH 1/5] Platform/RPi: Add firmware call to read installed memory size
Date: Tue, 3 Mar 2020 11:37:23 +0100 [thread overview]
Message-ID: <CAKv+Gu8VVBSGd5cALfYTNFyMTE+hgF7fxA0teB9YGXaWs0_3_w@mail.gmail.com> (raw)
In-Reply-To: <20200303103339.7468-2-pete@akeo.ie>
On Tue, 3 Mar 2020 at 11:33, Pete Batard <pete@akeo.ie> wrote:
>
> From: Andrei Warkentin <andrey.warkentin@gmail.com>
>
> Add a new RPiFirmwareGetModelInstalledMB () call in RpiFirmwareDxe
> to return the amount of detected installed RAM on the system (in MB).
>
> Use the new call in PlatformSmbiosDxe.
>
> Signed-off-by: Pete Batard <pete@akeo.ie>
Please split this into two patches
> ---
> Platform/RaspberryPi/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c | 10 ++---
> Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c | 29 +++++++++++-
> Platform/RaspberryPi/Include/Protocol/RpiFirmware.h | 47 +++++++++++---------
> 3 files changed, 59 insertions(+), 27 deletions(-)
>
> diff --git a/Platform/RaspberryPi/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c b/Platform/RaspberryPi/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c
> index f25c439f89c8..5585cb846f41 100644
> --- a/Platform/RaspberryPi/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c
> +++ b/Platform/RaspberryPi/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c
> @@ -870,21 +870,19 @@ MemArrMapInfoUpdateSmbiosType19 (
> )
> {
> EFI_STATUS Status;
> - UINT32 BoardRevision = 0;
> + UINT32 InstalledMB = 0;
>
> // Note: Type 19 addresses are expressed in KB, not bytes
> // The memory layout used in all known Pi SoC's starts at 0
> mMemArrMapInfoType19.StartingAddress = 0;
> +
> // The minimum RAM size used on any Raspberry Pi model is 256 MB
> mMemArrMapInfoType19.EndingAddress = 256 * 1024;
> - Status = mFwProtocol->GetModelRevision (&BoardRevision);
> + Status = mFwProtocol->GetModelInstalledMB (&InstalledMB);
> if (Status != EFI_SUCCESS) {
> DEBUG ((DEBUG_WARN, "Couldn't get the board memory size - defaulting to 256 MB: %r\n", Status));
> } else {
> - // 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 = InstalledMB * 1024;
> }
> mMemArrMapInfoType19.EndingAddress -= 1;
>
> diff --git a/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c b/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
> index 75826fdc0e53..40c78b5d57cf 100644
> --- a/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
> +++ b/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
> @@ -606,6 +606,32 @@ RpiFirmwareGetModelName (
> }
> }
>
> +STATIC
> +EFI_STATUS
> +EFIAPI
> +RPiFirmwareGetModelInstalledMB (
> + OUT UINT32 *InstalledMB
> + )
> +{
> + EFI_STATUS Status;
> + UINT32 Revision;
> +
> + Status = RpiFirmwareGetModelRevision(&Revision);
> + if (EFI_ERROR(Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: Could not get the board revision: Status == %r\n",
> + __FUNCTION__, Status));
> + return EFI_DEVICE_ERROR;
> + }
> +
> + //
> + // 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.)
> + //
> + *InstalledMB = 256 << ((Revision >> 20) & 0x07);
> + return EFI_SUCCESS;
> +}
> +
> STATIC
> EFI_STATUS
> EFIAPI
> @@ -1236,7 +1262,8 @@ STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL mRpiFirmwareProtocol = {
> RpiFirmwareGetFirmwareRevision,
> RpiFirmwareGetManufacturerName,
> RpiFirmwareGetCpuName,
> - RpiFirmwareGetArmMemory
> + RpiFirmwareGetArmMemory,
> + RPiFirmwareGetModelInstalledMB,
> };
>
> /**
> diff --git a/Platform/RaspberryPi/Include/Protocol/RpiFirmware.h b/Platform/RaspberryPi/Include/Protocol/RpiFirmware.h
> index e3287e3c040f..108becbd3b6d 100644
> --- a/Platform/RaspberryPi/Include/Protocol/RpiFirmware.h
> +++ b/Platform/RaspberryPi/Include/Protocol/RpiFirmware.h
> @@ -115,6 +115,12 @@ EFI_STATUS
> UINT32 *Revision
> );
>
> +typedef
> +EFI_STATUS
> +(EFIAPI *GET_MODEL_INSTALLED_MB) (
> + UINT32 *InstalledMB
> + );
> +
> typedef
> CHAR8*
> (EFIAPI *GET_MANUFACTURER_NAME) (
> @@ -135,26 +141,27 @@ EFI_STATUS
> );
>
> typedef struct {
> - SET_POWER_STATE SetPowerState;
> - GET_MAC_ADDRESS GetMacAddress;
> - GET_COMMAND_LINE GetCommandLine;
> - GET_CLOCK_RATE GetClockRate;
> - GET_CLOCK_RATE GetMaxClockRate;
> - GET_CLOCK_RATE GetMinClockRate;
> - SET_CLOCK_RATE SetClockRate;
> - GET_FB GetFB;
> - FREE_FB FreeFB;
> - GET_FB_SIZE GetFBSize;
> - SET_LED SetLed;
> - GET_SERIAL GetSerial;
> - GET_MODEL GetModel;
> - GET_MODEL_REVISION GetModelRevision;
> - GET_MODEL_NAME GetModelName;
> - GET_MODEL_FAMILY GetModelFamily;
> - GET_FIRMWARE_REVISION GetFirmwareRevision;
> - GET_MANUFACTURER_NAME GetManufacturerName;
> - GET_CPU_NAME GetCpuName;
> - GET_ARM_MEM GetArmMem;
> + SET_POWER_STATE SetPowerState;
> + GET_MAC_ADDRESS GetMacAddress;
> + GET_COMMAND_LINE GetCommandLine;
> + GET_CLOCK_RATE GetClockRate;
> + GET_CLOCK_RATE GetMaxClockRate;
> + GET_CLOCK_RATE GetMinClockRate;
> + SET_CLOCK_RATE SetClockRate;
> + GET_FB GetFB;
> + FREE_FB FreeFB;
> + GET_FB_SIZE GetFBSize;
> + SET_LED SetLed;
> + GET_SERIAL GetSerial;
> + GET_MODEL GetModel;
> + GET_MODEL_REVISION GetModelRevision;
> + GET_MODEL_NAME GetModelName;
> + GET_MODEL_FAMILY GetModelFamily;
> + GET_FIRMWARE_REVISION GetFirmwareRevision;
> + GET_MANUFACTURER_NAME GetManufacturerName;
> + GET_CPU_NAME GetCpuName;
> + GET_ARM_MEM GetArmMem;
> + GET_MODEL_INSTALLED_MB GetModelInstalledMB;
> } RASPBERRY_PI_FIRMWARE_PROTOCOL;
>
> extern EFI_GUID gRaspberryPiFirmwareProtocolGuid;
> --
> 2.21.0.windows.1
>
next prev parent reply other threads:[~2020-03-03 10:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-03 10:33 [edk2-devel][PATCH 0/5] Platform/RPi: User config improvements Pete Batard
2020-03-03 10:33 ` [edk2-devel][PATCH 1/5] Platform/RPi: Add firmware call to read installed memory size Pete Batard
2020-03-03 10:37 ` Ard Biesheuvel [this message]
2020-03-03 10:33 ` [edk2-devel][PATCH 2/5] Platform/RPi: Separate RAM descriptors between 0-3 GB and 3+ GB Pete Batard
2020-03-03 10:39 ` Ard Biesheuvel
2020-03-03 10:33 ` [edk2-devel][PATCH 3/5] Platform/RPi: Make 3GB/4GB a runtime (BIOS setup) choice Pete Batard
2020-03-03 10:42 ` Ard Biesheuvel
2020-03-03 10:33 ` [edk2-devel][PATCH 4/5] Platform/RPi: Make Device Tree provision " Pete Batard
2020-03-03 10:45 ` Ard Biesheuvel
2020-03-03 10:33 ` [edk2-devel][PATCH 5/5] Platform/RPi/ConfigDxe: Improve RPi configuration forms Pete Batard
2020-03-03 10:45 ` Ard Biesheuvel
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=CAKv+Gu8VVBSGd5cALfYTNFyMTE+hgF7fxA0teB9YGXaWs0_3_w@mail.gmail.com \
--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