[edk2-devel] [edk2-platforms][PATCH 2/4] JadePkg: Leverage ArmPkg/Smbios (Type 0, 1, 2, 3, 13, 32)

Minh Nguyen via groups.io posted 4 patches 1 year, 1 month ago
[edk2-devel] [edk2-platforms][PATCH 2/4] JadePkg: Leverage ArmPkg/Smbios (Type 0, 1, 2, 3, 13, 32)
Posted by Minh Nguyen via groups.io 1 year, 1 month ago
This implementation helps SMBIOS Table (Type 0, 1, 2, 3, 13, 32)
of Altra and AltraMax platform to utilize framework from ArmPkg.

Signed-off-by: Minh Nguyen <minhnguyen1@os.amperecomputing.com>
---
 Platform/Ampere/JadePkg/Jade.dsc                                        |   7 +-
 Platform/Ampere/JadePkg/Jade.fdf                                        |   1 +
 Platform/Ampere/JadePkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf |  10 -
 Platform/Ampere/JadePkg/Library/OemMiscLib/OemMiscLib.inf               |  15 +-
 Silicon/Ampere/AmpereAltraPkg/Include/Library/AmpereCpuLib.h            |  22 +
 Platform/Ampere/JadePkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c   | 470 --------------------
 Platform/Ampere/JadePkg/Library/OemMiscLib/OemMiscLib.c                 | 246 +++++++++-
 Silicon/Ampere/AmpereAltraPkg/Library/AmpereCpuLib/AmpereCpuLibCommon.c |  42 ++
 8 files changed, 326 insertions(+), 487 deletions(-)

diff --git a/Platform/Ampere/JadePkg/Jade.dsc b/Platform/Ampere/JadePkg/Jade.dsc
index f14d286cdfb8..2f530740140d 100644
--- a/Platform/Ampere/JadePkg/Jade.dsc
+++ b/Platform/Ampere/JadePkg/Jade.dsc
@@ -117,8 +117,8 @@ [PcdsFixedAtBuild.common]
   gArmTokenSpaceGuid.PcdProcessorManufacturer|L"Ampere(R)"
   gArmTokenSpaceGuid.PcdProcessorVersion|L"Ampere(R) Altra(R) Processor"
 
-  gAmpereTokenSpaceGuid.PcdSmbiosTables1MajorVersion|$(MAJOR_VER)
-  gAmpereTokenSpaceGuid.PcdSmbiosTables1MinorVersion|$(MINOR_VER)
+  gAmpereTokenSpaceGuid.PcdSmbiosTables0MajorVersion|$(MAJOR_VER)
+  gAmpereTokenSpaceGuid.PcdSmbiosTables0MinorVersion|$(MINOR_VER)
 
   # Clearing BIT0 in this PCD prevents installing a 32-bit SMBIOS entry point,
   # if the entry point version is >= 3.0. AARCH64 OSes cannot assume the
@@ -137,8 +137,6 @@ [PcdsFixedAtBuild.common]
 !endif
 
 [PcdsDynamicDefault.common.DEFAULT]
-  # SMBIOS Type 0 - BIOS Information
-  gAmpereTokenSpaceGuid.PcdSmbiosTables0BiosReleaseDate|"MM/DD/YYYY"
 
 [PcdsPatchableInModule]
   #
@@ -181,6 +179,7 @@ [Components.common]
   MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
   Platform/Ampere/JadePkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
   ArmPkg/Universal/Smbios/ProcessorSubClassDxe/ProcessorSubClassDxe.inf
+  ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDxe.inf
   Platform/Ampere/JadePkg/Drivers/SmbiosMemInfoDxe/SmbiosMemInfoDxe.inf
 
   #
diff --git a/Platform/Ampere/JadePkg/Jade.fdf b/Platform/Ampere/JadePkg/Jade.fdf
index a578d05330ec..7795f0e11115 100644
--- a/Platform/Ampere/JadePkg/Jade.fdf
+++ b/Platform/Ampere/JadePkg/Jade.fdf
@@ -347,6 +347,7 @@ [FV.FvMain]
   INF MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
   INF Platform/Ampere/JadePkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
   INF ArmPkg/Universal/Smbios/ProcessorSubClassDxe/ProcessorSubClassDxe.inf
+  INF ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDxe.inf
   INF Platform/Ampere/JadePkg/Drivers/SmbiosMemInfoDxe/SmbiosMemInfoDxe.inf
 
   #
diff --git a/Platform/Ampere/JadePkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf b/Platform/Ampere/JadePkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
index 77148b417b0f..549aa38b1774 100644
--- a/Platform/Ampere/JadePkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
+++ b/Platform/Ampere/JadePkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
@@ -28,7 +28,6 @@ [LibraryClasses]
   BaseLib
   BaseMemoryLib
   DebugLib
-  HobLib
   MemoryAllocationLib
   UefiBootServicesTableLib
   UefiDriverEntryPoint
@@ -38,16 +37,7 @@ [Protocols]
   gEfiSmbiosProtocolGuid                     ## CONSUMED
 
 [Pcd]
-  # Type 0
-  gAmpereTokenSpaceGuid.PcdSmbiosTables0BiosReleaseDate
-  gAmpereTokenSpaceGuid.PcdSmbiosTables0MajorVersion
-  gAmpereTokenSpaceGuid.PcdSmbiosTables0MinorVersion
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString
-
   gArmTokenSpaceGuid.PcdFdSize
 
-[Guids]
-  gPlatformInfoHobGuid
-
 [Depex]
   gEfiSmbiosProtocolGuid
