[edk2-devel] [PATCH v6 22/22] ArmPkg: Add Universal/Smbios/SmbiosMiscDxe

Rebecca Cran posted 22 patches 3 years, 10 months ago
There is a newer version of this series
[edk2-devel] [PATCH v6 22/22] ArmPkg: Add Universal/Smbios/SmbiosMiscDxe
Posted by Rebecca Cran 3 years, 10 months ago
SmbiosMiscDxe provides SMBIOS tables 0, 1, 2, 3, 13, and 32.

Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
---
 ArmPkg/ArmPkg.dsc                                              |   1 +
 ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDxe.inf        |  89 ++++++++
 ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMisc.h             | 134 ++++++++++++
 ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDataTable.c    |  62 ++++++
 ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscEntryPoint.c   | 227 ++++++++++++++++++++
 ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDxeStrings.uni |  22 ++
 6 files changed, 535 insertions(+)

diff --git a/ArmPkg/ArmPkg.dsc b/ArmPkg/ArmPkg.dsc
index fce86cb6d710..7194eb2d3c44 100644
--- a/ArmPkg/ArmPkg.dsc
+++ b/ArmPkg/ArmPkg.dsc
@@ -149,6 +149,7 @@ [Components.common]
   ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf
 
   ArmPkg/Universal/Smbios/ProcessorSubClassDxe/ProcessorSubClassDxe.inf
+  ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDxe.inf
 
 [Components.AARCH64]
   ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
