From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by mx.groups.io with SMTP id smtpd.web11.3391.1583240910012173479 for ; Tue, 03 Mar 2020 05:08:30 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@akeo-ie.20150623.gappssmtp.com header.s=20150623 header.b=rvcP2ZC1; spf=none, err=permanent DNS error (domain: akeo.ie, ip: 209.85.221.66, mailfrom: pete@akeo.ie) Received: by mail-wr1-f66.google.com with SMTP id v2so4184620wrp.12 for ; Tue, 03 Mar 2020 05:08:29 -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=/o9+tr2kyy4OhKlTBvODwAZcSuT01kvL686N/xZRp/I=; b=rvcP2ZC1/oa/i3MyVuGa2wngb+xnHdX8BWxg340C54xsDjOj+99EXHVASKEikGLApa 1oQa7zeUXD5sOrATWQZ8DeHN8LPCe8YT5tf+lLP+4m2CFmQsqnN1Pnw+Z3aeJYlLeoAg WLBRkHTlJnHgbphGF/JS2TvSl7biLfmZKoGSC0Yd3vcaVcnUVRUV5qEkdw5TPmD4YqS0 tYp3sx0hs1ojPwJcLSKd0DoHV6FFpPLuR+XZRUua99FQEmRMEGfFdOx0WagnUMFFAZwZ IihrdlQ2WL40o8XUnjZU+G9kLjmcRSNc0Bwd8eY4NaMPRmd1GAFGCljx/Z38vgUi8H55 ToxQ== 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=/o9+tr2kyy4OhKlTBvODwAZcSuT01kvL686N/xZRp/I=; b=QiHcbXYO8fuJXTxCU6AZfs3KRiWWWKi365IEqFTD9px8NMK1PWbrhb4HkikOwQgol1 n45L8gJZ7QunQjEg+YkEVRHUALSs75XxEmWwEzj0gcqKzHL9z75/3eOsSPCBInAPJV2b Jv5Xg4sHEhQaA2a5sZeYYEOF7Z/y6sRWwWhsOVYWPpXkuT38iHpgD0qV4MuckeJj4TeH 42//H6eEy/kt+W5Na2HZ4I/OaqgJCbV7V27f5DfvFKM7KYWriZxwuyfv0a3i+1y7jA+2 WdJ/Bt5HGYUIlxv8E++OJrNOTFYwfCfH34PQ2v+dPTOd2DjTvIBi+yAsy463Jgf6w+23 Davg== X-Gm-Message-State: ANhLgQ0Um78IMa9kU7CDuEyXdNiVGIZ9HDQJpS0bh04MJKqGyeZqRe/F Btod4kJPaiIBoaEfnE4aAOXlBcndKO4= X-Google-Smtp-Source: ADFU+vvGIV6Ni2bkBhI5vc7txq5cfG7yAOch99ew6aGP4R+tFZBoINYsRn9ENkN3Yfi0bASNHbLufg== X-Received: by 2002:adf:b1d4:: with SMTP id r20mr5299241wra.303.1583240908282; Tue, 03 Mar 2020 05:08:28 -0800 (PST) Return-Path: Received: from localhost.localdomain ([84.203.56.244]) by smtp.gmail.com with ESMTPSA id j5sm3907620wmi.33.2020.03.03.05.08.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Mar 2020 05:08:27 -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 v2 1/6] Platform/RPi: Add firmware call to read installed memory size Date: Tue, 3 Mar 2020 13:08:09 +0000 Message-Id: <20200303130814.3092-2-pete@akeo.ie> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20200303130814.3092-1-pete@akeo.ie> References: <20200303130814.3092-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). Signed-off-by: Pete Batard --- Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c | 29 +++++++++++- Platform/RaspberryPi/Include/Protocol/RpiFirmware.h | 47 +++++++++++--------- 2 files changed, 55 insertions(+), 21 deletions(-) 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