[edk2-devel] [edk2-platforms][PATCH V1 05/11] Platform/ARM/SgiPkg: Add SMBIOS Type3 Table

Pranav Madhu pranav.madhu at arm.com
Fri Jan 15 18:26:42 UTC 2021


Add the SMBIOS type 3 table (System Enclosure) that includes information
about manufacturer, type, serial number and other information related to
system enclosure.

Signed-off-by: Pranav Madhu <pranav.madhu at arm.com>
---
 Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf  |  1 +
 Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.h    | 10 +++
 Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c    |  1 +
 Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type3SystemEnclosure.c | 77 ++++++++++++++++++++
 4 files changed, 89 insertions(+)

diff --git a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
index 6a00912ab742..8095257a4c94 100644
--- a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
+++ b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
@@ -27,6 +27,7 @@
   SmbiosPlatformDxe.c
   Type0BiosInformation.c
   Type1SystemInformation.c
+  Type3SystemEnclosure.c
 
 [Packages]
   ArmPkg/ArmPkg.dec
diff --git a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.h b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.h
index 43427158106d..749439f939ee 100644
--- a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.h
+++ b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.h
@@ -21,4 +21,14 @@ InstallSystemInformation (
   IN     EFI_SMBIOS_PROTOCOL    *Smbios
   );
 
+EFI_STATUS
+EFIAPI
+InstallSystemEnclosure (
+  IN     EFI_SMBIOS_PROTOCOL    *Smbios
+  );
+
+enum SMBIOS_REFRENCE_HANDLES {
+  SMBIOS_HANDLE_ENCLOSURE = 0x1000,
+};
+
 #endif // SMBIOS_PLATFORM_DXE_H_
diff --git a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c
index 1068398bcba3..2eff18630030 100644
--- a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c
+++ b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c
@@ -23,6 +23,7 @@ STATIC
 ARM_RD_SMBIOS_TABLE_INSTALL_FPTR mSmbiosTableList[] = {
   &InstallBiosInformation,
   &InstallSystemInformation,
+  &InstallSystemEnclosure,
 };
 
 /**
diff --git a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type3SystemEnclosure.c b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type3SystemEnclosure.c
new file mode 100644
index 000000000000..c6d134e5af59
--- /dev/null
+++ b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type3SystemEnclosure.c
@@ -0,0 +1,77 @@
+/** @file
+  SMBIOS Type 3 (System enclosure) table for ARM RD platforms.
+
+  Copyright (c) 2020-2021, ARM Limited. All rights reserved.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/DebugLib.h>
+#include <Protocol/Smbios.h>
+
+#include "SmbiosPlatformDxe.h"
+
+#define TYPE3_STRINGS                                   \
+  "ARM LTD\0"                   /* Manufacturer */      \
+  "Version not set\0"           /* Version */           \
+  "Serial not set\0"            /* Serial */            \
+  "Asset Tag not set\0"         /* Asset Tag */
+
+/* SMBIOS Type3 structure */
+#pragma pack(1)
+struct ArmRdSmbiosType3 {
+  SMBIOS_TABLE_TYPE3  Base;
+  UINT8               Strings[sizeof (TYPE3_STRINGS)];
+};
+#pragma pack()
+
+/* System information (SMBIOS 3.4 spec, section 7.4) */
+static struct ArmRdSmbiosType3 mArmRdSmbiosType3 = {
+  {
+    {
+      // SMBIOS header
+      EFI_SMBIOS_TYPE_SYSTEM_ENCLOSURE,   // Type 3
+      sizeof (SMBIOS_TABLE_TYPE1),        // Length
+      SMBIOS_HANDLE_ENCLOSURE,            // Assign an unused handle number
+    },
+    1,                              // Manufacturer
+    2,                              // Enclosure type unknown
+    2,                              // Version
+    3,                              // Serial
+    4,                              // Asset Tag
+    ChassisStateSafe,               // Boot chassis state
+    ChassisStateSafe,               // Power supply state
+    ChassisStateSafe,               // Thermal state
+    ChassisSecurityStatusUnknown,   // Security Status
+    {0},                            // BIOS vendor specific Information
+  },
+  // Text strings (unformatted)
+  TYPE3_STRINGS
+};
+
+/**
+  Install SMBIOS System Enclosure Table
+
+  @retval EFI_SUCCESS           Record was added.
+  @retval EFI_OUT_OF_RESOURCES  Record was not added.
+  @retval EFI_ALREADY_STARTED   The SmbiosHandle passed in is already in use.
+**/
+EFI_STATUS
+InstallSystemEnclosure (
+  IN     EFI_SMBIOS_PROTOCOL    *Smbios
+  )
+{
+  EFI_STATUS Status;
+  EFI_SMBIOS_HANDLE SmbiosHandle;
+
+  SmbiosHandle = ((EFI_SMBIOS_TABLE_HEADER *)&mArmRdSmbiosType3)->Handle;
+  Status = Smbios->Add (
+                     Smbios,
+                     NULL,
+                     &SmbiosHandle,
+                     (EFI_SMBIOS_TABLE_HEADER *)&mArmRdSmbiosType3
+                     );
+
+  return Status;
+}
-- 
2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#70442): https://edk2.groups.io/g/devel/message/70442
Mute This Topic: https://groups.io/mt/79709187/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-






More information about the edk2-devel-archive mailing list