From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by mx.groups.io with SMTP id smtpd.web10.9899.1595502510460789187 for ; Thu, 23 Jul 2020 04:08:30 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20150623.gappssmtp.com header.s=20150623 header.b=YRgpn0cL; spf=pass (domain: nuviainc.com, ip: 209.85.221.66, mailfrom: leif@nuviainc.com) Received: by mail-wr1-f66.google.com with SMTP id q5so4751141wru.6 for ; Thu, 23 Jul 2020 04:08:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=/7bGAbLeRSD87BWhTjkvaWjbaaeAsmT0LjuVh7qZ4Vk=; b=YRgpn0cLgmsgBF2MBEv+cUofq4pjLApkIuFufIXHV9xBj3KeJXhe2cks1+8dJ6cNd3 tF/RXzXHpfBnw2B9uqQaWWwMRer0TGilmGsY2kOjt8/wXL9BdKIVKMpmlwOgN278knpD 8JFZair35YJFRjva0Qs77XSfm1rJf0dDWjGPlmUIDY1dq1sxhm9b+k5XE7VhaDoin9h1 9qVvxBYnouPNJAQy4RLUYHDL5b8T35KAN+8jvhPqhgUTe6I2fYjFor3+qXyXzvp/fr9r 7BlyfHv5fRQuDCu3xUsqPxKGaoTfbEfsn6kmSyG+AtT0Xy/LmRsjFVzfIChdnmI4ELhy M30A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=/7bGAbLeRSD87BWhTjkvaWjbaaeAsmT0LjuVh7qZ4Vk=; b=NpSELEyQfdUHtOxy3JewM7PvXDRGJAp3YA55y3wt7bps+y3f2uvXE8IyxHn+TNlrsA wBH+wLuYHICJq+dgSOktQ0ooarbp2koEOzPdUrok+lOOLhu4l18hrBcARcqwDxIvnmdK PSBMgNMOZaOkTOVFTMDDGOlX/d0HFOj4ANDgyz4uqIMMjmoyrUGFYeSA8TsJreRDqG0L oMQcIP/bC3IlUi24efF0rHenYekrVsiwp5N3CZ3zIU9yJiOiUr9irTxMVc1XOzPutpuF 1qPmv7tLE0C+LLmMo+CRWw7QzU2IsEix0D4c1D8OroHZ32RJTic2NKIzDo8IoRLyUCk6 htOw== X-Gm-Message-State: AOAM5328+4gIsTVcEOyhxf0U5XcA7o8VgtN6VqujjbY0jXUIiS6iikbh OINS5Z9MTAIrEF0w3g2beu30Pg== X-Google-Smtp-Source: ABdhPJwbbiNQp75jN7SALNeR9Z5sEuWKTKe9lqpgpHmOGfQ+jKT/FeBKJlDnnMVRYMjwzAAygci5BQ== X-Received: by 2002:adf:e690:: with SMTP id r16mr3865361wrm.249.1595502508874; Thu, 23 Jul 2020 04:08:28 -0700 (PDT) Return-Path: Received: from vanye ([2001:470:1f09:12f0:b26e:bfff:fea9:f1b8]) by smtp.gmail.com with ESMTPSA id q1sm3256681wro.82.2020.07.23.04.08.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2020 04:08:28 -0700 (PDT) Date: Thu, 23 Jul 2020 12:08:26 +0100 From: "Leif Lindholm" To: Pete Batard Cc: devel@edk2.groups.io, ard.biesheuvel@arm.com, awarkentin@vmware.com, samer.el-haj-mahmoud@arm.com Subject: Re: [edk2-platforms][PATCH 1/1] Platforms/RaspberryPi: Fix BIOS Release Date and System Manufacturer Message-ID: <20200723110826.GM1337@vanye> References: <20200720161507.14352-1-pete@akeo.ie> MIME-Version: 1.0 In-Reply-To: <20200720161507.14352-1-pete@akeo.ie> User-Agent: Mutt/1.10.1 (2018-07-13) Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Jul 20, 2020 at 17:15:07 +0100, Pete Batard wrote: > Per SMBIOS specs, The Type 0 BIOS Release Date is not a free form field but > must be specified in a US middle-endian format (mm/dd/yyyy), so make sure > we populate it accordingly by converting gcc's __DATE__ string. This is > required for platforms like Windows, that fail to parse the date otherwise. > > Also, the system manufacturer should not be set to the same value as the > board manufacturer for the Type 1 strings, as, on the Raspberry Pi, this is > not representative of the actual manufacturer of the system, which is the > Raspberry Pi Foundation always. > > It should be noted that we do not expect other compilers than ones using > a __DATE__ format similar to gcc's to be used for the foreseeable future. > > Signed-off-by: Pete Batard > --- > Platform/RaspberryPi/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c | 31 ++++++++++++++++++-- > 1 file changed, 29 insertions(+), 2 deletions(-) > > diff --git a/Platform/RaspberryPi/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c b/Platform/RaspberryPi/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c > index d5fb843d43ce..fb775d00feba 100644 > --- a/Platform/RaspberryPi/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c > +++ b/Platform/RaspberryPi/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c > @@ -119,11 +119,12 @@ SMBIOS_TABLE_TYPE0 mBIOSInfoType0 = { > > CHAR8 mBiosVendor[128] = "EDK2"; > CHAR8 mBiosVersion[128] = "EDK2-DEV"; > +CHAR8 mBiosDate[12] = "00/00/0000"; > > CHAR8 *mBIOSInfoType0Strings[] = { > mBiosVendor, // Vendor > mBiosVersion, // Version > - __DATE__ " " __TIME__, // Release Date > + mBiosDate, // Release Date > NULL > }; > > @@ -149,7 +150,7 @@ CHAR8 mSysInfoSerial[sizeof (UINT64) * 2 + 1]; > CHAR8 mSysInfoSKU[sizeof (UINT64) * 2 + 1]; > > CHAR8 *mSysInfoType1Strings[] = { > - mSysInfoManufName, > + "Raspberry Pi Foundation", > mSysInfoProductName, > mSysInfoVersionName, > mSysInfoSerial, > @@ -626,6 +627,28 @@ BIOSInfoUpdateSmbiosType0 ( > INTN i; > INTN State = 0; > INTN Value[2]; > + INTN Year = (__DATE__[7] == '?' ? 1900 \ > + : (((__DATE__[7] - '0') * 1000 ) \ > + + (__DATE__[8] - '0') * 100 \ > + + (__DATE__[9] - '0') * 10 \ > + + __DATE__[10] - '0')); > + INTN Month = ( __DATE__ [2] == '?' ? 1 \ > + : __DATE__ [2] == 'n' ? ( \ > + __DATE__ [1] == 'a' ? 1 : 6) \ > + : __DATE__ [2] == 'b' ? 2 \ > + : __DATE__ [2] == 'r' ? ( \ > + __DATE__ [0] == 'M' ? 3 : 4) \ > + : __DATE__ [2] == 'y' ? 5 \ > + : __DATE__ [2] == 'l' ? 7 \ > + : __DATE__ [2] == 'g' ? 8 \ > + : __DATE__ [2] == 'p' ? 9 \ > + : __DATE__ [2] == 't' ? 10 \ > + : __DATE__ [2] == 'v' ? 11 \ > + : 12); > + INTN Day = ( __DATE__[4] == '?' ? 1 \ > + : ((__DATE__[4] == ' ' ? 0 : \ > + ((__DATE__[4] - '0') * 10)) \ > + + __DATE__[5] - '0')); So, this hunk is very neat, but nigh-on unreviewable. I.e. we should defintely have it - but only once. Could you break this up into some macros to go into some generic helper lib? (I don't have a better idea than EmbeddedPkg TimeBaseLib, but then that is already included in this module.) Would you be OK to break that snippet out separate? / Leif > // Populate the Firmware major and minor. > Status = mFwProtocol->GetFirmwareRevision (&EpochSeconds); > @@ -648,6 +671,10 @@ BIOSInfoUpdateSmbiosType0 ( > mBiosVendor, sizeof (mBiosVendor)); > UnicodeStrToAsciiStrS ((CHAR16*)PcdGetPtr (PcdFirmwareVersionString), > mBiosVersion, sizeof (mBiosVersion)); > + ASSERT (Year >= 0 && Year <= 9999); > + ASSERT (Month >= 1 && Month <= 12); > + ASSERT (Day >= 1 && Day <= 31); > + AsciiSPrint (mBiosDate, sizeof (mBiosDate), "%02d/%02d/%04d", Month, Day, Year); > > // Look for a "x.y" numeric string anywhere in mBiosVersion and > // try to parse it to populate the BIOS major and minor. > -- > 2.21.0.windows.1 >