summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Warkentin <andrey.warkentin@gmail.com>2020-03-03 13:08:09 +0000
committerArd Biesheuvel <ard.biesheuvel@linaro.org>2020-03-03 15:06:19 +0100
commit639b1d5fd9b6a64dad49085d6644255b814a9434 (patch)
tree46db0b5b0004512bf6ad44431dd609d4dfc3f18f
parentd5f7c68948a30b1dba28dda410214fa6d0cb13e9 (diff)
Platform/RPi: Add firmware call to read installed memory size
Add a new RPiFirmwareGetModelInstalledMB () call in RpiFirmwareDxe to return the amount of detected installed RAM on the system (in MB). Signed-off-by: Pete Batard <pete@akeo.ie> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
-rw-r--r--Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c29
-rw-r--r--Platform/RaspberryPi/Include/Protocol/RpiFirmware.h47
2 files changed, 55 insertions, 21 deletions
diff --git a/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c b/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
index 75826fdc..40c78b5d 100644
--- a/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
+++ b/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
@@ -609,6 +609,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
RPiFirmwareGetModelFamily (
OUT UINT32 *ModelFamily
)
@@ -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 e3287e3c..108becbd 100644
--- a/Platform/RaspberryPi/Include/Protocol/RpiFirmware.h
+++ b/Platform/RaspberryPi/Include/Protocol/RpiFirmware.h
@@ -116,6 +116,12 @@ EFI_STATUS
);
typedef
+EFI_STATUS
+(EFIAPI *GET_MODEL_INSTALLED_MB) (
+ UINT32 *InstalledMB
+ );
+
+typedef
CHAR8*
(EFIAPI *GET_MANUFACTURER_NAME) (
INTN ManufacturerId
@@ -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;