diff --git a/Platform/Ampere/JadePkg/Library/OemMiscLib/OemMiscLib.inf b/Platform/Ampere/JadePkg/Library/OemMiscLib/OemMiscLib.inf
index b67ce01fb27f..9d1a0b7e9e06 100644
--- a/Platform/Ampere/JadePkg/Library/OemMiscLib/OemMiscLib.inf
+++ b/Platform/Ampere/JadePkg/Library/OemMiscLib/OemMiscLib.inf
@@ -1,7 +1,7 @@
 #/** @file
 #    OemMiscLib.inf
 #
-#    Copyright (c) 2021, Ampere Computing LLC. All rights reserved.
+#    Copyright (c) 2021 - 2023, Ampere Computing LLC. All rights reserved.
 #    Copyright (c) 2021, NUVIA Inc. All rights reserved.
 #    Copyright (c) 2018, Hisilicon Limited. All rights reserved.
 #    Copyright (c) 2018, Linaro Limited. All rights reserved.
@@ -27,6 +27,7 @@ [Packages]
   MdeModulePkg/MdeModulePkg.dec
   MdePkg/MdePkg.dec
   Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec
+  Silicon/Ampere/AmpereSiliconPkg/AmpereSiliconPkg.dec
 
 [LibraryClasses]
   AmpereCpuLib
@@ -34,3 +35,15 @@ [LibraryClasses]
   BaseLib
   BaseMemoryLib
   DebugLib
+
+[FixedPcd]
+  gArmTokenSpaceGuid.PcdSystemMemoryBase
+  gAmpereTokenSpaceGuid.PcdSmbiosTables0MajorVersion
+  gAmpereTokenSpaceGuid.PcdSmbiosTables0MinorVersion
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString
+
+[Guids]
+  gZeroGuid
+
+[Depex]
+  TRUE
diff --git a/Silicon/Ampere/AmpereAltraPkg/Include/Library/AmpereCpuLib.h b/Silicon/Ampere/AmpereAltraPkg/Include/Library/AmpereCpuLib.h
index 94944cbe3abe..c425ed4431da 100644
--- a/Silicon/Ampere/AmpereAltraPkg/Include/Library/AmpereCpuLib.h
+++ b/Silicon/Ampere/AmpereAltraPkg/Include/Library/AmpereCpuLib.h
@@ -160,6 +160,28 @@ GetNumberOfConfiguredCPMs (
   UINT8 SocketId
   );
 
+/**
+  Get version of SCP.
+
+  @param[out]   ScpVer   Pointer to contain version of SCP value.
+**/
+VOID
+EFIAPI
+GetScpVersion (
+  UINT8 **ScpVer
+  );
+
+/**
+  Get date of build release for SCP.
+
+  @param[out]   ScpBuild   Pointer to contain date of build release for SCP.
+**/
+VOID
+EFIAPI
+GetScpBuild (
+  UINT8 **ScpBuild
+  );
+
 /**
   Set the number of configured CPM per socket.
 
diff --git a/Platform/Ampere/JadePkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c b/Platform/Ampere/JadePkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c
index 32735496ecdc..448912f146ec 100644
--- a/Platform/Ampere/JadePkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c
+++ b/Platform/Ampere/JadePkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c
@@ -8,63 +8,19 @@
 
 #include <Uefi.h>
 
-#include <Guid/PlatformInfoHob.h>
 #include <Guid/SmBios.h>
 #include <Library/BaseLib.h>
 #include <Library/BaseMemoryLib.h>
 #include <Library/DebugLib.h>
-#include <Library/HobLib.h>
 #include <Library/MemoryAllocationLib.h>
 #include <Library/PrintLib.h>
 #include <Library/UefiBootServicesTableLib.h>
 #include <Protocol/Smbios.h>
 
-// Type0 Data
-#define VENDOR_TEMPLATE       "Ampere(R)\0"
-#define BIOS_VERSION_TEMPLATE "TianoCore 0.00.00000000 (SYS: 0.00.00000000)\0"
-#define RELEASE_DATE_TEMPLATE "MM/DD/YYYY\0"
-
-#define TYPE0_ADDITIONAL_STRINGS                    \
-  VENDOR_TEMPLATE       /* Vendor */         \
-  BIOS_VERSION_TEMPLATE /* BiosVersion */    \
-  RELEASE_DATE_TEMPLATE /* BiosReleaseDate */
-
-// Type1 Data
-#define MANUFACTURER_TEMPLATE "Ampere(R)\0"
-#define PRODUCT_NAME_TEMPLATE "Mt. Jade\0"
-#define SYS_VERSION_TEMPLATE  "PR010\0"
-#define SERIAL_TEMPLATE       "123456789ABCDEFF123456789ABCDEFF\0"
-#define SKU_TEMPLATE          "FEDCBA9876543211FEDCBA9876543211\0"
-#define FAMILY_TEMPLATE       "Altra\0"
-
-#define TYPE1_ADDITIONAL_STRINGS                  \
-  MANUFACTURER_TEMPLATE /* Manufacturer */  \
-  PRODUCT_NAME_TEMPLATE /* Product Name */  \
-  SYS_VERSION_TEMPLATE  /* Version */       \
-  SERIAL_TEMPLATE       /* Serial Number */ \
-  SKU_TEMPLATE          /* SKU Number */    \
-  FAMILY_TEMPLATE       /* Family */
-
-#define TYPE2_ADDITIONAL_STRINGS                   \
-  MANUFACTURER_TEMPLATE /* Manufacturer */   \
-  PRODUCT_NAME_TEMPLATE /* Product Name */   \
-  "EVT2\0"              /* Version */        \
-  "Serial Not Set\0"    /* Serial */         \
-  "Base of Chassis\0"   /* board location */ \
-  "FF\0"                /* Version */        \
-  "FF\0"                /* Version */
-
 #define CHASSIS_VERSION_TEMPLATE    "None               \0"
 #define CHASSIS_SERIAL_TEMPLATE     "Serial Not Set     \0"
 #define CHASSIS_ASSET_TAG_TEMPLATE  "Asset Tag Not Set  \0"
 
