From nobody Thu May 2 04:29:41 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+46807+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+46807+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1567599275; cv=none; d=zoho.com; s=zohoarc; b=dGV0mfPn134W4Tf2KyXMXcf/eXxMLANG6t7E6U6ctb6EUt9S9kJeVsdN8HtjIIPoeCiQEdTUxJkHiGm6FhAFLpPeFS44GfZNYRwZ2oKlEUD8ndcl2e8mt7kvwlNj78XFmAGIJUuKMGWHFTs4d6ZK7hRL06YN5ccKbTufEFmag9Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567599275; 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=pYsA801EOAmPKVmSwor2y+4MSZTvuPAc+0bN0ZLxmCI=; b=Ej5VKkkgDuW+qI1fh8jPtiYnvu7WApYJAhrum4h3bXmG62gZwRk7aFWa/mg7VLyB+d9TLlDIlRYhzFGmDLMtyGifqBKqcO5tXaOIyCIfdkYJDkbNsCTByCf0zAy+FUlufwCmX+Wm+TTsGwGG69l5tYClYJJ9Dxnm8osJ8kZdkjo= 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+46807+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1567599275083455.0618945396043; Wed, 4 Sep 2019 05:14:35 -0700 (PDT) Return-Path: X-Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by groups.io with SMTP; Wed, 04 Sep 2019 05:14:33 -0700 X-Received: by mail-wr1-f66.google.com with SMTP id q14so1632846wrm.9 for ; Wed, 04 Sep 2019 05:14:33 -0700 (PDT) X-Gm-Message-State: APjAAAXOdvgU0X8xoQR3321L1sAL2D8VJv6mj4dXKYIqhHedNPrWWCO1 Kt1H/ApZ2tHQYfn9KaAeJRjupdRvSAw= X-Google-Smtp-Source: APXvYqxFsOejZEah7udx0Mapowa12XkwLexIumhfqiakywK/NMJ42FjfYJyrWXo37KpoLz9vmOgNFQ== X-Received: by 2002:a5d:6504:: with SMTP id x4mr24574527wru.227.1567599271726; Wed, 04 Sep 2019 05:14:31 -0700 (PDT) X-Received: from localhost.localdomain ([84.203.56.193]) by smtp.gmail.com with ESMTPSA id n12sm2791631wmc.24.2019.09.04.05.14.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Sep 2019 05:14:30 -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 1/2] Platform/RPi3: Add more query functions in RpiFirmwareDxe Date: Wed, 4 Sep 2019 13:14:17 +0100 Message-Id: <20190904121418.3700-2-pete@akeo.ie> In-Reply-To: <20190904121418.3700-1-pete@akeo.ie> References: <20190904121418.3700-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=1567599274; bh=/3KRtvoy6N98aI0gqoncaXPLgiKYCZOSSR0BFQkACfA=; h=Cc:Date:From:Reply-To:Subject:To; b=Z6t/Y4yH5k91A42JFVXVkYXky6hZc9Rwh+5Y4fFb6VgRQbQ4liL+pZbLJGJLVNUjfjf bh8DZXfEf3LABfr7ARnKLHQuoMFqrQpiX/Xgpfg0U3nTdTgb04AEscx5LP+L9JBR4itDK jubwKJubpPXvZg30s4BE1lMR/NdXhTqQGho= 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. Also fixes a typo where "%s" was used instead of "%a" and improves RpiFirmwareGetSerial() to derive a serial from the the MAC address in case the platform returns 0 for the serial. Signed-off-by: Pete Batard --- Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c | 166 ++= +++++++++++++++++- Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h | 58 ++= +++-- 2 files changed, 205 insertions(+), 19 deletions(-) diff --git a/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDx= e.c b/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c index 9b5ee1946279..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() @@ -461,7 +468,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 +478,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 +513,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 +1163,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 (#46807): https://edk2.groups.io/g/devel/message/46807 Mute This Topic: https://groups.io/mt/33137773/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 Thu May 2 04:29:41 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+46808+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+46808+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1567599277; cv=none; d=zoho.com; s=zohoarc; b=NQFRp/GLUYwU4Q5aDBmmvwoi27RRUtrSezilcoq4peSIAlUwxrGPLz2AJoCr9VmBMjqqVgwSgs6++nc0afUIhDHoYBgBE9p6Y5oV41jhTRiMh2/OgRgXnchJ5bh6pV0VPCMNFzUczgA+RiYXJKyKhDkgUco97dNaxJdjXz0KQpo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567599277; 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=2MI6GF2exdwsrIcHoyJ2F1mb6mSG3k3s15WSAXqv9C4=; b=Y6zT1p8St4QwtVxdScZ6vn43Nfuszq2ixSQyY+R7geB+7yQZb5A2n7vdEt13zcazlVxcg+171GtrAq9kHia6UfvRPzaCaMpwSYf6jaxp11KcxaBQOMbUX/DCPG0TvugJ+WO9VvcMF4SkAzwMhoVqCLncrJrqanduGPIEbsRdNaU= 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+46808+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1567599277209325.2982099597508; Wed, 4 Sep 2019 05:14:37 -0700 (PDT) Return-Path: X-Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) by groups.io with SMTP; Wed, 04 Sep 2019 05:14:36 -0700 X-Received: by mail-wr1-f54.google.com with SMTP id l11so12181117wrx.5 for ; Wed, 04 Sep 2019 05:14:35 -0700 (PDT) X-Gm-Message-State: APjAAAU/xQli6Ul7vmFwOMzZOP1TPbEeh0bjHNsLwSA/1/1I1sLXgF6Q CVP+vzAyknuiU9jpQj2gn1vunvDfrxo= X-Google-Smtp-Source: APXvYqytKbzuNI8ttUWxEvcZg7RdwWWSaXCE3cjxP+uEHXaK0jfX95GweQhurkeNM0VNPAbpZYvZBA== X-Received: by 2002:a5d:6a49:: with SMTP id t9mr13619050wrw.134.1567599273950; Wed, 04 Sep 2019 05:14:33 -0700 (PDT) X-Received: from localhost.localdomain ([84.203.56.193]) by smtp.gmail.com with ESMTPSA id n12sm2791631wmc.24.2019.09.04.05.14.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Sep 2019 05:14:32 -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 2/2] Platform/RPi3: Improve the population of PlatformSmbiosDxe elements Date: Wed, 4 Sep 2019 13:14:18 +0100 Message-Id: <20190904121418.3700-3-pete@akeo.ie> In-Reply-To: <20190904121418.3700-1-pete@akeo.ie> References: <20190904121418.3700-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=1567599276; bh=68/8fJx4gU4jEhB7kgMOMlLqWyUYn7a4BUwZuyUxm7Q=; h=Cc:Date:From:Reply-To:Subject:To; b=fReHM9TL98Tp2+xQUSze1Ko/yhTMuC2B3dMeUTaayBcldLT5ueeT8iggQFDyV/TJmKP LdR/36gzRAOGRrz+682cLAdSmjKpPglcMXbDxRDDNDxxXCCZYgLQnRuyPe4ZuVZcRsb/L aswM4uqHIB0G1Gpx26qwl9k14gzhRSNsXDw= 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. String parsing code is also added to BIOSInfoUpdateSmbiosType0() so that any numeric "x.y" value being passed in PcdFirmwareVersionString will now be used to populate the BIOS major and minor. 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 = | 193 ++++++++++++-------- Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.inf = | 1 + Platform/RaspberryPi/RPi3/RPi3.dsc = | 2 +- 3 files changed, 117 insertions(+), 79 deletions(-) diff --git a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSm= biosDxe.c b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmb= iosDxe.c index bc35175279f2..66ffadd0cade 100644 --- a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe= .c +++ b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe= .c @@ -35,11 +35,14 @@ #include #include #include +#include #include #include #include #include =20 +#define SMB_IS_DIGIT(c) (((c) >=3D '0') && ((c) <=3D '9')) + STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL *mFwProtocol; =20 /*********************************************************************** @@ -49,7 +52,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 +100,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 +137,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 +162,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 +171,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 +180,8 @@ SMBIOS_TABLE_TYPE2 mBoardInfoType2 =3D { CHAR8 *mBoardInfoType2Strings[] =3D { mSysInfoManufName, mSysInfoProductName, - mSysInfoProductName, + mSysInfoVersionName, mSysInfoSerial, - "None", - mSysInfoSKU, NULL }; =20 @@ -214,7 +194,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 +210,6 @@ CHAR8 *mEnclosureInfoType3Strings[] =3D { mSysInfoManufName, mSysInfoProductName, mSysInfoSerial, - "None", NULL }; =20 @@ -240,9 +219,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 +285,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 +295,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 +408,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 +596,70 @@ 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)); + + // 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 @@ -631,7 +673,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 +706,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 +735,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 +798,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 2b9e619ad55c..138d3691dc56 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 (#46808): https://edk2.groups.io/g/devel/message/46808 Mute This Topic: https://groups.io/mt/33137777/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-