Branch: refs/heads/master
  Home:   https://github.com/tianocore/edk2
  Commit: 9b94ebb0c826ad9a747f93ee351d5d076e920f6e
      
https://github.com/tianocore/edk2/commit/9b94ebb0c826ad9a747f93ee351d5d076e920f6e
  Author: Sami Mujawar <sami.muja...@arm.com>
  Date:   2023-03-10 (Fri, 10 Mar 2023)

  Changed paths:
    M DynamicTablesPkg/DynamicTables.dsc.inc
    M DynamicTablesPkg/DynamicTablesPkg.dec
    M DynamicTablesPkg/DynamicTablesPkg.dsc
    A DynamicTablesPkg/Include/Library/SmbiosStringTableLib.h
    A 
DynamicTablesPkg/Library/Common/SmbiosStringTableLib/SmbiosStringTableLib.c
    A 
DynamicTablesPkg/Library/Common/SmbiosStringTableLib/SmbiosStringTableLib.inf

  Log Message:
  -----------
  DynamicTablesPkg: Add SMBIOS String table helper library

The Section 6.1.3, SMBIOS specification version 3.6.0 describes the
handling of test strings in SMBIOS tables.

Text strings are added at the end of the formatted portion of the SMBIOS
structure and are referenced by index in the SMBIOS structure.

Therefore, introduce a SmbiosStringTableLib to simplify the publishing
of the string set.

SmbiosStringTableLib introduces a concept of string table which records
the references to the SMBIOS strings as they are added and returns an
string reference which is then assigned to the string field in the
formatted portion of the SMBIOS structure. Once all strings are added,
the library provides an interface to get the required size for the string
set. This allows sufficient memory to be allocated for the SMBIOS table.
The library also provides an interface to publish the string set in
accordance with the SMBIOS specification.

Example:
EFI_STATUS
BuildSmbiosType17Table () {
  STRING_TABLE         StrTable;
  UINT8                DevLocatorRef;
  UINT8                BankLocatorRef;
  SMBIOS_TABLE_TYPE17  *SmbiosRecord;
  CHAR8                *StringSet;
  ...

  // Initialize string table for 7 strings
  StringTableInitialize (&StrTable, 7);

  StringTableAddString (&StrTable, "SIMM 3", &DevLocatorRef);
  StringTableAddString (&StrTable, "Bank 0", &BankLocatorRef);
  ...

  SmbiosRecord = AllocateZeroPool (
                   sizeof (SMBIOS_TABLE_TYPE17) +
                     StringTableGetStringSetSize (&StrTable)
                   );
  ...
  SmbiosRecord->DeviceLocator = DevLocatorRef;
  SmbiosRecord->BankLocator = BankLocatorRef;
  ...
  // get the string set area
  StringSet = (CHAR8*)(SmbiosRecord + 1);

  // publish the string set
  StringTablePublishStringSet (
    &StrTable,
    StringSet,
    StringTableGetStringSetSize (&StrTable)
    );

  // free string table
  StringTableFree (&StrTable);

  return EFI_SUCCESS;
}

Signed-off-by: Sami Mujawar <sami.muja...@arm.com>
Reviewed-by: Pierre Gondois <pierre.gond...@arm.com>
Cc: Alexei Fedorov <alexei.fedo...@arm.com>
Cc: Pierre Gondois <pierre.gond...@arm.com>
Cc: Girish Mahadevan <gmahade...@nvidia.com>
Cc: Jeff Brasen <jbra...@nvidia.com>
Cc: Ashish Singhal <ashishsin...@nvidia.com>
Cc: Nick Ramirez <nrami...@nvidia.com>
Cc: William Watson <wwat...@nvidia.com>
Cc: Samer El-Haj-Mahmoud <samer.el-haj-mahm...@arm.com>




_______________________________________________
edk2-commits mailing list
edk2-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to