From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: mx.groups.io; dkim=pass header.i=@akeo-ie.20150623.gappssmtp.com header.s=20150623 header.b=ornDmvfO; spf=none, err=permanent DNS error (domain: akeo.ie, ip: 209.85.221.43, mailfrom: pete@akeo.ie) Received: by mail-wr1-f43.google.com with SMTP id z9so11426902wrl.11 for ; Fri, 11 Oct 2019 04:08:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akeo-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PHxWm7oIuAvcr2ubRYCObXzs0jXGekTWNBrFkuq/meE=; b=ornDmvfO0pQpgVQVb/6EHuRiQDspIDZU7+H4v7/lNFSumiTz0giENtuDV1Xl+h08nA zWvV1z5tvW4rYUAlbVOgOX/xIA5cOLlZ4Q5A8waEPi5b+51Htze+Su9zzXLASS0Ezce9 VCPQME/ZBhBsXtOc/oA7RjbQLAnU9ItEJd0u031Fo0SvNnEFi7jlfrkyGp3LEoCs341W Sp/UbFZ2cmSdDbGyj1V3ALFuPNflxQdiFp07I4rINWCL2mg3k9q3fw4iDrpouPga/a5a BRb75Qg1KEZeL3cpar65B2wAgVFuTT6xpiQRlUr5IlQO069VgdDpwXabW4Tt5VdWIJQN rJJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PHxWm7oIuAvcr2ubRYCObXzs0jXGekTWNBrFkuq/meE=; b=XT9oWlW1qHskI9l0apKu9bkWb4nLGl+lvsa2cHkUPgATP7FForJCYrYfj09UiB1Dao BU5BWrpJZ/NJD3z7k6jerg/6WafzNTqedwZah13tG5WSbsdZGZuFNc397QpUGdYQij60 uF/LL0T/WShDvxZ6Idkf0Qwm3jQMjvUr2qA6Fj/4QfPiW1UfXaWWudduMps8oMehtLrv 2Om1TA92YpvL2HcNHCz13toP7/RxK+emdzmxOoLJO79/esCQie/GkmVnfnPsCl6AGuKK zXeJw6ZqlKZ1GZv4NeeP8faMASPSs9Dp4MZcYDDnlJtviRVW1DldzqRUpaBHlpXiO+3u y1XQ== X-Gm-Message-State: APjAAAVufhRbI0wv6TKmAKN6B+2nm8Do1cVve6Bhp3b5EV10ZZ7L0z8t Y3/lZJRU2ltC773GI4LdyYzqNHa/WZE= 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) Return-Path: 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-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> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20191011110746.1952-1-pete@akeo.ie> References: <20191011110746.1952-1-pete@akeo.ie> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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/PlatformSmbiosDxe.c b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.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 = { // VirtualMachineSupported :1; // ExtensionByte2Reserved :3; }, - 0xFF, // SystemBiosMajorRelease - 0xFF, // SystemBiosMinorRelease - 0xFF, // EmbeddedControllerFirmwareMajorRelease - 0xFF, // EmbeddedControllerFirmwareMinorRelease + 0, // SystemBiosMajorRelease + 0, // SystemBiosMinorRelease + 0, // EmbeddedControllerFirmwareMajorRelease + 0, // EmbeddedControllerFirmwareMinorRelease }; +CHAR8 mBiosVendor[128] = "EDK2"; +CHAR8 mBiosVersion[128] = "EDK2-DEV"; + CHAR8 *mBIOSInfoType0Strings[] = { - "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 }; @@ -132,42 +136,19 @@ SMBIOS_TABLE_TYPE1 mSysInfoType1 = { 6, // Family String }; -#define PROD_BASE 8 -#define PROD_KNOWN 13 -#define PROD_UNKNOWN 11 -CHAR8 *ProductNames[] = { - /* 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[] = { - "???", - /* 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. xxxxxxxx)")]; +CHAR8 mSysInfoManufName[128]; +CHAR8 mSysInfoProductName[128]; +CHAR8 mSysInfoVersionName[128]; CHAR8 mSysInfoSerial[sizeof (UINT64) * 2 + 1]; CHAR8 mSysInfoSKU[sizeof (UINT64) * 2 + 1]; CHAR8 *mSysInfoType1Strings[] = { mSysInfoManufName, mSysInfoProductName, - mSysInfoProductName, + mSysInfoVersionName, mSysInfoSerial, mSysInfoSKU, - "edk2", + "Raspberry Pi", NULL }; @@ -180,7 +161,7 @@ SMBIOS_TABLE_TYPE2 mBoardInfoType2 = { 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 = { 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 = { CHAR8 *mBoardInfoType2Strings[] = { mSysInfoManufName, mSysInfoProductName, - mSysInfoProductName, + mSysInfoVersionName, mSysInfoSerial, - "None", - mSysInfoSKU, NULL }; @@ -214,7 +193,7 @@ SMBIOS_TABLE_TYPE3 mEnclosureInfoType3 = { 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[] = { mSysInfoManufName, mSysInfoProductName, mSysInfoSerial, - "None", NULL }; @@ -306,9 +284,9 @@ SMBIOS_TABLE_TYPE4 mProcessorInfoType4 = { 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 = { ProcessorFamilyARM, // ARM Processor Family; }; +CHAR8 mCpuName[128] = "Unknown ARM CPU"; + CHAR8 *mProcessorInfoType4Strings[] = { "Socket", - "ARM", - "BCM2837 ARMv8", - "1.0", - "1.0", - "1.0", + "Broadcom", + mCpuName, NULL }; @@ -618,6 +595,29 @@ BIOSInfoUpdateSmbiosType0 ( VOID ) { + UINT32 FirmwareRevision = 0; + EFI_STATUS Status = EFI_SUCCESS; + + // Populate the Firmware major and minor. + Status = 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 = + (UINT8)((FirmwareRevision >> 16) & 0xFF); + mBIOSInfoType0.EmbeddedControllerFirmwareMinorRelease = + (UINT8)(FirmwareRevision & 0xFF); + } + + // mBiosVendor and mBiosVersion, which are referenced in mBIOSInfoType0Strings, + // 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, mBIOSInfoType0Strings, NULL); } @@ -664,34 +664,25 @@ SysInfoUpdateSmbiosType1 ( UINT32 BoardRevision = 0; EFI_STATUS Status = EFI_SUCCESS; UINT64 BoardSerial = 0; - UINTN Prod = PROD_UNKNOWN; - UINTN Manu = MANU_UNKNOWN; + INTN Prod = -1; + INTN Manu = -1; Status = mFwProtocol->GetModelRevision (&BoardRevision); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "Failed to get board model: %r\n", Status)); } else { Prod = (BoardRevision >> 4) & 0xFF; + Manu = (BoardRevision >> 16) & 0x0F; } - if (Prod > PROD_KNOWN) { - Prod = PROD_UNKNOWN; - } - Prod -= PROD_BASE; - AsciiSPrint (mSysInfoProductName, sizeof (mSysInfoProductName), - "64-bit Raspberry Pi %a (rev. %x)", ProductNames[Prod], BoardRevision); - - Manu = (BoardRevision >> 16) & 0xF; - if (Manu > MANU_KNOWN) { - Manu = MANU_UNKNOWN; - } else { - Manu += MANU_BASE; - } - AsciiSPrint (mSysInfoManufName, sizeof (mSysInfoManufName), "%a", ManufNames[Manu]); + AsciiStrCpyS (mSysInfoProductName, sizeof (mSysInfoProductName), + mFwProtocol->GetModelName (Prod)); + AsciiStrCpyS (mSysInfoManufName, sizeof (mSysInfoManufName), + mFwProtocol->GetManufacturerName (Manu)); + AsciiSPrint (mSysInfoVersionName, sizeof (mSysInfoVersionName), + "%X", BoardRevision); - I64ToHexString (mSysInfoSKU, - sizeof (mSysInfoSKU), - BoardRevision); + I64ToHexString (mSysInfoSKU, sizeof (mSysInfoSKU), BoardRevision); Status = mFwProtocol->GetSerial (&BoardSerial); if (EFI_ERROR (Status)) { @@ -702,9 +693,11 @@ SysInfoUpdateSmbiosType1 ( DEBUG ((DEBUG_ERROR, "Board Serial Number: %a\n", mSysInfoSerial)); - mSysInfoType1.Uuid.Data1 = *(UINT32*)"RPi3"; + mSysInfoType1.Uuid.Data1 = BoardRevision; mSysInfoType1.Uuid.Data2 = 0x0; mSysInfoType1.Uuid.Data3 = 0x0; + // Swap endianness, so that the serial is more user-friendly as a UUID + BoardSerial = SwapBytes64 (BoardSerial); CopyMem (mSysInfoType1.Uuid.Data4, &BoardSerial, sizeof (BoardSerial)); LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mSysInfoType1, mSysInfoType1Strings, NULL); @@ -763,6 +756,8 @@ ProcessorInfoUpdateSmbiosType4 ( DEBUG ((DEBUG_INFO, "Current CPU speed: %uHz\n", Rate)); } + AsciiStrCpyS (mCpuName, sizeof (mCpuName), mFwProtocol->GetCpuName (-1)); + LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mProcessorInfoType4, mProcessorInfoType4Strings, NULL); } diff --git a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.inf b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.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] [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] gEmbeddedTokenSpaceGuid.PcdDmaDeviceOffset|0xc0000000 - gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString|L"edk2-1.0" + gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString|L"EDK2-DEV" !if $(SECURE_BOOT_ENABLE) == 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|FALSE gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0x31 } - gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVendor|L"Raspberry Pi 3 64-bit UEFI" + gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVendor|L"EDK2" gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|TRUE [PcdsDynamicHii.common.DEFAULT] -- 2.21.0.windows.1