From nobody Fri Apr 26 06:25:51 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+48569+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+48569+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1570538337; cv=none; d=zoho.com; s=zohoarc; b=eYgkd+heouz2IH3AcXeLP+2Y/Q5mkjHk//htSAMfvmaE3qODkk4+iDG5ZE5bL7CnKHCIJjejboWPjVagzZEwoQBqdY7FPyI53S9SQhbuKNZv0Iyy020b+ZRTtdTbqBEbTaKrHnBdm/nDfr8Czvh4JxqutehIlQF+pBpjqibGOS8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570538337; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=/TiG20w63g1aatfJyACv3jid4SM5VZ2nmUy2znjENXc=; b=m0f7UVbln47Y02D1OAQwZhDX/fcwd+e7i7m4zzFXxquNO0luvnE3rZD/h8IcM4hZGmPYHl2R5rucrg5T7KhD8452Qs+ensNDjWa+fy2t/lHisGYxGgV9oV3p0O9SDmrkya4IVGDnEKLZp6RY4jEqBdRIMIHnSTQ15gLaYbP6Fuk= 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+48569+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1570538337906642.5945431841608; Tue, 8 Oct 2019 05:38:57 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id aaaaYY1788612xaaaaaaaaaa; Tue, 08 Oct 2019 05:38:57 -0700 X-Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by groups.io with SMTP; Tue, 08 Oct 2019 05:38:56 -0700 X-Received: by mail-wr1-f68.google.com with SMTP id z9so19180559wrl.11 for ; Tue, 08 Oct 2019 05:38:56 -0700 (PDT) X-Gm-Message-State: aaaaaaaaaaaaaaaaaaaaaaaax1787277AA= X-Google-Smtp-Source: APXvYqwNLLDRWSV1/SQ6o+XKrWPJ9t7ABHrZSXsz5g3uXv/9x6nE6Z9VFTULffPiTsZLzYOFL45l6w== X-Received: by 2002:a5d:6284:: with SMTP id k4mr27136180wru.205.1570538334618; Tue, 08 Oct 2019 05:38:54 -0700 (PDT) X-Received: from localhost.localdomain ([84.203.40.122]) by smtp.gmail.com with ESMTPSA id r6sm3203087wmh.38.2019.10.08.05.38.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Oct 2019 05:38:54 -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 v2 1/5] Platform/RPi3/RpiFirmwareDxe: Add more query functions Date: Tue, 8 Oct 2019 13:38:37 +0100 Message-Id: <20191008123841.12952-2-pete@akeo.ie> In-Reply-To: <20191008123841.12952-1-pete@akeo.ie> References: <20191008123841.12952-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=1570538337; bh=FB8JZHvmXfr6elGkQm7Z/ZZfnUlykXjhWXUvJub//mw=; h=Cc:Date:From:Reply-To:Subject:To; b=Is1216hlS3RIefzfM1RpgEg0Ka7d3G8kCrLev0LTi7ffYqlMreoRlPCxDp837I0NAIz fytmli6EU0A8AaIgDS5wFnRZcL5GIFW2jGdlxMNrDdNOkIrzZcWN2pgqK6a4+pLK14bBx t7xehC7ALiXmdHguTuSIFrmuyiXCSBcTCvE= 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 --- Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c | 155 ++= +++++++++++++++++- Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h | 58 ++= ++++-- 2 files changed, 196 insertions(+), 17 deletions(-) diff --git a/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDx= e.c b/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c index 9b5ee1946279..378c99bcba05 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,153 @@ 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 +1156,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 (#48569): https://edk2.groups.io/g/devel/message/48569 Mute This Topic: https://groups.io/mt/34441816/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 Fri Apr 26 06:25:51 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+48570+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+48570+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1570538338; cv=none; d=zoho.com; s=zohoarc; b=CjFVTig4CjXT489wQ/FnatCs/EQDnBl6JdEhaLy2YYNcz/I2jLNyaGCOgZ8UOP+5x+DKZnY4ksaQkhkoF5WbtgP5S7IpLkJrbkZjGZgb+wUlxaDHs+Xvew4LEinQNPXF9S6iUaOFrJv223J/tsaZSisTajDuaMfIdLWjbhRpXuE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570538338; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=8da5mS+fAWB9wYEnO543/ttKqwR3bJyhvJJeb3WS+wc=; b=EoO3+HLMxij7DlHe8xRjsl9e3ooFA8QEgakticlgvEbGsAw5NBmIKPRA0YXPVicbqi5fTLRjLoKurbkvi5I7R66ElbD6vzDe7OQp85CClokmFTBBs41USJLnCc7LXlqV1/av+e5n/09xYJGJD7UyIvWPmfVyihktvm3TuMVUEEw= 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+48570+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1570538338621698.7462416670667; Tue, 8 Oct 2019 05:38:58 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id aaaaYY1788612xaaaaaaaaaa; Tue, 08 Oct 2019 05:38:58 -0700 X-Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by groups.io with SMTP; Tue, 08 Oct 2019 05:38:57 -0700 X-Received: by mail-wr1-f67.google.com with SMTP id r5so19157640wrm.12 for ; Tue, 08 Oct 2019 05:38:57 -0700 (PDT) X-Gm-Message-State: aaaaaaaaaaaaaaaaaaaaaaaax1787277AA= X-Google-Smtp-Source: APXvYqwN3nxf3u9Ea/aIt0DszKttxAhATXtyrKHKMb4Vn0OZ0RGW0fE861Zw6L5Z9mBYAlODvOiXSA== X-Received: by 2002:a5d:5145:: with SMTP id u5mr12654653wrt.125.1570538335598; Tue, 08 Oct 2019 05:38:55 -0700 (PDT) X-Received: from localhost.localdomain ([84.203.40.122]) by smtp.gmail.com with ESMTPSA id r6sm3203087wmh.38.2019.10.08.05.38.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Oct 2019 05:38:55 -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 v2 2/5] Platform/RPi3/RpiFirmwareDxe: Improve serial number population Date: Tue, 8 Oct 2019 13:38:38 +0100 Message-Id: <20191008123841.12952-3-pete@akeo.ie> In-Reply-To: <20191008123841.12952-1-pete@akeo.ie> References: <20191008123841.12952-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=1570538338; bh=nXGqZdJ5WOftsFsBV3GG5GVw2JhenCMzpQM38Ve7qcA=; h=Cc:Date:From:Reply-To:Subject:To; b=b1bbt1B9kawPMpC3gGQPsPczCMF73UaXtPPbWx1c083LeegXdT/vDHNDT5I+M10SVan AwIVX1TGNUZ/d8a2hwN4T11vTTZUO/KG1Yl9C1rWwuNx7J+9Vng4hwkLuZDh3rV1Cabhm mxBX0X5oUZgn//84a1t4mwG0q1dBu/a+W0s= 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. Also fix a typo where "%s" was used instead of "%a". Signed-off-by: Pete Batard --- Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c | 11 +++= ++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDx= e.c b/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c index 378c99bcba05..c2344252d2c0 100644 --- a/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c +++ b/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c @@ -219,7 +219,7 @@ RpiFirmwareSetPowerState ( =20 if (!EFI_ERROR (Status) && PowerState ^ (Cmd->TagBody.PowerState & RPI_MBOX_POWER_STATE_ENABLE)= ) { - DEBUG ((DEBUG_ERROR, "%a: failed to %sable power for device %d\n", + DEBUG ((DEBUG_ERROR, "%a: failed to %aable power for device %d\n", __FUNCTION__, PowerState ? "en" : "dis", DeviceId)); Status =3D EFI_DEVICE_ERROR; } @@ -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 (#48570): https://edk2.groups.io/g/devel/message/48570 Mute This Topic: https://groups.io/mt/34441817/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 Fri Apr 26 06:25:51 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+48571+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+48571+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1570538340; cv=none; d=zoho.com; s=zohoarc; b=Rorq7B2E7OndKaZo0afwAAv+luhEcVCvTLbu/mzzPEjWxTP1Zz/HwYv7zRxVvLsMkQEdt87VR2xTO66i7UfjGPH+kPEFTcExfOuit4m5F8JNEh2DDwVn80ZEnvs2LCwlMVoqIj6hHsH6MuFz7ves3YB2ZGzEjfW1/ryGvdqaE/U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570538340; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=KC6k9GhtbFrFKGcUcAP/bPo3pGEeo7WzgJM+ajLdzvo=; b=T7eKSbcVl95oQWEmSjTXB8Cx+2izUpz9W1akXVKBeA4QOdPJYANiW9iMfPSHF8MBuiUULFxOtWRPcSm+tf/60k2nDRVlavdMHnS7BxRjKrDbJXEU/IIDMPIQF6QhJm3fkLuY6Y2pf7v4hgGvEbgonrPrPke/bGD2s8oqgUISbdA= 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+48571+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1570538340583428.5081349946422; Tue, 8 Oct 2019 05:39:00 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id aaaaYY1788612xaaaaaaaaaa; Tue, 08 Oct 2019 05:38:59 -0700 X-Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by groups.io with SMTP; Tue, 08 Oct 2019 05:38:59 -0700 X-Received: by mail-wr1-f47.google.com with SMTP id n14so19178045wrw.9 for ; Tue, 08 Oct 2019 05:38:58 -0700 (PDT) X-Gm-Message-State: aaaaaaaaaaaaaaaaaaaaaaaax1787277AA= X-Google-Smtp-Source: APXvYqzADoSlhx3+UBsugfvXZLetdyenJd/0+BI9YLzZ7AtJS9vv/6+ZyscgIxtYwjDkZCG0Aw4opQ== X-Received: by 2002:a5d:6347:: with SMTP id b7mr21314657wrw.131.1570538337022; Tue, 08 Oct 2019 05:38:57 -0700 (PDT) X-Received: from localhost.localdomain ([84.203.40.122]) by smtp.gmail.com with ESMTPSA id r6sm3203087wmh.38.2019.10.08.05.38.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Oct 2019 05:38:56 -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 v2 3/5] Platform/RPi3/PlatformSmbiosDxe: Improve population of SMBIOS entries Date: Tue, 8 Oct 2019 13:38:39 +0100 Message-Id: <20191008123841.12952-4-pete@akeo.ie> In-Reply-To: <20191008123841.12952-1-pete@akeo.ie> References: <20191008123841.12952-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=1570538339; bh=+gRWOUo+wDxN1IsU1Jfgf9VJVcJSkXPbJj78LDjuWT8=; h=Cc:Date:From:Reply-To:Subject:To; b=Svw9XjNdS00TA0n4azKYDyiByGkVcCOTlQFtaSznB9UbJO0KO7kp+nQmkyHdfVK/3aW q32OTdGyvUcQPcbmiVFHydavzRRXTWWSYU+ADYcbUpy7FfSZVu9617A/STdfzKzUlmA+r hn49Uscq6PIdtNWUNZIWk1bvVpOKSe+D+jY= 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. Additional minor improvements are also applied, such as consistent use of uppercase values. Signed-off-by: Pete Batard --- Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c = | 153 ++++++++++---------- Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.inf = | 1 + Platform/RaspberryPi/RPi3/RPi3.dsc = | 2 +- 3 files changed, 76 insertions(+), 80 deletions(-) diff --git a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSm= biosDxe.c b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmb= iosDxe.c index bc35175279f2..8a4840267780 100644 --- a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe= .c +++ b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe= .c @@ -35,12 +35,13 @@ #include #include #include +#include #include #include #include #include =20 -STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL *mFwProtocol; +static RASPBERRY_PI_FIRMWARE_PROTOCOL *mFwProtocol; =20 /*********************************************************************** SMBIOS data definition TYPE0 BIOS Information @@ -49,7 +50,7 @@ SMBIOS_TABLE_TYPE0 mBIOSInfoType0 =3D { { EFI_SMBIOS_TYPE_BIOS_INFORMATION, sizeof (SMBIOS_TABLE_TYPE0), 0 }, 1, // Vendor String 2, // BiosVersion String - 0x0, // BiosSegment + 0, // BiosSegment 3, // BiosReleaseDate String 0x1F, // BiosSize { // BiosCharacteristics @@ -97,23 +98,25 @@ SMBIOS_TABLE_TYPE0 mBIOSInfoType0 =3D { // Boot1394IsSupported :1; // SmartBatteryIsSupported :1; // BIOSCharacteristicsExtensionBytes[1] - 0x0e, // BiosBootSpecIsSupported :1; + 0x0E, // BiosBootSpecIsSupported :1; // FunctionKeyNetworkBootIsSupported :1; // TargetContentDistributionEnabled :1; // UefiSpecificationSupported :1; // VirtualMachineSupported :1; // ExtensionByte2Reserved :3; }, - 0xFF, // SystemBiosMajorRelease - 0xFF, // SystemBiosMinorRelease - 0xFF, // EmbeddedControllerFirmwareMajorRelease - 0xFF, // EmbeddedControllerFirmwareMinorRelease + 0, // SystemBiosMajorRelease + 0, // SystemBiosMinorRelease + 0, // EmbeddedControllerFirmwareMajorRelease + 0, // EmbeddedControllerFirmwareMinorRelease }; =20 +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__, + "TianoCore", // Vendor + mBiosVersion, // Version + __DATE__ " " __TIME__, // Release Date NULL }; =20 @@ -132,42 +135,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 +160,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 +169,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 +178,8 @@ SMBIOS_TABLE_TYPE2 mBoardInfoType2 =3D { CHAR8 *mBoardInfoType2Strings[] =3D { mSysInfoManufName, mSysInfoProductName, - mSysInfoProductName, + mSysInfoVersionName, mSysInfoSerial, - "None", - mSysInfoSKU, NULL }; =20 @@ -214,7 +192,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 +208,6 @@ CHAR8 *mEnclosureInfoType3Strings[] =3D { mSysInfoManufName, mSysInfoProductName, mSysInfoSerial, - "None", NULL }; =20 @@ -240,9 +217,9 @@ CHAR8 *mEnclosureInfoType3Strings[] =3D { SMBIOS_TABLE_TYPE4 mProcessorInfoType4 =3D { { EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION, sizeof (SMBIOS_TABLE_TYPE4), 0}, 1, // Socket String - CentralProcessor, // ProcessorType; = ///< The enumeration value from PROCESSOR_TYPE_DATA. + CentralProcessor, // ProcessorType; ///< The enu= meration value from PROCESSOR_TYPE_DATA. ProcessorFamilyIndicatorFamily2, // ProcessorFamily; ///< The enu= meration value from PROCESSOR_FAMILY2_DATA. - 2, // ProcessorManufacture String; + 2, // ProcessorManufacturer String; { // ProcessorId; { // PROCESSOR_SIGNATURE 0, // ProcessorSteppingId:4; @@ -306,9 +283,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 +293,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 @@ -430,7 +406,7 @@ SMBIOS_TABLE_TYPE17 mMemDevInfoType17 =3D { 0x0400, // Size; // When bit 15 is 0: Size in MB // When bit 15 is 1: Size in KB, and continues in ExtendedSi= ze MemoryFormFactorUnknown, // FormFactor; ///< The enu= meration value from MEMORY_FORM_FACTOR. - 0xff, // DeviceSet; + 0xFF, // DeviceSet; 1, // DeviceLocator String 2, // BankLocator String MemoryTypeDram, // MemoryType; ///< The enum= eration value from MEMORY_DEVICE_TYPE. @@ -618,6 +594,30 @@ BIOSInfoUpdateSmbiosType0 ( VOID ) { + UINT32 FirmwareRevision =3D 0; + EFI_STATUS Status =3D EFI_SUCCESS; + INTN i; + INTN State =3D 0; + INTN Value[2]; + + // 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); + } + + // mBiosVersion, which is referenced in mBIOSInfoType0Strings, + // is not modified if the following call fails. + UnicodeStrToAsciiStrS ((CHAR16*)PcdGetPtr (PcdFirmwareVersionString), + mBiosVersion, sizeof (mBiosVersion)); + LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mBIOSInfoType0, mBIOSInfoType0= Strings, NULL); } =20 @@ -631,7 +631,7 @@ I64ToHexString ( IN UINT64 Value ) { - static CHAR8 ItoH[] =3D { '0','1','2','3','4','5','6','7','8','9','A','B= ','C','D','E','F' }; + STATIC CHAR8 ItoH[] =3D { '0','1','2','3','4','5','6','7','8','9','A','B= ','C','D','E','F' }; UINT8 StringInx; INT8 NibbleInx; =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.Data2 =3D 0x0; - mSysInfoType1.Uuid.Data3 =3D 0x0; + mSysInfoType1.Uuid.Data1 =3D BoardRevision; + mSysInfoType1.Uuid.Data2 =3D 0; + mSysInfoType1.Uuid.Data3 =3D 0; + // 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..fde194ea5d90 100644 --- a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe= .inf +++ b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe= .inf @@ -48,3 +48,4 @@ [Depex] =20 [Pcd] gArmTokenSpaceGuid.PcdSystemMemorySize + gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc b/Platform/RaspberryPi/RPi3= /RPi3.dsc index b37a02e97da7..6adc21bcc370 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 --=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 (#48571): https://edk2.groups.io/g/devel/message/48571 Mute This Topic: https://groups.io/mt/34441818/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 Fri Apr 26 06:25:51 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+48572+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+48572+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1570538341; cv=none; d=zoho.com; s=zohoarc; b=HRT74qzZUkXN30EEFWS0pdjE/cZlFSfkFAhoactMG1I7XFyQwQ5GI7V7TJ0P7tGGZ8k5Kk7+0SYPOhxrwawfiZv73cP1eAhEkoiFp1pnTMxESKhT8/nXVVpWRS5EmbKF2aBzeMJ4QnxBlIzNEslj4xmKjPOmqgTX5/KXwAB5Ybc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570538341; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=T/cJkEA/hXlglv7a2QumNKzhxdtfeChC9JrjOdTQ1q4=; b=PT2IqajSoqa+dVssUtZ6BF9NJ83H2n48RopGSLK6vSyn9JC/H3T0HksaP1QyC6eUDjLEdHC7cHLXizJ5vIQyB95jNot1xqgA//UaX/y7QL5kk6qDDQJs3LoRWrxv1a3tUBWo3RO/7ia96FOWTFKM3Tp1ADJuliqztiRnhx2xa1o= 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+48572+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1570538341726418.40660021819167; Tue, 8 Oct 2019 05:39:01 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id aaaaYY1788612xaaaaaaaaaa; Tue, 08 Oct 2019 05:39:00 -0700 X-Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by groups.io with SMTP; Tue, 08 Oct 2019 05:39:00 -0700 X-Received: by mail-wr1-f67.google.com with SMTP id q9so19231424wrm.8 for ; Tue, 08 Oct 2019 05:38:59 -0700 (PDT) X-Gm-Message-State: aaaaaaaaaaaaaaaaaaaaaaaax1787277AA= X-Google-Smtp-Source: APXvYqzZ9r9Yrzp4Yu/cTQlN/36zWsA03epTFGPa+dWnn1vQC0+pM5qZrmy5EqpJ8WMTTBguACKR+w== X-Received: by 2002:adf:e60d:: with SMTP id p13mr10818269wrm.298.1570538338202; Tue, 08 Oct 2019 05:38:58 -0700 (PDT) X-Received: from localhost.localdomain ([84.203.40.122]) by smtp.gmail.com with ESMTPSA id r6sm3203087wmh.38.2019.10.08.05.38.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Oct 2019 05:38:57 -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 v2 4/5] Platform/RPi3/PlatformSmbiosDxe: Populate BIOS major/minor from PCD Date: Tue, 8 Oct 2019 13:38:40 +0100 Message-Id: <20191008123841.12952-5-pete@akeo.ie> In-Reply-To: <20191008123841.12952-1-pete@akeo.ie> References: <20191008123841.12952-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=1570538340; bh=Gxj7j3nFxqybGtuvIDcWHm38EG+KvRAha6jJFEO9OS4=; h=Cc:Date:From:Reply-To:Subject:To; b=CJkOac3PBrQMjAzCOai1nlZVeH+eVcBpchhuak1a0xfBCst4dgqQjKoLyCkYvwjUp46 ooLe5tEy0Io9abspRkISQ8HS/AgRGzXaUoJ7WDDu5x2p/MLPg0hDEQ+exx+/po5pCR1l6 oaY0+GyTg4DZx4TnLrL6tojGVCueQOnSWaI= 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 --- Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c | = 44 +++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSm= biosDxe.c b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmb= iosDxe.c index 8a4840267780..66ffadd0cade 100644 --- a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe= .c +++ b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe= .c @@ -41,7 +41,9 @@ #include #include =20 -static RASPBERRY_PI_FIRMWARE_PROTOCOL *mFwProtocol; +#define SMB_IS_DIGIT(c) (((c) >=3D '0') && ((c) <=3D '9')) + +STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL *mFwProtocol; =20 /*********************************************************************** SMBIOS data definition TYPE0 BIOS Information @@ -618,6 +620,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 (#48572): https://edk2.groups.io/g/devel/message/48572 Mute This Topic: https://groups.io/mt/34441819/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 Fri Apr 26 06:25:51 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+48573+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+48573+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1570538343; cv=none; d=zoho.com; s=zohoarc; b=E8M1dzqLCKcax2ay3+RqwMbVYHJuyy7M/Zgxu3TCBvv7khrRQNGVN8KWT7Bkxvvxv3kUuspTswwwQuDwPjrdfI/3xa+BIqvekGSL95pe3Q3rkOZhWDo6CfBzbPF3w2m/huuE3lJ7cNgnpbIBbsi4J/Bb9ABAVrb4+DhSzE+TqYE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570538343; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=bcR65LZrg7jsyeT4Yi7oBL6rcrN75OAdDQKs1iYo/mU=; b=kUH0D3ORsafUTRvDX2UIOlFkB4NH0mQxESJiwavbTxkgJvE3Dm46ydVnBgQv+P3GugxT94YtfkcyiQL7Xn3rvlOxYfAtxkkpJ0CoKUHTcswaaDJKBbIpWG3kryrNlLJsemfk1hNROrvV0RHlYAqgSFLOe0ecXVaicXDX3R051D4= 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+48573+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1570538343108854.6818160323469; Tue, 8 Oct 2019 05:39:03 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id aaaaYY1788612xaaaaaaaaaa; Tue, 08 Oct 2019 05:39:02 -0700 X-Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by groups.io with SMTP; Tue, 08 Oct 2019 05:39:02 -0700 X-Received: by mail-wm1-f67.google.com with SMTP id m18so2974148wmc.1 for ; Tue, 08 Oct 2019 05:39:01 -0700 (PDT) X-Gm-Message-State: aaaaaaaaaaaaaaaaaaaaaaaax1787277AA= X-Google-Smtp-Source: APXvYqxBhxLXna/iq1OeEhqEyb0DPMkSNQwl4QbiNVmhu+kUIzSXxGnDi7ZPwxkauNRTea2X64AgoA== X-Received: by 2002:a7b:c631:: with SMTP id p17mr3645548wmk.5.1570538339820; Tue, 08 Oct 2019 05:38:59 -0700 (PDT) X-Received: from localhost.localdomain ([84.203.40.122]) by smtp.gmail.com with ESMTPSA id r6sm3203087wmh.38.2019.10.08.05.38.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Oct 2019 05:38: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 v2 5/5] Platform/RPi3/PlatformSmbiosDxe: Derive RAM size from board revision Date: Tue, 8 Oct 2019 13:38:41 +0100 Message-Id: <20191008123841.12952-6-pete@akeo.ie> In-Reply-To: <20191008123841.12952-1-pete@akeo.ie> References: <20191008123841.12952-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=1570538342; bh=VddGTAW+gFWk9KQUc4z966RmMW9GkS7HC3ga6mMbQoI=; h=Cc:Date:From:Reply-To:Subject:To; b=CgTNKh31LdHEcTfVaVCBT02+uF1+EgMPhUtws7Xo8MVVYJ1Lg3dDYOhx1EsaRpsE3wR 0Uqdc7ZgTXLNsTDjvsEJtBDnVQjB2ucw9tpnWLI9nXLIIzl08a5wRKwjn5U6HtLDGliEJ ieCPxgNvbv1g8zCMeGyPSH9ji1BLpsgivAo= 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 --- 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 66ffadd0cade..540e3fd61f25 100644 --- a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe= .c +++ b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe= .c @@ -863,16 +863,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 (#48573): https://edk2.groups.io/g/devel/message/48573 Mute This Topic: https://groups.io/mt/34441820/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-