-#define TYPE3_ADDITIONAL_STRINGS                 \
-  MANUFACTURER_TEMPLATE      /* Manufacturer */ \
-  CHASSIS_VERSION_TEMPLATE   /* Version */      \
-  CHASSIS_SERIAL_TEMPLATE    /* Serial  */      \
-  CHASSIS_ASSET_TAG_TEMPLATE /* Asset Tag */    \
-  SKU_TEMPLATE               /* SKU Number */
-
 #define TYPE8_ADDITIONAL_STRINGS      \
   "VGA1 - Rear VGA Connector\0"       \
   "DB-15 Male (VGA)         \0"
@@ -75,9 +31,6 @@
 #define TYPE11_ADDITIONAL_STRINGS       \
   "www.amperecomputing.com\0"
 
-#define TYPE13_ADDITIONAL_STRINGS       \
-  "en|US|iso8859-1\0"
-
 #define TYPE41_ADDITIONAL_STRINGS       \
   "Onboard VGA\0"
 
@@ -94,26 +47,6 @@
 // the SMBIOS specification (section 6.2, version 3.0)
 //
 #pragma pack(1)
-typedef struct {
-  SMBIOS_TABLE_TYPE0 Base;
-  CHAR8              Strings[sizeof (TYPE0_ADDITIONAL_STRINGS)];
-} ARM_TYPE0;
-
-typedef struct {
-  SMBIOS_TABLE_TYPE1 Base;
-  CHAR8              Strings[sizeof (TYPE1_ADDITIONAL_STRINGS)];
-} ARM_TYPE1;
-
-typedef struct {
-  SMBIOS_TABLE_TYPE2 Base;
-  CHAR8              Strings[sizeof (TYPE2_ADDITIONAL_STRINGS)];
-} ARM_TYPE2;
-
-typedef struct {
-  SMBIOS_TABLE_TYPE3 Base;
-  CHAR8              Strings[sizeof (TYPE3_ADDITIONAL_STRINGS)];
-} ARM_TYPE3;
-
 typedef struct {
   SMBIOS_TABLE_TYPE8 Base;
   CHAR8              Strings[sizeof (TYPE8_ADDITIONAL_STRINGS)];
@@ -129,11 +62,6 @@ typedef struct {
   CHAR8               Strings[sizeof (TYPE11_ADDITIONAL_STRINGS)];
 } ARM_TYPE11;
 
-typedef struct {
-  SMBIOS_TABLE_TYPE13 Base;
-  CHAR8               Strings[sizeof (TYPE13_ADDITIONAL_STRINGS)];
-} ARM_TYPE13;
-
 typedef struct {
   SMBIOS_TABLE_TYPE41 Base;
   CHAR8               Strings[sizeof (TYPE41_ADDITIONAL_STRINGS)];
@@ -141,125 +69,6 @@ typedef struct {
 
 #pragma pack()
 
-// Type 0 BIOS information
-STATIC ARM_TYPE0 mArmDefaultType0 = {
-  {
-    {                                   // Header
-      EFI_SMBIOS_TYPE_BIOS_INFORMATION, // UINT8 Type
-      sizeof (SMBIOS_TABLE_TYPE0),      // UINT8 Length, The length of the structure's string-set is not included.
-      SMBIOS_HANDLE_PI_RESERVED,
-    },
-
-    ADDITIONAL_STR_INDEX_1,     // SMBIOS_TABLE_STRING       Vendor
-    ADDITIONAL_STR_INDEX_2,     // SMBIOS_TABLE_STRING       BiosVersion
-    0,                          // UINT16                    BiosSegment
-    ADDITIONAL_STR_INDEX_3,     // SMBIOS_TABLE_STRING       BiosReleaseDate
-    0,                          // UINT8                     BiosSize
-
-    // MISC_BIOS_CHARACTERISTICS BiosCharacteristics
-    {
-      0,0,0,0,0,0,
-      1, // PCI supported
-      0,
-      1, // PNP supported
-      0,
-      1, // BIOS upgradable
-      0, 0, 0,
-      0, // Boot from CD
-      1, // selectable boot
-    },
-
-    // BIOSCharacteristicsExtensionBytes[2]
-    {
-      0,
-      0,
-    },
-
-    0,     // UINT8                     SystemBiosMajorRelease
-    0,     // UINT8                     SystemBiosMinorRelease
-
-    // If the system does not have field upgradeable embedded controller
-    // firmware, the value is 0FFh
-    0xFF,  // UINT8                     EmbeddedControllerFirmwareMajorRelease
-    0xFF   // UINT8                     EmbeddedControllerFirmwareMinorRelease
-  },
-
-  // Text strings (unformatted area)
-  TYPE0_ADDITIONAL_STRINGS
-};
-
-// Type 1 System information
-STATIC ARM_TYPE1 mArmDefaultType1 = {
-  {
-    { // Header
-      EFI_SMBIOS_TYPE_SYSTEM_INFORMATION,
-      sizeof (SMBIOS_TABLE_TYPE1),
-      SMBIOS_HANDLE_PI_RESERVED,
-    },
-
-    ADDITIONAL_STR_INDEX_1,                                                     // Manufacturer
-    ADDITIONAL_STR_INDEX_2,                                                     // Product Name
-    ADDITIONAL_STR_INDEX_3,                                                     // Version
-    ADDITIONAL_STR_INDEX_4,                                                     // Serial Number
-    { 0x12345678, 0x9ABC, 0xDEFF, { 0x12,0x34,0x56,0x78,0x9A,0xBC,0xDE,0xFF }}, // UUID
-    SystemWakeupTypePowerSwitch,                                                // Wakeup type
-    ADDITIONAL_STR_INDEX_5,                                                     // SKU Number
-    ADDITIONAL_STR_INDEX_6,                                                     // Family
-  },
-
-  // Text strings (unformatted)
-  TYPE1_ADDITIONAL_STRINGS
-};
-
-// Type 2 Baseboard
-STATIC ARM_TYPE2 mArmDefaultType2 = {
-  {
-    {                                        // SMBIOS_STRUCTURE Hdr
-      EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION, // UINT8 Type
-      sizeof (SMBIOS_TABLE_TYPE2),           // UINT8 Length
-      SMBIOS_HANDLE_PI_RESERVED,
-    },
-    ADDITIONAL_STR_INDEX_1, // Manufacturer
-    ADDITIONAL_STR_INDEX_2, // Product Name
-    ADDITIONAL_STR_INDEX_3, // Version
-    ADDITIONAL_STR_INDEX_4, // Serial
-    0,                      // Asset tag
-    {1},                    // motherboard, not replaceable
-    ADDITIONAL_STR_INDEX_5, // location of board
-    0xFFFF,                 // chassis handle
-    BaseBoardTypeMotherBoard,
-    0,
-    {0},
-  },
-  TYPE2_ADDITIONAL_STRINGS
-};
-
-// Type 3 Enclosure
-STATIC CONST ARM_TYPE3 mArmDefaultType3 = {
-  {
-    {                                   // SMBIOS_STRUCTURE Hdr
-      EFI_SMBIOS_TYPE_SYSTEM_ENCLOSURE, // UINT8 Type
-      sizeof (SMBIOS_TABLE_TYPE3),      // UINT8 Length
-      SMBIOS_HANDLE_PI_RESERVED,
-    },
-    ADDITIONAL_STR_INDEX_1,          // Manufacturer
-    MiscChassisTypeRackMountChassis, // Rack-mounted chassis
-    ADDITIONAL_STR_INDEX_2,          // version
-    ADDITIONAL_STR_INDEX_3,          // serial
-    ADDITIONAL_STR_INDEX_4,          // asset tag
-    ChassisStateUnknown,             // boot chassis state
-    ChassisStateSafe,                // power supply state
-    ChassisStateSafe,                // thermal state
-    ChassisSecurityStatusNone,       // security state
-    {0,0,0,0},                       // OEM defined
-    2,                               // 2U height
-    2,                               // number of power cords
-    0,                               // no contained elements
-    3,                               // ContainedElementRecordLength;
-  },
-  TYPE3_ADDITIONAL_STRINGS
-};
-
 // Type 8 Port Connector Information
 STATIC CONST ARM_TYPE8 mArmDefaultType8Vga = {
   {
@@ -611,22 +420,6 @@ STATIC ARM_TYPE11 mArmDefaultType11 = {
   TYPE11_ADDITIONAL_STRINGS
 };
 
-// Type 13 BIOS Language Information
-STATIC ARM_TYPE13 mArmDefaultType13 = {
-  {
-    {                                            // SMBIOS_STRUCTURE Hdr
-      EFI_SMBIOS_TYPE_BIOS_LANGUAGE_INFORMATION, // UINT8 Type
-      sizeof (SMBIOS_TABLE_TYPE13),              // UINT8 Length
-      SMBIOS_HANDLE_PI_RESERVED,
-    },
-    1,
-    0,
-    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-    1,
-  },
-  TYPE13_ADDITIONAL_STRINGS
-};
-
 // Type 24 Hardware Security
 STATIC SMBIOS_TABLE_TYPE24 mArmDefaultType24 = {
   {                                    // SMBIOS_STRUCTURE Hdr
@@ -637,17 +430,6 @@ STATIC SMBIOS_TABLE_TYPE24 mArmDefaultType24 = {
   0
 };
 
-// Type 32 System Boot Information
-STATIC SMBIOS_TABLE_TYPE32 mArmDefaultType32 = {
-  {                                          // SMBIOS_STRUCTURE Hdr
-    EFI_SMBIOS_TYPE_SYSTEM_BOOT_INFORMATION, // UINT8 Type
-    sizeof (SMBIOS_TABLE_TYPE32),            // UINT8 Length
-    SMBIOS_HANDLE_PI_RESERVED,
-  },
-  {0, 0, 0, 0, 0, 0},
-  0
-};
-
 // Type 38 IPMI Device Information
 STATIC SMBIOS_TABLE_TYPE38 mArmDefaultType38 = {
   {                                          // SMBIOS_STRUCTURE Hdr
@@ -694,9 +476,6 @@ STATIC SMBIOS_TABLE_TYPE42 mArmDefaultType42 = {
 
 STATIC CONST VOID *DefaultCommonTables[] =
 {
-  &mArmDefaultType0,
-  &mArmDefaultType1,
-  &mArmDefaultType2,
   &mArmDefaultType8Vga,
   &mArmDefaultType8USBFront,
   &mArmDefaultType8USBRear,
@@ -714,9 +493,7 @@ STATIC CONST VOID *DefaultCommonTables[] =
   &mArmDefaultType9Sk1NvmeM2Slot1,
   &mArmDefaultType9Sk1NvmeM2Slot2,
   &mArmDefaultType11,
-  &mArmDefaultType13,
   &mArmDefaultType24,
-  &mArmDefaultType32,
   &mArmDefaultType38,
   &mArmDefaultType41,
   &mArmDefaultType42,
@@ -728,80 +505,6 @@ typedef struct {
   CHAR8 DigitStr[3];     // example "01", Smbios date format, month
 } MonthStringDig;
 
-STATIC MonthStringDig MonthMatch[12] = {
-  { "Jan", "01" },
-  { "Feb", "02" },
-  { "Mar", "03" },
-  { "Apr", "04" },
-  { "May", "05" },
-  { "Jun", "06" },
-  { "Jul", "07" },
-  { "Aug", "08" },
-  { "Sep", "09" },
-  { "Oct", "10" },
-  { "Nov", "11" },
-  { "Dec", "12" }
-};
-
-STATIC
-VOID
-ConstructBuildDate (
-  OUT CHAR8 *DateBuf
-  )
-{
-  UINTN i;
-
-  // GCC __DATE__ format is "Feb  2 1996"
-  // If the day of the month is less than 10, it is padded with a space on the left
-  CHAR8 *BuildDate = __DATE__;
-
-  // SMBIOS spec date string: MM/DD/YYYY
-  CHAR8 SmbiosDateStr[sizeof (RELEASE_DATE_TEMPLATE)] = { 0 };
-
-  SmbiosDateStr[sizeof (RELEASE_DATE_TEMPLATE) - 1] = '\0';
-
-  SmbiosDateStr[2] = '/';
-  SmbiosDateStr[5] = '/';
-
-  // Month
-  for (i = 0; i < sizeof (MonthMatch) / sizeof (MonthMatch[0]); i++) {
-    if (AsciiStrnCmp (&BuildDate[0], MonthMatch[i].MonthNameStr, AsciiStrLen (MonthMatch[i].MonthNameStr)) == 0) {
-      CopyMem (&SmbiosDateStr[0], MonthMatch[i].DigitStr, AsciiStrLen (MonthMatch[i].DigitStr));
-      break;
-    }
-  }
-
-  // Day
-  CopyMem (&SmbiosDateStr[3], &BuildDate[4], 2);
-  if (BuildDate[4] == ' ') {
-    // day is less then 10, SAPCE filed by compiler, SMBIOS requires 0
-    SmbiosDateStr[3] = '0';
-  }
-
-  // Year
-  CopyMem (&SmbiosDateStr[6], &BuildDate[7], 4);
-
-  CopyMem (DateBuf, SmbiosDateStr, AsciiStrLen (RELEASE_DATE_TEMPLATE));
-}
-
-STATIC
-UINT8
-GetBiosVerMajor (
-  VOID
-  )
-{
-  return (PcdGet8 (PcdSmbiosTables0MajorVersion));
-}
-
-STATIC
-UINT8
-GetBiosVerMinor (
-  VOID
-  )
-{
-  return (PcdGet8 (PcdSmbiosTables0MinorVersion));
-}
-
 STATIC
 UINTN
 GetStringPackSize (
@@ -881,148 +584,6 @@ UpdateStringPack (
   return EFI_SUCCESS;
 }
 
-STATIC
-EFI_STATUS
-UpdateSmbiosType0 (
-  PLATFORM_INFO_HOB  *PlatformHob
-  )
-{
-  EFI_STATUS                          Status        = EFI_SUCCESS;
-  MISC_BIOS_CHARACTERISTICS_EXTENSION *MiscExt      = NULL;
-  CHAR8                               *ReleaseDateBuf = NULL;
-  CHAR8                               *PcdReleaseDate = NULL;
-  CHAR8                               AsciiVersion[32];
-  UINTN                               Index;
-  CHAR8                               BiosVersionStr[128];
-  CHAR8                               *StringPack;
-  CHAR8                               SizeOfFirmwareVer;
-  UINT16                              *FirmwareVersionPcdPtr;
-
-  //
-  //  Update Type0 information
-  //
-
-  ReleaseDateBuf = &mArmDefaultType0.Strings[0]
-                   + sizeof (VENDOR_TEMPLATE) - 1
-                   + sizeof (BIOS_VERSION_TEMPLATE) - 1;
-  PcdReleaseDate = (CHAR8 *)PcdGetPtr (PcdSmbiosTables0BiosReleaseDate);
-
-  if (AsciiStrnCmp (PcdReleaseDate, RELEASE_DATE_TEMPLATE, AsciiStrLen (RELEASE_DATE_TEMPLATE)) == 0) {
-    // If PCD is still template date MM/DD/YYYY, use compiler date
-    ConstructBuildDate (ReleaseDateBuf);
-  } else {
-    // PCD is updated somehow, use PCD date
-    CopyMem (ReleaseDateBuf, PcdReleaseDate, AsciiStrLen (PcdReleaseDate));
-  }
-
-  if (PcdGet32 (PcdFdSize) < SIZE_16MB) {
-    mArmDefaultType0.Base.BiosSize = (PcdGet32 (PcdFdSize) / SIZE_64KB) - 1;
-
-    mArmDefaultType0.Base.ExtendedBiosSize.Size = 0;
-    mArmDefaultType0.Base.ExtendedBiosSize.Unit = 0;
-  } else {
-    // Need to update Extended BIOS ROM Size
-    mArmDefaultType0.Base.BiosSize = 0xFF;
-
-    // As a reminder
-    ASSERT (FALSE);
-  }
-
-  // Type0 BIOS Characteristics Extension Byte 1
-  MiscExt = (MISC_BIOS_CHARACTERISTICS_EXTENSION *)&(mArmDefaultType0.Base.BIOSCharacteristicsExtensionBytes);
-
-  MiscExt->BiosReserved.AcpiIsSupported = 1;
-
-  // Type0 BIOS Characteristics Extension Byte 2
-  MiscExt->SystemReserved.BiosBootSpecIsSupported = 1;
-  MiscExt->SystemReserved.FunctionKeyNetworkBootIsSupported = 1;
-  MiscExt->SystemReserved.UefiSpecificationSupported = 1;
-
-  // Type0 BIOS Release
-  // Decide another way: If the system does not support the use of this
-  // field, the value is 0FFh
-  mArmDefaultType0.Base.SystemBiosMajorRelease = GetBiosVerMajor ();
-  mArmDefaultType0.Base.SystemBiosMinorRelease = GetBiosVerMinor ();
-
-  //
-  // Format of PcdFirmwareVersionString is
-  // "(MAJOR_VER).(MINOR_VER).(BUILD) Build YYYY.MM.DD", we only need
-  // "(MAJOR_VER).(MINOR_VER).(BUILD)" showed in Bios version. Using
-  // space character to determine this string. Another case uses null
-  // character to end while loop.
-  //
-  SizeOfFirmwareVer = 0;
-  FirmwareVersionPcdPtr = (UINT16 *)PcdGetPtr (PcdFirmwareVersionString);
-  while (*FirmwareVersionPcdPtr != ' ' && *FirmwareVersionPcdPtr != '\0') {
-    SizeOfFirmwareVer++;
-    FirmwareVersionPcdPtr++;
-  }
-
-  AsciiSPrint (
-    BiosVersionStr,
-    sizeof (BiosVersionStr),
-    "TianoCore %.*s (SYS: %a.%a)",
-    SizeOfFirmwareVer,
-    PcdGetPtr (PcdFirmwareVersionString),
-    PlatformHob->SmPmProVer,
-    PlatformHob->SmPmProBuild
-    );
-  StringPack = mArmDefaultType0.Strings;
-
-  UpdateStringPack (StringPack, BiosVersionStr, ADDITIONAL_STR_INDEX_2);
-
-  /* Update SMBIOS Type 0 EC Info */
-  CopyMem (
-    (VOID *)&AsciiVersion,
-    (VOID *)&PlatformHob->SmPmProVer,
-    sizeof (PlatformHob->SmPmProVer)
-    );
-  /* The AsciiVersion is formated as "major.minor" */
-  for (Index = 0; Index < (UINTN)AsciiStrLen (AsciiVersion); Index++) {
-    if (AsciiVersion[Index] == '.') {
-      AsciiVersion[Index] = '\0';
-      break;
-    }
-  }
-
-  mArmDefaultType0.Base.EmbeddedControllerFirmwareMajorRelease =
-    (UINT8)AsciiStrDecimalToUintn (AsciiVersion);
-  mArmDefaultType0.Base.EmbeddedControllerFirmwareMinorRelease =
-    (UINT8)AsciiStrDecimalToUintn (AsciiVersion + Index + 1);
-
-  return Status;
-}
-
-STATIC
-EFI_STATUS
-InstallType3Structure (
-  IN EFI_SMBIOS_PROTOCOL *Smbios
-  )
-{
-  EFI_STATUS          Status = EFI_SUCCESS;
-  EFI_SMBIOS_HANDLE   SmbiosHandle;
-
-  ASSERT (Smbios != NULL);
-
-  SmbiosHandle = ((EFI_SMBIOS_TABLE_HEADER*) &mArmDefaultType3)->Handle;
-  Status = Smbios->Add (
-                     Smbios,
-                     NULL,
-                     &SmbiosHandle,
-                     (EFI_SMBIOS_TABLE_HEADER *)&mArmDefaultType3
-                     );
-  if (EFI_ERROR (Status)) {
-    DEBUG ((DEBUG_ERROR, "adding SMBIOS type 3 failed\n"));
-    // stop adding rather than continuing
-    return Status;
-  }
-
-  // Save this handle to type 2 table
-  mArmDefaultType2.Base.ChassisHandle = SmbiosHandle;
-
-  return Status;
-}
-
 /**
    Install a whole table worth of structures
 
@@ -1060,31 +621,6 @@ InstallStructures (
   return EFI_SUCCESS;
 }
 
-STATIC
-VOID
-UpdateSmbiosInfo (
-  VOID
-  )
-{
-  VOID               *Hob;
-  PLATFORM_INFO_HOB  *PlatformHob;
-
-  /* Get the Platform HOB */
-  Hob = GetFirstGuidHob (&gPlatformInfoHobGuid);
-  ASSERT (Hob != NULL);
-  if (Hob == NULL) {
-    return;
-  }
-
-  PlatformHob = (PLATFORM_INFO_HOB *)GET_GUID_HOB_DATA (Hob);
-
-  //
-  //  Update Type0 information
-  //
-  UpdateSmbiosType0 (PlatformHob);
-
-}
-
 /**
    Install all structures from the DefaultTables structure
 
@@ -1100,12 +636,6 @@ InstallAllStructures (
 
   ASSERT (Smbios != NULL);
 
-  // Update SMBIOS Tables
-  UpdateSmbiosInfo ();
-
-  // Install Type 3 table
-  InstallType3Structure (Smbios);
-
   // Install Tables
   Status = InstallStructures (Smbios, DefaultCommonTables);
   ASSERT_EFI_ERROR (Status);
diff --git a/Platform/Ampere/JadePkg/Library/OemMiscLib/OemMiscLib.c b/Platform/Ampere/JadePkg/Library/OemMiscLib/OemMiscLib.c
index 6f5869b1ef1c..0604bf351c89 100644
--- a/Platform/Ampere/JadePkg/Library/OemMiscLib/OemMiscLib.c
+++ b/Platform/Ampere/JadePkg/Library/OemMiscLib/OemMiscLib.c
@@ -1,7 +1,7 @@
 /** @file
 *  OemMiscLib.c
 *
-*  Copyright (c) 2021, Ampere Computing LLC. All rights reserved.
+*  Copyright (c) 2021 - 2023, Ampere Computing LLC. All rights reserved.
 *  Copyright (c) 2021, NUVIA Inc. All rights reserved.
 *  Copyright (c) 2018, Hisilicon Limited. All rights reserved.
 *  Copyright (c) 2018, Linaro Limited. All rights reserved.
@@ -10,6 +10,7 @@
 *
 **/
 
+#include <PiPei.h>
 #include <Uefi.h>
 #include <IndustryStandard/ArmCache.h>
 #include <Library/AmpereCpuLib.h>
@@ -17,10 +18,21 @@
 #include <Library/BaseMemoryLib.h>
 #include <Library/DebugLib.h>
 #include <Library/HiiLib.h>
+#include <Library/HobLib.h>
+#include <Library/MemoryAllocationLib.h>
 #include <Library/OemMiscLib.h>
+#include <Library/PrintLib.h>
+#include <Guid/PlatformInfoHob.h>
+
+#define PROCESSOR_VERSION_ALTRA       L"Ampere(R) Altra(R) Processor"
+#define PROCESSOR_VERSION_ALTRA_MAX   L"Ampere(R) Altra(R) Max Processor"
 
 #define MHZ_SCALE_FACTOR    1000000
 
+#define SCP_VERSION_STRING_MAX_LENGTH 32
+
+#define OEM_DEFAULT_INFORMATION L"To Be Filled By O.E.M."
+
 UINT32
 GetCacheConfig (
   IN UINT32  CacheLevel,
@@ -216,6 +228,74 @@ OemIsProcessorPresent (
   return FALSE;
 }
 
+/**
+  Update the firmware version in SMBIOS Type 0.
+  This is the combination of UEFI and Ampere system firmware version.
+
+**/
+VOID
+UpdateFirmwareVersionString (
+  OUT CHAR16  *Version
+  )
+{
+  UINT8   UnicodeStrLen;
+  UINT8   FirmwareVersionStrLen;
+  UINT8   FirmwareVersionStrSize;
+  UINT8   *ScpVersion;
+  UINT8   *ScpBuild;
+  CHAR16  UnicodeStr[SMBIOS_STRING_MAX_LENGTH * sizeof (CHAR16)];
+  CHAR16  *FirmwareVersionPcdPtr;
+
+  FirmwareVersionStrLen = 0;
+  ZeroMem (UnicodeStr, sizeof (UnicodeStr));
+  FirmwareVersionPcdPtr  = (CHAR16 *)FixedPcdGetPtr (PcdFirmwareVersionString);
+  FirmwareVersionStrSize = SMBIOS_STRING_MAX_LENGTH * sizeof (CHAR16);
+
+  //
+  // Format of PcdFirmwareVersionString is
+  // "(MAJOR_VER).(MINOR_VER).(BUILD) Build YYYY.MM.DD", we only need
+  // "(MAJOR_VER).(MINOR_VER).(BUILD)" showed in BIOS version. Using
+  // space character to determine this string. Another case uses null
+  // character to end while loop.
+  //
+  while (*FirmwareVersionPcdPtr != ' ' && *FirmwareVersionPcdPtr != '\0') {
+    FirmwareVersionStrLen++;
+    FirmwareVersionPcdPtr++;
+  }
+
+  FirmwareVersionPcdPtr = (CHAR16 *)FixedPcdGetPtr (PcdFirmwareVersionString);
+  UnicodeStrLen         = FirmwareVersionStrLen * sizeof (CHAR16);
+  CopyMem (UnicodeStr, FirmwareVersionPcdPtr, UnicodeStrLen);
+
+  GetScpVersion (&ScpVersion);
+  GetScpBuild (&ScpBuild);
+  if ((ScpVersion == NULL) || (ScpBuild == NULL)) {
+    DEBUG ((
+      DEBUG_ERROR,
+      "%a:%d: Fail to get SMpro/PMpro information\n",
+      __func__,
+      __LINE__
+      ));
+    UnicodeSPrint (
+      Version,
+      FirmwareVersionStrSize,
+      L"TianoCore %.*s (SYS: 0.00.00000000)",
+      FirmwareVersionStrLen,
+      (UINT16 *)UnicodeStr
+      );
+  } else {
+    UnicodeSPrint (
+      Version,
+      FirmwareVersionStrSize,
+      L"TianoCore %.*s (SYS: %a.%a)",
+      FirmwareVersionStrLen,
+      (UINT16 *)UnicodeStr,
+      ScpVersion,
+      ScpBuild
+      );
+  }
+}
+
 /** Updates the HII string for the specified field.
 
   @param HiiHandle     The HII handle.
@@ -230,7 +310,91 @@ OemUpdateSmbiosInfo (
   IN OEM_MISC_SMBIOS_HII_STRING_FIELD Field
   )
 {
-  return;
+  EFI_STRING UnicodeString;
+  UINT8      StringLength;
+
+  StringLength = SMBIOS_STRING_MAX_LENGTH * sizeof (CHAR16);
+  UnicodeString = AllocatePool (StringLength);
+  if (UnicodeString == NULL) {
+    DEBUG ((
+      DEBUG_ERROR,
+      "%a:%d: There is not enough memory remaining to satisfy the request\n",
+      __func__,
+      __LINE__));
+
+    goto Exit;
+  }
+
+  switch (Field) {
+    case ProductNameType01:
+    case SystemManufacturerType01:
+    case VersionType01:
+    case SerialNumType01:
+    case SkuNumberType01:
+      UnicodeSPrint (
+        UnicodeString,
+        StringLength,
+        OEM_DEFAULT_INFORMATION
+        );
+      break;
+
+    case FamilyType01:
+      UnicodeSPrint (
+        UnicodeString,
+        StringLength,
+        IsAc01Processor () ? L"Altra\0" : L"Altra Max\0"
+        );
+      break;
+
+    case ProductNameType02:
+    case AssetTagType02:
+    case VersionType02:
+    case SerialNumberType02:
+    case BoardManufacturerType02:
+      UnicodeSPrint (
+        UnicodeString,
+        StringLength,
+        OEM_DEFAULT_INFORMATION
+        );
+      break;
+
+    case ChassisLocationType02:
+      UnicodeSPrint (
+        UnicodeString,
+        StringLength,
+        L"Base of Chassis"
+        );
+      break;
+
+    case SerialNumberType03:
+    case VersionType03:
+    case ManufacturerType03:
+    case AssetTagType03:
+    case SkuNumberType03:
+      UnicodeSPrint (
+        UnicodeString,
+        StringLength,
+        OEM_DEFAULT_INFORMATION
+        );
+      break;
+
+    case BiosVersionType00:
+      UpdateFirmwareVersionString (UnicodeString);
+      break;
+
+    default:
+      UnicodeSPrint (
+        UnicodeString,
+        StringLength,
+        L"Not Specified"
+        );
+  }
+
+  // Update string value for respective token.
+  HiiSetString (HiiHandle, TokenToUpdate, UnicodeString, NULL);
+
+Exit:
+  FreePool (UnicodeString);
 }
 
 /** Fetches the Type 32 boot information status.
@@ -323,3 +487,81 @@ OemGetChassisNumPowerCords (
 {
   return 2;
 }
+
+/** Fetches the BIOS release.
+
+  @return The BIOS release.
+**/
+UINT16
+EFIAPI
+OemGetBiosRelease (
+  VOID
+  )
+{
+  UINT16 BiosRelease;
+
+  BiosRelease = (UINT16)(((PcdGet8 (PcdSmbiosTables0MajorVersion)) << 8)
+                         | PcdGet8 (PcdSmbiosTables0MinorVersion));
+
+  return BiosRelease;
+}
+
+/**
+  Fetches the embedded controller firmware release.
+
+  @return   UINT16   The embedded controller firmware release.
+**/
+UINT16
+EFIAPI
+OemGetEmbeddedControllerFirmwareRelease (
+  VOID
+  )
+{
+  CHAR8  AsciiScpVer[SCP_VERSION_STRING_MAX_LENGTH];
+  UINT8  *ScpVer = NULL;
+  UINT8  Index;
+  UINT16 FirmwareRelease;
+
+  GetScpVersion (&ScpVer);
+  if (ScpVer == NULL) {
+    DEBUG ((
+      DEBUG_ERROR,
+      "%a:%d: Fail to get SMpro/PMpro information\n",
+      __func__,
+      __LINE__));
+
+      return 0xFFFF;
+  }
+
+  CopyMem ((VOID *)AsciiScpVer, (VOID *)ScpVer, AsciiStrLen ((CHAR8 *)ScpVer));
+  /* The AsciiVersion is formated as "major.minor" */
+  for (Index = 0; Index < (UINTN)AsciiStrLen (AsciiScpVer); Index++) {
+    if (AsciiScpVer[Index] == '.') {
+      AsciiScpVer[Index] = '\0';
+      break;
+    }
+  }
+
+  FirmwareRelease = ((UINT8)AsciiStrDecimalToUintn (AsciiScpVer) << 8)
+                    + (UINT8)AsciiStrDecimalToUintn (AsciiScpVer + Index + 1);
+
+  return FirmwareRelease;
+}
+
+/**
+  Fetches the system UUID.
+
+  @param[out]   SystemUuid   The pointer to the buffer to store the System UUID.
+**/
+VOID
+EFIAPI
+OemGetSystemUuid (
+  OUT GUID  *SystemUuid
+  )
+{
+  if (SystemUuid == NULL) {
+    return;
+  }
+
+  CopyGuid (SystemUuid, &gZeroGuid);
+}
diff --git a/Silicon/Ampere/AmpereAltraPkg/Library/AmpereCpuLib/AmpereCpuLibCommon.c b/Silicon/Ampere/AmpereAltraPkg/Library/AmpereCpuLib/AmpereCpuLibCommon.c
index 919d9d77b25c..853ab5543f11 100644
--- a/Silicon/Ampere/AmpereAltraPkg/Library/AmpereCpuLib/AmpereCpuLibCommon.c
+++ b/Silicon/Ampere/AmpereAltraPkg/Library/AmpereCpuLib/AmpereCpuLibCommon.c
@@ -513,6 +513,48 @@ GetNumberOfConfiguredCPMs (
   return Count;
 }
 
+/**
+  Get version of SCP.
+
+  @param[out]   ScpVer   Pointer to contain version of SCP value.
+**/
+VOID
+EFIAPI
+GetScpVersion (
+  UINT8 **ScpVer
+  )
+{
+  PLATFORM_INFO_HOB *PlatformHob;
+
+  PlatformHob = GetPlatformHob ();
+  if (PlatformHob != NULL) {
+    *ScpVer = (UINT8 *)PlatformHob->SmPmProVer;
+  } else {
+    *ScpVer = NULL;
+  }
+}
+
+/**
+  Get date of build release for SCP.
+
+  @param[out]   ScpBuild   Pointer to contain date of build release for SCP.
+**/
+VOID
+EFIAPI
+GetScpBuild (
+  UINT8 **ScpBuild
+  )
+{
+  PLATFORM_INFO_HOB *PlatformHob;
+
+  PlatformHob = GetPlatformHob ();
+  if (PlatformHob != NULL) {
+    *ScpBuild = (UINT8 *)PlatformHob->SmPmProBuild;
+  } else {
+    *ScpBuild = NULL;
+  }
+}
+
 /**
   Set the number of configured CPM per socket.
 
-- 
2.39.0



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#105267): https://edk2.groups.io/g/devel/message/105267
Mute This Topic: https://groups.io/mt/99111898/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-