From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by mx.groups.io with SMTP id smtpd.web11.1945.1583231634837799756 for ; Tue, 03 Mar 2020 02:33:55 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@akeo-ie.20150623.gappssmtp.com header.s=20150623 header.b=QlVt5Maz; spf=none, err=permanent DNS error (domain: akeo.ie, ip: 209.85.128.66, mailfrom: pete@akeo.ie) Received: by mail-wm1-f66.google.com with SMTP id a141so2282890wme.2 for ; Tue, 03 Mar 2020 02:33:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akeo-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/4ZyAdnzP90zmfcSC1CIDyJaHpNjBmczzc1/I+XSUcg=; b=QlVt5MazUYBtahoSCT1wWyhgC/Y18MtLn51H38RS1/pt0sqpxaT6xqoQa21cmeG5ym lc6t7+9MlaNX0PD/+s8Y+ehnP/xjnZVPsv+5Dx19rBHYx/MD8cGtuJQN/UocIEXgekL3 6M3MSXY5cVNAYNLPca2yfOWA8Beg7VKFTSRo7ZlMiclf3+fflxdXhyV9zqfpjgVNSp0w mqzQ9ijwvUDPjjIaTJWyZqMnjMZ6B3m2k4ElxdS+NeHssmDz0aSm9msLbmUk3nhWl6qo AL87vA3abhj1hdYxSXd9L5pz+phvIq5J7o4mQ2Y3dNHqtiUJDW21r6VeDLmbpA0VXjm/ 40tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/4ZyAdnzP90zmfcSC1CIDyJaHpNjBmczzc1/I+XSUcg=; b=FbrryMvrheuSc01Md2CKrqJt0WFDpyVrWJcCxLsmCKZ6QURVPLTJbpN4v1KreM6K1L oopcqVANj70tbNBT/OISYn/muirRhkSvqFCle/Taml3BImW40OY3Oo77ayPHcgj8yjWB ExAximT9duJKJJuPnQbdUq5LAEAcExIDObH73nnRiSX6mhyIuwQWRAUtVmrLP9ktnw6P 1eS5iH7TY0BVd3zMyTsqO5NOg2Oen8pdbHnvoZJKmytGLRb2jD6JfRUwFC3bnkgjQGRu rBQQVuXUz6PLd2FNdSNSfPipAqY9Dt7rk8OuXnXoSBL8r2QR+c3BeV7m/+qsr+CnZl/+ /gvw== X-Gm-Message-State: ANhLgQ27eTIb+ufvMdD2JThqh7l5f3AB863oyR9LliqWTlL5WMeGGV9C /1aSiXR0Stum1ACmpqrp//Tqmt+W4d8= X-Google-Smtp-Source: ADFU+vtRTBQ8Vwjysyg5UXr6hL4YSMrzkZCMPPrjMzmfoHsg3YDVIsPCmOrR3E7jgNe15qXjOXG8kg== X-Received: by 2002:a1c:1d84:: with SMTP id d126mr3538676wmd.187.1583231632940; Tue, 03 Mar 2020 02:33:52 -0800 (PST) Return-Path: Received: from localhost.localdomain ([84.203.56.244]) by smtp.gmail.com with ESMTPSA id c4sm3255193wml.7.2020.03.03.02.33.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Mar 2020 02:33:52 -0800 (PST) From: "Pete Batard" To: devel@edk2.groups.io Cc: ard.biesheuvel@linaro.org, leif@nuviainc.com, philmd@redhat.com, awarkentin@vmware.com Subject: [edk2-devel][PATCH 1/5] Platform/RPi: Add firmware call to read installed memory size Date: Tue, 3 Mar 2020 10:33:35 +0000 Message-Id: <20200303103339.7468-2-pete@akeo.ie> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20200303103339.7468-1-pete@akeo.ie> References: <20200303103339.7468-1-pete@akeo.ie> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Andrei Warkentin 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 --- 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