On 1/8/20 6:00 PM, Pete Batard wrote:
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 <p...@akeo.ie>
---
  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 <Library/PcdLib.h>
  #include <Library/BaseMemoryLib.h>
  #include <Library/MemoryAllocationLib.h>
+#include <Library/TimeBaseLib.h>
  #include <Library/UefiBootServicesTableLib.h>
  #include <Library/PrintLib.h>
@@ -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


Reviewed-by: Philippe Mathieu-Daude <phi...@redhat.com>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#53417): https://edk2.groups.io/g/devel/message/53417
Mute This Topic: https://groups.io/mt/69532223/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to