diff --git a/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDxe.inf b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDxe.inf
new file mode 100644
index 000000000000..60d8fe31c219
--- /dev/null
+++ b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDxe.inf
@@ -0,0 +1,89 @@
+#/** @file
+# Component description file for SmbiosMisc instance.
+#
+# Parses the MiscSubclassDataTable and reports any generated data to the DataHub.
+#  All .uni file who tagged with "ToolCode="DUMMY"" in following file list is included by
+#  MiscSubclassDriver.uni file, the StrGather tool will expand MiscSubclassDriver.uni file
+#  and parse all .uni file.
+#
+# Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
+# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2015, Hisilicon Limited. All rights reserved.<BR>
+# Copyright (c) 2015, Linaro Limited. All rights reserved.<BR>
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+#
+# Based on files under Nt32Pkg/MiscSubClassPlatformDxe/
+#**/
+
+
+[Defines]
+  INF_VERSION                    = 1.29
+  BASE_NAME                      = SmbiosMiscDxe
+  FILE_GUID                      = 7e5e26d4-0be9-401f-b5e1-1c2bda7ca777
+  MODULE_TYPE                    = DXE_DRIVER
+  VERSION_STRING                 = 1.0
+  ENTRY_POINT                    = SmbiosMiscEntryPoint
+
+[Sources]
+  SmbiosMisc.h
+  SmbiosMiscDataTable.c
+  SmbiosMiscEntryPoint.c
+  SmbiosMiscDxeStrings.uni
+  Type00/MiscBiosVendorData.c
+  Type00/MiscBiosVendorFunction.c
+  Type01/MiscSystemManufacturerData.c
+  Type01/MiscSystemManufacturerFunction.c
+  Type02/MiscBaseBoardManufacturerData.c
+  Type02/MiscBaseBoardManufacturerFunction.c
+  Type03/MiscChassisManufacturerData.c
+  Type03/MiscChassisManufacturerFunction.c
+  Type13/MiscNumberOfInstallableLanguagesData.c
+  Type13/MiscNumberOfInstallableLanguagesFunction.c
+  Type32/MiscBootInformationData.c
+  Type32/MiscBootInformationFunction.c
+
+[Packages]
+  ArmPkg/ArmPkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  BaseLib
+  BaseMemoryLib
+  DebugLib
+  DevicePathLib
+  PcdLib
+  HiiLib
+  HobLib
+  MemoryAllocationLib
+  OemMiscLib
+  UefiBootServicesTableLib
+  UefiDriverEntryPoint
+  UefiLib
+  UefiRuntimeServicesTableLib
+
+[Protocols]
+  gEfiSmbiosProtocolGuid                       # PROTOCOL ALWAYS_CONSUMED
+
+[Pcd]
+  gArmTokenSpaceGuid.PcdFdSize
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVendor
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString
+  gArmTokenSpaceGuid.PcdSystemBiosRelease
+  gArmTokenSpaceGuid.PcdEmbeddedControllerFirmwareRelease
+  gArmTokenSpaceGuid.PcdSystemProductName
+  gArmTokenSpaceGuid.PcdSystemVersion
+  gArmTokenSpaceGuid.PcdBaseBoardManufacturer
+  gArmTokenSpaceGuid.PcdBaseBoardProductName
+  gArmTokenSpaceGuid.PcdBaseBoardVersion
+  gArmTokenSpaceGuid.PcdFdBaseAddress
+
+[Guids]
+  gEfiGenericVariableGuid
+
+[Depex]
+  gEfiSmbiosProtocolGuid
+
+
diff --git a/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMisc.h b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMisc.h
new file mode 100644
index 000000000000..4fd37c4cdc0b
--- /dev/null
+++ b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMisc.h
@@ -0,0 +1,134 @@
+/** @file
+  Header file for the SmbiosMisc Driver.
+
+  Based on files under Nt32Pkg/MiscSubClassPlatformDxe/
+
+  Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
+  Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2015, Hisilicon Limited. All rights reserved.<BR>
+  Copyright (c) 2015, Linaro Limited. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef SMBIOS_MISC_H_
+#define SMBIOS_MISC_H_
+
+#include <Protocol/Smbios.h>
+#include <IndustryStandard/SmBios.h>
+
+//
+// Data table entry update function.
+//
+typedef EFI_STATUS (EFIAPI SMBIOS_MISC_DATA_FUNCTION) (
+  IN  VOID                 *RecordData,
+  IN  EFI_SMBIOS_PROTOCOL  *Smbios
+  );
+
+
+//
+// Data table entry definition.
+//
+typedef struct {
+  //
+  // intermediate input data for SMBIOS record
+  //
+  VOID                          *RecordData;
+  SMBIOS_MISC_DATA_FUNCTION     *Function;
+} SMBIOS_MISC_DATA_TABLE;
+
+
+//
+// SMBIOS table extern definitions
+//
+#define SMBIOS_MISC_TABLE_EXTERNS(NAME1, NAME2, NAME3) \
+extern NAME1 NAME2 ## Data; \
+extern SMBIOS_MISC_DATA_FUNCTION NAME3 ## Function;
+
+
+//
+// SMBIOS data table entries
+//
+// This is used to define a pair of table structure pointer and functions
+// in order to iterate through the list of tables, populate them and add
+// them into the system.
+#define SMBIOS_MISC_TABLE_ENTRY_DATA_AND_FUNCTION(NAME1, NAME2) \
+{ \
+  & NAME1 ## Data, \
+    NAME2 ## Function \
+}
+
+//
+// Global definition macros.
+//
+#define SMBIOS_MISC_TABLE_DATA(NAME1, NAME2) \
+  NAME1 NAME2 ## Data
+
+#define SMBIOS_MISC_TABLE_FUNCTION(NAME2) \
+  EFI_STATUS EFIAPI NAME2 ## Function( \
+  IN  VOID                  *RecordData, \
+  IN  EFI_SMBIOS_PROTOCOL   *Smbios \
+  )
+
+//
+// Data Table Array Entries
+//
+extern EFI_HII_HANDLE               mSmbiosMiscHiiHandle;
+
+typedef struct _SMBIOS_TYPE13_BIOS_LANGUAGE_INFORMATION_STRING{
+  UINT8                               *LanguageSignature;
+  EFI_STRING_ID                       InstallableLanguageLongString;
+  EFI_STRING_ID                       InstallableLanguageAbbreviateString;
+} SMBIOS_TYPE13_BIOS_LANGUAGE_INFORMATION_STRING;
+
+
+/**
+  Adds an SMBIOS record.
+
+  @param  Buffer        The data for the SMBIOS record.
+                        The format of the record is determined by
+                        EFI_SMBIOS_TABLE_HEADER.Type. The size of the
+                        formatted area is defined by EFI_SMBIOS_TABLE_HEADER.Length
+                        and either followed by a double-null (0x0000) or a set
+                        of null terminated strings and a null.
+  @param  SmbiosHandle  A unique handle will be assigned to the SMBIOS record
+                        if not NULL.
+
+  @retval EFI_SUCCESS           Record was added.
+  @retval EFI_OUT_OF_RESOURCES  Record was not added due to lack of system resources.
+  @retval EFI_ALREADY_STARTED   The SmbiosHandle passed in was already in use.
+
+**/
+EFI_STATUS
+SmbiosMiscAddRecord (
+  IN       UINT8                      *Buffer,
+  IN  OUT  EFI_SMBIOS_HANDLE          *SmbiosHandle OPTIONAL
+  );
+
+/**
+ Get Link Type Handle.
+
+ @param [in]   SmbiosType     Get this Type from SMBIOS table
+ @param [out]  HandleArray    Pointer to handle array which will be freed by caller
+ @param [out]  HandleCount    Pointer to handle count
+
+**/
+VOID
+SmbiosMiscGetLinkTypeHandle(
+  IN  UINT8                 SmbiosType,
+  OUT UINT16                **HandleArray,
+  OUT UINTN                 *HandleCount
+  );
+
+//
+// Data Table Array
+//
+extern SMBIOS_MISC_DATA_TABLE   mSmbiosMiscDataTable[];
+
+//
+// Data Table Array Entries
+//
+extern UINTN   mSmbiosMiscDataTableEntries;
+extern UINT8   mSmbiosMiscDxeStrings[];
+
+#endif // SMBIOS_MISC_H_
diff --git a/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDataTable.c b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDataTable.c
new file mode 100644
index 000000000000..ac16c3a2688e
--- /dev/null
+++ b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDataTable.c
@@ -0,0 +1,62 @@
+/** @file
+  This file provides SMBIOS Misc Type.
+
+  Based on files under Nt32Pkg/MiscSubClassPlatformDxe/
+
+  Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
+  Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2015, Hisilicon Limited. All rights reserved.<BR>
+  Copyright (c) 2015, Linaro Limited. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent\
+
+**/
+
+#include "SmbiosMisc.h"
+
+SMBIOS_MISC_TABLE_EXTERNS (SMBIOS_TABLE_TYPE0,
+                           MiscBiosVendor,
+                           MiscBiosVendor)
+SMBIOS_MISC_TABLE_EXTERNS (SMBIOS_TABLE_TYPE1,
+                           MiscSystemManufacturer,
+                           MiscSystemManufacturer)
+SMBIOS_MISC_TABLE_EXTERNS (SMBIOS_TABLE_TYPE3,
+                          MiscChassisManufacturer,
+                          MiscChassisManufacturer)
+SMBIOS_MISC_TABLE_EXTERNS (SMBIOS_TABLE_TYPE2,
+                           MiscBaseBoardManufacturer,
+                           MiscBaseBoardManufacturer)
+SMBIOS_MISC_TABLE_EXTERNS (SMBIOS_TABLE_TYPE13,
+                           MiscNumberOfInstallableLanguages,
+                           MiscNumberOfInstallableLanguages)
+SMBIOS_MISC_TABLE_EXTERNS (SMBIOS_TABLE_TYPE32,
+                           MiscBootInformation,
+                           MiscBootInformation)
+
+
+SMBIOS_MISC_DATA_TABLE mSmbiosMiscDataTable[] = {
+  // Type0
+  SMBIOS_MISC_TABLE_ENTRY_DATA_AND_FUNCTION (MiscBiosVendor,
+                                             MiscBiosVendor),
+  // Type1
+  SMBIOS_MISC_TABLE_ENTRY_DATA_AND_FUNCTION (MiscSystemManufacturer,
+                                             MiscSystemManufacturer),
+  // Type3
+  SMBIOS_MISC_TABLE_ENTRY_DATA_AND_FUNCTION (MiscChassisManufacturer,
+                                             MiscChassisManufacturer),
+  // Type2
+  SMBIOS_MISC_TABLE_ENTRY_DATA_AND_FUNCTION (MiscBaseBoardManufacturer,
+                                             MiscBaseBoardManufacturer),
+  // Type13
+  SMBIOS_MISC_TABLE_ENTRY_DATA_AND_FUNCTION (MiscNumberOfInstallableLanguages,
+                                             MiscNumberOfInstallableLanguages),
+  // Type32
+  SMBIOS_MISC_TABLE_ENTRY_DATA_AND_FUNCTION (MiscBootInformation,
+                                             MiscBootInformation),
+};
+
+
+//
+// Number of Data Table entries.
+//
+UINTN mSmbiosMiscDataTableEntries =
+  (sizeof (mSmbiosMiscDataTable)) / sizeof (SMBIOS_MISC_DATA_TABLE);
diff --git a/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscEntryPoint.c b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscEntryPoint.c
new file mode 100644
index 000000000000..37e79d285e57
--- /dev/null
+++ b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscEntryPoint.c
@@ -0,0 +1,227 @@
+/** @file
+  This driver parses the mSmbiosMiscDataTable structure and reports
+  any generated data using SMBIOS protocol.
+
+  Based on files under Nt32Pkg/MiscSubClassPlatformDxe/
+
+  Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
+  Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2015, Hisilicon Limited. All rights reserved.<BR>
+  Copyright (c) 2015, Linaro Limited. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/HiiLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+
+#include "SmbiosMisc.h"
+
+
+STATIC EFI_HANDLE           mSmbiosMiscImageHandle;
+STATIC EFI_SMBIOS_PROTOCOL  *mSmbiosMiscSmbios = NULL;
+
+EFI_HII_HANDLE       mSmbiosMiscHiiHandle;
+
+/**
+  Standard EFI driver point.  This driver parses the mSmbiosMiscDataTable
+  structure and reports any generated data using SMBIOS protocol.
+
+  @param  ImageHandle     Handle for the image of this driver
+  @param  SystemTable     Pointer to the EFI System Table
+
+  @retval  EFI_SUCCESS    The data was successfully stored.
+
+**/
+EFI_STATUS
+EFIAPI
+SmbiosMiscEntryPoint(
+  IN EFI_HANDLE         ImageHandle,
+  IN EFI_SYSTEM_TABLE   *SystemTable
+  )
+{
+  UINTN                Index;
+  EFI_STATUS           EfiStatus;
+
+  mSmbiosMiscImageHandle = ImageHandle;
+
+  EfiStatus = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL,
+                                   (VOID**)&mSmbiosMiscSmbios);
+  if (EFI_ERROR (EfiStatus)) {
+    DEBUG ((DEBUG_ERROR, "Could not locate SMBIOS protocol.  %r\n", EfiStatus));
+    return EfiStatus;
+  }
+
+  mSmbiosMiscHiiHandle = HiiAddPackages (
+                 &gEfiCallerIdGuid,
+                  mSmbiosMiscImageHandle,
+                  SmbiosMiscDxeStrings,
+                  NULL
+                  );
+  if (mSmbiosMiscHiiHandle == NULL) {
+    return EFI_OUT_OF_RESOURCES;
+  }
+
+  for (Index = 0; Index < mSmbiosMiscDataTableEntries; ++Index) {
+    //
+    // If the entry have a function pointer, just log the data.
+    //
+    if (mSmbiosMiscDataTable[Index].Function != NULL) {
+      EfiStatus = (*mSmbiosMiscDataTable[Index].Function)(
+          mSmbiosMiscDataTable[Index].RecordData,
+          mSmbiosMiscSmbios
+          );
+
+      if (EFI_ERROR(EfiStatus)) {
+        DEBUG ((DEBUG_ERROR, "Misc smbios store error.  Index=%d,"
+                "ReturnStatus=%r\n", Index, EfiStatus));
+        return EfiStatus;
+      }
+    }
+  }
+
+  return EfiStatus;
+}
+
+
+/**
+  Adds an SMBIOS record.
+
+  @param  Buffer        The data for the SMBIOS record.
+                        The format of the record is determined by
+                        EFI_SMBIOS_TABLE_HEADER.Type. The size of the
+                        formatted area is defined by EFI_SMBIOS_TABLE_HEADER.Length
+                        and either followed by a double-null (0x0000) or a set
+                        of null terminated strings and a null.
+  @param  SmbiosHandle  A unique handle will be assigned to the SMBIOS record
+                        if not NULL.
+
+  @retval EFI_SUCCESS           Record was added.
+  @retval EFI_OUT_OF_RESOURCES  Record was not added due to lack of system resources.
+  @retval EFI_ALREADY_STARTED   The SmbiosHandle passed in was already in use.
+
+**/
+EFI_STATUS
+SmbiosMiscAddRecord (
+  IN  UINT8                 *Buffer,
+  IN OUT EFI_SMBIOS_HANDLE  *SmbiosHandle OPTIONAL
+  )
+{
+  EFI_STATUS         Status;
+  EFI_SMBIOS_HANDLE  Handle;
+
+  Handle = SMBIOS_HANDLE_PI_RESERVED;
+
+  if (SmbiosHandle != NULL) {
+    Handle = *SmbiosHandle;
+  }
+
+  Status = mSmbiosMiscSmbios->Add (
+             mSmbiosMiscSmbios,
+             NULL,
+             &Handle,
+             (EFI_SMBIOS_TABLE_HEADER *)Buffer
+             );
+
+  if (SmbiosHandle != NULL) {
+    *SmbiosHandle = Handle;
+  }
+
+  return Status;
+}
+
+
+/** Fetches the number of handles of the specified SMBIOS type
+ *
+ *  @param SmbiosType The type of SMBIOS record to look for
+ *
+ *  @return The number of handles
+ *
+**/
+STATIC
+UINTN
+GetHandleCount (
+  IN  UINT8 SmbiosType
+  )
+{
+  UINTN                    HandleCount;
+  EFI_STATUS               Status;
+  EFI_SMBIOS_HANDLE        SmbiosHandle;
+  EFI_SMBIOS_TABLE_HEADER  *Record;
+
+  HandleCount = 0;
+
+  // Iterate through entries to get the number
+  do {
+    Status = mSmbiosMiscSmbios->GetNext (
+                        mSmbiosMiscSmbios,
+                        &SmbiosHandle,
+                        &SmbiosType,
+                        &Record,
+                        NULL
+                        );
+
+    if (Status == EFI_SUCCESS) {
+      HandleCount++;
+    }
+  } while (!EFI_ERROR (Status));
+
+  return HandleCount;
+}
+
+/**
+  Fetches a list of the specified SMBIOS table types.
+
+  @param[in]  SmbiosType    The type of table to fetch
+  @param[out] **HandleArray The array of handles
+  @param[out] *HandleCount  Number of handles in the array
+**/
+VOID
+SmbiosMiscGetLinkTypeHandle(
+  IN  UINT8                 SmbiosType,
+  OUT SMBIOS_HANDLE         **HandleArray,
+  OUT UINTN                 *HandleCount
+  )
+{
+  UINTN                    Index;
+  EFI_STATUS               Status;
+  EFI_SMBIOS_HANDLE        SmbiosHandle;
+  EFI_SMBIOS_TABLE_HEADER  *Record;
+
+  if (mSmbiosMiscSmbios == NULL) {
+    return;
+  }
+
+  SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
+  *HandleCount = GetHandleCount (SmbiosType);
+
+  *HandleArray = AllocateZeroPool (sizeof (SMBIOS_HANDLE) * (*HandleCount));
+  if (*HandleArray == NULL) {
+    DEBUG ((DEBUG_ERROR, "HandleArray allocate memory resource failed.\n"));
+    *HandleCount = 0;
+    return;
+  }
+
+  SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
+
+  for (Index = 0; Index < (*HandleCount); Index++) {
+    Status = mSmbiosMiscSmbios->GetNext (
+                        mSmbiosMiscSmbios,
+                        &SmbiosHandle,
+                        &SmbiosType,
+                        &Record,
+                        NULL
+                        );
+
+    if (!EFI_ERROR (Status)) {
+      (*HandleArray)[Index] = Record->Handle;
+    } else {
+      break;
+    }
+  }
+}
+
diff --git a/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDxeStrings.uni b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDxeStrings.uni
new file mode 100644
index 000000000000..6f877e706922
--- /dev/null
+++ b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDxeStrings.uni
@@ -0,0 +1,22 @@
+/** @file
+ *  Based on files under Nt32Pkg/MiscSubClassPlatformDxe/
+ *
+ *  Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
+ *  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+ *  Copyright (c) 2015, Hisilicon Limited. All rights reserved.<BR>
+ *  Copyright (c) 2015, Linaro Limited. All rights reserved.<BR>
+ *  SPDX-License-Identifier: BSD-2-Clause-Patent
+ *
+ *
+**/
+
+
+/=#
+
+#langdef en-US "English"
+
+#include "Type00/MiscBiosVendor.uni"
+#include "Type01/MiscSystemManufacturer.uni"
+#include "Type02/MiscBaseBoardManufacturer.uni"
+#include "Type03/MiscChassisManufacturer.uni"
+#include "Type13/MiscNumberOfInstallableLanguages.uni"
-- 
2.26.2



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


