From nobody Mon Apr 29 11:40:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+48815+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+48815+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1570792082; cv=none; d=zoho.com; s=zohoarc; b=TJumfQb08rYEIvyM8WGCYDOfHSHTxly2wKtA2bycrsKuWfmAnKNKOZLXrEf5R6bnWwC4JQqzcCwk4JBjdHTESVZ0pLukTY5JaS/alOy4QXMMQlUP6SISZ9oWsOCSShvMcc/+2QQF06nv6PulxaiDeZy91MK8w7CkklKeTK+NfGY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570792082; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=u9GkXwbevIj8FAFqKQ4DCoVYjwEu9WEG9bvHQy5cdXw=; b=EsO7P8hicPbzs4kd8byYQczI3AzbqNqrB07h/oZL0FXnh9lQFYrRgmix1Y6wyQtI0R+C5teiSWhIJTc3z3S96neZCCYFyY+peUf60GVu/a+cjNdCDU+44qDq1z67wi2yYdm9HklN4E62us5Bqoozwf6tV+Wb4Uhh0Aqdm1zX5/4= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+48815+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1570792082201237.9532075296736; Fri, 11 Oct 2019 04:08:02 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id yxnAYY1788612xZnRhj8Jjw0; Fri, 11 Oct 2019 04:08:01 -0700 X-Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by mx.groups.io with SMTP id smtpd.web10.8152.1570792080933481530 for ; Fri, 11 Oct 2019 04:08:01 -0700 X-Received: by mail-wm1-f66.google.com with SMTP id 5so9999802wmg.0 for ; Fri, 11 Oct 2019 04:08:00 -0700 (PDT) X-Gm-Message-State: h57cDv33XC9b5vEH1oYgY0PHx1787277AA= X-Google-Smtp-Source: APXvYqz2zJYANldzzgQgvrfT0965C4/mXDFbsd/rH6vV3vZDol0HNBhXDCsDOmAZCiQJGnY2R/dTgg== X-Received: by 2002:a05:600c:22d7:: with SMTP id 23mr2705479wmg.31.1570792079143; Fri, 11 Oct 2019 04:07:59 -0700 (PDT) X-Received: from localhost.localdomain ([84.203.40.122]) by smtp.gmail.com with ESMTPSA id r18sm12806044wme.48.2019.10.11.04.07.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Oct 2019 04:07:58 -0700 (PDT) From: "Pete Batard" To: devel@edk2.groups.io Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org Subject: [edk2-devel] [edk2-platforms][PATCH v3 1/5] Platform/RPi3/RpiFirmwareDxe: Add more query functions Date: Fri, 11 Oct 2019 12:07:42 +0100 Message-Id: <20191011110746.1952-2-pete@akeo.ie> In-Reply-To: <20191011110746.1952-1-pete@akeo.ie> References: <20191011110746.1952-1-pete@akeo.ie> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pete@akeo.ie Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1570792081; bh=RBWNVNu1xYACYV8Ar4LBdi4UA2/AOZ0Ms3Obz5TigU4=; h=Cc:Date:From:Reply-To:Subject:To; b=OlGn6TYg99fslrhBSJP1jyKbv0wDiULe4yEhP7Tfywrx1geVL5dHOjWithUuAeHpWhJ SEv+OYP7H4QqcTQsaTxldH3CBKcj0YYv6FYUvjUIJzYtgZD8Sg22u5dywpxgMx4oIezub GrqPgpqZVtTl43HMpKcBSIsD4Z7HzKIiTL4= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" This patch introduces the capability to also query the Model Name/ Manufacturer Name/CPU Name/Firmware Revision using the RpiFirmware protocol. This is aims at making the driver more suitable to cater for platforms other than the Raspberry Pi 3 as well as simplifying the population of entries in PlatformSmbiosDxe. Signed-off-by: Pete Batard Reviewed-by: Leif Lindholm Reviewed-by: Philippe Mathieu-Daude --- Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c | 158 ++= +++++++++++++++++- Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h | 58 ++= +++-- 2 files changed, 199 insertions(+), 17 deletions(-) diff --git a/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDx= e.c b/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c index 9b5ee1946279..25d7fa3974c0 100644 --- a/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c +++ b/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c @@ -461,7 +461,7 @@ typedef struct { RPI_FW_TAG_HEAD TagHead; RPI_FW_MODEL_REVISION_TAG TagBody; UINT32 EndTag; -} RPI_FW_GET_MODEL_REVISION_CMD; +} RPI_FW_GET_REVISION_CMD; #pragma pack() =20 STATIC @@ -471,7 +471,7 @@ RpiFirmwareGetModelRevision ( OUT UINT32 *Revision ) { - RPI_FW_GET_MODEL_REVISION_CMD *Cmd; + RPI_FW_GET_REVISION_CMD *Cmd; EFI_STATUS Status; UINT32 Result; =20 @@ -506,6 +506,156 @@ RpiFirmwareGetModelRevision ( return EFI_SUCCESS; } =20 +STATIC +EFI_STATUS +EFIAPI +RpiFirmwareGetFirmwareRevision ( + OUT UINT32 *Revision + ) +{ + RPI_FW_GET_REVISION_CMD *Cmd; + EFI_STATUS Status; + UINT32 Result; + + if (!AcquireSpinLockOrFail (&mMailboxLock)) { + DEBUG ((DEBUG_ERROR, "%a: failed to acquire spinlock\n", __FUNCTION__)= ); + return EFI_DEVICE_ERROR; + } + + Cmd =3D mDmaBuffer; + ZeroMem (Cmd, sizeof (*Cmd)); + + Cmd->BufferHead.BufferSize =3D sizeof (*Cmd); + Cmd->BufferHead.Response =3D 0; + Cmd->TagHead.TagId =3D RPI_MBOX_GET_REVISION; + Cmd->TagHead.TagSize =3D sizeof (Cmd->TagBody); + Cmd->TagHead.TagValueSize =3D 0; + Cmd->EndTag =3D 0; + + Status =3D MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_C= HANNEL, &Result); + + ReleaseSpinLock (&mMailboxLock); + + if (EFI_ERROR (Status) || + Cmd->BufferHead.Response !=3D RPI_MBOX_RESP_SUCCESS) { + DEBUG ((DEBUG_ERROR, + "%a: mailbox transaction error: Status =3D=3D %r, Response =3D=3D 0x= %x\n", + __FUNCTION__, Status, Cmd->BufferHead.Response)); + return EFI_DEVICE_ERROR; + } + + *Revision =3D Cmd->TagBody.Revision; + return EFI_SUCCESS; +} + +STATIC +CHAR8* +EFIAPI +RpiFirmwareGetModelName ( + IN INTN ModelId + ) +{ + UINT32 Revision; + + // If a negative ModelId is passed, detect it. + if ((ModelId < 0) && (RpiFirmwareGetModelRevision (&Revision) =3D=3D EFI= _SUCCESS)) { + ModelId =3D (Revision >> 4) & 0xFF; + } + + switch (ModelId) { + // www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes= /README.md + case 0x00: + return "Raspberry Pi Model A"; + case 0x01: + return "Raspberry Pi Model B"; + case 0x02: + return "Raspberry Pi Model A+"; + case 0x03: + return "Raspberry Pi Model B+"; + case 0x04: + return "Raspberry Pi 2 Model B"; + case 0x06: + return "Raspberry Pi Compute Module 1"; + case 0x08: + return "Raspberry Pi 3 Model B"; + case 0x09: + return "Raspberry Pi Zero"; + case 0x0A: + return "Raspberry Pi Compute Module 3"; + case 0x0C: + return "Raspberry Pi Zero W"; + case 0x0D: + return "Raspberry Pi 3 Model B+"; + case 0x0E: + return "Raspberry Pi 3 Model A+"; + case 0x11: + return "Raspberry Pi 4 Model B"; + default: + return "Unknown Raspberry Pi Model"; + } +} + +STATIC +CHAR8* +EFIAPI +RpiFirmwareGetManufacturerName ( + IN INTN ManufacturerId + ) +{ + UINT32 Revision; + + // If a negative ModelId is passed, detect it. + if ((ManufacturerId < 0) && (RpiFirmwareGetModelRevision (&Revision) =3D= =3D EFI_SUCCESS)) { + ManufacturerId =3D (Revision >> 16) & 0x0F; + } + + switch (ManufacturerId) { + // www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes= /README.md + case 0x00: + return "Sony UK"; + case 0x01: + return "Egoman"; + case 0x02: + case 0x04: + return "Embest"; + case 0x03: + return "Sony Japan"; + case 0x05: + return "Stadium"; + default: + return "Unknown Manufacturer"; + } +} + +STATIC +CHAR8* +EFIAPI +RpiFirmwareGetCpuName ( + IN INTN CpuId + ) +{ + UINT32 Revision; + + // If a negative CpuId is passed, detect it. + if ((CpuId < 0) && (RpiFirmwareGetModelRevision (&Revision) =3D=3D EFI_S= UCCESS)) { + CpuId =3D (Revision >> 12) & 0x0F; + } + + switch (CpuId) { + // www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes= /README.md + case 0x00: + return "BCM2835 (ARM11)"; + case 0x01: + return "BCM2836 (ARM Cortex-A7)"; + case 0x02: + return "BCM2837 (ARM Cortex-A53)"; + case 0x03: + return "BCM2711 (ARM Cortex-A72)"; + default: + return "Unknown CPU Model"; + } +} + #pragma pack() typedef struct { UINT32 Width; @@ -1009,6 +1159,10 @@ STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL mRpiFirmwarePr= otocol =3D { RpiFirmwareGetSerial, RpiFirmwareGetModel, RpiFirmwareGetModelRevision, + RpiFirmwareGetModelName, + RpiFirmwareGetFirmwareRevision, + RpiFirmwareGetManufacturerName, + RpiFirmwareGetCpuName, RpiFirmwareGetArmMemory }; =20 diff --git a/Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h b/Pla= tform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h index ec70f28efe1a..e49d6e6132d9 100644 --- a/Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h +++ b/Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h @@ -96,6 +96,30 @@ EFI_STATUS UINT32 *Revision ); =20 +typedef +CHAR8* +(EFIAPI *GET_MODEL_NAME) ( + INTN ModelId + ); + +typedef +EFI_STATUS +(EFIAPI *GET_FIRMWARE_REVISION) ( + UINT32 *Revision + ); + +typedef +CHAR8* +(EFIAPI *GET_MANUFACTURER_NAME) ( + INTN ManufacturerId + ); + +typedef +CHAR8* +(EFIAPI *GET_CPU_NAME) ( + INTN CpuId + ); + typedef EFI_STATUS (EFIAPI *GET_ARM_MEM) ( @@ -104,21 +128,25 @@ EFI_STATUS ); =20 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_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_FIRMWARE_REVISION GetFirmwareRevision; + GET_MANUFACTURER_NAME GetManufacturerName; + GET_CPU_NAME GetCpuName; + GET_ARM_MEM GetArmMem; } RASPBERRY_PI_FIRMWARE_PROTOCOL; =20 extern EFI_GUID gRaspberryPiFirmwareProtocolGuid; --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#48815): https://edk2.groups.io/g/devel/message/48815 Mute This Topic: https://groups.io/mt/34485899/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon Apr 29 11:40:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+48816+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+48816+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1570792083; cv=none; d=zoho.com; s=zohoarc; b=O7+GYQ5IW7uS4dHlBADGaW9PSKsIbR3QJgwp8Oem+31nvF316trdSDv7t7VI2dZgw5Qlf9xefyM2K9EkZ8PdhmqbZ/Fw1SxvpnS5mdjXEUMI3807vFMKTIWgP9JbMhWBc/Kl8lqROnv92utWsM5bgIGReca7R5VpURBKa1qHnAE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570792083; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=bWAFcvZnGqSmxIXagWji1L2RpVPDVxtDIL8nxF4DhvM=; b=HAwKCG6CppGHAOFoJj+zBfJgC4HIJzcZS7NXkfy5n1Lo4tach1wKnTRZLmJS5agIcAwq530zqsM3V7+LWeFQb8oXW1UL7ClK84yOn2/41QvQtXn+huMHxjmV9I70V1jN8vRR0s1DZ+OZBHvumRQk/10vn+IZ34N5EEClJoCf4VU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+48816+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1570792083977239.06865442856054; Fri, 11 Oct 2019 04:08:03 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id sKcNYY1788612x9bdLcI2uc7; Fri, 11 Oct 2019 04:08:02 -0700 X-Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by mx.groups.io with SMTP id smtpd.web10.8154.1570792081897433438 for ; Fri, 11 Oct 2019 04:08:02 -0700 X-Received: by mail-wr1-f66.google.com with SMTP id z9so11426789wrl.11 for ; Fri, 11 Oct 2019 04:08:01 -0700 (PDT) X-Gm-Message-State: ongFqqfsJPaP19BQNcJhQXqhx1787277AA= X-Google-Smtp-Source: APXvYqx45IdYqNJoxMKIcBmE9PjjZkStClm3lfM0CNA8MhM6snkPpn95OHz7igo4N/K5Cf5SrWIeow== X-Received: by 2002:adf:fd0a:: with SMTP id e10mr11880708wrr.55.1570792080195; Fri, 11 Oct 2019 04:08:00 -0700 (PDT) X-Received: from localhost.localdomain ([84.203.40.122]) by smtp.gmail.com with ESMTPSA id r18sm12806044wme.48.2019.10.11.04.07.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Oct 2019 04:07:59 -0700 (PDT) From: "Pete Batard" To: devel@edk2.groups.io Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org Subject: [edk2-devel] [edk2-platforms][PATCH v3 2/5] Platform/RPi3/RpiFirmwareDxe: Improve serial number population Date: Fri, 11 Oct 2019 12:07:43 +0100 Message-Id: <20191011110746.1952-3-pete@akeo.ie> In-Reply-To: <20191011110746.1952-1-pete@akeo.ie> References: <20191011110746.1952-1-pete@akeo.ie> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pete@akeo.ie Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1570792082; bh=a7BHvr/hBbUm7zGwvWiFID+zYRW224JX55LnM0adGQQ=; h=Cc:Date:From:Reply-To:Subject:To; b=fIZdTS7GdXu1y8BTooyN6wwWUE2kkf18QLQHYhj/Vv9R/XysLejDZPvrSKLkyxspW2o aOw0qS/cKU9oMZ/tud+IAvG/nL6Oy594Tvf5RM9EOTP06rytu+IZX0N3D4p+KdauKwf1z 1b6h607ffVOhNXSxST52y5+c/VMEey6nOok= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Improve RpiFirmwareGetSerial() to derive a serial number from the MAC address, in case the platform returns 0 for the serial number. Signed-off-by: Pete Batard Reviewed-by: Leif Lindholm --- Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c | 9 ++++= ++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDx= e.c b/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c index 25d7fa3974c0..5a9d4c3f1787 100644 --- a/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c +++ b/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c @@ -393,7 +393,14 @@ RpiFirmwareGetSerial ( } =20 *Serial =3D Cmd->TagBody.Serial; - return EFI_SUCCESS; + // Some platforms return 0 for serial. For those, try to use the MAC add= ress. + if (*Serial =3D=3D 0) { + Status =3D RpiFirmwareGetMacAddress ((UINT8*) Serial); + // Convert to a more user-friendly value + *Serial =3D SwapBytes64 (*Serial << 16); + } + + return Status; } =20 #pragma pack() --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#48816): https://edk2.groups.io/g/devel/message/48816 Mute This Topic: https://groups.io/mt/34485900/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon Apr 29 11:40:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+48817+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+48817+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1570792084; cv=none; d=zoho.com; s=zohoarc; b=OhKZYqTk87BWFBzykFIqfNpKoRN5bsYSVp0BsjrtrxaMOqyWL4Esvfp+L4A7AJ0ilGXH4dMkTwGyxI0ADG+T17R4NNDVFImw2MOvhYzzk1nlq/Yf0uT8RhUIhHNWT2Z8c1gicFUqWNbmBeBdJtOevufU2mLJ/L4mprqMgtkyVs4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570792084; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=yQLbDS16Cu7cXvbjKBMoH9cQDtPyzwy9kkHrzM2pa14=; b=lbhdkykMBOZ6bTeua43BgZy7r5L5oEsu0fce62nh2heVRyWhPIUFn2MgmDeyAaidlnjGixIAGwRM56ANNy/THE0Yre7cvPuS2TfsYtb3n/iSzT0/sSIhfI8uROGFyhx2CZhJZ1oxzTiVYpRm0nRbhqZrSQx/xn9XGz8Wn/MPpmc= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+48817+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1570792084644230.9863052711496; Fri, 11 Oct 2019 04:08:04 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 9B1eYY1788612xhazSHjDSKF; Fri, 11 Oct 2019 04:08:04 -0700 X-Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) by mx.groups.io with SMTP id smtpd.web10.8155.1570792083482470939 for ; Fri, 11 Oct 2019 04:08:03 -0700 X-Received: by mail-wr1-f43.google.com with SMTP id z9so11426902wrl.11 for ; Fri, 11 Oct 2019 04:08:03 -0700 (PDT) X-Gm-Message-State: IQ4Y7MIqDVbu1Y29ksLt5eWUx1787277AA= X-Google-Smtp-Source: APXvYqyW8e8iOOD+4wQlqskDIyfRKEm0QFkXXAwZvJhDQcdM7XYlVJZBEoFHFq1GpAHoZfbPZWhnwQ== X-Received: by 2002:adf:9001:: with SMTP id h1mr13321446wrh.185.1570792081696; Fri, 11 Oct 2019 04:08:01 -0700 (PDT) X-Received: from localhost.localdomain ([84.203.40.122]) by smtp.gmail.com with ESMTPSA id r18sm12806044wme.48.2019.10.11.04.08.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Oct 2019 04:08:01 -0700 (PDT) From: "Pete Batard" To: devel@edk2.groups.io Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org Subject: [edk2-devel] [edk2-platforms][PATCH v3 3/5] Platform/RPi3/PlatformSmbiosDxe: Improve population of SMBIOS entries Date: Fri, 11 Oct 2019 12:07:44 +0100 Message-Id: <20191011110746.1952-4-pete@akeo.ie> In-Reply-To: <20191011110746.1952-1-pete@akeo.ie> References: <20191011110746.1952-1-pete@akeo.ie> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pete@akeo.ie Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1570792084; bh=3RrUe37PZZMUo98VjNCPCvW8LcF+/CkPiJRdbS6Necc=; h=Cc:Date:From:Reply-To:Subject:To; b=Ag+LBhtQvVP5gvkWaB5ih2JszakbCUuQ0hy2N/hHE9u/tJJu59W4eZA7KnzYoaa9/db N6S30gh9L1vR+3uo47PQJywk432xANgCTUx/cxQqOBI9o/K6NKgHzCKZugWdYHRqD41lX fqcQ6CgDxXsS2kH3rLGL/jbgRJxfZjIDdxI= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" This patch cleans up the population SMBIOS entries by removing elements that we don't have data for, as well as properly filling the ones for which we do, through the newly added queries from RpiFirmwareDxe. Signed-off-by: Pete Batard Reviewed-by: Leif Lindholm --- Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c = | 135 ++++++++++---------- Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.inf = | 2 + Platform/RaspberryPi/RPi3/RPi3.dsc = | 4 +- 3 files changed, 69 insertions(+), 72 deletions(-) diff --git a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSm= biosDxe.c b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmb= iosDxe.c index bc35175279f2..9150dcfd8c5b 100644 --- a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe= .c +++ b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe= .c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -104,16 +105,19 @@ SMBIOS_TABLE_TYPE0 mBIOSInfoType0 =3D { // VirtualMachineSupported :1; // ExtensionByte2Reserved :3; }, - 0xFF, // SystemBiosMajorRelease - 0xFF, // SystemBiosMinorRelease - 0xFF, // EmbeddedControllerFirmwareMajorRelease - 0xFF, // EmbeddedControllerFirmwareMinorRelease + 0, // SystemBiosMajorRelease + 0, // SystemBiosMinorRelease + 0, // EmbeddedControllerFirmwareMajorRelease + 0, // EmbeddedControllerFirmwareMinorRelease }; =20 +CHAR8 mBiosVendor[128] =3D "EDK2"; +CHAR8 mBiosVersion[128] =3D "EDK2-DEV"; + CHAR8 *mBIOSInfoType0Strings[] =3D { - "https://github.com/andreiw/RaspberryPiPkg", // Vendor String - "Raspberry Pi 64-bit UEFI (" __DATE__ " " __TIME__ ")", // BiosVersion = String - __DATE__, + mBiosVendor, // Vendor + mBiosVersion, // Version + __DATE__ " " __TIME__, // Release Date NULL }; =20 @@ -132,42 +136,19 @@ SMBIOS_TABLE_TYPE1 mSysInfoType1 =3D { 6, // Family String }; =20 -#define PROD_BASE 8 -#define PROD_KNOWN 13 -#define PROD_UNKNOWN 11 -CHAR8 *ProductNames[] =3D { - /* 8 */ "3", - /* 9 */ "Zero", - /* 10 */ "CM3", - /* 11 */ "???", - /* 12 */ "Zero W", - /* 13 */ "3B+" -}; - -#define MANU_UNKNOWN 0 -#define MANU_KNOWN 4 -#define MANU_BASE 1 -CHAR8 *ManufNames[] =3D { - "???", - /* 0 */ "Sony", - /* 1 */ "Egoman", - /* 2 */ "Embest", - /* 3 */ "Sony Japan", - /* 4 */ "Embest" -}; - -CHAR8 mSysInfoManufName[sizeof ("Sony Japan")]; -CHAR8 mSysInfoProductName[sizeof ("64-bit Raspberry Pi XXXXXX (rev. xxxxxx= xx)")]; +CHAR8 mSysInfoManufName[128]; +CHAR8 mSysInfoProductName[128]; +CHAR8 mSysInfoVersionName[128]; CHAR8 mSysInfoSerial[sizeof (UINT64) * 2 + 1]; CHAR8 mSysInfoSKU[sizeof (UINT64) * 2 + 1]; =20 CHAR8 *mSysInfoType1Strings[] =3D { mSysInfoManufName, mSysInfoProductName, - mSysInfoProductName, + mSysInfoVersionName, mSysInfoSerial, mSysInfoSKU, - "edk2", + "Raspberry Pi", NULL }; =20 @@ -180,7 +161,7 @@ SMBIOS_TABLE_TYPE2 mBoardInfoType2 =3D { 2, // ProductName String 3, // Version String 4, // SerialNumber String - 5, // AssetTag String + 0, // AssetTag String { // FeatureFlag 1, // Motherboard :1; 0, // RequiresDaughterCard :1; @@ -189,7 +170,7 @@ SMBIOS_TABLE_TYPE2 mBoardInfoType2 =3D { 0, // HotSwappable :1; 0, // Reserved :3; }, - 6, // LocationInChassis String + 0, // LocationInChassis String 0, // ChassisHandle; BaseBoardTypeMotherBoard, // BoardType; 0, // NumberOfContainedObjectHandles; @@ -198,10 +179,8 @@ SMBIOS_TABLE_TYPE2 mBoardInfoType2 =3D { CHAR8 *mBoardInfoType2Strings[] =3D { mSysInfoManufName, mSysInfoProductName, - mSysInfoProductName, + mSysInfoVersionName, mSysInfoSerial, - "None", - mSysInfoSKU, NULL }; =20 @@ -214,7 +193,7 @@ SMBIOS_TABLE_TYPE3 mEnclosureInfoType3 =3D { MiscChassisEmbeddedPc, // Type; 2, // Version String 3, // SerialNumber String - 4, // AssetTag String + 0, // AssetTag String ChassisStateSafe, // BootupState; ChassisStateSafe, // PowerSupplyState; ChassisStateSafe, // ThermalState; @@ -230,7 +209,6 @@ CHAR8 *mEnclosureInfoType3Strings[] =3D { mSysInfoManufName, mSysInfoProductName, mSysInfoSerial, - "None", NULL }; =20 @@ -306,9 +284,9 @@ SMBIOS_TABLE_TYPE4 mProcessorInfoType4 =3D { 0, // L1CacheHandle; 0, // L2CacheHandle; 0, // L3CacheHandle; - 4, // SerialNumber; - 5, // AssetTag; - 6, // PartNumber; + 0, // SerialNumber; + 0, // AssetTag; + 0, // PartNumber; 4, // CoreCount; 4, // EnabledCoreCount; 4, // ThreadCount; @@ -316,13 +294,12 @@ SMBIOS_TABLE_TYPE4 mProcessorInfoType4 =3D { ProcessorFamilyARM, // ARM Processor Family; }; =20 +CHAR8 mCpuName[128] =3D "Unknown ARM CPU"; + CHAR8 *mProcessorInfoType4Strings[] =3D { "Socket", - "ARM", - "BCM2837 ARMv8", - "1.0", - "1.0", - "1.0", + "Broadcom", + mCpuName, NULL }; =20 @@ -618,6 +595,29 @@ BIOSInfoUpdateSmbiosType0 ( VOID ) { + UINT32 FirmwareRevision =3D 0; + EFI_STATUS Status =3D EFI_SUCCESS; + + // Populate the Firmware major and minor. + Status =3D mFwProtocol->GetFirmwareRevision (&FirmwareRevision); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to get firmware revision: %r\n", Status)); + } else { + // This expects Broadcom / The Raspberry Pi Foundation to switch to + // less nonsensical VideoCore firmware revisions in the future... + mBIOSInfoType0.EmbeddedControllerFirmwareMajorRelease =3D + (UINT8)((FirmwareRevision >> 16) & 0xFF); + mBIOSInfoType0.EmbeddedControllerFirmwareMinorRelease =3D + (UINT8)(FirmwareRevision & 0xFF); + } + + // mBiosVendor and mBiosVersion, which are referenced in mBIOSInfoType0S= trings, + // are left unchanged if the following calls fail. + UnicodeStrToAsciiStrS ((CHAR16*)PcdGetPtr (PcdFirmwareVendor), + mBiosVendor, sizeof (mBiosVendor)); + UnicodeStrToAsciiStrS ((CHAR16*)PcdGetPtr (PcdFirmwareVersionString), + mBiosVersion, sizeof (mBiosVersion)); + LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mBIOSInfoType0, mBIOSInfoType0= Strings, NULL); } =20 @@ -664,34 +664,25 @@ SysInfoUpdateSmbiosType1 ( UINT32 BoardRevision =3D 0; EFI_STATUS Status =3D EFI_SUCCESS; UINT64 BoardSerial =3D 0; - UINTN Prod =3D PROD_UNKNOWN; - UINTN Manu =3D MANU_UNKNOWN; + INTN Prod =3D -1; + INTN Manu =3D -1; =20 Status =3D mFwProtocol->GetModelRevision (&BoardRevision); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "Failed to get board model: %r\n", Status)); } else { Prod =3D (BoardRevision >> 4) & 0xFF; + Manu =3D (BoardRevision >> 16) & 0x0F; } =20 - if (Prod > PROD_KNOWN) { - Prod =3D PROD_UNKNOWN; - } - Prod -=3D PROD_BASE; - AsciiSPrint (mSysInfoProductName, sizeof (mSysInfoProductName), - "64-bit Raspberry Pi %a (rev. %x)", ProductNames[Prod], BoardRevision); - - Manu =3D (BoardRevision >> 16) & 0xF; - if (Manu > MANU_KNOWN) { - Manu =3D MANU_UNKNOWN; - } else { - Manu +=3D MANU_BASE; - } - AsciiSPrint (mSysInfoManufName, sizeof (mSysInfoManufName), "%a", ManufN= ames[Manu]); + AsciiStrCpyS (mSysInfoProductName, sizeof (mSysInfoProductName), + mFwProtocol->GetModelName (Prod)); + AsciiStrCpyS (mSysInfoManufName, sizeof (mSysInfoManufName), + mFwProtocol->GetManufacturerName (Manu)); + AsciiSPrint (mSysInfoVersionName, sizeof (mSysInfoVersionName), + "%X", BoardRevision); =20 - I64ToHexString (mSysInfoSKU, - sizeof (mSysInfoSKU), - BoardRevision); + I64ToHexString (mSysInfoSKU, sizeof (mSysInfoSKU), BoardRevision); =20 Status =3D mFwProtocol->GetSerial (&BoardSerial); if (EFI_ERROR (Status)) { @@ -702,9 +693,11 @@ SysInfoUpdateSmbiosType1 ( =20 DEBUG ((DEBUG_ERROR, "Board Serial Number: %a\n", mSysInfoSerial)); =20 - mSysInfoType1.Uuid.Data1 =3D *(UINT32*)"RPi3"; + mSysInfoType1.Uuid.Data1 =3D BoardRevision; mSysInfoType1.Uuid.Data2 =3D 0x0; mSysInfoType1.Uuid.Data3 =3D 0x0; + // Swap endianness, so that the serial is more user-friendly as a UUID + BoardSerial =3D SwapBytes64 (BoardSerial); CopyMem (mSysInfoType1.Uuid.Data4, &BoardSerial, sizeof (BoardSerial)); =20 LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mSysInfoType1, mSysInfoType1St= rings, NULL); @@ -763,6 +756,8 @@ ProcessorInfoUpdateSmbiosType4 ( DEBUG ((DEBUG_INFO, "Current CPU speed: %uHz\n", Rate)); } =20 + AsciiStrCpyS (mCpuName, sizeof (mCpuName), mFwProtocol->GetCpuName (-1)); + LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mProcessorInfoType4, mProcesso= rInfoType4Strings, NULL); } =20 diff --git a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSm= biosDxe.inf b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformS= mbiosDxe.inf index f7c74f7f5456..485450625b54 100644 --- a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe= .inf +++ b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe= .inf @@ -48,3 +48,5 @@ [Depex] =20 [Pcd] gArmTokenSpaceGuid.PcdSystemMemorySize + gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVendor + gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc b/Platform/RaspberryPi/RPi3= /RPi3.dsc index b37a02e97da7..bc424a06bb45 100644 --- a/Platform/RaspberryPi/RPi3/RPi3.dsc +++ b/Platform/RaspberryPi/RPi3/RPi3.dsc @@ -309,7 +309,7 @@ [PcdsFixedAtBuild.common] =20 gEmbeddedTokenSpaceGuid.PcdDmaDeviceOffset|0xc0000000 =20 - gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString|L"edk2-1.0" + gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString|L"EDK2-DEV" =20 !if $(SECURE_BOOT_ENABLE) =3D=3D TRUE # override the default values from SecurityPkg to ensure images from all= sources are verified in secure boot @@ -383,7 +383,7 @@ [PcdsFixedAtBuild.common] gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FAL= SE gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c= , 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0= x31 } =20 - gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVendor|L"Raspberry Pi 3 64-bit= UEFI" + gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVendor|L"EDK2" gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|TRUE =20 [PcdsDynamicHii.common.DEFAULT] --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#48817): https://edk2.groups.io/g/devel/message/48817 Mute This Topic: https://groups.io/mt/34485901/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon Apr 29 11:40:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+48818+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+48818+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1570792085; cv=none; d=zoho.com; s=zohoarc; b=Yb5wBQPXvmBKPlAYPsDFXbidWu2f27G3t/03sraCRi3uE7VtxBudA1G3mQs2Jy7jaIdkSLhzk4c/zme8lAeJSWEdwqf+jIAix7tnSnEN3vb9qfA4cuzw9Enhi/kuJ7pp4BTI4892Eo+L+BfZLkylPxA1W5TKAFGW3mpIEBpqyKs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570792085; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=vUqu6HZ2VXoBQ+GVPeafqD2A+n8Ki6MSLcdSxOM2Gqk=; b=U9WdYg5U3hVFhAoKbNE8431GaQ1Rs5bwm7IOSjLXRFzeQCb/kY9NL37Sp8+JSyHdNRIh7h1waeAJm7QaI6WBqxgvJpHITcakCkt03T8EvSTP30mX1tiRDyBV8KDUTZXD6WcfE1O+vexptCzYXtwZ6hKbSd4CrH+KXqn3Fjzl2+U= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+48818+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1570792085873535.1674570546774; Fri, 11 Oct 2019 04:08:05 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 83DOYY1788612xPO6jsjSXR2; Fri, 11 Oct 2019 04:08:05 -0700 X-Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by mx.groups.io with SMTP id smtpd.web10.8156.1570792084321694081 for ; Fri, 11 Oct 2019 04:08:04 -0700 X-Received: by mail-wr1-f65.google.com with SMTP id p14so11437231wro.4 for ; Fri, 11 Oct 2019 04:08:04 -0700 (PDT) X-Gm-Message-State: swHeReyNrzEMxETAN5jeMncHx1787277AA= X-Google-Smtp-Source: APXvYqzLbUTwBNY+NViZzYx2NUqhiBfpjCcAzhjO5/xZES2B0tTX1gn6IZnOcF7MfRPTLqS51bQJDg== X-Received: by 2002:adf:ea86:: with SMTP id s6mr12236180wrm.397.1570792082643; Fri, 11 Oct 2019 04:08:02 -0700 (PDT) X-Received: from localhost.localdomain ([84.203.40.122]) by smtp.gmail.com with ESMTPSA id r18sm12806044wme.48.2019.10.11.04.08.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Oct 2019 04:08:02 -0700 (PDT) From: "Pete Batard" To: devel@edk2.groups.io Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org Subject: [edk2-devel] [edk2-platforms][PATCH v3 4/5] Platform/RPi3/PlatformSmbiosDxe: Populate BIOS major/minor from PCD Date: Fri, 11 Oct 2019 12:07:45 +0100 Message-Id: <20191011110746.1952-5-pete@akeo.ie> In-Reply-To: <20191011110746.1952-1-pete@akeo.ie> References: <20191011110746.1952-1-pete@akeo.ie> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pete@akeo.ie Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1570792085; bh=6J19eU4dg/n8mzfIyXfkKGhQixNtkf+bpmuU8ozrsDc=; h=Cc:Date:From:Reply-To:Subject:To; b=wFOYmE9G/Sxi50dI/EDkfcpA5DtBgVTAbk6B5WQCNV6zR+RCdSIWFE1+AnJXpbXZnQN qrUPXrGnqvL0d+CLrOPO4SEHDYT5SRsb47VbDVjMwGjoDybgNnT7V5n2JV89ytkCcT70/ Iej2SIyS50XRON6zGuiViyJmeN4qFbKERbk= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" String parsing code is added to BIOSInfoUpdateSmbiosType0() so that any numeric "x.y" value being passed in PcdFirmwareVersionString is now used to populate the BIOS major and minor. Signed-off-by: Pete Batard Reviewed-by: Leif Lindholm --- Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c | = 45 ++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSm= biosDxe.c b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmb= iosDxe.c index 9150dcfd8c5b..b5dcff897a59 100644 --- a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe= .c +++ b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe= .c @@ -41,6 +41,8 @@ #include #include =20 +#define SMB_IS_DIGIT(c) (((c) >=3D '0') && ((c) <=3D '9')) + STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL *mFwProtocol; =20 /*********************************************************************** @@ -597,6 +599,9 @@ BIOSInfoUpdateSmbiosType0 ( { UINT32 FirmwareRevision =3D 0; EFI_STATUS Status =3D EFI_SUCCESS; + INTN i; + INTN State =3D 0; + INTN Value[2]; =20 // Populate the Firmware major and minor. Status =3D mFwProtocol->GetFirmwareRevision (&FirmwareRevision); @@ -618,6 +623,46 @@ BIOSInfoUpdateSmbiosType0 ( UnicodeStrToAsciiStrS ((CHAR16*)PcdGetPtr (PcdFirmwareVersionString), mBiosVersion, sizeof (mBiosVersion)); =20 + // Look for a "x.y" numeric string anywhere in mBiosVersion and + // try to parse it to populate the BIOS major and minor. + for (i =3D 0; (i < AsciiStrLen (mBiosVersion)) && (State < 4); i++) { + switch (State) { + case 0: + if (!SMB_IS_DIGIT (mBiosVersion[i])) + break; + Value[0] =3D Value[1] =3D 0; + State++; + // Fall through + case 1: + case 3: + if (SMB_IS_DIGIT (mBiosVersion[i])) { + Value[State / 2] =3D (Value[State / 2] * 10) + (mBiosVersion[i] - = '0'); + if (Value[State / 2] > 255) { + while (SMB_IS_DIGIT (mBiosVersion[i + 1])) + i++; + // Reset our state (we may have something like "Firmware X83737.= 1 v1.23") + State =3D 0; + } + } else { + State++; + } + if (State !=3D 2) + break; + // Fall through + case 2: + if ((mBiosVersion[i] =3D=3D '.') && (SMB_IS_DIGIT (mBiosVersion[i + = 1]))) { + State++; + } else { + State =3D 0; + } + break; + } + } + if ((State =3D=3D 3) || (State =3D=3D 4)) { + mBIOSInfoType0.SystemBiosMajorRelease =3D (UINT8)Value[0]; + mBIOSInfoType0.SystemBiosMinorRelease =3D (UINT8)Value[1]; + } + LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mBIOSInfoType0, mBIOSInfoType0= Strings, NULL); } =20 --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#48818): https://edk2.groups.io/g/devel/message/48818 Mute This Topic: https://groups.io/mt/34485902/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon Apr 29 11:40:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+48819+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+48819+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1570792087; cv=none; d=zoho.com; s=zohoarc; b=kxb4wyAd1k3/+YLriYjK3bj91T7v6zcxM+Eoh0U9oWWkElkGVAIQ535Z/YDmHr68BcdV26ZrRCb6M1nhNYtbNKw/rDIIZ+cDP8ZD8tITAbtpP9/zK+yd/QF/W4XjiznypYJdwrhfO+w+IfgTu9vWpWlp6mRK4z7W3O724QKLOLI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570792087; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=lBJb0b+XKPmIP7IjmWTolCwZywOlZH9xfBiVVpgJt1E=; b=d7+LP9UX7lxhER6xt2rb85wgyybehkoR7eN6F/pWKKgIdQVizz3zvywW+aT8dgJuDOm1GUfScgqrKagdEBGPd/P07k9okuSM+hUx7KcxD8qqgkZIHHKlcYRvp8vt/feKHEjO0sx51CPInjTwt7ekSwzHDCQO/cfh+wm6c9p96y4= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+48819+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1570792087676813.343265116663; Fri, 11 Oct 2019 04:08:07 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id fPm2YY1788612xQ4fbtnl7fa; Fri, 11 Oct 2019 04:08:06 -0700 X-Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by mx.groups.io with SMTP id smtpd.web12.8275.1570792085941770485 for ; Fri, 11 Oct 2019 04:08:06 -0700 X-Received: by mail-wm1-f67.google.com with SMTP id 3so9797508wmi.3 for ; Fri, 11 Oct 2019 04:08:05 -0700 (PDT) X-Gm-Message-State: tzsz9Ew7Bfcn5YVzZ0IoBANYx1787277AA= X-Google-Smtp-Source: APXvYqyi68yjDJztgnvTZFoSvAEdLc1RiaCZ+88hNpELpmxgH39xQKxW9ukzMQwYirIc/jcAofZbWg== X-Received: by 2002:a1c:f709:: with SMTP id v9mr2933183wmh.62.1570792084174; Fri, 11 Oct 2019 04:08:04 -0700 (PDT) X-Received: from localhost.localdomain ([84.203.40.122]) by smtp.gmail.com with ESMTPSA id r18sm12806044wme.48.2019.10.11.04.08.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Oct 2019 04:08:03 -0700 (PDT) From: "Pete Batard" To: devel@edk2.groups.io Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org Subject: [edk2-devel] [edk2-platforms][PATCH v3 5/5] Platform/RPi3/PlatformSmbiosDxe: Derive RAM size from board revision Date: Fri, 11 Oct 2019 12:07:46 +0100 Message-Id: <20191011110746.1952-6-pete@akeo.ie> In-Reply-To: <20191011110746.1952-1-pete@akeo.ie> References: <20191011110746.1952-1-pete@akeo.ie> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pete@akeo.ie Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1570792086; bh=p36UmG/byU+T9Wq1zATk79oc3ccEVhdpY5CT4AHOvSg=; h=Cc:Date:From:Reply-To:Subject:To; b=KD6GasT0zUmC5IHXXlKBEy8lfC0aREEVtwXaZ6CdC/MHtlz1pjmG0O1BJk5MtjUcUkn v81eEmB4eLXZtzomesDeSE9EbKUGEWcLLF9MnFPkm2m9bljJn18MXIM/vkadM0vcjbAAB FVXqh0ihVTY1qvvR5FbynFfl6frrZ91+Wpg= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Leif Lindholm Reviewed-by: Philippe Mathieu-Daude --- Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c | = 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSm= biosDxe.c b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmb= iosDxe.c index b5dcff897a59..5abc82b8d363 100644 --- a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe= .c +++ b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe= .c @@ -866,16 +866,22 @@ MemArrMapInfoUpdateSmbiosType19 ( ) { EFI_STATUS Status; - UINT32 Base; - UINT32 Size; + UINT32 BoardRevision =3D 0; =20 - Status =3D mFwProtocol->GetArmMem (&Base, &Size); + // Note: Type 19 addresses are expressed in KB, not bytes + mMemArrMapInfoType19.StartingAddress =3D 0; + // The minimum RAM size used on any Raspberry Pi model is 256 MB + mMemArrMapInfoType19.EndingAddress =3D 256 * 1024; + Status =3D mFwProtocol->GetModelRevision (&BoardRevision); if (Status !=3D 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 - defaultin= g to 256 MB: %r\n", Status)); } else { - mMemArrMapInfoType19.StartingAddress =3D Base / 1024; - mMemArrMapInfoType19.EndingAddress =3D (Base + Size - 1) / 1024; + // www.raspberrypi.org/documentation/hardware/raspberrypi/revision-cod= es/README.md + // Bits [20-22] indicate the amount of memory starting with 256MB (000= b) + // and doubling in size for each value (001b =3D 512 MB, 010b =3D 1GB,= etc.) + mMemArrMapInfoType19.EndingAddress <<=3D (BoardRevision >> 20) & 0x07; } + mMemArrMapInfoType19.EndingAddress -=3D 1; =20 LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mMemArrMapInfoType19, mMemArrM= apInfoType19Strings, NULL); } --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#48819): https://edk2.groups.io/g/devel/message/48819 Mute This Topic: https://groups.io/mt/34485903/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-