From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by mx.groups.io with SMTP id smtpd.web09.10760.1578502819133740801 for ; Wed, 08 Jan 2020 09:00:19 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@akeo-ie.20150623.gappssmtp.com header.s=20150623 header.b=D8s+BpMg; spf=none, err=permanent DNS error (domain: akeo.ie, ip: 209.85.221.68, mailfrom: pete@akeo.ie) Received: by mail-wr1-f68.google.com with SMTP id q6so4139580wro.9 for ; Wed, 08 Jan 2020 09:00:18 -0800 (PST) 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=D5hxjbw32YtFh/hISDI1xdp5HMkqKSM7Ds5oGEj2iUA=; b=D8s+BpMge6lChWxJaRifkEjtBS9UrwGBswYpQ7p+ZJlzIKW3aklNgPmqcjePvclm1z eKOpNXFAqb1hMXXOhDTE9i7MSB2o4PhDc8te1Ofiz9GDt/BXSECjXIPpYzP7IAn78YkL noEf7Wkb9BF+Pwd+Lj/y+sabh0NDrCHXbDl2oU3aqtrBoKHpq7fJ4kWhFTlwdi+kLoEN qby5g4zGLrOdJKYxOCZLbnXYh9PTQrIkzmPaZ7U4VrsYXPg/FTlRnzM7A2QiJ+3JJRu/ TQlrjLMSHP5W2D2di0EHCiVla/yM7LGppO9MLyyR03E/rm+8oO9xP8LXX4NXuXI8Awv5 jiag== 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=D5hxjbw32YtFh/hISDI1xdp5HMkqKSM7Ds5oGEj2iUA=; b=AgR3rD0OpGKbIh4pmGcmIvVuCFcv0BiLYBSxi3gt1SH0cTAToHy+eo6MWfBvak1hR5 DGTYTgDdO7PnoXaDtnlSbDq5SZP6KW/WjSvUlg+R9t17W2RyB5EENiA/xjQhU9/APpoo 0b5pFMT7SQ+7OLJ8QHoX+nMrb9xyWUeaRoq+v059wMdZackYsrfWUv6NBvSbU66yUBZb 08W20HfWP9SJ84g0HQiKK5HGyDeXw7urmen2X/9USy6CEX5D483chb1cfuuhQos/YgIr Q5AOnxJFPZLUKOAxw4O1pNKWrV9G+UrHvIGghkfTOucY5mK5l41RXvsgPvSzr4ctVy0V mMow== X-Gm-Message-State: APjAAAUjuZrR6QiUrR5xs7UyYuYvJ7V0M8/w6o0SBh+5MW9CL/qNrCkp dZny26Pu7TN2+3hx6QtSuQ1C8AyQa74= X-Google-Smtp-Source: APXvYqx1oNwbvIsdj4S+5TtjHKLBh4SxH4FOC8FRIG1YUGoHUoAA1W5BcS37jIE049dlQTP5bbqtbQ== X-Received: by 2002:a5d:53c1:: with SMTP id a1mr5417182wrw.373.1578502817279; Wed, 08 Jan 2020 09:00:17 -0800 (PST) Return-Path: Received: from localhost.localdomain ([84.203.81.176]) by smtp.gmail.com with ESMTPSA id i16sm4786496wmb.36.2020.01.08.09.00.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Jan 2020 09:00:16 -0800 (PST) From: "Pete Batard" To: devel@edk2.groups.io Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org, philmd@redhat.com Subject: [edk2-platforms][PATCH 1/2] Platform/RPi/SmbiosDxe: Report a more human readable firmware revision Date: Wed, 8 Jan 2020 17:00:03 +0000 Message-Id: <20200108170004.6680-2-pete@akeo.ie> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20200108170004.6680-1-pete@akeo.ie> References: <20200108170004.6680-1-pete@akeo.ie> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The firmware revision that is queried through the VideoCore mailbox is really the 32-bit timestamp of when the VideoCore firmware was generated. To make this more palatable for human reporting, convert it to a YY.MM firmware revision, so that end-users can get an approximative idea of how old their VideoCore firmware is. Signed-off-by: Pete Batard --- Platform/RaspberryPi/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c | 20 ++++++++++++-------- Platform/RaspberryPi/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.inf | 2 ++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Platform/RaspberryPi/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c b/Platform/RaspberryPi/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c index 6aa68a0925ba..06c73d691f9d 100644 --- a/Platform/RaspberryPi/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c +++ b/Platform/RaspberryPi/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -597,23 +598,26 @@ BIOSInfoUpdateSmbiosType0 ( VOID ) { - UINT32 FirmwareRevision = 0; + UINT32 EpochSeconds = 0; EFI_STATUS Status = EFI_SUCCESS; + EFI_TIME Time; INTN i; INTN State = 0; INTN Value[2]; // Populate the Firmware major and minor. - Status = mFwProtocol->GetFirmwareRevision (&FirmwareRevision); + Status = mFwProtocol->GetFirmwareRevision (&EpochSeconds); 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); + // The firmware revision is really an epoch time which we convert to a + // YY.MM major.minor. This is good enough for our purpose, where this + // revision is merely provided as a loose indicator of when the + // VideoCore firmware was generated. + EpochToEfiTime (EpochSeconds, &Time); + ASSERT (Time.Year >= 2000 && Time.Year <= 2255); + mBIOSInfoType0.EmbeddedControllerFirmwareMajorRelease = (UINT8)(Time.Year - 2000); + mBIOSInfoType0.EmbeddedControllerFirmwareMinorRelease = Time.Month; } // mBiosVendor and mBiosVersion, which are referenced in mBIOSInfoType0Strings, diff --git a/Platform/RaspberryPi/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.inf b/Platform/RaspberryPi/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.inf index 0bd72c3ba6a1..9554c2e998f1 100644 --- a/Platform/RaspberryPi/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.inf +++ b/Platform/RaspberryPi/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.inf @@ -27,6 +27,7 @@ [Packages] ArmPlatformPkg/ArmPlatformPkg.dec ArmPkg/ArmPkg.dec Platform/RaspberryPi/RaspberryPi.dec + EmbeddedPkg/EmbeddedPkg.dec [LibraryClasses] UefiBootServicesTableLib @@ -37,6 +38,7 @@ [LibraryClasses] UefiDriverEntryPoint DebugLib PrintLib + TimeBaseLib [Protocols] gEfiSmbiosProtocolGuid # PROTOCOL SOMETIMES_CONSUMED -- 2.21.0.windows.1