Re: [edk2-devel] [PATCH v6 22/22] ArmPkg: Add Universal/Smbios/SmbiosMiscDxe
Posted by Samer El-Haj-Mahmoud 3 years, 10 months ago
I thought I reviewed this but maybe I forgot to send RB:

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



> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Rebecca
> Cran via groups.io
> Sent: Thursday, January 14, 2021 11:36 AM
> To: devel@edk2.groups.io
> Cc: Rebecca Cran <rebecca@nuviainc.com>; Leif Lindholm
> <leif@nuviainc.com>; Ard Biesheuvel <Ard.Biesheuvel@arm.com>; nd
> <nd@arm.com>; Sami Mujawar <Sami.Mujawar@arm.com>; Liming Gao
> <gaoliming@byosoft.com.cn>; Michael D Kinney
> <michael.d.kinney@intel.com>; Zhiguang Liu <zhiguang.liu@intel.com>
> Subject: [edk2-devel] [PATCH v6 22/22] ArmPkg: Add
> Universal/Smbios/SmbiosMiscDxe
> 
> SmbiosMiscDxe provides SMBIOS tables 0, 1, 2, 3, 13, and 32.
> 
> Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
> ---
>  ArmPkg/ArmPkg.dsc                                              |   1 +
>  ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDxe.inf        |  89
> ++++++++
>  ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMisc.h             | 134
> ++++++++++++
>  ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDataTable.c    |  62
> ++++++
>  ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscEntryPoint.c   | 227
> ++++++++++++++++++++
>  ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDxeStrings.uni |  22
> ++
>  6 files changed, 535 insertions(+)
> 
> diff --git a/ArmPkg/ArmPkg.dsc b/ArmPkg/ArmPkg.dsc index
> fce86cb6d710..7194eb2d3c44 100644
> --- a/ArmPkg/ArmPkg.dsc
> +++ b/ArmPkg/ArmPkg.dsc
> @@ -149,6 +149,7 @@ [Components.common]
>    ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf
> 
> 
> ArmPkg/Universal/Smbios/ProcessorSubClassDxe/ProcessorSubClassDxe.inf
> +  ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDxe.inf
> 
>  [Components.AARCH64]
>    ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
> diff --git a/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDxe.inf
> b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDxe.inf
> new file mode 100644
> index 000000000000..60d8fe31c219
> --- /dev/null
> +++ b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDxe.inf
> @@ -0,0 +1,89 @@
> +#/** @file
> +# Component description file for SmbiosMisc instance.
> +#
> +# Parses the MiscSubclassDataTable and reports any generated data to the
> DataHub.
> +#  All .uni file who tagged with "ToolCode="DUMMY"" in following file
> +list is included by #  MiscSubclassDriver.uni file, the StrGather tool
> +will expand MiscSubclassDriver.uni file #  and parse all .uni file.
> +#
> +# Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR> # Copyright
> +(c) 2006 - 2010, Intel Corporation. All rights reserved.<BR> #
> +Copyright (c) 2015, Hisilicon Limited. All rights reserved.<BR> #
> +Copyright (c) 2015, Linaro Limited. All rights reserved.<BR> # #
> +SPDX-License-Identifier: BSD-2-Clause-Patent # # # Based on files under
> +Nt32Pkg/MiscSubClassPlatformDxe/ #**/
> +
> +
> +[Defines]
> +  INF_VERSION                    = 1.29
> +  BASE_NAME                      = SmbiosMiscDxe
> +  FILE_GUID                      = 7e5e26d4-0be9-401f-b5e1-1c2bda7ca777
> +  MODULE_TYPE                    = DXE_DRIVER
> +  VERSION_STRING                 = 1.0
> +  ENTRY_POINT                    = SmbiosMiscEntryPoint
> +
> +[Sources]
> +  SmbiosMisc.h
> +  SmbiosMiscDataTable.c
> +  SmbiosMiscEntryPoint.c
> +  SmbiosMiscDxeStrings.uni
> +  Type00/MiscBiosVendorData.c
> +  Type00/MiscBiosVendorFunction.c
> +  Type01/MiscSystemManufacturerData.c
> +  Type01/MiscSystemManufacturerFunction.c
> +  Type02/MiscBaseBoardManufacturerData.c
> +  Type02/MiscBaseBoardManufacturerFunction.c
> +  Type03/MiscChassisManufacturerData.c
> +  Type03/MiscChassisManufacturerFunction.c
> +  Type13/MiscNumberOfInstallableLanguagesData.c
> +  Type13/MiscNumberOfInstallableLanguagesFunction.c
> +  Type32/MiscBootInformationData.c
> +  Type32/MiscBootInformationFunction.c
> +
> +[Packages]
> +  ArmPkg/ArmPkg.dec
> +  MdeModulePkg/MdeModulePkg.dec
> +  MdePkg/MdePkg.dec
> +
> +[LibraryClasses]
> +  BaseLib
> +  BaseMemoryLib
> +  DebugLib
> +  DevicePathLib
> +  PcdLib
> +  HiiLib
> +  HobLib
> +  MemoryAllocationLib
> +  OemMiscLib
> +  UefiBootServicesTableLib
> +  UefiDriverEntryPoint
> +  UefiLib
> +  UefiRuntimeServicesTableLib
> +
> +[Protocols]
> +  gEfiSmbiosProtocolGuid                       # PROTOCOL ALWAYS_CONSUMED
> +
> +[Pcd]
> +  gArmTokenSpaceGuid.PcdFdSize
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVendor
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString
> +  gArmTokenSpaceGuid.PcdSystemBiosRelease
> +  gArmTokenSpaceGuid.PcdEmbeddedControllerFirmwareRelease
> +  gArmTokenSpaceGuid.PcdSystemProductName
> +  gArmTokenSpaceGuid.PcdSystemVersion
> +  gArmTokenSpaceGuid.PcdBaseBoardManufacturer
> +  gArmTokenSpaceGuid.PcdBaseBoardProductName
> +  gArmTokenSpaceGuid.PcdBaseBoardVersion
> +  gArmTokenSpaceGuid.PcdFdBaseAddress
> +
> +[Guids]
> +  gEfiGenericVariableGuid
> +
> +[Depex]
> +  gEfiSmbiosProtocolGuid
> +
> +
> diff --git a/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMisc.h
> b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMisc.h
> new file mode 100644
> index 000000000000..4fd37c4cdc0b
> --- /dev/null
> +++ b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMisc.h
> @@ -0,0 +1,134 @@
> +/** @file
> +  Header file for the SmbiosMisc Driver.
> +
> +  Based on files under Nt32Pkg/MiscSubClassPlatformDxe/
> +
> +  Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>  Copyright
> + (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
> + Copyright (c) 2015, Hisilicon Limited. All rights reserved.<BR>
> + Copyright (c) 2015, Linaro Limited. All rights reserved.<BR>
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef SMBIOS_MISC_H_
> +#define SMBIOS_MISC_H_
> +
> +#include <Protocol/Smbios.h>
> +#include <IndustryStandard/SmBios.h>
> +
> +//
> +// Data table entry update function.
> +//
> +typedef EFI_STATUS (EFIAPI SMBIOS_MISC_DATA_FUNCTION) (
> +  IN  VOID                 *RecordData,
> +  IN  EFI_SMBIOS_PROTOCOL  *Smbios
> +  );
> +
> +
> +//
> +// Data table entry definition.
> +//
> +typedef struct {
> +  //
> +  // intermediate input data for SMBIOS record
> +  //
> +  VOID                          *RecordData;
> +  SMBIOS_MISC_DATA_FUNCTION     *Function;
> +} SMBIOS_MISC_DATA_TABLE;
> +
> +
> +//
> +// SMBIOS table extern definitions
> +//
> +#define SMBIOS_MISC_TABLE_EXTERNS(NAME1, NAME2, NAME3) \ extern
> NAME1
> +NAME2 ## Data; \ extern SMBIOS_MISC_DATA_FUNCTION NAME3 ##
> Function;
> +
> +
> +//
> +// SMBIOS data table entries
> +//
> +// This is used to define a pair of table structure pointer and
> +functions // in order to iterate through the list of tables, populate
> +them and add // them into the system.
> +#define SMBIOS_MISC_TABLE_ENTRY_DATA_AND_FUNCTION(NAME1,
> NAME2) \ { \
> +  & NAME1 ## Data, \
> +    NAME2 ## Function \
> +}
> +
> +//
> +// Global definition macros.
> +//
> +#define SMBIOS_MISC_TABLE_DATA(NAME1, NAME2) \
> +  NAME1 NAME2 ## Data
> +
> +#define SMBIOS_MISC_TABLE_FUNCTION(NAME2) \
> +  EFI_STATUS EFIAPI NAME2 ## Function( \
> +  IN  VOID                  *RecordData, \
> +  IN  EFI_SMBIOS_PROTOCOL   *Smbios \
> +  )
> +
> +//
> +// Data Table Array Entries
> +//
> +extern EFI_HII_HANDLE               mSmbiosMiscHiiHandle;
> +
> +typedef struct
> _SMBIOS_TYPE13_BIOS_LANGUAGE_INFORMATION_STRING{
> +  UINT8                               *LanguageSignature;
> +  EFI_STRING_ID                       InstallableLanguageLongString;
> +  EFI_STRING_ID                       InstallableLanguageAbbreviateString;
> +} SMBIOS_TYPE13_BIOS_LANGUAGE_INFORMATION_STRING;
> +
> +
> +/**
> +  Adds an SMBIOS record.
> +
> +  @param  Buffer        The data for the SMBIOS record.
> +                        The format of the record is determined by
> +                        EFI_SMBIOS_TABLE_HEADER.Type. The size of the
> +                        formatted area is defined by
> EFI_SMBIOS_TABLE_HEADER.Length
> +                        and either followed by a double-null (0x0000) or a set
> +                        of null terminated strings and a null.
> +  @param  SmbiosHandle  A unique handle will be assigned to the SMBIOS
> record
> +                        if not NULL.
> +
> +  @retval EFI_SUCCESS           Record was added.
> +  @retval EFI_OUT_OF_RESOURCES  Record was not added due to lack of
> system resources.
> +  @retval EFI_ALREADY_STARTED   The SmbiosHandle passed in was already
> in use.
> +
> +**/
> +EFI_STATUS
> +SmbiosMiscAddRecord (
> +  IN       UINT8                      *Buffer,
> +  IN  OUT  EFI_SMBIOS_HANDLE          *SmbiosHandle OPTIONAL
> +  );
> +
> +/**
> + Get Link Type Handle.
> +
> + @param [in]   SmbiosType     Get this Type from SMBIOS table
> + @param [out]  HandleArray    Pointer to handle array which will be freed by
> caller
> + @param [out]  HandleCount    Pointer to handle count
> +
> +**/
> +VOID
> +SmbiosMiscGetLinkTypeHandle(
> +  IN  UINT8                 SmbiosType,
> +  OUT UINT16                **HandleArray,
> +  OUT UINTN                 *HandleCount
> +  );
> +
> +//
> +// Data Table Array
> +//
> +extern SMBIOS_MISC_DATA_TABLE   mSmbiosMiscDataTable[];
> +
> +//
> +// Data Table Array Entries
> +//
> +extern UINTN   mSmbiosMiscDataTableEntries;
> +extern UINT8   mSmbiosMiscDxeStrings[];
> +
> +#endif // SMBIOS_MISC_H_
> diff --git
> a/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDataTable.c
> b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDataTable.c
> new file mode 100644
> index 000000000000..ac16c3a2688e
> --- /dev/null
> +++ b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDataTable.c
> @@ -0,0 +1,62 @@
> +/** @file
> +  This file provides SMBIOS Misc Type.
> +
> +  Based on files under Nt32Pkg/MiscSubClassPlatformDxe/
> +
> +  Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>  Copyright
> + (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
> + Copyright (c) 2015, Hisilicon Limited. All rights reserved.<BR>
> + Copyright (c) 2015, Linaro Limited. All rights reserved.<BR>
> +  SPDX-License-Identifier: BSD-2-Clause-Patent\
> +
> +**/
> +
> +#include "SmbiosMisc.h"
> +
> +SMBIOS_MISC_TABLE_EXTERNS (SMBIOS_TABLE_TYPE0,
> +                           MiscBiosVendor,
> +                           MiscBiosVendor) SMBIOS_MISC_TABLE_EXTERNS
> +(SMBIOS_TABLE_TYPE1,
> +                           MiscSystemManufacturer,
> +                           MiscSystemManufacturer)
> +SMBIOS_MISC_TABLE_EXTERNS (SMBIOS_TABLE_TYPE3,
> +                          MiscChassisManufacturer,
> +                          MiscChassisManufacturer)
> +SMBIOS_MISC_TABLE_EXTERNS (SMBIOS_TABLE_TYPE2,
> +                           MiscBaseBoardManufacturer,
> +                           MiscBaseBoardManufacturer)
> +SMBIOS_MISC_TABLE_EXTERNS (SMBIOS_TABLE_TYPE13,
> +                           MiscNumberOfInstallableLanguages,
> +                           MiscNumberOfInstallableLanguages)
> +SMBIOS_MISC_TABLE_EXTERNS (SMBIOS_TABLE_TYPE32,
> +                           MiscBootInformation,
> +                           MiscBootInformation)
> +
> +
> +SMBIOS_MISC_DATA_TABLE mSmbiosMiscDataTable[] = {
> +  // Type0
> +  SMBIOS_MISC_TABLE_ENTRY_DATA_AND_FUNCTION (MiscBiosVendor,
> +                                             MiscBiosVendor),
> +  // Type1
> +  SMBIOS_MISC_TABLE_ENTRY_DATA_AND_FUNCTION
> (MiscSystemManufacturer,
> +                                             MiscSystemManufacturer),
> +  // Type3
> +  SMBIOS_MISC_TABLE_ENTRY_DATA_AND_FUNCTION
> (MiscChassisManufacturer,
> +                                             MiscChassisManufacturer),
> +  // Type2
> +  SMBIOS_MISC_TABLE_ENTRY_DATA_AND_FUNCTION
> (MiscBaseBoardManufacturer,
> +
> +MiscBaseBoardManufacturer),
> +  // Type13
> +  SMBIOS_MISC_TABLE_ENTRY_DATA_AND_FUNCTION
> (MiscNumberOfInstallableLanguages,
> +
> +MiscNumberOfInstallableLanguages),
> +  // Type32
> +  SMBIOS_MISC_TABLE_ENTRY_DATA_AND_FUNCTION
> (MiscBootInformation,
> +                                             MiscBootInformation), };
> +
> +
> +//
> +// Number of Data Table entries.
> +//
> +UINTN mSmbiosMiscDataTableEntries =
> +  (sizeof (mSmbiosMiscDataTable)) / sizeof (SMBIOS_MISC_DATA_TABLE);
> diff --git
> a/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscEntryPoint.c
> b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscEntryPoint.c
> new file mode 100644
> index 000000000000..37e79d285e57
> --- /dev/null
> +++ b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscEntryPoint.c
> @@ -0,0 +1,227 @@
> +/** @file
> +  This driver parses the mSmbiosMiscDataTable structure and reports
> +  any generated data using SMBIOS protocol.
> +
> +  Based on files under Nt32Pkg/MiscSubClassPlatformDxe/
> +
> +  Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>  Copyright
> + (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
> + Copyright (c) 2015, Hisilicon Limited. All rights reserved.<BR>
> + Copyright (c) 2015, Linaro Limited. All rights reserved.<BR>
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <Library/BaseLib.h>
> +#include <Library/BaseMemoryLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/HiiLib.h>
> +#include <Library/MemoryAllocationLib.h> #include
> +<Library/UefiBootServicesTableLib.h>
> +
> +#include "SmbiosMisc.h"
> +
> +
> +STATIC EFI_HANDLE           mSmbiosMiscImageHandle;
> +STATIC EFI_SMBIOS_PROTOCOL  *mSmbiosMiscSmbios = NULL;
> +
> +EFI_HII_HANDLE       mSmbiosMiscHiiHandle;
> +
> +/**
> +  Standard EFI driver point.  This driver parses the
> +mSmbiosMiscDataTable
> +  structure and reports any generated data using SMBIOS protocol.
> +
> +  @param  ImageHandle     Handle for the image of this driver
> +  @param  SystemTable     Pointer to the EFI System Table
> +
> +  @retval  EFI_SUCCESS    The data was successfully stored.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +SmbiosMiscEntryPoint(
> +  IN EFI_HANDLE         ImageHandle,
> +  IN EFI_SYSTEM_TABLE   *SystemTable
> +  )
> +{
> +  UINTN                Index;
> +  EFI_STATUS           EfiStatus;
> +
> +  mSmbiosMiscImageHandle = ImageHandle;
> +
> +  EfiStatus = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL,
> +                                   (VOID**)&mSmbiosMiscSmbios);  if
> + (EFI_ERROR (EfiStatus)) {
> +    DEBUG ((DEBUG_ERROR, "Could not locate SMBIOS protocol.  %r\n",
> EfiStatus));
> +    return EfiStatus;
> +  }
> +
> +  mSmbiosMiscHiiHandle = HiiAddPackages (
> +                 &gEfiCallerIdGuid,
> +                  mSmbiosMiscImageHandle,
> +                  SmbiosMiscDxeStrings,
> +                  NULL
> +                  );
> +  if (mSmbiosMiscHiiHandle == NULL) {
> +    return EFI_OUT_OF_RESOURCES;
> +  }
> +
> +  for (Index = 0; Index < mSmbiosMiscDataTableEntries; ++Index) {
> +    //
> +    // If the entry have a function pointer, just log the data.
> +    //
> +    if (mSmbiosMiscDataTable[Index].Function != NULL) {
> +      EfiStatus = (*mSmbiosMiscDataTable[Index].Function)(
> +          mSmbiosMiscDataTable[Index].RecordData,
> +          mSmbiosMiscSmbios
> +          );
> +
> +      if (EFI_ERROR(EfiStatus)) {
> +        DEBUG ((DEBUG_ERROR, "Misc smbios store error.  Index=%d,"
> +                "ReturnStatus=%r\n", Index, EfiStatus));
> +        return EfiStatus;
> +      }
> +    }
> +  }
> +
> +  return EfiStatus;
> +}
> +
> +
> +/**
> +  Adds an SMBIOS record.
> +
> +  @param  Buffer        The data for the SMBIOS record.
> +                        The format of the record is determined by
> +                        EFI_SMBIOS_TABLE_HEADER.Type. The size of the
> +                        formatted area is defined by
> EFI_SMBIOS_TABLE_HEADER.Length
> +                        and either followed by a double-null (0x0000) or a set
> +                        of null terminated strings and a null.
> +  @param  SmbiosHandle  A unique handle will be assigned to the SMBIOS
> record
> +                        if not NULL.
> +
> +  @retval EFI_SUCCESS           Record was added.
> +  @retval EFI_OUT_OF_RESOURCES  Record was not added due to lack of
> system resources.
> +  @retval EFI_ALREADY_STARTED   The SmbiosHandle passed in was already
> in use.
> +
> +**/
> +EFI_STATUS
> +SmbiosMiscAddRecord (
> +  IN  UINT8                 *Buffer,
> +  IN OUT EFI_SMBIOS_HANDLE  *SmbiosHandle OPTIONAL
> +  )
> +{
> +  EFI_STATUS         Status;
> +  EFI_SMBIOS_HANDLE  Handle;
> +
> +  Handle = SMBIOS_HANDLE_PI_RESERVED;
> +
> +  if (SmbiosHandle != NULL) {
> +    Handle = *SmbiosHandle;
> +  }
> +
> +  Status = mSmbiosMiscSmbios->Add (
> +             mSmbiosMiscSmbios,
> +             NULL,
> +             &Handle,
> +             (EFI_SMBIOS_TABLE_HEADER *)Buffer
> +             );
> +
> +  if (SmbiosHandle != NULL) {
> +    *SmbiosHandle = Handle;
> +  }
> +
> +  return Status;
> +}
> +
> +
> +/** Fetches the number of handles of the specified SMBIOS type
> + *
> + *  @param SmbiosType The type of SMBIOS record to look for
> + *
> + *  @return The number of handles
> + *
> +**/
> +STATIC
> +UINTN
> +GetHandleCount (
> +  IN  UINT8 SmbiosType
> +  )
> +{
> +  UINTN                    HandleCount;
> +  EFI_STATUS               Status;
> +  EFI_SMBIOS_HANDLE        SmbiosHandle;
> +  EFI_SMBIOS_TABLE_HEADER  *Record;
> +
> +  HandleCount = 0;
> +
> +  // Iterate through entries to get the number  do {
> +    Status = mSmbiosMiscSmbios->GetNext (
> +                        mSmbiosMiscSmbios,
> +                        &SmbiosHandle,
> +                        &SmbiosType,
> +                        &Record,
> +                        NULL
> +                        );
> +
> +    if (Status == EFI_SUCCESS) {
> +      HandleCount++;
> +    }
> +  } while (!EFI_ERROR (Status));
> +
> +  return HandleCount;
> +}
> +
> +/**
> +  Fetches a list of the specified SMBIOS table types.
> +
> +  @param[in]  SmbiosType    The type of table to fetch
> +  @param[out] **HandleArray The array of handles
> +  @param[out] *HandleCount  Number of handles in the array **/ VOID
> +SmbiosMiscGetLinkTypeHandle(
> +  IN  UINT8                 SmbiosType,
> +  OUT SMBIOS_HANDLE         **HandleArray,
> +  OUT UINTN                 *HandleCount
> +  )
> +{
> +  UINTN                    Index;
> +  EFI_STATUS               Status;
> +  EFI_SMBIOS_HANDLE        SmbiosHandle;
> +  EFI_SMBIOS_TABLE_HEADER  *Record;
> +
> +  if (mSmbiosMiscSmbios == NULL) {
> +    return;
> +  }
> +
> +  SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;  *HandleCount =
> + GetHandleCount (SmbiosType);
> +
> +  *HandleArray = AllocateZeroPool (sizeof (SMBIOS_HANDLE) *
> + (*HandleCount));  if (*HandleArray == NULL) {
> +    DEBUG ((DEBUG_ERROR, "HandleArray allocate memory resource
> failed.\n"));
> +    *HandleCount = 0;
> +    return;
> +  }
> +
> +  SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
> +
> +  for (Index = 0; Index < (*HandleCount); Index++) {
> +    Status = mSmbiosMiscSmbios->GetNext (
> +                        mSmbiosMiscSmbios,
> +                        &SmbiosHandle,
> +                        &SmbiosType,
> +                        &Record,
> +                        NULL
> +                        );
> +
> +    if (!EFI_ERROR (Status)) {
> +      (*HandleArray)[Index] = Record->Handle;
> +    } else {
> +      break;
> +    }
> +  }
> +}
> +
> diff --git
> a/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDxeStrings.uni
> b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDxeStrings.uni
> new file mode 100644
> index 000000000000..6f877e706922
> --- /dev/null
> +++ b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDxeStrings.uni
> @@ -0,0 +1,22 @@
> +/** @file
> + *  Based on files under Nt32Pkg/MiscSubClassPlatformDxe/
> + *
> + *  Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
> + *  Copyright (c) 2006 - 2010, Intel Corporation. All rights
> +reserved.<BR>
> + *  Copyright (c) 2015, Hisilicon Limited. All rights reserved.<BR>
> + *  Copyright (c) 2015, Linaro Limited. All rights reserved.<BR>
> + *  SPDX-License-Identifier: BSD-2-Clause-Patent
> + *
> + *
> +**/
> +
> +
> +/=#
> +
> +#langdef en-US "English"
> +
> +#include "Type00/MiscBiosVendor.uni"
> +#include "Type01/MiscSystemManufacturer.uni"
> +#include "Type02/MiscBaseBoardManufacturer.uni"
> +#include "Type03/MiscChassisManufacturer.uni"
> +#include "Type13/MiscNumberOfInstallableLanguages.uni"
> --
> 2.26.2
> 
> 
> 
> 
> 



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


Re: [edk2-devel] [PATCH v6 22/22] ArmPkg: Add Universal/Smbios/SmbiosMiscDxe
Posted by Leif Lindholm 3 years, 10 months ago
On Thu, Jan 14, 2021 at 09:36:28 -0700, Rebecca Cran wrote:
> SmbiosMiscDxe provides SMBIOS tables 0, 1, 2, 3, 13, and 32.
> 
> Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>

Whitespace comments only.
If addressed, please add
Reviewed-by: Leif Lindholm <leif@nuviainc.com>

> ---
>  ArmPkg/ArmPkg.dsc                                              |   1 +
>  ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDxe.inf        |  89 ++++++++
>  ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMisc.h             | 134 ++++++++++++
>  ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDataTable.c    |  62 ++++++
>  ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscEntryPoint.c   | 227 ++++++++++++++++++++
>  ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDxeStrings.uni |  22 ++
>  6 files changed, 535 insertions(+)
> 
> diff --git a/ArmPkg/ArmPkg.dsc b/ArmPkg/ArmPkg.dsc
> index fce86cb6d710..7194eb2d3c44 100644
> --- a/ArmPkg/ArmPkg.dsc
> +++ b/ArmPkg/ArmPkg.dsc
> @@ -149,6 +149,7 @@ [Components.common]
>    ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf
>  
>    ArmPkg/Universal/Smbios/ProcessorSubClassDxe/ProcessorSubClassDxe.inf
> +  ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDxe.inf
>  
>  [Components.AARCH64]
>    ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
> diff --git a/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDxe.inf b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDxe.inf
> new file mode 100644
> index 000000000000..60d8fe31c219
> --- /dev/null
> +++ b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDxe.inf
> @@ -0,0 +1,89 @@
> +#/** @file
> +# Component description file for SmbiosMisc instance.
> +#
> +# Parses the MiscSubclassDataTable and reports any generated data to the DataHub.
> +#  All .uni file who tagged with "ToolCode="DUMMY"" in following file list is included by
> +#  MiscSubclassDriver.uni file, the StrGather tool will expand MiscSubclassDriver.uni file
> +#  and parse all .uni file.
> +#
> +# Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
> +# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
> +# Copyright (c) 2015, Hisilicon Limited. All rights reserved.<BR>
> +# Copyright (c) 2015, Linaro Limited. All rights reserved.<BR>
> +#
> +#  SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +#
> +# Based on files under Nt32Pkg/MiscSubClassPlatformDxe/
> +#**/
> +
> +
> +[Defines]
> +  INF_VERSION                    = 1.29
> +  BASE_NAME                      = SmbiosMiscDxe
> +  FILE_GUID                      = 7e5e26d4-0be9-401f-b5e1-1c2bda7ca777
> +  MODULE_TYPE                    = DXE_DRIVER
> +  VERSION_STRING                 = 1.0
> +  ENTRY_POINT                    = SmbiosMiscEntryPoint
> +
> +[Sources]
> +  SmbiosMisc.h
> +  SmbiosMiscDataTable.c
> +  SmbiosMiscEntryPoint.c
> +  SmbiosMiscDxeStrings.uni
> +  Type00/MiscBiosVendorData.c
> +  Type00/MiscBiosVendorFunction.c
> +  Type01/MiscSystemManufacturerData.c
> +  Type01/MiscSystemManufacturerFunction.c
> +  Type02/MiscBaseBoardManufacturerData.c
> +  Type02/MiscBaseBoardManufacturerFunction.c
> +  Type03/MiscChassisManufacturerData.c
> +  Type03/MiscChassisManufacturerFunction.c
> +  Type13/MiscNumberOfInstallableLanguagesData.c
> +  Type13/MiscNumberOfInstallableLanguagesFunction.c
> +  Type32/MiscBootInformationData.c
> +  Type32/MiscBootInformationFunction.c
> +
> +[Packages]
> +  ArmPkg/ArmPkg.dec
> +  MdeModulePkg/MdeModulePkg.dec
> +  MdePkg/MdePkg.dec
> +
> +[LibraryClasses]
> +  BaseLib
> +  BaseMemoryLib
> +  DebugLib
> +  DevicePathLib
> +  PcdLib
> +  HiiLib
> +  HobLib
> +  MemoryAllocationLib
> +  OemMiscLib
> +  UefiBootServicesTableLib
> +  UefiDriverEntryPoint
> +  UefiLib
> +  UefiRuntimeServicesTableLib
> +
> +[Protocols]
> +  gEfiSmbiosProtocolGuid                       # PROTOCOL ALWAYS_CONSUMED
> +
> +[Pcd]
> +  gArmTokenSpaceGuid.PcdFdSize
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVendor
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString
> +  gArmTokenSpaceGuid.PcdSystemBiosRelease
> +  gArmTokenSpaceGuid.PcdEmbeddedControllerFirmwareRelease
> +  gArmTokenSpaceGuid.PcdSystemProductName
> +  gArmTokenSpaceGuid.PcdSystemVersion
> +  gArmTokenSpaceGuid.PcdBaseBoardManufacturer
> +  gArmTokenSpaceGuid.PcdBaseBoardProductName
> +  gArmTokenSpaceGuid.PcdBaseBoardVersion
> +  gArmTokenSpaceGuid.PcdFdBaseAddress
> +
> +[Guids]
> +  gEfiGenericVariableGuid
> +
> +[Depex]
> +  gEfiSmbiosProtocolGuid
> +
> +
> diff --git a/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMisc.h b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMisc.h
> new file mode 100644
> index 000000000000..4fd37c4cdc0b
> --- /dev/null
> +++ b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMisc.h
> @@ -0,0 +1,134 @@
> +/** @file
> +  Header file for the SmbiosMisc Driver.
> +
> +  Based on files under Nt32Pkg/MiscSubClassPlatformDxe/
> +
> +  Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
> +  Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
> +  Copyright (c) 2015, Hisilicon Limited. All rights reserved.<BR>
> +  Copyright (c) 2015, Linaro Limited. All rights reserved.<BR>
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef SMBIOS_MISC_H_
> +#define SMBIOS_MISC_H_
> +
> +#include <Protocol/Smbios.h>
> +#include <IndustryStandard/SmBios.h>
> +
> +//
> +// Data table entry update function.
> +//
> +typedef EFI_STATUS (EFIAPI SMBIOS_MISC_DATA_FUNCTION) (
> +  IN  VOID                 *RecordData,
> +  IN  EFI_SMBIOS_PROTOCOL  *Smbios
> +  );
> +
> +
> +//
> +// Data table entry definition.
> +//
> +typedef struct {
> +  //
> +  // intermediate input data for SMBIOS record
> +  //
> +  VOID                          *RecordData;
> +  SMBIOS_MISC_DATA_FUNCTION     *Function;
> +} SMBIOS_MISC_DATA_TABLE;
> +
> +
> +//
> +// SMBIOS table extern definitions
> +//
> +#define SMBIOS_MISC_TABLE_EXTERNS(NAME1, NAME2, NAME3) \
> +extern NAME1 NAME2 ## Data; \
> +extern SMBIOS_MISC_DATA_FUNCTION NAME3 ## Function;
> +
> +
> +//
> +// SMBIOS data table entries
> +//
> +// This is used to define a pair of table structure pointer and functions
> +// in order to iterate through the list of tables, populate them and add
> +// them into the system.
> +#define SMBIOS_MISC_TABLE_ENTRY_DATA_AND_FUNCTION(NAME1, NAME2) \
> +{ \
> +  & NAME1 ## Data, \
> +    NAME2 ## Function \
> +}
> +
> +//
> +// Global definition macros.
> +//
> +#define SMBIOS_MISC_TABLE_DATA(NAME1, NAME2) \
> +  NAME1 NAME2 ## Data
> +
> +#define SMBIOS_MISC_TABLE_FUNCTION(NAME2) \
> +  EFI_STATUS EFIAPI NAME2 ## Function( \
> +  IN  VOID                  *RecordData, \
> +  IN  EFI_SMBIOS_PROTOCOL   *Smbios \
> +  )
> +
> +//
> +// Data Table Array Entries
> +//
> +extern EFI_HII_HANDLE               mSmbiosMiscHiiHandle;
> +
> +typedef struct _SMBIOS_TYPE13_BIOS_LANGUAGE_INFORMATION_STRING{
> +  UINT8                               *LanguageSignature;
> +  EFI_STRING_ID                       InstallableLanguageLongString;
> +  EFI_STRING_ID                       InstallableLanguageAbbreviateString;
> +} SMBIOS_TYPE13_BIOS_LANGUAGE_INFORMATION_STRING;
> +
> +
> +/**
> +  Adds an SMBIOS record.
> +
> +  @param  Buffer        The data for the SMBIOS record.
> +                        The format of the record is determined by
> +                        EFI_SMBIOS_TABLE_HEADER.Type. The size of the
> +                        formatted area is defined by EFI_SMBIOS_TABLE_HEADER.Length
> +                        and either followed by a double-null (0x0000) or a set
> +                        of null terminated strings and a null.
> +  @param  SmbiosHandle  A unique handle will be assigned to the SMBIOS record
> +                        if not NULL.
> +
> +  @retval EFI_SUCCESS           Record was added.
> +  @retval EFI_OUT_OF_RESOURCES  Record was not added due to lack of system resources.
> +  @retval EFI_ALREADY_STARTED   The SmbiosHandle passed in was already in use.
> +
> +**/
> +EFI_STATUS
> +SmbiosMiscAddRecord (
> +  IN       UINT8                      *Buffer,
> +  IN  OUT  EFI_SMBIOS_HANDLE          *SmbiosHandle OPTIONAL
> +  );
> +
> +/**
> + Get Link Type Handle.
> +
> + @param [in]   SmbiosType     Get this Type from SMBIOS table
> + @param [out]  HandleArray    Pointer to handle array which will be freed by caller
> + @param [out]  HandleCount    Pointer to handle count
> +
> +**/
> +VOID
> +SmbiosMiscGetLinkTypeHandle(
> +  IN  UINT8                 SmbiosType,
> +  OUT UINT16                **HandleArray,
> +  OUT UINTN                 *HandleCount
> +  );
> +
> +//
> +// Data Table Array
> +//
> +extern SMBIOS_MISC_DATA_TABLE   mSmbiosMiscDataTable[];
> +
> +//
> +// Data Table Array Entries
> +//
> +extern UINTN   mSmbiosMiscDataTableEntries;
> +extern UINT8   mSmbiosMiscDxeStrings[];
> +
> +#endif // SMBIOS_MISC_H_
> diff --git a/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDataTable.c b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDataTable.c
> new file mode 100644
> index 000000000000..ac16c3a2688e
> --- /dev/null
> +++ b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDataTable.c
> @@ -0,0 +1,62 @@
> +/** @file
> +  This file provides SMBIOS Misc Type.
> +
> +  Based on files under Nt32Pkg/MiscSubClassPlatformDxe/
> +
> +  Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
> +  Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
> +  Copyright (c) 2015, Hisilicon Limited. All rights reserved.<BR>
> +  Copyright (c) 2015, Linaro Limited. All rights reserved.<BR>
> +  SPDX-License-Identifier: BSD-2-Clause-Patent\
> +
> +**/
> +
> +#include "SmbiosMisc.h"
> +
> +SMBIOS_MISC_TABLE_EXTERNS (SMBIOS_TABLE_TYPE0,
> +                           MiscBiosVendor,
> +                           MiscBiosVendor)
> +SMBIOS_MISC_TABLE_EXTERNS (SMBIOS_TABLE_TYPE1,
> +                           MiscSystemManufacturer,
> +                           MiscSystemManufacturer)
> +SMBIOS_MISC_TABLE_EXTERNS (SMBIOS_TABLE_TYPE3,
> +                          MiscChassisManufacturer,
> +                          MiscChassisManufacturer)
> +SMBIOS_MISC_TABLE_EXTERNS (SMBIOS_TABLE_TYPE2,
> +                           MiscBaseBoardManufacturer,
> +                           MiscBaseBoardManufacturer)
> +SMBIOS_MISC_TABLE_EXTERNS (SMBIOS_TABLE_TYPE13,
> +                           MiscNumberOfInstallableLanguages,
> +                           MiscNumberOfInstallableLanguages)
> +SMBIOS_MISC_TABLE_EXTERNS (SMBIOS_TABLE_TYPE32,
> +                           MiscBootInformation,
> +                           MiscBootInformation)
> +
> +
> +SMBIOS_MISC_DATA_TABLE mSmbiosMiscDataTable[] = {
> +  // Type0
> +  SMBIOS_MISC_TABLE_ENTRY_DATA_AND_FUNCTION (MiscBiosVendor,
> +                                             MiscBiosVendor),
> +  // Type1
> +  SMBIOS_MISC_TABLE_ENTRY_DATA_AND_FUNCTION (MiscSystemManufacturer,
> +                                             MiscSystemManufacturer),
> +  // Type3
> +  SMBIOS_MISC_TABLE_ENTRY_DATA_AND_FUNCTION (MiscChassisManufacturer,
> +                                             MiscChassisManufacturer),
> +  // Type2
> +  SMBIOS_MISC_TABLE_ENTRY_DATA_AND_FUNCTION (MiscBaseBoardManufacturer,
> +                                             MiscBaseBoardManufacturer),
> +  // Type13
> +  SMBIOS_MISC_TABLE_ENTRY_DATA_AND_FUNCTION (MiscNumberOfInstallableLanguages,
> +                                             MiscNumberOfInstallableLanguages),
> +  // Type32
> +  SMBIOS_MISC_TABLE_ENTRY_DATA_AND_FUNCTION (MiscBootInformation,
> +                                             MiscBootInformation),
> +};
> +
> +
> +//
> +// Number of Data Table entries.
> +//
> +UINTN mSmbiosMiscDataTableEntries =
> +  (sizeof (mSmbiosMiscDataTable)) / sizeof (SMBIOS_MISC_DATA_TABLE);
> diff --git a/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscEntryPoint.c b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscEntryPoint.c
> new file mode 100644
> index 000000000000..37e79d285e57
> --- /dev/null
> +++ b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscEntryPoint.c
> @@ -0,0 +1,227 @@
> +/** @file
> +  This driver parses the mSmbiosMiscDataTable structure and reports
> +  any generated data using SMBIOS protocol.
> +
> +  Based on files under Nt32Pkg/MiscSubClassPlatformDxe/
> +
> +  Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
> +  Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
> +  Copyright (c) 2015, Hisilicon Limited. All rights reserved.<BR>
> +  Copyright (c) 2015, Linaro Limited. All rights reserved.<BR>
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <Library/BaseLib.h>
> +#include <Library/BaseMemoryLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/HiiLib.h>
> +#include <Library/MemoryAllocationLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +
> +#include "SmbiosMisc.h"
> +
> +
> +STATIC EFI_HANDLE           mSmbiosMiscImageHandle;
> +STATIC EFI_SMBIOS_PROTOCOL  *mSmbiosMiscSmbios = NULL;
> +
> +EFI_HII_HANDLE       mSmbiosMiscHiiHandle;
> +
> +/**
> +  Standard EFI driver point.  This driver parses the mSmbiosMiscDataTable
> +  structure and reports any generated data using SMBIOS protocol.
> +
> +  @param  ImageHandle     Handle for the image of this driver
> +  @param  SystemTable     Pointer to the EFI System Table
> +
> +  @retval  EFI_SUCCESS    The data was successfully stored.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +SmbiosMiscEntryPoint(
> +  IN EFI_HANDLE         ImageHandle,
> +  IN EFI_SYSTEM_TABLE   *SystemTable
> +  )
> +{
> +  UINTN                Index;
> +  EFI_STATUS           EfiStatus;
> +
> +  mSmbiosMiscImageHandle = ImageHandle;
> +
> +  EfiStatus = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL,
> +                                   (VOID**)&mSmbiosMiscSmbios);
> +  if (EFI_ERROR (EfiStatus)) {
> +    DEBUG ((DEBUG_ERROR, "Could not locate SMBIOS protocol.  %r\n", EfiStatus));
> +    return EfiStatus;
> +  }
> +
> +  mSmbiosMiscHiiHandle = HiiAddPackages (
> +                 &gEfiCallerIdGuid,
> +                  mSmbiosMiscImageHandle,
> +                  SmbiosMiscDxeStrings,
> +                  NULL
> +                  );

Indentation.

> +  if (mSmbiosMiscHiiHandle == NULL) {
> +    return EFI_OUT_OF_RESOURCES;
> +  }
> +
> +  for (Index = 0; Index < mSmbiosMiscDataTableEntries; ++Index) {
> +    //
> +    // If the entry have a function pointer, just log the data.
> +    //
> +    if (mSmbiosMiscDataTable[Index].Function != NULL) {
> +      EfiStatus = (*mSmbiosMiscDataTable[Index].Function)(
> +          mSmbiosMiscDataTable[Index].RecordData,
> +          mSmbiosMiscSmbios
> +          );

Indentation.

> +
> +      if (EFI_ERROR(EfiStatus)) {
> +        DEBUG ((DEBUG_ERROR, "Misc smbios store error.  Index=%d,"
> +                "ReturnStatus=%r\n", Index, EfiStatus));
> +        return EfiStatus;
> +      }
> +    }
> +  }
> +
> +  return EfiStatus;
> +}
> +
> +
> +/**
> +  Adds an SMBIOS record.
> +
> +  @param  Buffer        The data for the SMBIOS record.
> +                        The format of the record is determined by
> +                        EFI_SMBIOS_TABLE_HEADER.Type. The size of the
> +                        formatted area is defined by EFI_SMBIOS_TABLE_HEADER.Length
> +                        and either followed by a double-null (0x0000) or a set
> +                        of null terminated strings and a null.
> +  @param  SmbiosHandle  A unique handle will be assigned to the SMBIOS record
> +                        if not NULL.
> +
> +  @retval EFI_SUCCESS           Record was added.
> +  @retval EFI_OUT_OF_RESOURCES  Record was not added due to lack of system resources.
> +  @retval EFI_ALREADY_STARTED   The SmbiosHandle passed in was already in use.
> +
> +**/
> +EFI_STATUS
> +SmbiosMiscAddRecord (
> +  IN  UINT8                 *Buffer,
> +  IN OUT EFI_SMBIOS_HANDLE  *SmbiosHandle OPTIONAL
> +  )
> +{
> +  EFI_STATUS         Status;
> +  EFI_SMBIOS_HANDLE  Handle;
> +
> +  Handle = SMBIOS_HANDLE_PI_RESERVED;
> +
> +  if (SmbiosHandle != NULL) {
> +    Handle = *SmbiosHandle;
> +  }
> +
> +  Status = mSmbiosMiscSmbios->Add (
> +             mSmbiosMiscSmbios,
> +             NULL,
> +             &Handle,
> +             (EFI_SMBIOS_TABLE_HEADER *)Buffer
> +             );
> +
> +  if (SmbiosHandle != NULL) {
> +    *SmbiosHandle = Handle;
> +  }
> +
> +  return Status;
> +}
> +
> +
> +/** Fetches the number of handles of the specified SMBIOS type
> + *
> + *  @param SmbiosType The type of SMBIOS record to look for
> + *
> + *  @return The number of handles
> + *
> +**/
> +STATIC
> +UINTN
> +GetHandleCount (
> +  IN  UINT8 SmbiosType
> +  )
> +{
> +  UINTN                    HandleCount;
> +  EFI_STATUS               Status;
> +  EFI_SMBIOS_HANDLE        SmbiosHandle;
> +  EFI_SMBIOS_TABLE_HEADER  *Record;
> +
> +  HandleCount = 0;
> +
> +  // Iterate through entries to get the number
> +  do {
> +    Status = mSmbiosMiscSmbios->GetNext (
> +                        mSmbiosMiscSmbios,
> +                        &SmbiosHandle,
> +                        &SmbiosType,
> +                        &Record,
> +                        NULL
> +                        );

Indentation.

> +
> +    if (Status == EFI_SUCCESS) {
> +      HandleCount++;
> +    }
> +  } while (!EFI_ERROR (Status));
> +
> +  return HandleCount;
> +}
> +
> +/**
> +  Fetches a list of the specified SMBIOS table types.
> +
> +  @param[in]  SmbiosType    The type of table to fetch
> +  @param[out] **HandleArray The array of handles
> +  @param[out] *HandleCount  Number of handles in the array
> +**/
> +VOID
> +SmbiosMiscGetLinkTypeHandle(
> +  IN  UINT8                 SmbiosType,
> +  OUT SMBIOS_HANDLE         **HandleArray,
> +  OUT UINTN                 *HandleCount
> +  )
> +{
> +  UINTN                    Index;
> +  EFI_STATUS               Status;
> +  EFI_SMBIOS_HANDLE        SmbiosHandle;
> +  EFI_SMBIOS_TABLE_HEADER  *Record;
> +
> +  if (mSmbiosMiscSmbios == NULL) {
> +    return;
> +  }
> +
> +  SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
> +  *HandleCount = GetHandleCount (SmbiosType);
> +
> +  *HandleArray = AllocateZeroPool (sizeof (SMBIOS_HANDLE) * (*HandleCount));
> +  if (*HandleArray == NULL) {
> +    DEBUG ((DEBUG_ERROR, "HandleArray allocate memory resource failed.\n"));
> +    *HandleCount = 0;
> +    return;
> +  }
> +
> +  SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
> +
> +  for (Index = 0; Index < (*HandleCount); Index++) {
> +    Status = mSmbiosMiscSmbios->GetNext (
> +                        mSmbiosMiscSmbios,
> +                        &SmbiosHandle,
> +                        &SmbiosType,
> +                        &Record,
> +                        NULL
> +                        );

Indentation.

/
    Leif

> +
> +    if (!EFI_ERROR (Status)) {
> +      (*HandleArray)[Index] = Record->Handle;
> +    } else {
> +      break;
> +    }
> +  }
> +}
> +
> diff --git a/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDxeStrings.uni b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDxeStrings.uni
> new file mode 100644
> index 000000000000..6f877e706922
> --- /dev/null
> +++ b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDxeStrings.uni
> @@ -0,0 +1,22 @@
> +/** @file
> + *  Based on files under Nt32Pkg/MiscSubClassPlatformDxe/
> + *
> + *  Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
> + *  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
> + *  Copyright (c) 2015, Hisilicon Limited. All rights reserved.<BR>
> + *  Copyright (c) 2015, Linaro Limited. All rights reserved.<BR>
> + *  SPDX-License-Identifier: BSD-2-Clause-Patent
> + *
> + *
> +**/
> +
> +
> +/=#
> +
> +#langdef en-US "English"
> +
> +#include "Type00/MiscBiosVendor.uni"
> +#include "Type01/MiscSystemManufacturer.uni"
> +#include "Type02/MiscBaseBoardManufacturer.uni"
> +#include "Type03/MiscChassisManufacturer.uni"
> +#include "Type13/MiscNumberOfInstallableLanguages.uni"
> -- 
> 2.26.2
> 


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