public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Samer El-Haj-Mahmoud" <samer.el-haj-mahmoud@arm.com>
To: Pete Batard <pete@akeo.ie>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: Ard Biesheuvel <Ard.Biesheuvel@arm.com>,
	"leif@nuviainc.com" <leif@nuviainc.com>,
	"Andrei Warkentin (awarkentin@vmware.com)"
	<awarkentin@vmware.com>,
	Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
Subject: Re: [edk2-platforms][PATCH 1/1] Platforms/RaspberryPi: Fix BIOS Release Date and System Manufacturer
Date: Mon, 20 Jul 2020 16:51:20 +0000	[thread overview]
Message-ID: <DB7PR08MB32601A175572322A9A367AAA907B0@DB7PR08MB3260.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <20200720161507.14352-1-pete@akeo.ie>

Reviewed-by: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>

> -----Original Message-----
> From: Pete Batard <pete@akeo.ie>
> Sent: Monday, July 20, 2020 12:15 PM
> To: devel@edk2.groups.io
> Cc: Ard Biesheuvel <Ard.Biesheuvel@arm.com>; leif@nuviainc.com; Andrei
> Warkentin (awarkentin@vmware.com) <awarkentin@vmware.com>; Samer
> El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
> Subject: [edk2-platforms][PATCH 1/1] Platforms/RaspberryPi: Fix BIOS
> Release Date and System Manufacturer
>
> 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 <pete@akeo.ie>
> ---
>  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'));
>
>    // 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

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

  parent reply	other threads:[~2020-07-20 16:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-20 16:15 [edk2-platforms][PATCH 1/1] Platforms/RaspberryPi: Fix BIOS Release Date and System Manufacturer Pete Batard
2020-07-20 16:47 ` Andrei Warkentin
2020-07-20 16:51 ` Samer El-Haj-Mahmoud [this message]
2020-07-23 11:08 ` Leif Lindholm
2020-07-23 14:38   ` Pete Batard
2020-07-23 15:47     ` Leif Lindholm
2020-07-23 17:15       ` [edk2-devel] " Andrew Fish
2020-07-23 17:44         ` Pete Batard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DB7PR08MB32601A175572322A9A367AAA907B0@DB7PR08MB3260.eurprd08.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox