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