public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [staging/dynamictables-reorg PATCH v0 00/12] DynamicTablesPkg: Add SMBIOS table generation support
@ 2025-02-05 22:08 Girish Mahadevan via groups.io
  2025-02-05 22:08 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 01/12] DynamicTablesPkg: SmbiosStringLib: Add new helper macro Girish Mahadevan via groups.io
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: Girish Mahadevan via groups.io @ 2025-02-05 22:08 UTC (permalink / raw)
  To: sami.mujawar, Alexei.Fedorov, pierre.gondois, abner.chang,
	Samer.El-Haj-Mahmoud, Jose.Marinho
  Cc: gmahadevan, jbrasen, ashishsingha, nramirez, devel

Initial Set of patches to add SMBIOS table generation to DynamicTablesPkg.
This includes generators for Type16, 17 and 19.
These patches have been based off of dynamictables-reorg branch in edk2-staging.

PR: https://github.com/tianocore/edk2-staging/pull/510

Girish Mahadevan (8):
  DynamicTablesPkg: SmbiosStringLib: Add new helper macro
  DynamicTablesPkg: Add extern call to build SMBIOS table
  DynamicTablesPkg: Add SMBIOS table generation
  DynamicTablesPkg: Split the ACPI and SMBIOS table generators
  DynamicTablesPkg: Introduce new namespace for SMBIOS Objects
  DynamicTablesPkg: Smbios Memory Device (Type 17)
  DynamicTablesPkg: Smbios Physical Memory Array (Type 16)
  DynamicTablesPkg: Smbios Memory Array Mapped Address (Type 19)

Sami Mujawar (4):
  DynamicTablesPkg: Define a SMBIOS Structure/Table type
  DynamicTablesPkg: Add SMBIOS table dispatcher
  DynamicTablesPkg: Update SMBIOS dispatcher dependency table
  DynamicTablesPkg: Add Ordered dispatch support for SMBIOS tables

 .../DynamicTableFactory.h                     |   5 +
 .../DynamicTableFactoryDxe.c                  |   9 +
 .../SmbiosTableFactory/SmbiosTableFactory.c   | 107 +++
 .../DynamicTableManagerDxe/AcpiTableBuilder.c | 762 ++++++++++++++++++
 .../DynamicTableManagerDxe.c                  | 750 +----------------
 .../DynamicTableManagerDxe.inf                |  11 +-
 .../SmbiosTableBuilder.c                      | 602 ++++++++++++++
 .../SmbiosTableDispatcher.c                   | 679 ++++++++++++++++
 .../SmbiosTableDispatcher.h                   | 181 +++++
 .../Include/ConfigurationManagerObject.h      |  14 +-
 .../Include/Library/SmbiosStringTableLib.h    |  20 +
 .../Protocol/DynamicTableFactoryProtocol.h    |   9 +
 .../Include/SmbiosNameSpaceObjects.h          | 170 ++++
 .../Include/SmbiosTableGenerator.h            | 203 ++++-
 .../Include/StandardNameSpaceObjects.h        |  17 +
 .../SmbiosType16Lib/SmbiosType16Generator.c   | 361 +++++++++
 .../SmbiosType16Lib/SmbiosType16Lib.inf       |  35 +
 .../SmbiosType17Lib/SmbiosType17Generator.c   | 491 +++++++++++
 .../SmbiosType17Lib/SmbiosType17Lib.inf       |  37 +
 .../SmbiosType19Lib/SmbiosType19Generator.c   | 364 +++++++++
 .../SmbiosType19Lib/SmbiosType19Lib.inf       |  36 +
 MdePkg/Include/IndustryStandard/SmBios.h      |   8 +
 22 files changed, 4150 insertions(+), 721 deletions(-)
 create mode 100644 DynamicTablesPkg/Drivers/DynamicTableManagerDxe/AcpiTableBuilder.c
 create mode 100644 DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableBuilder.c
 create mode 100644 DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c
 create mode 100644 DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.h
 create mode 100644 DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h
 create mode 100644 DynamicTablesPkg/Library/Smbios/SmbiosType16Lib/SmbiosType16Generator.c
 create mode 100644 DynamicTablesPkg/Library/Smbios/SmbiosType16Lib/SmbiosType16Lib.inf
 create mode 100644 DynamicTablesPkg/Library/Smbios/SmbiosType17Lib/SmbiosType17Generator.c
 create mode 100644 DynamicTablesPkg/Library/Smbios/SmbiosType17Lib/SmbiosType17Lib.inf
 create mode 100644 DynamicTablesPkg/Library/Smbios/SmbiosType19Lib/SmbiosType19Generator.c
 create mode 100644 DynamicTablesPkg/Library/Smbios/SmbiosType19Lib/SmbiosType19Lib.inf

-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#121085): https://edk2.groups.io/g/devel/message/121085
Mute This Topic: https://groups.io/mt/111022001/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 13+ messages in thread

* [edk2-devel] [staging/dynamictables-reorg PATCH v0 01/12] DynamicTablesPkg: SmbiosStringLib: Add new helper macro
  2025-02-05 22:08 [edk2-devel] [staging/dynamictables-reorg PATCH v0 00/12] DynamicTablesPkg: Add SMBIOS table generation support Girish Mahadevan via groups.io
@ 2025-02-05 22:08 ` Girish Mahadevan via groups.io
  2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 02/12] DynamicTablesPkg: Define a SMBIOS Structure/Table type Girish Mahadevan via groups.io
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Girish Mahadevan via groups.io @ 2025-02-05 22:08 UTC (permalink / raw)
  To: sami.mujawar, Alexei.Fedorov, pierre.gondois, abner.chang,
	Samer.El-Haj-Mahmoud, Jose.Marinho
  Cc: gmahadevan, jbrasen, ashishsingha, nramirez, devel

Add a new helper macro which is a wrapper over StringTableAddString().
It adds a string to the string table, and if the string is NULL or empty,
add "" string instead.

Signed-off-by: Dat Mach <dmach@nvidia.com>
Signed-off-by: Nick Ramirez <nramirez@nvidia.com>
Signed-off-by: Girish Mahadevan <gmahadevan@nvidia.com>
---
 .../Include/Library/SmbiosStringTableLib.h    | 20 +++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/DynamicTablesPkg/Include/Library/SmbiosStringTableLib.h b/DynamicTablesPkg/Include/Library/SmbiosStringTableLib.h
index fb183d427f..b95d83f457 100644
--- a/DynamicTablesPkg/Include/Library/SmbiosStringTableLib.h
+++ b/DynamicTablesPkg/Include/Library/SmbiosStringTableLib.h
@@ -2,6 +2,7 @@
   SMBIOS String Table Helper library.

 

   Copyright (c) 2022, Arm Limited. All rights reserved.<BR>

+

   SPDX-License-Identifier: BSD-2-Clause-Patent

 **/

 

@@ -116,4 +117,23 @@ StringTableFree (
   IN STRING_TABLE *CONST  StrTable

   );

 

+/** STRING_TABLE_ADD_STRING macro is the wrapper over StringTableAddString().

+    It adds a string to the string table, and if the string is NULL or empty,

+    add "" string instead.

+

+  @param [IN]   StrTable  Pointer to the string table

+  @param [IN]   Str       Pointer to the string

+  @param [OUT]  StrRef    The string field reference of the added string

+**/

+#define STRING_TABLE_ADD_STRING(StrTable, String, StringRef)              \

+  StringRef = 0;                                                          \

+  if ((String != NULL) && (String[0] != '\0')) {                          \

+    Status = StringTableAddString (&StrTable, String, &StringRef);        \

+  } else {                                                                \

+    Status = StringTableAddString (&StrTable, "", &StringRef);     \

+  }                                                                       \

+  if (EFI_ERROR (Status)) {                                               \

+    DEBUG ((DEBUG_ERROR, "Failed to add "#String" string %r\n", Status)); \

+  }                                                                       \

+

 #endif // SMBIOS_STRING_TABLE_H_

-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#121084): https://edk2.groups.io/g/devel/message/121084
Mute This Topic: https://groups.io/mt/111022000/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [edk2-devel] [staging/dynamictables-reorg PATCH v0 02/12] DynamicTablesPkg: Define a SMBIOS Structure/Table type
  2025-02-05 22:08 [edk2-devel] [staging/dynamictables-reorg PATCH v0 00/12] DynamicTablesPkg: Add SMBIOS table generation support Girish Mahadevan via groups.io
  2025-02-05 22:08 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 01/12] DynamicTablesPkg: SmbiosStringLib: Add new helper macro Girish Mahadevan via groups.io
@ 2025-02-05 22:09 ` Girish Mahadevan via groups.io
  2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 03/12] DynamicTablesPkg: Add SMBIOS table dispatcher Girish Mahadevan via groups.io
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Girish Mahadevan via groups.io @ 2025-02-05 22:09 UTC (permalink / raw)
  To: sami.mujawar, Alexei.Fedorov, pierre.gondois, abner.chang,
	Samer.El-Haj-Mahmoud, Jose.Marinho
  Cc: gmahadevan, jbrasen, ashishsingha, nramirez, devel

From: Sami Mujawar <sami.mujawar@arm.com>

SMBIOS Structure Types 0 through 127 (7Fh) are reserved
for and defined by the SMBIOS specification. Types 128
through 256 (80h to FFh) are available for system and
OEM-specific information.

Therefore, define a new type 'SMBIOS_TABLE_TYPE' that
represents a SMBIOS structure type and include it in
the definition of CM_STD_OBJ_SMBIOS_TABLE_INFO.

Acked-by: Abner Chang <abner.chang@amd.com>
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
Cc: Alexei Fedorov <Alexei.Fedorov@arm.com>
Cc: Pierre Gondois <pierre.gondois@arm.com>
Cc: Girish Mahadevan <gmahadevan@nvidia.com>
Cc: Jeff Brasen <jbrasen@nvidia.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com>
Cc: Nick Ramirez <nramirez@nvidia.com>
Cc: William Watson <wwatson@nvidia.com>
Cc: Abner Chang <abner.chang@amd.com>
Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
Cc: Jose Marinho <Jose.Marinho@arm.com>
---
 .../Include/StandardNameSpaceObjects.h          | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/DynamicTablesPkg/Include/StandardNameSpaceObjects.h b/DynamicTablesPkg/Include/StandardNameSpaceObjects.h
index 8ec3238225..c81efbc237 100644
--- a/DynamicTablesPkg/Include/StandardNameSpaceObjects.h
+++ b/DynamicTablesPkg/Include/StandardNameSpaceObjects.h
@@ -40,6 +40,20 @@
 **/

 typedef UINTN CM_OBJECT_TOKEN;

 

+/**

+  A type representing a SMBIOS structure/table type.

+

+  Types 0 through 127 (7Fh) are reserved for and defined by the

+  SMBIOS specification.

+  Types 128 through 256 (80h to FFh) are available for system and

+  OEM-specific information.

+

+  Note: This Dynamic SMBIOS table generation implementation defines

+  TableType FFh as a NULL table which is used by the Dynamic

+  SMBIOS table dispatcher to terminate the dependency sequence.

+*/

+typedef UINT8 SMBIOS_TABLE_TYPE;

+

 /** The ESTD_OBJECT_ID enum describes the Object IDs

     in the Standard Namespace.

 */

@@ -127,6 +141,9 @@ typedef struct CmAStdObjAcpiTableInfo {
   to NULL.

 */

 typedef struct CmStdObjSmbiosTableInfo {

+  /// SMBIOS Structure/Table Type

+  SMBIOS_TABLE_TYPE            TableType;

+

   /// The SMBIOS Table Generator ID

   SMBIOS_TABLE_GENERATOR_ID    TableGeneratorId;

 

-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#121086): https://edk2.groups.io/g/devel/message/121086
Mute This Topic: https://groups.io/mt/111022002/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [edk2-devel] [staging/dynamictables-reorg PATCH v0 03/12] DynamicTablesPkg: Add SMBIOS table dispatcher
  2025-02-05 22:08 [edk2-devel] [staging/dynamictables-reorg PATCH v0 00/12] DynamicTablesPkg: Add SMBIOS table generation support Girish Mahadevan via groups.io
  2025-02-05 22:08 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 01/12] DynamicTablesPkg: SmbiosStringLib: Add new helper macro Girish Mahadevan via groups.io
  2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 02/12] DynamicTablesPkg: Define a SMBIOS Structure/Table type Girish Mahadevan via groups.io
@ 2025-02-05 22:09 ` Girish Mahadevan via groups.io
  2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 04/12] DynamicTablesPkg: Add extern call to build SMBIOS table Girish Mahadevan via groups.io
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Girish Mahadevan via groups.io @ 2025-02-05 22:09 UTC (permalink / raw)
  To: sami.mujawar, Alexei.Fedorov, pierre.gondois, abner.chang,
	Samer.El-Haj-Mahmoud, Jose.Marinho
  Cc: gmahadevan, jbrasen, ashishsingha, nramirez, devel

From: Sami Mujawar <sami.mujawar@arm.com>

Some SMBIOS structure/table fields have dependency on other SMBIOS
structures/tables. These dependencies are established using handles
pointing to the dependent tables.

A SMBIOS table handle can be obtained by either installing a SMBIOS
table or by allocating a handle, which requires complex management
to avoid any clashes.

Obtaining a SMBIOS handle by installation requires that the dependent
table is installed before the parent SMBIOS table can be installed.
Therefore, introduce a SMBIOS table dispatcher that walks the SMBIOS
dependency list and schedules the dependent tables to be installed
before the parent table is installed.

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
Cc: Alexei Fedorov <Alexei.Fedorov@arm.com>
Cc: Pierre Gondois <pierre.gondois@arm.com>
Cc: Girish Mahadevan <gmahadevan@nvidia.com>
Cc: Jeff Brasen <jbrasen@nvidia.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com>
Cc: Nick Ramirez <nramirez@nvidia.com>
Cc: William Watson <wwatson@nvidia.com>
Cc: Abner Chang <abner.chang@amd.com>
Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
Cc: Jose Marinho <Jose.Marinho@arm.com>
---
 .../DynamicTableManagerDxe.inf                |   4 +-
 .../SmbiosTableDispatcher.c                   | 282 ++++++++++++++++++
 .../SmbiosTableDispatcher.h                   | 159 ++++++++++
 3 files changed, 444 insertions(+), 1 deletion(-)
 create mode 100644 DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c
 create mode 100644 DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.h

diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf
index 00d03e75be..56b35d4fb0 100644
--- a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf
+++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf
@@ -1,7 +1,7 @@
 ## @file

 # Module that drives the table generation and installation process.

 #

-#  Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.

+#  Copyright (c) 2017 - 2022, Arm Limited. All rights reserved.

 #

 #  SPDX-License-Identifier: BSD-2-Clause-Patent

 ##

@@ -23,6 +23,8 @@
 [Sources]

   DynamicTableManagerDxe.c

   DynamicTableManagerDxe.h

+  SmbiosTableDispatcher.c

+  SmbiosTableDispatcher.h

 

 [Sources.ARM, Sources.AARCH64]

   Arm/ArmDynamicTableManager.c

diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c
new file mode 100644
index 0000000000..0e728538d9
--- /dev/null
+++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c
@@ -0,0 +1,282 @@
+/** @file

+  Dynamic Smbios Table Dispatcher

+

+  Copyright (c) 2022 - 2023, Arm Limited. All rights reserved.

+

+  SPDX-License-Identifier: BSD-2-Clause-Patent

+

+**/

+#include <Library/DebugLib.h>

+#include <Protocol/Smbios.h>

+

+#include <Include/StandardNameSpaceObjects.h>

+#include <SmbiosTableDispatcher.h>

+

+/**

+  The SMBIOS dispatcher state table.

+

+  The SMBIOS dispatcher state table is used to establish the dependency

+  order in which the SMBIOS tables are installed. This allows the SMBIOS

+  dispatcher to dispatch the dependent tables for installation before the

+  parent table is installed.

+  The SMBIOS_TABLE_DISPATCHER.Dependency[] field is used to establish the

+  dependency list.

+  Elements in the Dependency list are resolved by increasing index. However,

+  all orders are equivalent as:

+  - the Parent SMBIOS table will only be installed once all dependencies

+    have been satisfied.

+  - no cyclic dependency is allowed.

+  The dependency list is terminated by SMTT_NULL.

+*/

+STATIC

+SMBIOS_TABLE_DISPATCHER  mSmBiosDispatcher[MAX_SMBIOS_TABLES] = {

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_BIOS_INFORMATION,                     SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_INFORMATION,                   SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_BASEBOARD_INFORMATION,                SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_ENCLOSURE,                     SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_PROCESSOR_INFORMATION,                SMBIOS_TYPE_CACHE_INFORMATION,              SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MEMORY_CONTROLLER_INFORMATION,        SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MEMORY_MODULE_INFORMATON,             SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_CACHE_INFORMATION,                    SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_PORT_CONNECTOR_INFORMATION,           SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_SLOTS,                         SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_ONBOARD_DEVICE_INFORMATION,           SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_OEM_STRINGS,                          SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_CONFIGURATION_OPTIONS,         SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_BIOS_LANGUAGE_INFORMATION,            SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_GROUP_ASSOCIATIONS,                   SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_EVENT_LOG,                     SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY,                SMBIOS_TYPE_32BIT_MEMORY_ERROR_INFORMATION, SMBIOS_TYPE_64BIT_MEMORY_ERROR_INFORMATION, SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MEMORY_DEVICE,                        SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY,          SMBIOS_TYPE_32BIT_MEMORY_ERROR_INFORMATION, SMBIOS_TYPE_64BIT_MEMORY_ERROR_INFORMATION, SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_32BIT_MEMORY_ERROR_INFORMATION,       SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS,          SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MEMORY_DEVICE_MAPPED_ADDRESS,         SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_BUILT_IN_POINTING_DEVICE,             SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_PORTABLE_BATTERY,                     SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_RESET,                         SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_HARDWARE_SECURITY,                    SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_POWER_CONTROLS,                SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_VOLTAGE_PROBE,                        SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_COOLING_DEVICE,                       SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_TEMPERATURE_PROBE,                    SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_ELECTRICAL_CURRENT_PROBE,             SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_OUT_OF_BAND_REMOTE_ACCESS,            SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_BOOT_INTEGRITY_SERVICE,               SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_BOOT_INFORMATION,              SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_64BIT_MEMORY_ERROR_INFORMATION,       SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MANAGEMENT_DEVICE,                    SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MANAGEMENT_DEVICE_COMPONENT,          SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MANAGEMENT_DEVICE_THRESHOLD_DATA,     SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MEMORY_CHANNEL,                       SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_IPMI_DEVICE_INFORMATION,              SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_POWER_SUPPLY,                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_ADDITIONAL_INFORMATION,               SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_ONBOARD_DEVICES_EXTENDED_INFORMATION, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MANAGEMENT_CONTROLLER_HOST_INTERFACE, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_TPM_DEVICE,                           SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_PROCESSOR_ADDITIONAL_INFORMATION,     SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_FIRMWARE_INVENTORY_INFORMATION,       SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_STRING_PROPERTY_INFORMATION,          SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL)

+};

+

+#if !defined (MDEPKG_NDEBUG)

+

+/**

+  A string table describing the SMBIOS dispatcher states.

+*/

+STATIC

+CONST CHAR8  *SmbiosTableStateTxt[] = {

+  "StNotPresent",

+  "StPresent",

+  "StDispatched"

+};

+

+/**

+  Print the SMBIOS Table Dispatcher state information.

+

+  @param Verbose Print detailed report

+**/

+STATIC

+VOID

+EFIAPI

+PrintDispatcherStatus (

+  IN BOOLEAN  Verbose

+  )

+{

+  UINTN  Index;

+

+  DEBUG ((DEBUG_VERBOSE, "Dispatcher Status:\n"));

+  for (Index = 0; Index < ARRAY_SIZE (mSmBiosDispatcher); Index++) {

+    if ((!Verbose) && (mSmBiosDispatcher[Index].State == StNotPresent)) {

+      continue;

+    }

+

+    DEBUG ((

+      DEBUG_VERBOSE,

+      "%02d: %10a [%02d, %02d, %02d, %02d, %02d]\n",

+      mSmBiosDispatcher[Index].TableType,

+      SmbiosTableStateTxt[mSmBiosDispatcher[Index].State],

+      mSmBiosDispatcher[Index].Dependency[0],

+      mSmBiosDispatcher[Index].Dependency[1],

+      mSmBiosDispatcher[Index].Dependency[2],

+      mSmBiosDispatcher[Index].Dependency[3],

+      mSmBiosDispatcher[Index].Dependency[4]

+      ));

+  } // for

+

+  DEBUG ((DEBUG_VERBOSE, "\n"));

+}

+

+#define DEBUG_PRINT_DISPATCHER_STATUS(Verbose)  PrintDispatcherStatus (Verbose)

+#else

+#define DEBUG_PRINT_DISPATCHER_STATUS(x)

+#endif

+

+/**

+  Initialise the SMBIOS table dispatcher.

+

+  @param SmbiosTableInfo  Pointer to the list of SMBIOS tables to be installed.

+  @param SmbiosTableCount Count of SMBIOS tables to be installed.

+**/

+VOID

+EFIAPI

+InitSmbiosTableDispatcher (

+  IN  CM_STD_OBJ_SMBIOS_TABLE_INFO  *SmbiosTableInfo,

+  IN  UINT32                        SmbiosTableCount

+  )

+{

+  UINTN              Index;

+  SMBIOS_TABLE_TYPE  TableType;

+

+  // Search for the list of SMBIOS tables presented

+  // for installation and update the dispatcher status.

+  for (Index = 0; Index < SmbiosTableCount; Index++) {

+    TableType = SmbiosTableInfo[Index].TableType;

+    ASSERT (mSmBiosDispatcher[TableType].State != StPresent);

+    mSmBiosDispatcher[TableType].State = StPresent;

+  }

+

+  DEBUG_PRINT_DISPATCHER_STATUS (FALSE);

+}

+

+/** Schedule the dispatch of a SMBIOS table.

+

+  The SMBIOS dispatcher state table is used to establish the dependency

+  order in which the SMBIOS tables are installed. This allows the SMBIOS

+  dispatcher to dispatch the dependent tables for installation before the

+  parent table is installed.

+  The SMBIOS_TABLE_DISPATCHER.Dependency[] field is used to establish the

+  dependency list.

+  Elements in the Dependency list are resolved by increasing index. However,

+  all orders are equivalent as:

+  - the Parent SMBIOS table will only be installed once all dependencies

+    have been satisfied.

+  - no cyclic dependency is allowed.

+  The dependency list is terminated by SMTT_NULL.

+

+  @param [in]  TableType            The SMBIOS table type to schedule for

+                                    dispatch.

+  @param [in]  TableFactoryProtocol Pointer to the Table Factory Protocol

+                                    interface.

+  @param [in]  CfgMgrProtocol       Pointer to the Configuration Manager

+                                    Protocol Interface.

+  @param [in]  SmbiosProtocol       Pointer to the SMBIOS protocol.

+  @param [in]  SmbiosTableInfo      Pointer to the SMBIOS table Info.

+  @param [in]  SmbiosTableCount     Count of SMBIOS table info objects.

+

+  @retval EFI_SUCCESS           Success.

+  @retval EFI_INVALID_PARAMETER A parameter is invalid.

+  @retval EFI_NOT_FOUND         Required object is not found.

+  @retval EFI_BAD_BUFFER_SIZE   Size returned by the Configuration Manager

+                                is less than the Object size for the

+                                requested object.

+**/

+EFI_STATUS

+EFIAPI

+DispatchSmbiosTable (

+  IN CONST SMBIOS_TABLE_TYPE                             TableType,

+  IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  *CONST  TableFactoryProtocol,

+  IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

+  IN       EFI_SMBIOS_PROTOCOL                           *SmbiosProtocol,

+  IN       CM_STD_OBJ_SMBIOS_TABLE_INFO          *CONST  SmbiosTableInfo,

+  IN CONST UINT32                                        SmbiosTableCount

+  )

+{

+  EFI_STATUS               Status;

+  UINTN                    Index;

+  SMBIOS_TABLE_DISPATCHER  *Disp;

+

+  DEBUG ((DEBUG_VERBOSE, "->DP %02d\n", TableType));

+  Disp = &mSmBiosDispatcher[TableType];

+  if (Disp->State == StNotPresent) {

+    DEBUG ((DEBUG_VERBOSE, "<-DP %02d : EFI_NOT_FOUND\n", TableType));

+    return EFI_NOT_FOUND;

+  }

+

+  if (Disp->State == StDispatched) {

+    DEBUG ((DEBUG_VERBOSE, "<-DP %02d : EFI_ALREADY_STARTED\n", TableType));

+    return EFI_ALREADY_STARTED;

+  }

+

+  // Table is present so check the dependency.

+  for (Index = 0; Index < MAX_SMBIOS_DEPENDENCY; Index++) {

+    // Check if the dependency list is terminated by SMTT_NULL.

+    if (Disp->Dependency[Index] == SMTT_NULL) {

+      break;

+    }

+

+    Status = DispatchSmbiosTable (

+               Disp->Dependency[Index],

+               TableFactoryProtocol,

+               CfgMgrProtocol,

+               SmbiosProtocol,

+               SmbiosTableInfo,

+               SmbiosTableCount

+               );

+    if (EFI_ERROR (Status)) {

+      if ((Status == EFI_ALREADY_STARTED) || (Status == EFI_NOT_FOUND)) {

+        // Some dependencies may already be satisfied

+        // as other tables may also have similar

+        // dependencies i.e. EFI_ALREADY_STARTED

+        // Or

+        // the dependent table may be optional

+        // and not provided i.e. EFI_NOT_FOUND.

+        continue;

+      }

+

+      DEBUG ((DEBUG_VERBOSE, "<-DP %02d : Status = %d\n", TableType, Status));

+      return Status;

+    }

+  }

+

+  DEBUG ((DEBUG_VERBOSE, "DP %02d : Status = %d\n", TableType, Status));

+

+  // All dependencies satisfied - Install SMBIOS table

+  Disp->State = StDispatched;

+  // Find the SMBIOS table info matching the TableType

+  for (Index = 0; Index < SmbiosTableCount; Index++) {

+    if (SmbiosTableInfo[Index].TableType == TableType) {

+      break;

+    }

+  }

+

+  Status = BuildAndInstallSmbiosTable (

+             TableFactoryProtocol,

+             CfgMgrProtocol,

+             SmbiosProtocol,

+             &SmbiosTableInfo[Index]

+             );

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: Failed to install SMBIOS Table." \

+      " Id = %u Status = %r\n",

+      SmbiosTableInfo[Index].TableGeneratorId,

+      Status

+      ));

+  }

+

+  DEBUG_PRINT_DISPATCHER_STATUS (FALSE);

+  DEBUG ((DEBUG_VERBOSE, "<-DP %0d\n", TableType));

+  return Status;

+}

diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.h b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.h
new file mode 100644
index 0000000000..d59eab4223
--- /dev/null
+++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.h
@@ -0,0 +1,159 @@
+/** @file

+

+  Copyright (c) 2022 - 2023, Arm Limited. All rights reserved.

+

+  SPDX-License-Identifier: BSD-2-Clause-Patent

+

+**/

+

+#ifndef SMBIOS_TABLE_DISPATCHER_H_

+#define SMBIOS_TABLE_DISPATCHER_H_

+

+#include <Protocol/ConfigurationManagerProtocol.h>

+#include <Protocol/DynamicTableFactoryProtocol.h>

+

+/**

+  A SMBIOS Table Type from the OEM range reserved for terminating

+  the SMBIOS table dispatch dependency.

+

+  Note: According to the SMBIOS specification, Table Types 0

+  through 127 (7Fh) are reserved for and defined by the

+  SMBIOS specification.

+  Types 128 through 256 (80h to FFh) are available for system and

+  OEM-specific information.

+

+  This Dynamic SMBIOS table generation implementation defines

+  TableType FFh as a NULL table which is used by the Dynamic

+  SMBIOS table dispatcher to terminate the dependency list.

+*/

+#define SMTT_NULL  0xFF

+

+/**

+  A macro defining the maximum number of dependendant SMBIOS tables

+  represented by the SMBIOS table dispatcher.

+*/

+#define MAX_SMBIOS_DEPENDENCY  5

+

+/**

+  A macro defining the maximum table types handled by the SMBIOS

+  table dispatcher.

+*/

+#define MAX_SMBIOS_TABLES  (SMBIOS_TYPE_STRING_PROPERTY_INFORMATION + 1)

+

+/**

+  A helper macro to populate the SMBIOS table dispatcher table

+*/

+#define SMBIOS_TABLE_DEP(TableId, Dep1, Dep2, Dep3, Dep4, Dep5) \

+  { \

+    TableId, \

+    StNotPresent, \

+    { Dep1, Dep2, Dep3, Dep4, Dep5 } \

+  }

+

+/**

+  An enum describing the states of the SMBIOS table dispatcher.

+*/

+typedef enum SmbiosTableState {

+  StNotPresent,   ///< SMBIOS table is not present for installation.

+  StPresent,      ///< SMBIOS table is present for installation.

+  StDispatched    ///< SMBIOS table generators have been dispatched.

+} SMBIOS_TABLE_STATE;

+

+/**

+  A structure describing the dependencies for a SMBIOS table and

+  the dispatcher state information.

+*/

+typedef struct SmBiosTableDispatcher {

+  /// SMBIOS Structure/Table Type

+  SMBIOS_TABLE_TYPE     TableType;

+  /// SMBIOS dispatcher state

+  SMBIOS_TABLE_STATE    State;

+  /// SMBIOS Structure/Table dependency list

+  /// The list is terminated using SMTT_NULL.

+  SMBIOS_TABLE_TYPE     Dependency[MAX_SMBIOS_DEPENDENCY];

+} SMBIOS_TABLE_DISPATCHER;

+

+/**

+  A helper function to build and install a SMBIOS table.

+

+  @param [in]  TableFactoryProtocol Pointer to the Table Factory Protocol

+                                    interface.

+  @param [in]  CfgMgrProtocol       Pointer to the Configuration Manager

+                                    Protocol Interface.

+  @param [in]  SmbiosProtocol       Pointer to the SMBIOS protocol.

+  @param [in]  SmbiosTableInfo      Pointer to the SMBIOS table Info.

+

+  @retval EFI_SUCCESS           Success.

+  @retval EFI_INVALID_PARAMETER A parameter is invalid.

+  @retval EFI_NOT_FOUND         Required object is not found.

+  @retval EFI_BAD_BUFFER_SIZE   Size returned by the Configuration Manager

+                                is less than the Object size for the

+                                requested object.

+**/

+extern

+EFI_STATUS

+EFIAPI

+BuildAndInstallSmbiosTable (

+  IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  *CONST  TableFactoryProtocol,

+  IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

+  IN       EFI_SMBIOS_PROTOCOL                           *SmbiosProtocol,

+  IN       CM_STD_OBJ_SMBIOS_TABLE_INFO          *CONST  SmbiosTableInfo

+  );

+

+/**

+  Initialise the SMBIOS table dispatcher.

+

+  @param SmbiosTableInfo  Pointer to the list of SMBIOS tables to be installed.

+  @param SmbiosTableCount Count of SMBIOS tables to be installed.

+**/

+VOID

+EFIAPI

+InitSmbiosTableDispatcher (

+  IN  CM_STD_OBJ_SMBIOS_TABLE_INFO  *SmbiosTableInfo,

+  IN  UINT32                        SmbiosTableCount

+  );

+

+/** Schedule the dispatch of a SMBIOS table.

+

+  The SMBIOS dispatcher state table is used to establish the dependency

+  order in which the SMBIOS tables are installed. This allows the SMBIOS

+  dispatcher to dispatch the dependent tables for installation before the

+  parent table is installed.

+  The SMBIOS_TABLE_DISPATCHER.Dependency[] field is used to establish the

+  dependency list.

+  Elements in the Dependency list are resolved by increasing index. However,

+  all orders are equivalent as:

+  - the Parent SMBIOS table will only be installed once all dependencies

+    have been satisfied.

+  - no cyclic dependency is allowed.

+  The dependency list is terminated by SMTT_NULL.

+

+  @param [in]  TableType            The SMBIOS table type to schedule for

+                                    dispatch.

+  @param [in]  TableFactoryProtocol Pointer to the Table Factory Protocol

+                                    interface.

+  @param [in]  CfgMgrProtocol       Pointer to the Configuration Manager

+                                    Protocol Interface.

+  @param [in]  SmbiosProtocol       Pointer to the SMBIOS protocol.

+  @param [in]  SmbiosTableInfo      Pointer to the SMBIOS table Info.

+  @param [in]  SmbiosTableCount     Count of SMBIOS table info objects.

+

+  @retval EFI_SUCCESS           Success.

+  @retval EFI_INVALID_PARAMETER A parameter is invalid.

+  @retval EFI_NOT_FOUND         Required object is not found.

+  @retval EFI_BAD_BUFFER_SIZE   Size returned by the Configuration Manager

+                                is less than the Object size for the

+                                requested object.

+**/

+EFI_STATUS

+EFIAPI

+DispatchSmbiosTable (

+  IN CONST SMBIOS_TABLE_TYPE                             TableType,

+  IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  *CONST  TableFactoryProtocol,

+  IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

+  IN       EFI_SMBIOS_PROTOCOL                           *SmbiosProtocol,

+  IN       CM_STD_OBJ_SMBIOS_TABLE_INFO          *CONST  SmbiosTableInfo,

+  IN CONST UINT32                                        SmbiosTableCount

+  );

+

+#endif // SMBIOS_TABLE_DISPATCHER_H_

-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#121088): https://edk2.groups.io/g/devel/message/121088
Mute This Topic: https://groups.io/mt/111022004/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [edk2-devel] [staging/dynamictables-reorg PATCH v0 04/12] DynamicTablesPkg: Add extern call to build SMBIOS table
  2025-02-05 22:08 [edk2-devel] [staging/dynamictables-reorg PATCH v0 00/12] DynamicTablesPkg: Add SMBIOS table generation support Girish Mahadevan via groups.io
                   ` (2 preceding siblings ...)
  2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 03/12] DynamicTablesPkg: Add SMBIOS table dispatcher Girish Mahadevan via groups.io
@ 2025-02-05 22:09 ` Girish Mahadevan via groups.io
  2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 05/12] DynamicTablesPkg: Update SMBIOS dispatcher dependency table Girish Mahadevan via groups.io
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Girish Mahadevan via groups.io @ 2025-02-05 22:09 UTC (permalink / raw)
  To: sami.mujawar, Alexei.Fedorov, pierre.gondois, abner.chang,
	Samer.El-Haj-Mahmoud, Jose.Marinho
  Cc: gmahadevan, jbrasen, ashishsingha, nramirez, devel

Add an extern call to build SMBIOS table as this seemed to have
been removed during v2.

Signed-off-by: Girish Mahadevan <gmahadevan@nvidia.com>
---
 .../DynamicTableManagerDxe/SmbiosTableDispatcher.c     | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c
index 0e728538d9..7366e1f7ca 100644
--- a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c
+++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c
@@ -12,6 +12,16 @@
 #include <Include/StandardNameSpaceObjects.h>

 #include <SmbiosTableDispatcher.h>

 

+extern

+EFI_STATUS

+EFIAPI

+BuildAndInstallSmbiosTable (

+   IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  *CONST  TableFactoryProtocol,

+   IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

+   IN       EFI_SMBIOS_PROTOCOL                           *SmbiosProtocol,

+   IN       CM_STD_OBJ_SMBIOS_TABLE_INFO          *CONST  SmbiosTableInfo

+);

+

 /**

   The SMBIOS dispatcher state table.

 

-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#121087): https://edk2.groups.io/g/devel/message/121087
Mute This Topic: https://groups.io/mt/111022003/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [edk2-devel] [staging/dynamictables-reorg PATCH v0 05/12] DynamicTablesPkg: Update SMBIOS dispatcher dependency table
  2025-02-05 22:08 [edk2-devel] [staging/dynamictables-reorg PATCH v0 00/12] DynamicTablesPkg: Add SMBIOS table generation support Girish Mahadevan via groups.io
                   ` (3 preceding siblings ...)
  2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 04/12] DynamicTablesPkg: Add extern call to build SMBIOS table Girish Mahadevan via groups.io
@ 2025-02-05 22:09 ` Girish Mahadevan via groups.io
  2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 06/12] DynamicTablesPkg: Add Ordered dispatch support for SMBIOS tables Girish Mahadevan via groups.io
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Girish Mahadevan via groups.io @ 2025-02-05 22:09 UTC (permalink / raw)
  To: sami.mujawar, Alexei.Fedorov, pierre.gondois, abner.chang,
	Samer.El-Haj-Mahmoud, Jose.Marinho
  Cc: gmahadevan, jbrasen, ashishsingha, nramirez, devel

From: Sami Mujawar <sami.mujawar@arm.com>

Update the SMBIOS table dispatcher dependency table to add the
table dependencies for SMBIOS table Type 19, Type 20, Type 27,
Type 35 and Type 37.

The SMBIOS table Type 35 can have dependency on 6 other SMBIOS
tables. Therefore, increase the MAX_SMBIOS_DEPENDENCY to 6, and
also update the SMBIOS table dispatcher table accordingly.

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
Cc: Alexei Fedorov <Alexei.Fedorov@arm.com>
Cc: Pierre Gondois <pierre.gondois@arm.com>
Cc: Girish Mahadevan <gmahadevan@nvidia.com>
Cc: Jeff Brasen <jbrasen@nvidia.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com>
Cc: Nick Ramirez <nramirez@nvidia.com>
Cc: William Watson <wwatson@nvidia.com>
Cc: Abner Chang <abner.chang@amd.com>
Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
Cc: Jose Marinho <Jose.Marinho@arm.com>
---
 .../SmbiosTableDispatcher.c                   | 94 +++++++++----------
 .../SmbiosTableDispatcher.h                   |  6 +-
 2 files changed, 50 insertions(+), 50 deletions(-)

diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c
index 7366e1f7ca..eceb7e927e 100644
--- a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c
+++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c
@@ -40,53 +40,53 @@ BuildAndInstallSmbiosTable (
 */

 STATIC

 SMBIOS_TABLE_DISPATCHER  mSmBiosDispatcher[MAX_SMBIOS_TABLES] = {

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_BIOS_INFORMATION,                     SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_INFORMATION,                   SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_BASEBOARD_INFORMATION,                SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_ENCLOSURE,                     SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_PROCESSOR_INFORMATION,                SMBIOS_TYPE_CACHE_INFORMATION,              SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MEMORY_CONTROLLER_INFORMATION,        SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MEMORY_MODULE_INFORMATON,             SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_CACHE_INFORMATION,                    SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_PORT_CONNECTOR_INFORMATION,           SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_SLOTS,                         SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_ONBOARD_DEVICE_INFORMATION,           SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_OEM_STRINGS,                          SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_CONFIGURATION_OPTIONS,         SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_BIOS_LANGUAGE_INFORMATION,            SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_GROUP_ASSOCIATIONS,                   SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_EVENT_LOG,                     SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY,                SMBIOS_TYPE_32BIT_MEMORY_ERROR_INFORMATION, SMBIOS_TYPE_64BIT_MEMORY_ERROR_INFORMATION, SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MEMORY_DEVICE,                        SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY,          SMBIOS_TYPE_32BIT_MEMORY_ERROR_INFORMATION, SMBIOS_TYPE_64BIT_MEMORY_ERROR_INFORMATION, SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_32BIT_MEMORY_ERROR_INFORMATION,       SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS,          SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MEMORY_DEVICE_MAPPED_ADDRESS,         SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_BUILT_IN_POINTING_DEVICE,             SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_PORTABLE_BATTERY,                     SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_RESET,                         SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_HARDWARE_SECURITY,                    SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_POWER_CONTROLS,                SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_VOLTAGE_PROBE,                        SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_COOLING_DEVICE,                       SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_TEMPERATURE_PROBE,                    SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_ELECTRICAL_CURRENT_PROBE,             SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_OUT_OF_BAND_REMOTE_ACCESS,            SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_BOOT_INTEGRITY_SERVICE,               SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_BOOT_INFORMATION,              SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_64BIT_MEMORY_ERROR_INFORMATION,       SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MANAGEMENT_DEVICE,                    SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MANAGEMENT_DEVICE_COMPONENT,          SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MANAGEMENT_DEVICE_THRESHOLD_DATA,     SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MEMORY_CHANNEL,                       SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_IPMI_DEVICE_INFORMATION,              SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_POWER_SUPPLY,                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_ADDITIONAL_INFORMATION,               SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_ONBOARD_DEVICES_EXTENDED_INFORMATION, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MANAGEMENT_CONTROLLER_HOST_INTERFACE, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_TPM_DEVICE,                           SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_PROCESSOR_ADDITIONAL_INFORMATION,     SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_FIRMWARE_INVENTORY_INFORMATION,       SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_STRING_PROPERTY_INFORMATION,          SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL, SMTT_NULL)

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_BIOS_INFORMATION,                     SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_INFORMATION,                   SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_BASEBOARD_INFORMATION,                SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_ENCLOSURE,                     SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_PROCESSOR_INFORMATION,                SMBIOS_TYPE_CACHE_INFORMATION,              SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MEMORY_CONTROLLER_INFORMATION,        SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MEMORY_MODULE_INFORMATON,             SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_CACHE_INFORMATION,                    SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_PORT_CONNECTOR_INFORMATION,           SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_SLOTS,                         SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_ONBOARD_DEVICE_INFORMATION,           SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_OEM_STRINGS,                          SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_CONFIGURATION_OPTIONS,         SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_BIOS_LANGUAGE_INFORMATION,            SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_GROUP_ASSOCIATIONS,                   SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_EVENT_LOG,                     SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY,                SMBIOS_TYPE_32BIT_MEMORY_ERROR_INFORMATION, SMBIOS_TYPE_64BIT_MEMORY_ERROR_INFORMATION, SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MEMORY_DEVICE,                        SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY,          SMBIOS_TYPE_32BIT_MEMORY_ERROR_INFORMATION, SMBIOS_TYPE_64BIT_MEMORY_ERROR_INFORMATION, SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_32BIT_MEMORY_ERROR_INFORMATION,       SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS,          SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY,          SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MEMORY_DEVICE_MAPPED_ADDRESS,         SMBIOS_TYPE_MEMORY_DEVICE,                  SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS,    SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_BUILT_IN_POINTING_DEVICE,             SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_PORTABLE_BATTERY,                     SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_RESET,                         SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_HARDWARE_SECURITY,                    SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_POWER_CONTROLS,                SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_VOLTAGE_PROBE,                        SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_COOLING_DEVICE,                       SMBIOS_TYPE_TEMPERATURE_PROBE,              SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_TEMPERATURE_PROBE,                    SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_ELECTRICAL_CURRENT_PROBE,             SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_OUT_OF_BAND_REMOTE_ACCESS,            SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_BOOT_INTEGRITY_SERVICE,               SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_BOOT_INFORMATION,              SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_64BIT_MEMORY_ERROR_INFORMATION,       SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MANAGEMENT_DEVICE,                    SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MANAGEMENT_DEVICE_COMPONENT,          SMBIOS_TYPE_MANAGEMENT_DEVICE,              SMBIOS_TYPE_VOLTAGE_PROBE,                  SMBIOS_TYPE_COOLING_DEVICE,                 SMBIOS_TYPE_TEMPERATURE_PROBE, SMBIOS_TYPE_ELECTRICAL_CURRENT_PROBE, SMBIOS_TYPE_MANAGEMENT_DEVICE_THRESHOLD_DATA),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MANAGEMENT_DEVICE_THRESHOLD_DATA,     SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MEMORY_CHANNEL,                       SMBIOS_TYPE_MEMORY_DEVICE,                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_IPMI_DEVICE_INFORMATION,              SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_POWER_SUPPLY,                  SMBIOS_TYPE_VOLTAGE_PROBE,                  SMBIOS_TYPE_COOLING_DEVICE,                 SMBIOS_TYPE_ELECTRICAL_CURRENT_PROBE,       SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_ADDITIONAL_INFORMATION,               SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_ONBOARD_DEVICES_EXTENDED_INFORMATION, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MANAGEMENT_CONTROLLER_HOST_INTERFACE, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_TPM_DEVICE,                           SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_PROCESSOR_ADDITIONAL_INFORMATION,     SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_FIRMWARE_INVENTORY_INFORMATION,       SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_STRING_PROPERTY_INFORMATION,          SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL)

 };

 

 #if !defined (MDEPKG_NDEBUG)

diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.h b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.h
index d59eab4223..e98ac18c7d 100644
--- a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.h
+++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.h
@@ -32,7 +32,7 @@
   A macro defining the maximum number of dependendant SMBIOS tables

   represented by the SMBIOS table dispatcher.

 */

-#define MAX_SMBIOS_DEPENDENCY  5

+#define MAX_SMBIOS_DEPENDENCY  6

 

 /**

   A macro defining the maximum table types handled by the SMBIOS

@@ -43,11 +43,11 @@
 /**

   A helper macro to populate the SMBIOS table dispatcher table

 */

-#define SMBIOS_TABLE_DEP(TableId, Dep1, Dep2, Dep3, Dep4, Dep5) \

+#define SMBIOS_TABLE_DEP(TableId, Dep1, Dep2, Dep3, Dep4, Dep5, Dep6) \

   { \

     TableId, \

     StNotPresent, \

-    { Dep1, Dep2, Dep3, Dep4, Dep5 } \

+    { Dep1, Dep2, Dep3, Dep4, Dep5, Dep6 } \

   }

 

 /**

-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#121089): https://edk2.groups.io/g/devel/message/121089
Mute This Topic: https://groups.io/mt/111022005/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [edk2-devel] [staging/dynamictables-reorg PATCH v0 06/12] DynamicTablesPkg: Add Ordered dispatch support for SMBIOS tables
  2025-02-05 22:08 [edk2-devel] [staging/dynamictables-reorg PATCH v0 00/12] DynamicTablesPkg: Add SMBIOS table generation support Girish Mahadevan via groups.io
                   ` (4 preceding siblings ...)
  2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 05/12] DynamicTablesPkg: Update SMBIOS dispatcher dependency table Girish Mahadevan via groups.io
@ 2025-02-05 22:09 ` Girish Mahadevan via groups.io
  2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 07/12] DynamicTablesPkg: Add SMBIOS table generation Girish Mahadevan via groups.io
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Girish Mahadevan via groups.io @ 2025-02-05 22:09 UTC (permalink / raw)
  To: sami.mujawar, Alexei.Fedorov, pierre.gondois, abner.chang,
	Samer.El-Haj-Mahmoud, Jose.Marinho
  Cc: gmahadevan, jbrasen, ashishsingha, nramirez, devel

From: Sami Mujawar <sami.mujawar@arm.com>

Some SMBIOS tables do not have a fixed dependency and can depend on any
other SMBIOS tables. Therefore, the SMBIOS dispatcher cannot define a
fixed sequence for dispatching these tables. A possible solution is to
defer the dispatch of such SMBIOS tables towards the end, assuming that
the dependent SMBIOS tables would have been dispatched by then.

Therefore, introduce a dispatch order attribute such that SMBIOS tables
that have a fixed dependency sequence are configured as Default Ordered,
and the SMBIOS tables that do not have a fixed dependency have an Order
attribute specifying an Order Level. An Order Level is used to sequence
the dispatch of Ordered SMBIOS tables.

The Default Ordered SMBIOS tables are dispatched first and a dependency
walk is performed to dispatch the dependent tables by iterating through
the SMBIOS_TABLE_DISPATCHER.Dependency[].

Once all Default ordered SMBIOS tables have been dispatched, the Ordered
SMBIOS tables would be scheduled for dispatch in increasing order as of
the Order Level, e.g. OrderL1, OrderL2, ...
Note: The dispatcher does not perform a dependency walk for the Ordered
SMBIOS tables as the expectation is that the dependent SMBIOS tables
would be already dispatched.

A top level dispatch function DispatchSmbiosTables() has been introduced
to schedule the dispatch of Default Ordered and Ordered SMBIOS tables.

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
Cc: Alexei Fedorov <Alexei.Fedorov@arm.com>
Cc: Pierre Gondois <pierre.gondois@arm.com>
Cc: Girish Mahadevan <gmahadevan@nvidia.com>
Cc: Jeff Brasen <jbrasen@nvidia.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com>
Cc: Nick Ramirez <nramirez@nvidia.com>
Cc: William Watson <wwatson@nvidia.com>
Cc: Abner Chang <abner.chang@amd.com>
Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
Cc: Jose Marinho <Jose.Marinho@arm.com>
---
 .../SmbiosTableDispatcher.c                   | 523 +++++++++++++++---
 .../SmbiosTableDispatcher.h                   |  34 +-
 2 files changed, 483 insertions(+), 74 deletions(-)

diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c
index eceb7e927e..778ed3bf10 100644
--- a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c
+++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c
@@ -37,56 +37,65 @@ BuildAndInstallSmbiosTable (
     have been satisfied.

   - no cyclic dependency is allowed.

   The dependency list is terminated by SMTT_NULL.

+

+  The SMBIOS dispatcher dispatches the tables that have the default

+  order (OrderDef) set before the ordered SMBIOS tables are dispatched.

+  The SMBIOS_TABLE_DISPATCHER.Order field is used to establish the

+  dispatch order.

+

+  The order specified in the SMBIOS dispatcher table must be unique for all

+  orders other than OrderDef. The dependency walk is only done for tables

+  that have the default dispatch order.

 */

 STATIC

 SMBIOS_TABLE_DISPATCHER  mSmBiosDispatcher[MAX_SMBIOS_TABLES] = {

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_BIOS_INFORMATION,                     SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_INFORMATION,                   SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_BASEBOARD_INFORMATION,                SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_ENCLOSURE,                     SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_PROCESSOR_INFORMATION,                SMBIOS_TYPE_CACHE_INFORMATION,              SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MEMORY_CONTROLLER_INFORMATION,        SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MEMORY_MODULE_INFORMATON,             SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_CACHE_INFORMATION,                    SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_PORT_CONNECTOR_INFORMATION,           SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_SLOTS,                         SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_ONBOARD_DEVICE_INFORMATION,           SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_OEM_STRINGS,                          SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_CONFIGURATION_OPTIONS,         SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_BIOS_LANGUAGE_INFORMATION,            SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_GROUP_ASSOCIATIONS,                   SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_EVENT_LOG,                     SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY,                SMBIOS_TYPE_32BIT_MEMORY_ERROR_INFORMATION, SMBIOS_TYPE_64BIT_MEMORY_ERROR_INFORMATION, SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MEMORY_DEVICE,                        SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY,          SMBIOS_TYPE_32BIT_MEMORY_ERROR_INFORMATION, SMBIOS_TYPE_64BIT_MEMORY_ERROR_INFORMATION, SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_32BIT_MEMORY_ERROR_INFORMATION,       SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS,          SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY,          SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MEMORY_DEVICE_MAPPED_ADDRESS,         SMBIOS_TYPE_MEMORY_DEVICE,                  SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS,    SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_BUILT_IN_POINTING_DEVICE,             SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_PORTABLE_BATTERY,                     SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_RESET,                         SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_HARDWARE_SECURITY,                    SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_POWER_CONTROLS,                SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_VOLTAGE_PROBE,                        SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_COOLING_DEVICE,                       SMBIOS_TYPE_TEMPERATURE_PROBE,              SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_TEMPERATURE_PROBE,                    SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_ELECTRICAL_CURRENT_PROBE,             SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_OUT_OF_BAND_REMOTE_ACCESS,            SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_BOOT_INTEGRITY_SERVICE,               SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_BOOT_INFORMATION,              SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_64BIT_MEMORY_ERROR_INFORMATION,       SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MANAGEMENT_DEVICE,                    SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MANAGEMENT_DEVICE_COMPONENT,          SMBIOS_TYPE_MANAGEMENT_DEVICE,              SMBIOS_TYPE_VOLTAGE_PROBE,                  SMBIOS_TYPE_COOLING_DEVICE,                 SMBIOS_TYPE_TEMPERATURE_PROBE, SMBIOS_TYPE_ELECTRICAL_CURRENT_PROBE, SMBIOS_TYPE_MANAGEMENT_DEVICE_THRESHOLD_DATA),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MANAGEMENT_DEVICE_THRESHOLD_DATA,     SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MEMORY_CHANNEL,                       SMBIOS_TYPE_MEMORY_DEVICE,                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_IPMI_DEVICE_INFORMATION,              SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_POWER_SUPPLY,                  SMBIOS_TYPE_VOLTAGE_PROBE,                  SMBIOS_TYPE_COOLING_DEVICE,                 SMBIOS_TYPE_ELECTRICAL_CURRENT_PROBE,       SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_ADDITIONAL_INFORMATION,               SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_ONBOARD_DEVICES_EXTENDED_INFORMATION, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MANAGEMENT_CONTROLLER_HOST_INTERFACE, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_TPM_DEVICE,                           SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_PROCESSOR_ADDITIONAL_INFORMATION,     SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_FIRMWARE_INVENTORY_INFORMATION,       SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

-  SMBIOS_TABLE_DEP (SMBIOS_TYPE_STRING_PROPERTY_INFORMATION,          SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL)

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_BIOS_INFORMATION,                     OrderDef, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_INFORMATION,                   OrderDef, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_BASEBOARD_INFORMATION,                OrderL1,  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_ENCLOSURE,                     OrderDef, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_PROCESSOR_INFORMATION,                OrderDef, SMBIOS_TYPE_CACHE_INFORMATION,              SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MEMORY_CONTROLLER_INFORMATION,        OrderDef, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MEMORY_MODULE_INFORMATON,             OrderDef, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_CACHE_INFORMATION,                    OrderDef, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_PORT_CONNECTOR_INFORMATION,           OrderDef, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_SLOTS,                         OrderDef, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_ONBOARD_DEVICE_INFORMATION,           OrderDef, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_OEM_STRINGS,                          OrderDef, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_CONFIGURATION_OPTIONS,         OrderDef, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_BIOS_LANGUAGE_INFORMATION,            OrderDef, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_GROUP_ASSOCIATIONS,                   OrderL4,  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_EVENT_LOG,                     OrderDef, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY,                OrderDef, SMBIOS_TYPE_32BIT_MEMORY_ERROR_INFORMATION, SMBIOS_TYPE_64BIT_MEMORY_ERROR_INFORMATION, SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MEMORY_DEVICE,                        OrderDef, SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY,          SMBIOS_TYPE_32BIT_MEMORY_ERROR_INFORMATION, SMBIOS_TYPE_64BIT_MEMORY_ERROR_INFORMATION, SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_32BIT_MEMORY_ERROR_INFORMATION,       OrderDef, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS,          OrderDef, SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY,          SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MEMORY_DEVICE_MAPPED_ADDRESS,         OrderDef, SMBIOS_TYPE_MEMORY_DEVICE,                  SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS,    SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_BUILT_IN_POINTING_DEVICE,             OrderDef, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_PORTABLE_BATTERY,                     OrderDef, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_RESET,                         OrderDef, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_HARDWARE_SECURITY,                    OrderDef, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_POWER_CONTROLS,                OrderDef, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_VOLTAGE_PROBE,                        OrderDef, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_COOLING_DEVICE,                       OrderDef, SMBIOS_TYPE_TEMPERATURE_PROBE,              SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_TEMPERATURE_PROBE,                    OrderDef, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_ELECTRICAL_CURRENT_PROBE,             OrderDef, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_OUT_OF_BAND_REMOTE_ACCESS,            OrderDef, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_BOOT_INTEGRITY_SERVICE,               OrderDef, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_BOOT_INFORMATION,              OrderDef, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_64BIT_MEMORY_ERROR_INFORMATION,       OrderDef, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MANAGEMENT_DEVICE,                    OrderDef, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MANAGEMENT_DEVICE_COMPONENT,          OrderDef, SMBIOS_TYPE_MANAGEMENT_DEVICE,              SMBIOS_TYPE_VOLTAGE_PROBE,                  SMBIOS_TYPE_COOLING_DEVICE,                 SMBIOS_TYPE_TEMPERATURE_PROBE, SMBIOS_TYPE_ELECTRICAL_CURRENT_PROBE, SMBIOS_TYPE_MANAGEMENT_DEVICE_THRESHOLD_DATA),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MANAGEMENT_DEVICE_THRESHOLD_DATA,     OrderDef, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MEMORY_CHANNEL,                       OrderDef, SMBIOS_TYPE_MEMORY_DEVICE,                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_IPMI_DEVICE_INFORMATION,              OrderDef, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_SYSTEM_POWER_SUPPLY,                  OrderDef, SMBIOS_TYPE_VOLTAGE_PROBE,                  SMBIOS_TYPE_COOLING_DEVICE,                 SMBIOS_TYPE_ELECTRICAL_CURRENT_PROBE,       SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_ADDITIONAL_INFORMATION,               OrderL3,  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_ONBOARD_DEVICES_EXTENDED_INFORMATION, OrderDef, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_MANAGEMENT_CONTROLLER_HOST_INTERFACE, OrderDef, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_TPM_DEVICE,                           OrderDef, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_PROCESSOR_ADDITIONAL_INFORMATION,     OrderDef, SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_FIRMWARE_INVENTORY_INFORMATION,       OrderL2,  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL),

+  SMBIOS_TABLE_DEP (SMBIOS_TYPE_STRING_PROPERTY_INFORMATION,          OrderL5,  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                                  SMTT_NULL,                     SMTT_NULL,                            SMTT_NULL)

 };

 

 #if !defined (MDEPKG_NDEBUG)

@@ -169,7 +178,83 @@ InitSmbiosTableDispatcher (
   DEBUG_PRINT_DISPATCHER_STATUS (FALSE);

 }

 

-/** Schedule the dispatch of a SMBIOS table.

+/** Dispatch the SMBIOS table.

+

+  @param [in]  Disp                 Pointer to the  SMBIOS table dispatcher

+                                    object for the table to dispatch.

+  @param [in]  TableFactoryProtocol Pointer to the Table Factory Protocol

+                                    interface.

+  @param [in]  CfgMgrProtocol       Pointer to the Configuration Manager

+                                    Protocol Interface.

+  @param [in]  SmbiosProtocol       Pointer to the SMBIOS protocol.

+  @param [in]  SmbiosTableInfo      Pointer to the SMBIOS table Info.

+  @param [in]  SmbiosTableCount     Count of SMBIOS table info objects.

+

+  @retval EFI_SUCCESS           Success.

+  @retval EFI_INVALID_PARAMETER A parameter is invalid.

+  @retval EFI_NOT_FOUND         Required object is not found.

+  @retval EFI_BAD_BUFFER_SIZE   Size returned by the Configuration Manager

+                                is less than the Object size for the

+                                requested object.

+**/

+STATIC

+EFI_STATUS

+EFIAPI

+DispatchTable (

+  IN       SMBIOS_TABLE_DISPATCHER               *CONST  Disp,

+  IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  *CONST  TableFactoryProtocol,

+  IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

+  IN       EFI_SMBIOS_PROTOCOL                           *SmbiosProtocol,

+  IN       CM_STD_OBJ_SMBIOS_TABLE_INFO          *CONST  SmbiosTableInfo,

+  IN CONST UINT32                                        SmbiosTableCount

+  )

+{

+  UINTN       Index;

+  EFI_STATUS  Status;

+  BOOLEAN     Found;

+

+  if (Disp == NULL) {

+    return EFI_INVALID_PARAMETER;

+  }

+

+  Found = FALSE;

+

+  // Update the dospatcher state to dispatched.

+  Disp->State = StDispatched;

+  // Find the SMBIOS table info matching the TableType

+  for (Index = 0; Index < SmbiosTableCount; Index++) {

+    if (SmbiosTableInfo[Index].TableType == Disp->TableType) {

+      Found = TRUE;

+      break;

+    }

+  }

+

+  if (!Found) {

+    ASSERT (0);

+    return EFI_NOT_FOUND;

+  }

+

+  // Install the SMBIOS table

+  Status = BuildAndInstallSmbiosTable (

+             TableFactoryProtocol,

+             CfgMgrProtocol,

+             SmbiosProtocol,

+             &SmbiosTableInfo[Index]

+             );

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: Failed to install SMBIOS Table." \

+      " Id = %d Status = %r\n",

+      SmbiosTableInfo[Index].TableGeneratorId,

+      Status

+      ));

+  }

+

+  return Status;

+}

+

+/** Schedule the dispatch of a default ordered SMBIOS table.

 

   The SMBIOS dispatcher state table is used to establish the dependency

   order in which the SMBIOS tables are installed. This allows the SMBIOS

@@ -200,10 +285,17 @@ InitSmbiosTableDispatcher (
   @retval EFI_BAD_BUFFER_SIZE   Size returned by the Configuration Manager

                                 is less than the Object size for the

                                 requested object.

+  @retval EFI_NO_MAPPING        A dependent table may be optional and

+                                may not be in the list of tables to install.

+  @retval EFI_ALREADY_STARTED   A table may be in the dependency list of

+                                multiple tables and would have been installed

+                                when one of the other parent table's dependency

+                                list was fulfilled.

 **/

+STATIC

 EFI_STATUS

 EFIAPI

-DispatchSmbiosTable (

+DispatchDefaultOrderedSmbiosTable (

   IN CONST SMBIOS_TABLE_TYPE                             TableType,

   IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  *CONST  TableFactoryProtocol,

   IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

@@ -215,28 +307,56 @@ DispatchSmbiosTable (
   EFI_STATUS               Status;

   UINTN                    Index;

   SMBIOS_TABLE_DISPATCHER  *Disp;

+  SMBIOS_TABLE_TYPE        DepTableType;

 

   DEBUG ((DEBUG_VERBOSE, "->DP %02d\n", TableType));

   Disp = &mSmBiosDispatcher[TableType];

+

+  if (Disp->Order != OrderDef) {

+    DEBUG ((DEBUG_VERBOSE, "<-DP %d : EFI_INVALID_PARAMETER\n", TableType));

+    // The table being request for installation is

+    // not a default ordered table.

+    return EFI_INVALID_PARAMETER;

+  }

+

   if (Disp->State == StNotPresent) {

-    DEBUG ((DEBUG_VERBOSE, "<-DP %02d : EFI_NOT_FOUND\n", TableType));

-    return EFI_NOT_FOUND;

+    DEBUG ((DEBUG_VERBOSE, "<-DP %02d : EFI_NO_MAPPING\n", TableType));

+    // A dependent table may be optional and therefore may

+    // not be in the list of tables to install.

+    return EFI_NO_MAPPING;

   }

 

   if (Disp->State == StDispatched) {

     DEBUG ((DEBUG_VERBOSE, "<-DP %02d : EFI_ALREADY_STARTED\n", TableType));

+    // This table may be in the dependency list of multiple tables

+    // and would have been installed when one of the other parent

+    // table's dependency list was fulfilled.

     return EFI_ALREADY_STARTED;

   }

 

   // Table is present so check the dependency.

   for (Index = 0; Index < MAX_SMBIOS_DEPENDENCY; Index++) {

+    DepTableType = Disp->Dependency[Index];

     // Check if the dependency list is terminated by SMTT_NULL.

-    if (Disp->Dependency[Index] == SMTT_NULL) {

+    if (DepTableType == SMTT_NULL) {

       break;

     }

 

-    Status = DispatchSmbiosTable (

-               Disp->Dependency[Index],

+    if (mSmBiosDispatcher[DepTableType].Order != OrderDef) {

+      // An incorrect dependency has been set.

+      // The default ordered SMBIOS tables must not have

+      // a dependency on ordered SMBIOS tables.

+      DEBUG ((

+        DEBUG_VERBOSE,

+        "<-DP %02d : EFI_INVALID_PARAMETER - Invalid dependency\n",

+        TableType

+        ));

+      ASSERT (0);

+      return EFI_INVALID_PARAMETER;

+    }

+

+    Status = DispatchDefaultOrderedSmbiosTable (

+               DepTableType,

                TableFactoryProtocol,

                CfgMgrProtocol,

                SmbiosProtocol,

@@ -244,49 +364,316 @@ DispatchSmbiosTable (
                SmbiosTableCount

                );

     if (EFI_ERROR (Status)) {

-      if ((Status == EFI_ALREADY_STARTED) || (Status == EFI_NOT_FOUND)) {

+      if ((Status == EFI_ALREADY_STARTED) ||

+          (Status == EFI_NO_MAPPING))

+      {

         // Some dependencies may already be satisfied

         // as other tables may also have similar

         // dependencies i.e. EFI_ALREADY_STARTED

         // Or

         // the dependent table may be optional

-        // and not provided i.e. EFI_NOT_FOUND.

+        // and not provided i.e. EFI_NO_MAPPING.

+        DEBUG ((

+          DEBUG_VERBOSE,

+          "<-DP %02d : Status = %r - treated as Success, continue\n",

+          TableType,

+          Status

+          ));

+        // Therefore, reset Status to success

+        Status = EFI_SUCCESS;

         continue;

       }

 

-      DEBUG ((DEBUG_VERBOSE, "<-DP %02d : Status = %d\n", TableType, Status));

+      DEBUG ((

+        DEBUG_VERBOSE,

+        "<-DP %02d : Status = %r\n",

+        TableType,

+        Status

+        ));

       return Status;

     }

   }

 

-  DEBUG ((DEBUG_VERBOSE, "DP %02d : Status = %d\n", TableType, Status));

+  // All dependencies satisfied - dispatch SMBIOS table

+  Status = DispatchTable (

+             Disp,

+             TableFactoryProtocol,

+             CfgMgrProtocol,

+             SmbiosProtocol,

+             SmbiosTableInfo,

+             SmbiosTableCount

+             );

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: Failed to install SMBIOS Table." \

+      " TableType = %u Status = %r\n",

+      Disp->TableType,

+      Status

+      ));

+  }

 

-  // All dependencies satisfied - Install SMBIOS table

-  Disp->State = StDispatched;

-  // Find the SMBIOS table info matching the TableType

-  for (Index = 0; Index < SmbiosTableCount; Index++) {

-    if (SmbiosTableInfo[Index].TableType == TableType) {

+  DEBUG_PRINT_DISPATCHER_STATUS (FALSE);

+  DEBUG ((DEBUG_VERBOSE, "<-DP %0d\n", TableType));

+  return Status;

+}

+

+/** Schedule the dispatch of ordered SMBIOS tables.

+

+  The SMBIOS dispatcher dispatches the tables that have the default

+  order (OrderDef) set first before the ordered SMBIOS tables are

+  dispatched.

+  The SMBIOS_TABLE_DISPATCHER.Order field is used to establish the

+  dispatch order.

+

+  @param [in]  Order                The dispatch order for the SMBIOS table type

+                                    to be scheduled for dispatch.

+  @param [in]  TableFactoryProtocol Pointer to the Table Factory Protocol

+                                    interface.

+  @param [in]  CfgMgrProtocol       Pointer to the Configuration Manager

+                                    Protocol Interface.

+  @param [in]  SmbiosProtocol       Pointer to the SMBIOS protocol.

+  @param [in]  SmbiosTableInfo      Pointer to the SMBIOS table Info.

+  @param [in]  SmbiosTableCount     Count of SMBIOS table info objects.

+

+  @retval EFI_SUCCESS           Success.

+  @retval EFI_INVALID_PARAMETER A parameter is invalid.

+  @retval EFI_NOT_FOUND         Required object is not found.

+  @retval EFI_BAD_BUFFER_SIZE   Size returned by the Configuration Manager

+                                is less than the Object size for the

+                                requested object.

+**/

+STATIC

+EFI_STATUS

+EFIAPI

+DispatchOrderedSmbiosTables (

+  IN CONST DISPATCH_ORDER                                Order,

+  IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  *CONST  TableFactoryProtocol,

+  IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

+  IN       EFI_SMBIOS_PROTOCOL                           *SmbiosProtocol,

+  IN       CM_STD_OBJ_SMBIOS_TABLE_INFO          *CONST  SmbiosTableInfo,

+  IN CONST UINT32                                        SmbiosTableCount

+  )

+{

+  EFI_STATUS               Status;

+  UINTN                    Index;

+  SMBIOS_TABLE_DISPATCHER  *Disp;

+

+  DEBUG ((DEBUG_VERBOSE, "->DPO %d\n", Order));

+

+  if (Order == OrderDef) {

+    DEBUG ((DEBUG_VERBOSE, "<-DPO %d : EFI_INVALID_PARAMETER\n", Order));

+    return EFI_INVALID_PARAMETER;

+  }

+

+  Disp = NULL;

+  for (Index = 0; Index < ARRAY_SIZE (mSmBiosDispatcher); Index++) {

+    if (mSmBiosDispatcher[Index].Order == Order) {

+      Disp = &mSmBiosDispatcher[Index];

       break;

     }

+  } // for

+

+  if (Disp == NULL) {

+    // Table with specified order not found.

+    DEBUG ((DEBUG_VERBOSE, "<-DPO %d : EFI_INVALID_PARAMETER\n", Order));

+    ASSERT (0);

+    return EFI_INVALID_PARAMETER;

+  } else if (Disp->State == StNotPresent) {

+    // An ordered table of this order is not present

+    // for installation. So, nothing to do here.

+    DEBUG ((

+      DEBUG_VERBOSE,

+      "<-DPO %a - %d {%u}: EFI_SUCCESS\n",

+      SmbiosTableStateTxt[Disp->State],

+      Order,

+      Disp->TableType

+      ));

+    return EFI_SUCCESS;

+  } else if (Disp->State == StDispatched) {

+    // Ordered tables are dispatched in their dispatch order and

+    // cannot be in the dependency list of any other table.

+    // Therefore, the table cannot be already dispatched.

+    DEBUG ((

+      DEBUG_VERBOSE,

+      "<-DPO %a - %d {%u}: EFI_INVALID_PARAMETER\n",

+      SmbiosTableStateTxt[Disp->State],

+      Order,

+      Disp->TableType

+      ));

+

+    ASSERT (0);

+    return EFI_INVALID_PARAMETER;

+  } else if (Disp->State != StPresent) {

+    // Invalid state, at this point the only valid state

+    // should be StPresent, otherwise the state machine

+    // is incorrect.

+    DEBUG ((

+      DEBUG_VERBOSE,

+      "<-DPO %d - %d {%u}: EFI_INVALID_PARAMETER\n",

+      Disp->State,

+      Order,

+      Disp->TableType

+      ));

+    ASSERT (0);

+    return EFI_INVALID_PARAMETER;

   }

 

-  Status = BuildAndInstallSmbiosTable (

+  Status = DispatchTable (

+             Disp,

              TableFactoryProtocol,

              CfgMgrProtocol,

              SmbiosProtocol,

-             &SmbiosTableInfo[Index]

+             SmbiosTableInfo,

+             SmbiosTableCount

              );

   if (EFI_ERROR (Status)) {

     DEBUG ((

       DEBUG_ERROR,

       "ERROR: Failed to install SMBIOS Table." \

-      " Id = %u Status = %r\n",

-      SmbiosTableInfo[Index].TableGeneratorId,

+      " TableType = %u Status = %r\n",

+      Disp->TableType,

       Status

       ));

   }

 

   DEBUG_PRINT_DISPATCHER_STATUS (FALSE);

-  DEBUG ((DEBUG_VERBOSE, "<-DP %0d\n", TableType));

+  DEBUG ((DEBUG_VERBOSE, "<-DPO %d {%u}\n", Order, Disp->TableType));

+  return Status;

+}

+

+/** Schedule the dispatch of SMBIOS tables.

+

+  The SMBIOS dispatcher state table is used to establish the dependency

+  order in which the SMBIOS tables are installed. This allows the SMBIOS

+  dispatcher to dispatch the dependent tables for installation before the

+  parent table is installed.

+  The SMBIOS_TABLE_DISPATCHER.Dependency[] field is used to establish the

+  dependency list.

+  Elements in the Dependency list are resolved by increasing index. However,

+  all orders are equivalent as:

+  - the Parent SMBIOS table will only be installed once all dependencies

+    have been satisfied.

+  - no cyclic dependency is allowed.

+  The dependency list is terminated by SMTT_NULL.

+

+  The SMBIOS dispatcher dispatches the tables that have the default

+  order (OrderDef) set before the ordered SMBIOS tables are dispatched.

+  The SMBIOS_TABLE_DISPATCHER.Order field is used to establish the

+  dispatch order.

+

+  The order specified in the SMBIOS dispatcher table must be unique for all

+  orders other than OrderDef. The dependency walk is only done for tables

+  that have the default dispatch order.

+

+  @param [in]  TableFactoryProtocol Pointer to the Table Factory Protocol

+                                    interface.

+  @param [in]  CfgMgrProtocol       Pointer to the Configuration Manager

+                                    Protocol Interface.

+  @param [in]  SmbiosProtocol       Pointer to the SMBIOS protocol.

+  @param [in]  SmbiosTableInfo      Pointer to the SMBIOS table Info.

+  @param [in]  SmbiosTableCount     Count of SMBIOS table info objects.

+

+  @retval EFI_SUCCESS           Success.

+  @retval EFI_INVALID_PARAMETER A parameter is invalid.

+  @retval EFI_NOT_FOUND         Required object is not found.

+  @retval EFI_BAD_BUFFER_SIZE   Size returned by the Configuration Manager

+                                is less than the Object size for the

+                                requested object.

+**/

+EFI_STATUS

+EFIAPI

+DispatchSmbiosTables (

+  IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  *CONST  TableFactoryProtocol,

+  IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

+  IN       EFI_SMBIOS_PROTOCOL                           *SmbiosProtocol,

+  IN       CM_STD_OBJ_SMBIOS_TABLE_INFO          *CONST  SmbiosTableInfo,

+  IN CONST UINT32                                        SmbiosTableCount

+  )

+{

+  EFI_STATUS         Status;

+  UINTN              Index;

+  UINT8              Order;

+  SMBIOS_TABLE_TYPE  TableType;

+

+  if ((TableFactoryProtocol == NULL)  ||

+      (CfgMgrProtocol == NULL)        ||

+      (SmbiosProtocol == NULL)        ||

+      (SmbiosTableInfo == NULL)       ||

+      (SmbiosTableCount == 0))

+  {

+    return EFI_INVALID_PARAMETER;

+  }

+

+  // First dispatch the default ordered SMBIOS tables

+  for (Index = 0; Index < SmbiosTableCount; Index++) {

+    TableType = SmbiosTableInfo[Index].TableType;

+    if (mSmBiosDispatcher[TableType].Order != OrderDef) {

+      // Skip if the table is not a default order table.

+      continue;

+    }

+

+    Status = DispatchDefaultOrderedSmbiosTable (

+               TableType,

+               TableFactoryProtocol,

+               CfgMgrProtocol,

+               SmbiosProtocol,

+               SmbiosTableInfo,

+               SmbiosTableCount

+               );

+    if (EFI_ERROR (Status)) {

+      if ((Status == EFI_ALREADY_STARTED) ||

+          (Status == EFI_NO_MAPPING))

+      {

+        // Some dependencies may already be satisfied

+        // as other tables may also have similar

+        // dependencies i.e. EFI_ALREADY_STARTED

+        // Or

+        // the dependent table may be optional

+        // and not provided i.e. EFI_NO_MAPPING.

+        DEBUG ((

+          DEBUG_VERBOSE,

+          "TableType %02d : Status = %r - treated as Success, continue\n",

+          SmbiosTableInfo[Index].TableType,

+          Status

+          ));

+        // Therefore, reset Status to success

+        Status = EFI_SUCCESS;

+        continue;

+      }

+

+      DEBUG ((

+        DEBUG_ERROR,

+        "ERROR: Failed to install SMBIOS Table." \

+        " Id = %d Status = %r\n",

+        SmbiosTableInfo[Index].TableGeneratorId,

+        Status

+        ));

+      return Status;

+    }

+  }

+

+  // Now dispatch the ordered SMBIOS tables

+  for (Order = OrderL1; Order < OrderMax; Order++) {

+    Status = DispatchOrderedSmbiosTables (

+               (DISPATCH_ORDER)Order,

+               TableFactoryProtocol,

+               CfgMgrProtocol,

+               SmbiosProtocol,

+               SmbiosTableInfo,

+               SmbiosTableCount

+               );

+    if (EFI_ERROR (Status)) {

+      DEBUG ((

+        DEBUG_ERROR,

+        "ERROR: Failed to install SMBIOS Table." \

+        " Order = %d Status = %r\n",

+        Order,

+        Status

+        ));

+      break;

+    }

+  }

+

   return Status;

 }

diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.h b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.h
index e98ac18c7d..471570e57f 100644
--- a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.h
+++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.h
@@ -43,9 +43,10 @@
 /**

   A helper macro to populate the SMBIOS table dispatcher table

 */

-#define SMBIOS_TABLE_DEP(TableId, Dep1, Dep2, Dep3, Dep4, Dep5, Dep6) \

+#define SMBIOS_TABLE_DEP(TableId, Order, Dep1, Dep2, Dep3, Dep4, Dep5, Dep6) \

   { \

     TableId, \

+    Order, \

     StNotPresent, \

     { Dep1, Dep2, Dep3, Dep4, Dep5, Dep6 } \

   }

@@ -59,6 +60,19 @@ typedef enum SmbiosTableState {
   StDispatched    ///< SMBIOS table generators have been dispatched.

 } SMBIOS_TABLE_STATE;

 

+/**

+  An enum describing the dispatch order for the SMBIOS tables.

+*/

+typedef enum DispatchOrder {

+  OrderDef = 0,   ///< Default dispatch order.

+  OrderL1,        ///< Dispatch order 1.

+  OrderL2,        ///< Dispatch order 2.

+  OrderL3,        ///< Dispatch order 3.

+  OrderL4,        ///< Dispatch order 4.

+  OrderL5,        ///< Dispatch order 5.

+  OrderMax        ///< Dispatch order Max.

+} DISPATCH_ORDER;

+

 /**

   A structure describing the dependencies for a SMBIOS table and

   the dispatcher state information.

@@ -66,6 +80,8 @@ typedef enum SmbiosTableState {
 typedef struct SmBiosTableDispatcher {

   /// SMBIOS Structure/Table Type

   SMBIOS_TABLE_TYPE     TableType;

+  /// SMBIOS table dispatch order

+  DISPATCH_ORDER        Order;

   /// SMBIOS dispatcher state

   SMBIOS_TABLE_STATE    State;

   /// SMBIOS Structure/Table dependency list

@@ -113,7 +129,7 @@ InitSmbiosTableDispatcher (
   IN  UINT32                        SmbiosTableCount

   );

 

-/** Schedule the dispatch of a SMBIOS table.

+/** Schedule the dispatch of SMBIOS tables.

 

   The SMBIOS dispatcher state table is used to establish the dependency

   order in which the SMBIOS tables are installed. This allows the SMBIOS

@@ -128,8 +144,15 @@ InitSmbiosTableDispatcher (
   - no cyclic dependency is allowed.

   The dependency list is terminated by SMTT_NULL.

 

-  @param [in]  TableType            The SMBIOS table type to schedule for

-                                    dispatch.

+  The SMBIOS dispatcher dispatches the tables that have the default

+  order (OrderDef) set before the ordered SMBIOS tables are dispatched.

+  The SMBIOS_TABLE_DISPATCHER.Order field is used to establish the

+  dispatch order.

+

+  The order specified in the SMBIOS dispatcher table must be unique for all

+  orders other than OrderDef. The dependency walk is only done for tables

+  that have the default dispatch order.

+

   @param [in]  TableFactoryProtocol Pointer to the Table Factory Protocol

                                     interface.

   @param [in]  CfgMgrProtocol       Pointer to the Configuration Manager

@@ -147,8 +170,7 @@ InitSmbiosTableDispatcher (
 **/

 EFI_STATUS

 EFIAPI

-DispatchSmbiosTable (

-  IN CONST SMBIOS_TABLE_TYPE                             TableType,

+DispatchSmbiosTables (

   IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  *CONST  TableFactoryProtocol,

   IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

   IN       EFI_SMBIOS_PROTOCOL                           *SmbiosProtocol,

-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#121091): https://edk2.groups.io/g/devel/message/121091
Mute This Topic: https://groups.io/mt/111022008/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [edk2-devel] [staging/dynamictables-reorg PATCH v0 07/12] DynamicTablesPkg: Add SMBIOS table generation
  2025-02-05 22:08 [edk2-devel] [staging/dynamictables-reorg PATCH v0 00/12] DynamicTablesPkg: Add SMBIOS table generation support Girish Mahadevan via groups.io
                   ` (5 preceding siblings ...)
  2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 06/12] DynamicTablesPkg: Add Ordered dispatch support for SMBIOS tables Girish Mahadevan via groups.io
@ 2025-02-05 22:09 ` Girish Mahadevan via groups.io
  2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 08/12] DynamicTablesPkg: Split the ACPI and SMBIOS table generators Girish Mahadevan via groups.io
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Girish Mahadevan via groups.io @ 2025-02-05 22:09 UTC (permalink / raw)
  To: sami.mujawar, Alexei.Fedorov, pierre.gondois, abner.chang,
	Samer.El-Haj-Mahmoud, Jose.Marinho
  Cc: gmahadevan, jbrasen, ashishsingha, nramirez, devel

Add the SMBIOS Table generator code to the DynamicTablesPkg.

This change includes adding new logic to the DynamicTableManager
to process and add SMBIOS tables and augmenting the existing SMBIOS
Factory generator to include installing multiple SMBIOS tables .
Also included is running the SMBIOS and ACPI table generation as part
of the SMBIOS and ACPI protocol GUID callback notifications respectively.

Change-Id: Icc090108c16e87657260af6daf856f3d69b602e3
Signed-off-by: Girish Mahadevan <gmahadevan@nvidia.com>
Reviewed-by: Jeff Brasen <jbrasen@nvidia.com>
---
 .../DynamicTableFactory.h                     |   5 +
 .../DynamicTableFactoryDxe.c                  |   9 +
 .../SmbiosTableFactory/SmbiosTableFactory.c   | 107 +++
 .../DynamicTableManagerDxe.c                  | 677 +++++++++++++++++-
 .../DynamicTableManagerDxe.inf                |   5 +-
 .../Protocol/DynamicTableFactoryProtocol.h    |   9 +
 .../Include/SmbiosTableGenerator.h            | 203 +++++-
 MdePkg/Include/IndustryStandard/SmBios.h      |   8 +
 8 files changed, 991 insertions(+), 32 deletions(-)

diff --git a/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactory.h b/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactory.h
index b160dcf8ad..20e438ea70 100644
--- a/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactory.h
+++ b/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactory.h
@@ -49,6 +49,11 @@ typedef struct DynamicTableFactoryInfo {
         CustomDtTableGeneratorList[FixedPcdGet16 (

                                  PcdMaxCustomDTGenerators

                                  )];

+

+  /// An array for holding a map of SMBIOS handles and the CM Object

+  /// token used to build the SMBIOS record.

+  SMBIOS_HANDLE_MAP

+        SmbiosHandleMap[MAX_SMBIOS_HANDLES];

 } EDKII_DYNAMIC_TABLE_FACTORY_INFO;

 

 /** Return a pointer to the ACPI table generator.

diff --git a/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.c b/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.c
index 6d6d3fa746..da71d006a1 100644
--- a/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.c
+++ b/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.c
@@ -44,6 +44,9 @@ EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  DynamicTableFactoryProtocol = {
   GetDtTableGenerator,

   RegisterDtTableGenerator,

   DeregisterDtTableGenerator,

+  AddSmbiosHandle,

+  FindSmbiosHandle,

+  FindSmbiosHandleEx,

   &TableFactoryInfo

 };

 

@@ -65,6 +68,12 @@ DynamicTableFactoryDxeInitialize (
   )

 {

   EFI_STATUS  Status;

+  UINTN       Idx;

+

+  for (Idx = 0; Idx < MAX_SMBIOS_HANDLES; Idx++) {

+    TableFactoryInfo.SmbiosHandleMap[Idx].SmbiosTblHandle = SMBIOS_HANDLE_PI_RESERVED;

+    TableFactoryInfo.SmbiosHandleMap[Idx].SmbiosCmToken   = 0;

+  }

 

   Status = gBS->InstallProtocolInterface (

                   &ImageHandle,

diff --git a/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/SmbiosTableFactory/SmbiosTableFactory.c b/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/SmbiosTableFactory/SmbiosTableFactory.c
index 87795919f8..c8df6aace6 100644
--- a/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/SmbiosTableFactory/SmbiosTableFactory.c
+++ b/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/SmbiosTableFactory/SmbiosTableFactory.c
@@ -12,6 +12,7 @@
 #include <IndustryStandard/SmBios.h>

 #include <Library/BaseLib.h>

 #include <Library/BaseMemoryLib.h>

+#include <Library/MemoryAllocationLib.h>

 #include <Library/DebugLib.h>

 

 // Module specific include files.

@@ -24,6 +25,71 @@
 

 extern EDKII_DYNAMIC_TABLE_FACTORY_INFO  TableFactoryInfo;

 

+/** Add a new entry to the SMBIOS table Map.

+

+  @param [in]  Smbios         SMBIOS Protocol pointer.

+  @param [in]  SmbiosHandle   SMBIOS Handle to be added, if the value SMBIOS_HANDLE_PI_RESERVED

+                              is passed then a new SmbiosHandle is assigned.

+  @param [in]  CmObjectToken  CmObjectToken of the CM_OBJECT used to build the SMBIOS Table

+  @param [in]  GeneratorId    Smbios Table Generator Id.

+

+  @retval EFI_SUCCESS               Successfully added/generated the handle.

+  @retval EFI_OUT_OF_RESOURCESNULL  Failure to add/generate the handle.

+**/

+EFI_STATUS

+EFIAPI

+AddSmbiosHandle (

+  IN EFI_SMBIOS_PROTOCOL         *Smbios,

+  IN SMBIOS_HANDLE               *SmbiosHandle,

+  IN CM_OBJECT_TOKEN             CmObjectToken,

+  IN  SMBIOS_TABLE_GENERATOR_ID  GeneratorId

+  )

+{

+  EFI_STATUS  Status;

+  UINTN       Index;

+

+  Status = EFI_OUT_OF_RESOURCES;

+

+  for (Index = 0; Index < MAX_SMBIOS_HANDLES; Index++) {

+    if (TableFactoryInfo.SmbiosHandleMap[Index].SmbiosTblHandle == SMBIOS_HANDLE_PI_RESERVED) {

+      TableFactoryInfo.SmbiosHandleMap[Index].SmbiosTblHandle   = *SmbiosHandle;

+      TableFactoryInfo.SmbiosHandleMap[Index].SmbiosCmToken     = CmObjectToken;

+      TableFactoryInfo.SmbiosHandleMap[Index].SmbiosGeneratorId = GeneratorId;

+      Status                                                    = EFI_SUCCESS;

+      break;

+    }

+  }

+

+  return Status;

+}

+

+/** Return a pointer to the SMBIOS table Map.

+

+  @param [in]  GeneratorId  The CmObjectToken to look up an SMBIOS Handle.

+

+  @retval SMBIOS_HANDLE_MAP if the CmObjectToken is found.

+  @retval NULL if not found.

+**/

+SMBIOS_HANDLE_MAP *

+EFIAPI

+FindSmbiosHandle (

+  CM_OBJECT_TOKEN  CmObjectToken

+  )

+{

+  UINTN              Index;

+  SMBIOS_HANDLE_MAP  *SmbiosHandleMap;

+

+  SmbiosHandleMap = NULL;

+  for (Index = 0; Index < MAX_SMBIOS_HANDLES; Index++) {

+    if (TableFactoryInfo.SmbiosHandleMap[Index].SmbiosCmToken == CmObjectToken) {

+      SmbiosHandleMap = &TableFactoryInfo.SmbiosHandleMap[Index];

+      break;

+    }

+  }

+

+  return SmbiosHandleMap;

+}

+

 /** Return a pointer to the SMBIOS table generator.

 

   @param [in]  This         Pointer to the Dynamic Table Factory Protocol.

@@ -229,3 +295,44 @@ DeregisterSmbiosTableGenerator (
   DEBUG ((DEBUG_INFO, "Deregistering %s\n", Generator->Description));

   return EFI_SUCCESS;

 }

+

+/** Find and return SMBIOS handle based on associated CM object token.

+

+  @param [in]  GeneratorId     SMBIOS generator ID used to build the SMBIOS Table.

+  @param [in]  CmObjectToken   Token of the CM_OBJECT used to build the SMBIOS Table.

+

+  @return  SMBIOS handle of the table associated with SmbiosGeneratorId and

+           CmObjectToken if found. Otherwise, returns 0xFFFF.

+**/

+UINT16

+EFIAPI

+FindSmbiosHandleEx (

+  IN  SMBIOS_TABLE_GENERATOR_ID  GeneratorId,

+  IN  CM_OBJECT_TOKEN            CmObjToken

+  )

+{

+  SMBIOS_HANDLE_MAP  *HandleMap;

+

+  if (CmObjToken == CM_NULL_TOKEN) {

+    return SMBIOS_HANDLE_INVALID;

+  }

+

+  HandleMap = FindSmbiosHandle (CmObjToken);

+  if (HandleMap == NULL) {

+    return SMBIOS_HANDLE_INVALID;

+  }

+

+  if (HandleMap->SmbiosGeneratorId != GeneratorId) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "%a: Expect ID %d but get %d\n",

+      __FUNCTION__,

+      GeneratorId,

+      HandleMap->SmbiosGeneratorId

+      ));

+    ASSERT (FALSE);

+    return SMBIOS_HANDLE_INVALID;

+  }

+

+  return HandleMap->SmbiosTblHandle;

+}

diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.c b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.c
index dfccccb839..3a88b9327b 100644
--- a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.c
+++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.c
@@ -8,10 +8,13 @@
 **/

 

 #include <Library/DebugLib.h>

+#include <Library/UefiLib.h>

 #include <Library/PcdLib.h>

 #include <Library/UefiBootServicesTableLib.h>

 #include <Protocol/AcpiSystemDescriptionTable.h>

 #include <Protocol/AcpiTable.h>

+#include <Protocol/Smbios.h>

+#include <Library/BaseMemoryLib.h>

 

 // Module specific include files.

 #include <AcpiTableGenerator.h>

@@ -22,6 +25,7 @@
 #include <Protocol/ConfigurationManagerProtocol.h>

 #include <Protocol/DynamicTableFactoryProtocol.h>

 #include <SmbiosTableGenerator.h>

+#include <SmbiosTableDispatcher.h>

 

 #include "DynamicTableManagerDxe.h"

 

@@ -42,6 +46,18 @@ GET_OBJECT_LIST (
   CM_STD_OBJ_ACPI_TABLE_INFO

   )

 

+/** This macro expands to a function that retrieves the SMBIOS Table

+    List from the Configuration Manager.

+*/

+GET_OBJECT_LIST (

+  EObjNameSpaceStandard,

+  EStdObjSmbiosTableList,

+  CM_STD_OBJ_SMBIOS_TABLE_INFO

+  )

+

+STATIC VOID *AcpiTableProtocolRegistration;

+STATIC VOID  *SmbiosProtocolRegistration;

+

 /** A helper function to build and install a single ACPI table.

 

   This is a helper function that invokes the Table generator interface

@@ -488,6 +504,490 @@ VerifyMandatoryTablesArePresent (
   return Status;

 }

 

+/** A helper function to build and install an SMBIOS table.

+

+  This is a helper function that invokes the Table generator interface

+  for building an SMBIOS table. It uses the SmbiosProtocol to install the

+  table, then frees the resources allocated for generating it.

+

+  @param [in]  TableFactoryProtocol Pointer to the Table Factory Protocol

+                                    interface.

+  @param [in]  CfgMgrProtocol       Pointer to the Configuration Manager

+                                    Protocol Interface.

+  @param [in]  SmbiosProtocol       Pointer to the SMBIOS protocol.

+  @param [in]  SmbiosTableInfo      Pointer to the SMBIOS table Info.

+

+  @retval EFI_SUCCESS           Success.

+  @retval EFI_INVALID_PARAMETER A parameter is invalid.

+  @retval EFI_NOT_FOUND         Required object is not found.

+  @retval EFI_BAD_BUFFER_SIZE   Size returned by the Configuration Manager

+                                is less than the Object size for the

+                                requested object.

+**/

+STATIC

+EFI_STATUS

+EFIAPI

+BuildAndInstallSingleSmbiosTable (

+  IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  *CONST  TableFactoryProtocol,

+  IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

+  IN CONST SMBIOS_TABLE_GENERATOR                *CONST  Generator,

+  IN       EFI_SMBIOS_PROTOCOL                           *SmbiosProtocol,

+  IN       CM_STD_OBJ_SMBIOS_TABLE_INFO          *CONST  SmbiosTableInfo

+  )

+{

+  EFI_STATUS         Status;

+  EFI_STATUS         Status1;

+  SMBIOS_STRUCTURE   *SmbiosTable;

+  CM_OBJECT_TOKEN    CmObjToken;

+  EFI_SMBIOS_HANDLE  TableHandle;

+

+  SmbiosTable = NULL;

+  Status      = Generator->BuildSmbiosTable (

+                             Generator,

+                             TableFactoryProtocol,

+                             SmbiosTableInfo,

+                             CfgMgrProtocol,

+                             &SmbiosTable,

+                             &CmObjToken

+                             );

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: Failed to Build Table." \

+      " TableGeneratorId = 0x%x. Status = %r\n",

+      SmbiosTableInfo->TableGeneratorId,

+      Status

+      ));

+    // Free any allocated resources.

+    goto exit_handler;

+  }

+

+  if (SmbiosTable == NULL) {

+    Status = EFI_NOT_FOUND;

+    goto exit_handler;

+  }

+

+  TableHandle = SMBIOS_HANDLE_PI_RESERVED;

+  // Install SMBIOS table

+  Status = SmbiosProtocol->Add (

+                             SmbiosProtocol,

+                             NULL,

+                             &TableHandle,

+                             SmbiosTable

+                             );

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: Failed to Install SMBIOS Table. Status = %r\n",

+      Status

+      ));

+    // Free any allocated resources.

+    goto exit_handler;

+  }

+

+  Status = TableFactoryProtocol->AddSmbiosHandle (

+                                   SmbiosProtocol,

+                                   &TableHandle,

+                                   CmObjToken,

+                                   SmbiosTableInfo->TableGeneratorId

+                                   );

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: Failed to Add SMBIOS Handle. Status = %r\n",

+      Status

+      ));

+    // Free any allocated resources.

+    goto exit_handler;

+  }

+

+  DEBUG ((

+    DEBUG_INFO,

+    "INFO: SMBIOS Table installed. Status = %r\n",

+    Status

+    ));

+

+exit_handler:

+  // Free any resources allocated for generating the tables.

+  if (Generator->FreeTableResources != NULL) {

+    Status1 = Generator->FreeTableResources (

+                           Generator,

+                           TableFactoryProtocol,

+                           SmbiosTableInfo,

+                           CfgMgrProtocol,

+                           &SmbiosTable

+                           );

+    if (EFI_ERROR (Status1)) {

+      DEBUG ((

+        DEBUG_ERROR,

+        "ERROR: Failed to Free Table Resources." \

+        "TableGeneratorId = 0x%x. Status = %r\n",

+        SmbiosTableInfo->TableGeneratorId,

+        Status1

+        ));

+    }

+

+    // Return the first error status in case of failure

+    if (!EFI_ERROR (Status)) {

+      Status = Status1;

+    }

+  }

+

+  return Status;

+}

+

+/** A helper function to build and install multiple SMBIOS tables.

+

+  This is a helper function that invokes the Table generator interface

+  for building SMBIOS tables. It uses the SmbiosProtocol to install the

+  tables, then frees the resources allocated for generating it.

+

+  @param [in]  TableFactoryProtocol Pointer to the Table Factory Protocol

+                                    interface.

+  @param [in]  CfgMgrProtocol       Pointer to the Configuration Manager

+                                    Protocol Interface.

+  @param [in]  Generator            Pointer to the SmbiosTable generator.

+  @param [in]  SmbiosProtocol       Pointer to the Smbios protocol.

+  @param [in]  AcpiTableInfo        Pointer to the SMBIOS table Info.

+

+  @retval EFI_SUCCESS           Success.

+  @retval EFI_INVALID_PARAMETER A parameter is invalid.

+  @retval EFI_NOT_FOUND         Required object is not found.

+  @retval EFI_BAD_BUFFER_SIZE   Size returned by the Configuration Manager

+                                is less than the Object size for the

+                                requested object.

+**/

+STATIC

+EFI_STATUS

+EFIAPI

+BuildAndInstallMultipleSmbiosTables (

+  IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  *CONST  TableFactoryProtocol,

+  IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

+  IN CONST SMBIOS_TABLE_GENERATOR                *CONST  Generator,

+  IN       EFI_SMBIOS_PROTOCOL                           *SmbiosProtocol,

+  IN       CM_STD_OBJ_SMBIOS_TABLE_INFO          *CONST  SmbiosTableInfo

+  )

+{

+  EFI_STATUS         Status;

+  EFI_STATUS         Status1;

+  SMBIOS_STRUCTURE   **SmbiosTable;

+  CM_OBJECT_TOKEN    *CmObjToken;

+  EFI_SMBIOS_HANDLE  TableHandle;

+  UINTN              TableCount;

+  UINTN              Index;

+

+  TableCount = 0;

+  Status     = Generator->BuildSmbiosTableEx (

+                            Generator,

+                            TableFactoryProtocol,

+                            SmbiosTableInfo,

+                            CfgMgrProtocol,

+                            &SmbiosTable,

+                            &CmObjToken,

+                            &TableCount

+                            );

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: Failed to Build Table." \

+      " TableGeneratorId = 0x%x. Status = %r\n",

+      SmbiosTableInfo->TableGeneratorId,

+      Status

+      ));

+    // Free any allocated resources.

+    goto exit_handler;

+  }

+

+  if ((SmbiosTable == NULL) || (TableCount == 0)) {

+    Status = EFI_NOT_FOUND;

+    DEBUG ((

+      DEBUG_ERROR,

+      "%a: TableCount %u SmbiosTable %p \n",

+      __FUNCTION__,

+      TableCount,

+      SmbiosTable

+      ));

+    goto exit_handler;

+  }

+

+  for (Index = 0; Index < TableCount; Index++) {

+    TableHandle = SMBIOS_HANDLE_PI_RESERVED;

+

+    // Install SMBIOS table

+    Status = SmbiosProtocol->Add (

+                               SmbiosProtocol,

+                               NULL,

+                               &TableHandle,

+                               SmbiosTable[Index]

+                               );

+    if (EFI_ERROR (Status)) {

+      DEBUG ((

+        DEBUG_ERROR,

+        "ERROR: Failed to Install SMBIOS Table. Status = %r\n",

+        Status

+        ));

+      // Free any allocated resources.

+      goto exit_handler;

+    }

+

+    Status = TableFactoryProtocol->AddSmbiosHandle (

+                                     SmbiosProtocol,

+                                     &TableHandle,

+                                     CmObjToken[Index],

+                                     SmbiosTableInfo->TableGeneratorId

+                                     );

+    if (EFI_ERROR (Status)) {

+      DEBUG ((

+        DEBUG_ERROR,

+        "ERROR: Failed to Add SMBIOS Handle. Status = %r\n",

+        Status

+        ));

+      // Free any allocated resources.

+      goto exit_handler;

+    }

+

+    DEBUG ((

+      DEBUG_INFO,

+      "INFO: SMBIOS Table installed. Status = %r\n",

+      Status

+      ));

+  }

+

+exit_handler:

+  // Free any resources allocated for generating the tables.

+  if (Generator->FreeTableResourcesEx != NULL) {

+    Status1 = Generator->FreeTableResourcesEx (

+                           Generator,

+                           TableFactoryProtocol,

+                           SmbiosTableInfo,

+                           CfgMgrProtocol,

+                           &SmbiosTable,

+                           &CmObjToken,

+                           TableCount

+                           );

+    if (EFI_ERROR (Status1)) {

+      DEBUG ((

+        DEBUG_ERROR,

+        "ERROR: Failed to Free Table Resources." \

+        "TableGeneratorId = 0x%x. Status = %r\n",

+        SmbiosTableInfo->TableGeneratorId,

+        Status1

+        ));

+    }

+

+    // Return the first error status in case of failure

+    if (!EFI_ERROR (Status)) {

+      Status = Status1;

+    }

+  }

+

+  DEBUG ((DEBUG_ERROR, "%a: Returning %r\n", __FUNCTION__, Status));

+  return Status;

+}

+

+/** A helper function to invoke a Table generator

+

+  This is a helper function that invokes the Table generator interface

+  for building an SMBIOS table. It uses the SmbiosProtocol to install the

+  table, then frees the resources allocated for generating it.

+

+  @param [in]  TableFactoryProtocol Pointer to the Table Factory Protocol

+                                    interface.

+  @param [in]  CfgMgrProtocol       Pointer to the Configuration Manager

+                                    Protocol Interface.

+  @param [in]  SmbiosProtocol       Pointer to the SMBIOS protocol.

+  @param [in]  SmbiosTableInfo      Pointer to the SMBIOS table Info.

+

+  @retval EFI_SUCCESS           Success.

+  @retval EFI_INVALID_PARAMETER A parameter is invalid.

+  @retval EFI_NOT_FOUND         Required object is not found.

+  @retval EFI_BAD_BUFFER_SIZE   Size returned by the Configuration Manager

+                                is less than the Object size for the

+                                requested object.

+**/

+EFI_STATUS

+EFIAPI

+BuildAndInstallSmbiosTable (

+  IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  *CONST  TableFactoryProtocol,

+  IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

+  IN       EFI_SMBIOS_PROTOCOL                           *SmbiosProtocol,

+  IN       CM_STD_OBJ_SMBIOS_TABLE_INFO          *CONST  SmbiosTableInfo

+  )

+{

+  EFI_STATUS                    Status;

+  CONST SMBIOS_TABLE_GENERATOR  *Generator;

+

+  ASSERT (TableFactoryProtocol != NULL);

+  ASSERT (CfgMgrProtocol != NULL);

+  ASSERT (SmbiosProtocol != NULL);

+  ASSERT (SmbiosTableInfo != NULL);

+

+  DEBUG ((

+    DEBUG_INFO,

+    "INFO: EStdObjSmbiosTableList: Address = 0x%p," \

+    " TableGeneratorId = 0x%x\n",

+    SmbiosTableInfo,

+    SmbiosTableInfo->TableGeneratorId

+    ));

+

+  Generator = NULL;

+  Status    = TableFactoryProtocol->GetSmbiosTableGenerator (

+                                      TableFactoryProtocol,

+                                      SmbiosTableInfo->TableGeneratorId,

+                                      &Generator

+                                      );

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: Table Generator not found." \

+      " TableGeneratorId = 0x%x. Status = %r\n",

+      SmbiosTableInfo->TableGeneratorId,

+      Status

+      ));

+    return Status;

+  }

+

+  if (Generator == NULL) {

+    return EFI_NOT_FOUND;

+  }

+

+  DEBUG ((

+    DEBUG_INFO,

+    "INFO: Generator found : %s\n",

+    Generator->Description

+    ));

+

+  if (Generator->BuildSmbiosTableEx != NULL) {

+    Status = BuildAndInstallMultipleSmbiosTables (

+               TableFactoryProtocol,

+               CfgMgrProtocol,

+               Generator,

+               SmbiosProtocol,

+               SmbiosTableInfo

+               );

+    if (EFI_ERROR (Status)) {

+      DEBUG ((

+        DEBUG_ERROR,

+        "ERROR: Failed to find build and install SMBIOS Tables." \

+        " Status = %r\n",

+        Status

+        ));

+    }

+  } else if (Generator->BuildSmbiosTable != NULL) {

+    Status = BuildAndInstallSingleSmbiosTable (

+               TableFactoryProtocol,

+               CfgMgrProtocol,

+               Generator,

+               SmbiosProtocol,

+               SmbiosTableInfo

+               );

+    if (EFI_ERROR (Status)) {

+      DEBUG ((

+        DEBUG_ERROR,

+        "ERROR: Failed to find build and install SMBIOS Table." \

+        " Status = %r\n",

+        Status

+        ));

+    }

+  } else {

+    Status = EFI_INVALID_PARAMETER;

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: Table Generator does not implement the" \

+      "SMBIOS_TABLE_GENERATOR_BUILD_TABLE  interface." \

+      " TableGeneratorId = 0x%x. Status = %r\n",

+      SmbiosTableInfo->TableGeneratorId,

+      Status

+      ));

+  }

+

+  DEBUG ((DEBUG_ERROR, "%a: Returning %r\n", __FUNCTION__, Status));

+  return Status;

+}

+

+/** Generate and install SMBIOS tables.

+

+  The function gathers the information necessary for installing the

+  SMBIOS tables from the Configuration Manager, invokes the generators

+  and installs them (via BuildAndInstallAcpiTable).

+

+  @param [in]  TableFactoryProtocol Pointer to the Table Factory Protocol

+                                    interface.

+  @param [in]  CfgMgrProtocol       Pointer to the Configuration Manager

+                                    Protocol Interface.

+

+  @retval EFI_SUCCESS   Success.

+  @retval EFI_NOT_FOUND If a mandatory table or a generator is not found.

+**/

+STATIC

+EFI_STATUS

+EFIAPI

+ProcessSmbiosTables (

+  IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  *CONST  TableFactoryProtocol,

+  IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol

+  )

+{

+  EFI_STATUS                    Status;

+  EFI_SMBIOS_PROTOCOL           *SmbiosProtocol;

+  CM_STD_OBJ_SMBIOS_TABLE_INFO  *SmbiosTableInfo;

+  UINT32                        SmbiosTableCount;

+

+  Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)&SmbiosProtocol);

+  if (EFI_ERROR (Status)) {

+    DEBUG ((DEBUG_ERROR, "Could not locate SMBIOS protocol.  %r\n", Status));

+    return Status;

+  }

+

+  Status = GetEStdObjSmbiosTableList (

+             CfgMgrProtocol,

+             CM_NULL_TOKEN,

+             &SmbiosTableInfo,

+             &SmbiosTableCount

+             );

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: Failed to get SMBIOS Table List. Status = %r\n",

+      Status

+      ));

+    return Status;

+  }

+

+  if (SmbiosTableCount == 0) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: EStdObjSmbiosTableList: SmbiosTableCount = %d\n",

+      SmbiosTableCount

+      ));

+    return EFI_NOT_FOUND;

+  }

+

+  DEBUG ((

+    DEBUG_INFO,

+    "INFO: EStdObjSmbiosTableList: SmbiosTableCount = %d\n",

+    SmbiosTableCount

+    ));

+

+  InitSmbiosTableDispatcher (SmbiosTableInfo, SmbiosTableCount);

+

+  Status = DispatchSmbiosTables (

+             TableFactoryProtocol,

+             CfgMgrProtocol,

+             SmbiosProtocol,

+             SmbiosTableInfo,

+             SmbiosTableCount

+             );

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: Failed to install SMBIOS Tables.Status = %r\n",

+      Status

+      ));

+  }

+

+  return Status;

+}

+

 /** Generate and install ACPI tables.

 

   The function gathers the information necessary for installing the

@@ -661,30 +1161,20 @@ ProcessAcpiTables (
   return Status;

 }

 

-/** Entrypoint of Dynamic Table Manager Dxe.

+/** Callback function for ACPI Protocol .

 

-  The Dynamic Table Manager uses the Configuration Manager Protocol

-  to get the list of ACPI and SMBIOS tables to install. For each table

-  in the list it requests the corresponding ACPI/SMBIOS table factory for

-  a generator capable of building the ACPI/SMBIOS table.

-  If a suitable table generator is found, it invokes the generator interface

-  to build the table. The Dynamic Table Manager then installs the

-  table and invokes another generator interface to free any resources

-  allocated for building the table.

+  Callback function for ACPI protocol that installs ACPI tables

 

-  @param  ImageHandle

-  @param  SystemTable

+  @param  Event

+  @param  Context

 

-  @retval EFI_SUCCESS           Success.

-  @retval EFI_OUT_OF_RESOURCES  Memory allocation failed.

-  @retval EFI_NOT_FOUND         Required interface/object was not found.

-  @retval EFI_INVALID_PARAMETER Some parameter is incorrect/invalid.

+  @retval None

 **/

-EFI_STATUS

-EFIAPI

-DynamicTableManagerDxeInitialize (

-  IN  EFI_HANDLE        ImageHandle,

-  IN  EFI_SYSTEM_TABLE  *SystemTable

+STATIC

+VOID

+AcpiTableProtocolReady (

+  IN  EFI_EVENT  Event,

+  IN  VOID       *Context

   )

 {

   EFI_STATUS                             Status;

@@ -705,7 +1195,7 @@ DynamicTableManagerDxeInitialize (
       " Status = %r\n",

       Status

       ));

-    return Status;

+    return;

   }

 

   // Locate the Configuration Manager for the Platform

@@ -720,7 +1210,7 @@ DynamicTableManagerDxeInitialize (
       "ERROR: Failed to find Configuration Manager protocol. Status = %r\n",

       Status

       ));

-    return Status;

+    return;

   }

 

   Status = GetCgfMgrInfo (CfgMgrProtocol, &CfgMfrInfo);

@@ -730,7 +1220,7 @@ DynamicTableManagerDxeInitialize (
       "ERROR: Failed to get Configuration Manager info. Status = %r\n",

       Status

       ));

-    return Status;

+    return;

   }

 

   DEBUG ((

@@ -763,6 +1253,147 @@ DynamicTableManagerDxeInitialize (
       Status

       ));

   }

+}

+

+/** Callback function for SMBIOS Protocol .

+

+  Callback function for SMBIOS protocol that installs SMBIOS tables

+  that use the DynamicTables Package.

+

+  @param  Event

+  @param  Context

+

+  @retval None

+**/

+STATIC

+VOID

+SmbiosProtocolReady (

+  IN  EFI_EVENT  Event,

+  IN  VOID       *Context

+  )

+{

+  EFI_STATUS                             Status;

+  EDKII_CONFIGURATION_MANAGER_PROTOCOL   *CfgMgrProtocol;

+  CM_STD_OBJ_CONFIGURATION_MANAGER_INFO  *CfgMfrInfo;

+  EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL   *TableFactoryProtocol;

+

+  // Locate the Dynamic Table Factory

+  Status = gBS->LocateProtocol (

+                  &gEdkiiDynamicTableFactoryProtocolGuid,

+                  NULL,

+                  (VOID **)&TableFactoryProtocol

+                  );

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: Failed to find Dynamic Table Factory protocol." \

+      " Status = %r\n",

+      Status

+      ));

+    return;

+  }

+

+  // Locate the Configuration Manager for the Platform

+  Status = gBS->LocateProtocol (

+                  &gEdkiiConfigurationManagerProtocolGuid,

+                  NULL,

+                  (VOID **)&CfgMgrProtocol

+                  );

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: Failed to find Configuration Manager protocol. Status = %r\n",

+      Status

+      ));

+    return;

+  }

+

+  Status = GetCgfMgrInfo (CfgMgrProtocol, &CfgMfrInfo);

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: Failed to get Configuration Manager info. Status = %r\n",

+      Status

+      ));

+    return;

+  }

+

+  DEBUG ((

+    DEBUG_INFO,

+    "INFO: Configuration Manager Version = 0x%x, OemID = %c%c%c%c%c%c\n",

+    CfgMfrInfo->Revision,

+    CfgMfrInfo->OemId[0],

+    CfgMfrInfo->OemId[1],

+    CfgMfrInfo->OemId[2],

+    CfgMfrInfo->OemId[3],

+    CfgMfrInfo->OemId[4],

+    CfgMfrInfo->OemId[5]

+    ));

+

+  Status = ProcessSmbiosTables (TableFactoryProtocol, CfgMgrProtocol);

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: SMBIOS Table processing failure. Status = %r\n",

+      Status

+      ));

+  }

+}

+

+/** Entrypoint of Dynamic Table Manager Dxe.

+

+  The Dynamic Table Manager uses the Configuration Manager Protocol

+  to get the list of ACPI and SMBIOS tables to install. For each table

+  in the list it requests the corresponding ACPI/SMBIOS table factory for

+  a generator capable of building the ACPI/SMBIOS table.

+  If a suitable table generator is found, it invokes the generator interface

+  to build the table. The Dynamic Table Manager then installs the

+  table and invokes another generator interface to free any resources

+  allocated for building the table.

+

+  @param  ImageHandle

+  @param  SystemTable

+

+  @retval EFI_SUCCESS           Success.

+  @retval EFI_OUT_OF_RESOURCES  Memory allocation failed.

+  @retval EFI_NOT_FOUND         Required interface/object was not found.

+  @retval EFI_INVALID_PARAMETER Some parameter is incorrect/invalid.

+**/

+EFI_STATUS

+EFIAPI

+DynamicTableManagerDxeInitialize (

+  IN  EFI_HANDLE        ImageHandle,

+  IN  EFI_SYSTEM_TABLE  *SystemTable

+  )

+{

+  EFI_STATUS  Status;

+  EFI_EVENT   AcpiEvent;

+  EFI_EVENT   SmbiosEvent;

+

+  AcpiEvent = EfiCreateProtocolNotifyEvent (

+                &gEfiAcpiTableProtocolGuid,

+                TPL_CALLBACK,

+                AcpiTableProtocolReady,

+                NULL,

+                &AcpiTableProtocolRegistration

+                );

+  if (AcpiEvent == NULL) {

+    DEBUG ((DEBUG_ERROR, "%a: Failed to ACPI create protocol event\r\n", __FUNCTION__));

+    return EFI_OUT_OF_RESOURCES;

+  }

+

+  SmbiosEvent = EfiCreateProtocolNotifyEvent (

+                  &gEfiSmbiosProtocolGuid,

+                  TPL_CALLBACK,

+                  SmbiosProtocolReady,

+                  NULL,

+                  &SmbiosProtocolRegistration

+                  );

+  if (SmbiosEvent == NULL) {

+    DEBUG ((DEBUG_ERROR, "%a: Failed to SMBIOS create protocol event\r\n", __FUNCTION__));

+    gBS->CloseEvent (AcpiEvent);

+    return EFI_OUT_OF_RESOURCES;

+  }

 

   return Status;

 }

diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf
index 56b35d4fb0..2a6f1e7b55 100644
--- a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf
+++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf
@@ -1,5 +1,5 @@
 ## @file

-# Module that drives the table generation and installation process.

+#  Module that drives the table generation and installation process.

 #

 #  Copyright (c) 2017 - 2022, Arm Limited. All rights reserved.

 #

@@ -40,6 +40,7 @@
 [LibraryClasses]

   PrintLib

   TableHelperLib

+  UefiLib

   UefiBootServicesTableLib

   UefiDriverEntryPoint

 

@@ -49,12 +50,12 @@
 [Protocols]

   gEfiAcpiTableProtocolGuid                     # PROTOCOL ALWAYS_CONSUMED

   gEfiAcpiSdtProtocolGuid                       # PROTOCOL ALWAYS_CONSUMED

+  gEfiSmbiosProtocolGuid                        # PROTOCOL ALWAYS_CONSUMED

 

   gEdkiiConfigurationManagerProtocolGuid        # PROTOCOL ALWAYS_CONSUMED

   gEdkiiDynamicTableFactoryProtocolGuid         # PROTOCOL ALWAYS_CONSUMED

 

 [Depex]

-  gEfiAcpiTableProtocolGuid AND

   gEdkiiConfigurationManagerProtocolGuid AND

   gEdkiiDynamicTableFactoryProtocolGuid

 

diff --git a/DynamicTablesPkg/Include/Protocol/DynamicTableFactoryProtocol.h b/DynamicTablesPkg/Include/Protocol/DynamicTableFactoryProtocol.h
index b11fc0c9f1..3a24ee7a18 100644
--- a/DynamicTablesPkg/Include/Protocol/DynamicTableFactoryProtocol.h
+++ b/DynamicTablesPkg/Include/Protocol/DynamicTableFactoryProtocol.h
@@ -239,6 +239,15 @@ typedef struct DynamicTableFactoryProtocol {
   EDKII_DYNAMIC_TABLE_FACTORY_DEREGISTER_DT_TABLE_GENERATOR

                                                             DeregisterDtTableGenerator;

 

+  EDKII_DYNAMIC_TABLE_FACTORY_SMBIOS_TABLE_ADD_HANDLE

+                                                            AddSmbiosHandle;

+

+  EDKII_DYNAMIC_TABLE_FACTORY_SMBIOS_TABLE_GET_HANDLE

+                                                            GetSmbiosHandle;

+

+  EDKII_DYNAMIC_TABLE_FACTORY_SMBIOS_TABLE_GET_HANDLE_EX

+                                                            GetSmbiosHandleEx;

+

   /** Pointer to the data structure that holds the

       list of registered table generators

   */

diff --git a/DynamicTablesPkg/Include/SmbiosTableGenerator.h b/DynamicTablesPkg/Include/SmbiosTableGenerator.h
index 934d56c90d..6e4e09a522 100644
--- a/DynamicTablesPkg/Include/SmbiosTableGenerator.h
+++ b/DynamicTablesPkg/Include/SmbiosTableGenerator.h
@@ -10,7 +10,7 @@
 #define SMBIOS_TABLE_GENERATOR_H_

 

 #include <IndustryStandard/SmBios.h>

-

+#include <Protocol/Smbios.h>

 #include <TableGenerator.h>

 

 #pragma pack(1)

@@ -121,12 +121,21 @@ typedef enum StdSmbiosTableGeneratorId {
             ETableGeneratorNameSpaceStd,        \

             TableId                             \

             )

+#define MAX_SMBIOS_HANDLES  (255)

 

 /** Forward declarations.

 */

 typedef struct ConfigurationManagerProtocol EDKII_CONFIGURATION_MANAGER_PROTOCOL;

 typedef struct CmStdObjSmbiosTableInfo      CM_STD_OBJ_SMBIOS_TABLE_INFO;

 typedef struct SmbiosTableGenerator         SMBIOS_TABLE_GENERATOR;

+typedef struct DynamicTableFactoryProtocol  EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL;

+typedef UINTN                               CM_OBJECT_TOKEN;

+

+typedef struct SmbiosHandleCmObjMap {

+  SMBIOS_TABLE_GENERATOR_ID    SmbiosGeneratorId;

+  SMBIOS_HANDLE                SmbiosTblHandle;

+  CM_OBJECT_TOKEN              SmbiosCmToken;

+} SMBIOS_HANDLE_MAP;

 

 /** This function pointer describes the interface to SMBIOS table build

     functions provided by the SMBIOS table generator and called by the

@@ -143,9 +152,11 @@ typedef struct SmbiosTableGenerator         SMBIOS_TABLE_GENERATOR;
 **/

 typedef EFI_STATUS (*SMBIOS_TABLE_GENERATOR_BUILD_TABLE) (

   IN  CONST SMBIOS_TABLE_GENERATOR                        *Generator,

+  IN  CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  *CONST  TableFactoryProtocol,

   IN        CM_STD_OBJ_SMBIOS_TABLE_INFO          *CONST  SmbiosTableInfo,

   IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

-  OUT       SMBIOS_STRUCTURE                              **Table

+  OUT       SMBIOS_STRUCTURE                              **Table,

+  OUT       CM_OBJECT_TOKEN                               *CmObjToken

   );

 

 /** This function pointer describes the interface to used by the

@@ -163,32 +174,147 @@ typedef EFI_STATUS (*SMBIOS_TABLE_GENERATOR_BUILD_TABLE) (
 **/

 typedef EFI_STATUS (*SMBIOS_TABLE_GENERATOR_FREE_TABLE) (

   IN  CONST SMBIOS_TABLE_GENERATOR                        *Generator,

+  IN  CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  *CONST  TableFactoryProtocol,

   IN  CONST CM_STD_OBJ_SMBIOS_TABLE_INFO          *CONST  SmbiosTableInfo,

   IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

   IN        SMBIOS_STRUCTURE                              **Table

   );

 

+/** This function pointer describes the interface to SMBIOS table build

+    functions provided by the SMBIOS table generator and called by the

+    Table Manager to build an SMBIOS table.

+

+  @param [in]  Generator       Pointer to the SMBIOS table generator.

+  @param [in]  SmbiosTableInfo Pointer to the SMBIOS table information.

+  @param [in]  CfgMgrProtocol  Pointer to the Configuration Manager

+                               Protocol interface.

+  @param [out] Table           Pointer to the generated SMBIOS table.

+

+  @return EFI_SUCCESS  If the table is generated successfully or other

+                        failure codes as returned by the generator.

+**/

+typedef EFI_STATUS (*SMBIOS_TABLE_GENERATOR_BUILD_TABLEEX) (

+  IN  CONST SMBIOS_TABLE_GENERATOR                         *Generator,

+  IN  CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL   *CONST  TableFactoryProtocol,

+  IN        CM_STD_OBJ_SMBIOS_TABLE_INFO          *CONST   SmbiosTableInfo,

+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST   CfgMgrProtocol,

+  OUT       SMBIOS_STRUCTURE                               ***Table,

+  OUT       CM_OBJECT_TOKEN                                **CmObjectToken,

+  OUT       UINTN                                 *CONST   TableCount

+  );

+

+/** This function pointer describes the interface to used by the

+    Table Manager to give the generator an opportunity to free

+    any resources allocated for building the SMBIOS table.

+

+  @param [in]  Generator       Pointer to the SMBIOS table generator.

+  @param [in]  SmbiosTableInfo Pointer to the SMBIOS table information.

+  @param [in]  CfgMgrProtocol  Pointer to the Configuration Manager

+                               Protocol interface.

+  @param [in]  Table           Pointer to the generated SMBIOS table.

+

+  @return  EFI_SUCCESS If freed successfully or other failure codes

+                        as returned by the generator.

+**/

+typedef EFI_STATUS (*SMBIOS_TABLE_GENERATOR_FREE_TABLEEX) (

+  IN  CONST SMBIOS_TABLE_GENERATOR                        *Generator,

+  IN  CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  *CONST  TableFactoryProtocol,

+  IN  CONST CM_STD_OBJ_SMBIOS_TABLE_INFO          *CONST  SmbiosTableInfo,

+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

+  IN        SMBIOS_STRUCTURE                              ***Table,

+  IN        CM_OBJECT_TOKEN                               **CmObjectToken,

+  IN  CONST UINTN                                         TableCount

+  );

+

+/** This function pointer describes the interface to used by the

+    Table Manager to give the generator an opportunity to add

+    an SMBIOS Handle.

+

+  This function is called by the Dynamic Table Manager to add a newly added

+  SMBIOS Table OR it can be called by an SMBIOS Table generator to create

+  and add a new SMBIOS Handle if there is a reference to another table and

+  if there is a generator for that table that hasn't been called yet.

+

+  @param [in]  Smbios         Pointer to the SMBIOS protocol.

+  @param [in]  SmbiosHandle   Pointer to an SMBIOS handle (either generated by

+                              SmbiosDxe Driver or  SMBIOS_HANDLE_PI_RESERVED

+                              if a handle needs to be generated).

+  @param [in]  CmObjectToken  The CM Object token for that is used to generate

+                              SMBIOS record.

+  @param [in]  GeneratorId    The SMBIOS table generator Id.

+

+  @retval EFI_SUCCESS           Success.

+  @retval EFI_OUT_OF_RESOURCES  Unable to add the handle.

+  @retval EFI_NOT_FOUND         The requested generator is not found

+                                in the list of registered generators.

+**/

+typedef EFI_STATUS (EFIAPI *EDKII_DYNAMIC_TABLE_FACTORY_SMBIOS_TABLE_ADD_HANDLE)(

+  IN  EFI_SMBIOS_PROTOCOL        *Smbios,

+  IN  SMBIOS_HANDLE              *SmbiosHandle,

+  IN  CM_OBJECT_TOKEN            CmObjectToken,

+  IN  SMBIOS_TABLE_GENERATOR_ID  GeneratorId

+  );

+

+/** This function pointer describes the interface to used by the

+    Table Manager to give the generator an opportunity to find

+    an SMBIOS Handle.

+

+  This function is called by the SMBIOS table generator to find an SMBIOS

+  handle needed as part of generating an SMBIOS Table.

+

+  @param [in]  CmObjectToken    The CM Object token used to generate the SMBIOS

+                                record.

+

+  @retval EFI_SUCCESS           Success.

+  @retval EFI_NOT_FOUND         The requested generator is not found

+                                in the list of registered generators.

+**/

+typedef SMBIOS_HANDLE_MAP *(EFIAPI *EDKII_DYNAMIC_TABLE_FACTORY_SMBIOS_TABLE_GET_HANDLE)(

+  IN  CM_OBJECT_TOKEN      CmObjectToken

+  );

+

+/** Find and return SMBIOS handle based on associated CM object token.

+

+  @param [in]  GeneratorId     SMBIOS generator ID used to build the SMBIOS Table.

+  @param [in]  CmObjectToken   Token of the CM_OBJECT used to build the SMBIOS Table.

+

+  @return  SMBIOS handle of the table associated with SmbiosTableId and

+           CmObjectToken if found. Otherwise, returns 0xFFFF.

+**/

+typedef UINT16 (EFIAPI *EDKII_DYNAMIC_TABLE_FACTORY_SMBIOS_TABLE_GET_HANDLE_EX)(

+  IN  SMBIOS_TABLE_GENERATOR_ID  GeneratorId,

+  IN  CM_OBJECT_TOKEN            CmObjToken

+  );

+

 /** The SMBIOS_TABLE_GENERATOR structure provides an interface that the

     Table Manager can use to invoke the functions to build SMBIOS tables.

 */

 typedef struct SmbiosTableGenerator {

   /// The SMBIOS table generator ID.

-  SMBIOS_TABLE_GENERATOR_ID             GeneratorID;

+  SMBIOS_TABLE_GENERATOR_ID               GeneratorID;

 

   /// String describing the DT table

   /// generator.

-  CONST CHAR16                          *Description;

+  CONST CHAR16                            *Description;

 

   /// The SMBIOS table type.

-  SMBIOS_TYPE                           Type;

+  SMBIOS_TYPE                             Type;

 

   /// SMBIOS table build function pointer.

-  SMBIOS_TABLE_GENERATOR_BUILD_TABLE    BuildSmbiosTable;

+  SMBIOS_TABLE_GENERATOR_BUILD_TABLE      BuildSmbiosTable;

+

+  /** The function to free any resources

+      allocated for building the SMBIOS table.

+  */

+  SMBIOS_TABLE_GENERATOR_FREE_TABLE       FreeTableResources;

+

+  /// SMBIOS table extended build function pointer.

+  SMBIOS_TABLE_GENERATOR_BUILD_TABLEEX    BuildSmbiosTableEx;

 

   /** The function to free any resources

       allocated for building the SMBIOS table.

   */

-  SMBIOS_TABLE_GENERATOR_FREE_TABLE     FreeTableResources;

+  SMBIOS_TABLE_GENERATOR_FREE_TABLEEX     FreeTableResourcesEx;

 } SMBIOS_TABLE_GENERATOR;

 

 /** Register SMBIOS table factory generator.

@@ -229,6 +355,69 @@ DeregisterSmbiosTableGenerator (
   IN CONST SMBIOS_TABLE_GENERATOR                 *CONST  Generator

   );

 

+/** Add SMBIOS Handle.

+

+  This function is called by the Dynamic Table Manager to add a newly added

+  SMBIOS Table OR it can be called by an SMBIOS Table generator to create

+  and add a new SMBIOS Handle if there is a reference to another table and

+  if there is a generator for that table that hasn't been called yet.

+

+  @param [in]  Smbios         Pointer to the SMBIOS protocol.

+  @param [in]  SmbiosHandle   Pointer to an SMBIOS handle (either generated by

+                              SmbiosDxe Driver or  SMBIOS_HANDLE_PI_RESERVED

+                              if a handle needs to be generated).

+  @param [in]  CmObjectToken  The CM Object token for that is used to generate

+                              SMBIOS record.

+  @param [in]  GeneratorId    The SMBIOS table generator Id.

+

+  @retval EFI_SUCCESS           Success.

+  @retval EFI_OUT_OF_RESOURCES  Unable to add the handle.

+  @retval EFI_NOT_FOUND         The requested generator is not found

+                                in the list of registered generators.

+**/

+EFI_STATUS

+EFIAPI

+AddSmbiosHandle (

+  IN EFI_SMBIOS_PROTOCOL         *Smbios,

+  IN SMBIOS_HANDLE               *SmbiosHandle,

+  IN CM_OBJECT_TOKEN             CmObjectToken,

+  IN  SMBIOS_TABLE_GENERATOR_ID  GeneratorId

+  );

+

+/** Find SMBIOS Handle given the CM Object token used to generate the SMBIOS

+    record..

+

+  This function is called by the SMBIOS table generator to find an SMBIOS

+  handle needed as part of generating an SMBIOS Table.

+

+  @param [in]  CmObjectToken    The CM Object token used to generate the SMBIOS

+                                record.

+

+  @retval EFI_SUCCESS           Success.

+  @retval EFI_NOT_FOUND         The requested generator is not found

+                                in the list of registered generators.

+**/

+SMBIOS_HANDLE_MAP *

+EFIAPI

+FindSmbiosHandle (

+  IN CM_OBJECT_TOKEN  CmObjectToken

+  );

+

+/** Find and return SMBIOS handle based on associated CM object token.

+

+  @param [in]  GeneratorId     SMBIOS generator ID used to build the SMBIOS Table.

+  @param [in]  CmObjectToken   Token of the CM_OBJECT used to build the SMBIOS Table.

+

+  @return  SMBIOS handle of the table associated with SmbiosTableId and

+           CmObjectToken if found. Otherwise, returns 0xFFFF.

+**/

+UINT16

+EFIAPI

+FindSmbiosHandleEx (

+  IN  SMBIOS_TABLE_GENERATOR_ID  GeneratorId,

+  IN  CM_OBJECT_TOKEN            CmObjToken

+  );

+

 #pragma pack()

 

 #endif // SMBIOS_TABLE_GENERATOR_H_

diff --git a/MdePkg/Include/IndustryStandard/SmBios.h b/MdePkg/Include/IndustryStandard/SmBios.h
index 020733b777..78833462b6 100644
--- a/MdePkg/Include/IndustryStandard/SmBios.h
+++ b/MdePkg/Include/IndustryStandard/SmBios.h
@@ -28,6 +28,14 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 ///

 #define SMBIOS_HANDLE_PI_RESERVED  0xFFFE

 

+///

+/// Reference SMBIOS 3.6, chapter 6.1.2.

+/// Unless otherwise specified, when referring to another structure’s handle, the value

+/// 0FFFFh is used to indicate that the referenced handle is not applicable or does not

+/// exist.

+///

+#define SMBIOS_HANDLE_INVALID  0xFFFF

+

 ///

 /// Reference SMBIOS 2.6, chapter 3.1.3.

 /// Each text string is limited to 64 significant characters due to system MIF limitations.

-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#121090): https://edk2.groups.io/g/devel/message/121090
Mute This Topic: https://groups.io/mt/111022006/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [edk2-devel] [staging/dynamictables-reorg PATCH v0 08/12] DynamicTablesPkg: Split the ACPI and SMBIOS table generators
  2025-02-05 22:08 [edk2-devel] [staging/dynamictables-reorg PATCH v0 00/12] DynamicTablesPkg: Add SMBIOS table generation support Girish Mahadevan via groups.io
                   ` (6 preceding siblings ...)
  2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 07/12] DynamicTablesPkg: Add SMBIOS table generation Girish Mahadevan via groups.io
@ 2025-02-05 22:09 ` Girish Mahadevan via groups.io
  2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 09/12] DynamicTablesPkg: Introduce new namespace for SMBIOS Objects Girish Mahadevan via groups.io
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Girish Mahadevan via groups.io @ 2025-02-05 22:09 UTC (permalink / raw)
  To: sami.mujawar, Alexei.Fedorov, pierre.gondois, abner.chang,
	Samer.El-Haj-Mahmoud, Jose.Marinho
  Cc: gmahadevan, jbrasen, ashishsingha, nramirez, devel

Split the SMBIOS and ACPI table generators into their own files.

Signed-off-by: Girish Mahadevan <gmahadevan@nvidia.com>
Reviewed-by: Jeff Brasen <jbrasen@nvidia.com>
---
 .../DynamicTableManagerDxe/AcpiTableBuilder.c |  762 ++++++++++
 .../DynamicTableManagerDxe.c                  | 1325 +----------------
 .../DynamicTableManagerDxe.inf                |    2 +
 .../SmbiosTableBuilder.c                      |  605 ++++++++
 4 files changed, 1381 insertions(+), 1313 deletions(-)
 create mode 100644 DynamicTablesPkg/Drivers/DynamicTableManagerDxe/AcpiTableBuilder.c
 create mode 100644 DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableBuilder.c

diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/AcpiTableBuilder.c b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/AcpiTableBuilder.c
new file mode 100644
index 0000000000..40e17c3976
--- /dev/null
+++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/AcpiTableBuilder.c
@@ -0,0 +1,762 @@
+/** @file

+  Acpi Table Manager Dxe

+

+  Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.

+

+  SPDX-License-Identifier: BSD-2-Clause-Patent

+

+**/

+

+#include <Library/DebugLib.h>

+#include <Library/UefiLib.h>

+#include <Library/PcdLib.h>

+#include <Library/UefiBootServicesTableLib.h>

+#include <Protocol/AcpiSystemDescriptionTable.h>

+#include <Protocol/AcpiTable.h>

+#include <Library/BaseMemoryLib.h>

+

+// Module specific include files.

+#include <AcpiTableGenerator.h>

+#include <ConfigurationManagerObject.h>

+#include <ConfigurationManagerHelper.h>

+#include <DeviceTreeTableGenerator.h>

+#include <Library/TableHelperLib.h>

+#include <Protocol/ConfigurationManagerProtocol.h>

+#include <Protocol/DynamicTableFactoryProtocol.h>

+#include "DynamicTableManagerDxe.h"

+

+STATIC ACPI_TABLE_PRESENCE_INFO  *mAcpiVerifyTables;

+STATIC UINT32                    mAcpiVerifyTablesCount;

+STATIC INT32                     mAcpiVerifyTablesFadtIndex;

+

+/** This macro expands to a function that retrieves the ACPI Table

+    List from the Configuration Manager.

+*/

+GET_OBJECT_LIST (

+  EObjNameSpaceStandard,

+  EStdObjAcpiTableList,

+  CM_STD_OBJ_ACPI_TABLE_INFO

+  )

+

+/** A helper function to build and install a single ACPI table.

+

+  This is a helper function that invokes the Table generator interface

+  for building an ACPI table. It uses the AcpiTableProtocol to install the

+  table, then frees the resources allocated for generating it.

+

+  @param [in]  TableFactoryProtocol Pointer to the Table Factory Protocol

+                                    interface.

+  @param [in]  CfgMgrProtocol       Pointer to the Configuration Manager

+                                    Protocol Interface.

+  @param [in]  Generator            Pointer to the AcpiTable generator.

+  @param [in]  AcpiTableProtocol    Pointer to the AcpiTable protocol.

+  @param [in]  AcpiTableInfo        Pointer to the ACPI table Info.

+

+  @retval EFI_SUCCESS           Success.

+  @retval EFI_INVALID_PARAMETER A parameter is invalid.

+  @retval EFI_NOT_FOUND         Required object is not found.

+  @retval EFI_BAD_BUFFER_SIZE   Size returned by the Configuration Manager

+                                is less than the Object size for the

+                                requested object.

+**/

+STATIC

+EFI_STATUS

+EFIAPI

+BuildAndInstallSingleAcpiTable (

+  IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  *CONST  TableFactoryProtocol,

+  IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

+  IN CONST ACPI_TABLE_GENERATOR                  *CONST  Generator,

+  IN       EFI_ACPI_TABLE_PROTOCOL                       *AcpiTableProtocol,

+  IN CONST CM_STD_OBJ_ACPI_TABLE_INFO            *CONST  AcpiTableInfo

+  )

+{

+  EFI_STATUS                   Status;

+  EFI_STATUS                   Status1;

+  EFI_ACPI_DESCRIPTION_HEADER  *AcpiTable;

+  UINTN                        TableHandle;

+

+  AcpiTable = NULL;

+  Status    = Generator->BuildAcpiTable (

+                           Generator,

+                           AcpiTableInfo,

+                           CfgMgrProtocol,

+                           &AcpiTable

+                           );

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: Failed to Build Table." \

+      " TableGeneratorId = 0x%x. Status = %r\n",

+      AcpiTableInfo->TableGeneratorId,

+      Status

+      ));

+    // Free any allocated resources.

+    goto exit_handler;

+  }

+

+  if (AcpiTable == NULL) {

+    Status = EFI_NOT_FOUND;

+    goto exit_handler;

+  }

+

+  // Dump ACPI Table Header

+  DUMP_ACPI_TABLE_HEADER (AcpiTable);

+

+  // Install ACPI table

+  Status = AcpiTableProtocol->InstallAcpiTable (

+                                AcpiTableProtocol,

+                                AcpiTable,

+                                AcpiTable->Length,

+                                &TableHandle

+                                );

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: Failed to Install ACPI Table. Status = %r\n",

+      Status

+      ));

+    // Free any allocated resources.

+    goto exit_handler;

+  }

+

+  DEBUG ((

+    DEBUG_INFO,

+    "INFO: ACPI Table installed. Status = %r\n",

+    Status

+    ));

+

+exit_handler:

+  // Free any resources allocated for generating the tables.

+  if (Generator->FreeTableResources != NULL) {

+    Status1 = Generator->FreeTableResources (

+                           Generator,

+                           AcpiTableInfo,

+                           CfgMgrProtocol,

+                           &AcpiTable

+                           );

+    if (EFI_ERROR (Status1)) {

+      DEBUG ((

+        DEBUG_ERROR,

+        "ERROR: Failed to Free Table Resources." \

+        "TableGeneratorId = 0x%x. Status = %r\n",

+        AcpiTableInfo->TableGeneratorId,

+        Status1

+        ));

+    }

+

+    // Return the first error status in case of failure

+    if (!EFI_ERROR (Status)) {

+      Status = Status1;

+    }

+  }

+

+  return Status;

+}

+

+/** A helper function to build and install multiple ACPI tables.

+

+  This is a helper function that invokes the Table generator interface

+  for building an ACPI table. It uses the AcpiTableProtocol to install the

+  table, then frees the resources allocated for generating it.

+

+  @param [in]  TableFactoryProtocol Pointer to the Table Factory Protocol

+                                    interface.

+  @param [in]  CfgMgrProtocol       Pointer to the Configuration Manager

+                                    Protocol Interface.

+  @param [in]  Generator            Pointer to the AcpiTable generator.

+  @param [in]  AcpiTableProtocol    Pointer to the AcpiTable protocol.

+  @param [in]  AcpiTableInfo        Pointer to the ACPI table Info.

+

+  @retval EFI_SUCCESS           Success.

+  @retval EFI_INVALID_PARAMETER A parameter is invalid.

+  @retval EFI_NOT_FOUND         Required object is not found.

+  @retval EFI_BAD_BUFFER_SIZE   Size returned by the Configuration Manager

+                                is less than the Object size for the

+                                requested object.

+**/

+STATIC

+EFI_STATUS

+EFIAPI

+BuildAndInstallMultipleAcpiTable (

+  IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  *CONST  TableFactoryProtocol,

+  IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

+  IN CONST ACPI_TABLE_GENERATOR                  *CONST  Generator,

+  IN       EFI_ACPI_TABLE_PROTOCOL                       *AcpiTableProtocol,

+  IN CONST CM_STD_OBJ_ACPI_TABLE_INFO            *CONST  AcpiTableInfo

+  )

+{

+  EFI_STATUS                   Status;

+  EFI_STATUS                   Status1;

+  EFI_ACPI_DESCRIPTION_HEADER  **AcpiTable;

+  UINTN                        TableCount;

+  UINTN                        TableHandle;

+  UINTN                        Index;

+

+  AcpiTable  = NULL;

+  TableCount = 0;

+  Status     = Generator->BuildAcpiTableEx (

+                            Generator,

+                            AcpiTableInfo,

+                            CfgMgrProtocol,

+                            &AcpiTable,

+                            &TableCount

+                            );

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: Failed to Build Table." \

+      " TableGeneratorId = 0x%x. Status = %r\n",

+      AcpiTableInfo->TableGeneratorId,

+      Status

+      ));

+    // Free any allocated resources.

+    goto exit_handler;

+  }

+

+  if ((AcpiTable == NULL) || (TableCount == 0)) {

+    Status = EFI_NOT_FOUND;

+    goto exit_handler;

+  }

+

+  for (Index = 0; Index < TableCount; Index++) {

+    // Dump ACPI Table Header

+    DUMP_ACPI_TABLE_HEADER (AcpiTable[Index]);

+    // Install ACPI table

+    Status = AcpiTableProtocol->InstallAcpiTable (

+                                  AcpiTableProtocol,

+                                  AcpiTable[Index],

+                                  AcpiTable[Index]->Length,

+                                  &TableHandle

+                                  );

+    if (EFI_ERROR (Status)) {

+      DEBUG ((

+        DEBUG_ERROR,

+        "ERROR: Failed to Install ACPI Table. Status = %r\n",

+        Status

+        ));

+      // Free any allocated resources.

+      goto exit_handler;

+    }

+

+    DEBUG ((

+      DEBUG_INFO,

+      "INFO: ACPI Table installed. Status = %r\n",

+      Status

+      ));

+  }

+

+exit_handler:

+  // Free any resources allocated for generating the tables.

+  if (Generator->FreeTableResourcesEx != NULL) {

+    Status1 = Generator->FreeTableResourcesEx (

+                           Generator,

+                           AcpiTableInfo,

+                           CfgMgrProtocol,

+                           &AcpiTable,

+                           TableCount

+                           );

+    if (EFI_ERROR (Status1)) {

+      DEBUG ((

+        DEBUG_ERROR,

+        "ERROR: Failed to Free Table Resources." \

+        "TableGeneratorId = 0x%x. Status = %r\n",

+        AcpiTableInfo->TableGeneratorId,

+        Status1

+        ));

+    }

+

+    // Return the first error status in case of failure

+    if (!EFI_ERROR (Status)) {

+      Status = Status1;

+    }

+  }

+

+  return Status;

+}

+

+/** A helper function to invoke a Table generator

+

+  This is a helper function that invokes the Table generator interface

+  for building an ACPI table. It uses the AcpiTableProtocol to install the

+  table, then frees the resources allocated for generating it.

+

+  @param [in]  TableFactoryProtocol Pointer to the Table Factory Protocol

+                                    interface.

+  @param [in]  CfgMgrProtocol       Pointer to the Configuration Manager

+                                    Protocol Interface.

+  @param [in]  AcpiTableProtocol    Pointer to the AcpiTable protocol.

+  @param [in]  AcpiTableInfo        Pointer to the ACPI table Info.

+

+  @retval EFI_SUCCESS           Success.

+  @retval EFI_INVALID_PARAMETER A parameter is invalid.

+  @retval EFI_NOT_FOUND         Required object is not found.

+  @retval EFI_BAD_BUFFER_SIZE   Size returned by the Configuration Manager

+                                is less than the Object size for the

+                                requested object.

+**/

+STATIC

+EFI_STATUS

+EFIAPI

+BuildAndInstallAcpiTable (

+  IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  *CONST  TableFactoryProtocol,

+  IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

+  IN       EFI_ACPI_TABLE_PROTOCOL                       *AcpiTableProtocol,

+  IN CONST CM_STD_OBJ_ACPI_TABLE_INFO            *CONST  AcpiTableInfo

+  )

+{

+  EFI_STATUS                  Status;

+  CONST ACPI_TABLE_GENERATOR  *Generator;

+

+  ASSERT (TableFactoryProtocol != NULL);

+  ASSERT (CfgMgrProtocol != NULL);

+  ASSERT (AcpiTableProtocol != NULL);

+  ASSERT (AcpiTableInfo != NULL);

+

+  DEBUG ((

+    DEBUG_INFO,

+    "INFO: EStdObjAcpiTableList: Address = 0x%p," \

+    " TableGeneratorId = 0x%x\n",

+    AcpiTableInfo,

+    AcpiTableInfo->TableGeneratorId

+    ));

+

+  Generator = NULL;

+  Status    = TableFactoryProtocol->GetAcpiTableGenerator (

+                                      TableFactoryProtocol,

+                                      AcpiTableInfo->TableGeneratorId,

+                                      &Generator

+                                      );

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: Table Generator not found." \

+      " TableGeneratorId = 0x%x. Status = %r\n",

+      AcpiTableInfo->TableGeneratorId,

+      Status

+      ));

+    return Status;

+  }

+

+  if (Generator == NULL) {

+    return EFI_NOT_FOUND;

+  }

+

+  DEBUG ((

+    DEBUG_INFO,

+    "INFO: Generator found : %s\n",

+    Generator->Description

+    ));

+

+  if (Generator->BuildAcpiTableEx != NULL) {

+    Status = BuildAndInstallMultipleAcpiTable (

+               TableFactoryProtocol,

+               CfgMgrProtocol,

+               Generator,

+               AcpiTableProtocol,

+               AcpiTableInfo

+               );

+    if (EFI_ERROR (Status)) {

+      DEBUG ((

+        DEBUG_ERROR,

+        "ERROR: Failed to find build and install ACPI Table." \

+        " Status = %r\n",

+        Status

+        ));

+    }

+  } else if (Generator->BuildAcpiTable != NULL) {

+    Status = BuildAndInstallSingleAcpiTable (

+               TableFactoryProtocol,

+               CfgMgrProtocol,

+               Generator,

+               AcpiTableProtocol,

+               AcpiTableInfo

+               );

+    if (EFI_ERROR (Status)) {

+      DEBUG ((

+        DEBUG_ERROR,

+        "ERROR: Failed to find build and install ACPI Table." \

+        " Status = %r\n",

+        Status

+        ));

+    }

+  } else {

+    Status = EFI_INVALID_PARAMETER;

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: Table Generator does not implement the" \

+      " ACPI_TABLE_GENERATOR_BUILD_TABLE interface." \

+      " TableGeneratorId = 0x%x. Status = %r\n",

+      AcpiTableInfo->TableGeneratorId,

+      Status

+      ));

+  }

+

+  return Status;

+}

+

+/** The function checks if the Configuration Manager has provided the

+    mandatory ACPI tables for installation.

+

+  @param [in]  AcpiTableInfo      Pointer to the ACPI Table Info list.

+  @param [in]  AcpiTableCount     Count of ACPI Table Info.

+

+  @retval EFI_SUCCESS           Success.

+  @retval EFI_NOT_FOUND         If mandatory table is not found.

+  @retval EFI_ALREADY_STARTED   If mandatory table found in AcpiTableInfo is already installed.

+**/

+STATIC

+EFI_STATUS

+EFIAPI

+VerifyMandatoryTablesArePresent (

+  IN CONST CM_STD_OBJ_ACPI_TABLE_INFO  *CONST  AcpiTableInfo,

+  IN       UINT32                              AcpiTableCount

+  )

+{

+  EFI_STATUS                   Status;

+  UINTN                        Handle;

+  UINTN                        Index;

+  UINTN                        InstalledTableIndex;

+  EFI_ACPI_DESCRIPTION_HEADER  *DescHeader;

+  EFI_ACPI_TABLE_VERSION       Version;

+  EFI_ACPI_SDT_PROTOCOL        *AcpiSdt;

+

+  ASSERT (AcpiTableInfo != NULL);

+

+  Status = EFI_SUCCESS;

+

+  // Check against the statically initialized ACPI tables to see if they are in ACPI info list

+  while (AcpiTableCount-- != 0) {

+    for (Index = 0; Index < mAcpiVerifyTablesCount; Index++) {

+      if (AcpiTableInfo[AcpiTableCount].AcpiTableSignature == mAcpiVerifyTables[Index].AcpiTableSignature) {

+        mAcpiVerifyTables[Index].Presence |= ACPI_TABLE_PRESENT_INFO_LIST;

+        // Found this table, skip the rest.

+        break;

+      }

+    }

+  }

+

+  // They also might be published already, so we can search from there

+  if (FeaturePcdGet (PcdInstallAcpiSdtProtocol)) {

+    AcpiSdt = NULL;

+    Status  = gBS->LocateProtocol (&gEfiAcpiSdtProtocolGuid, NULL, (VOID **)&AcpiSdt);

+

+    if (EFI_ERROR (Status) || (AcpiSdt == NULL)) {

+      DEBUG ((DEBUG_ERROR, "ERROR: Failed to locate ACPI SDT protocol (0x%p) - %r\n", AcpiSdt, Status));

+      return Status;

+    }

+

+    for (Index = 0; Index < mAcpiVerifyTablesCount; Index++) {

+      Handle              = 0;

+      InstalledTableIndex = 0;

+      do {

+        Status = AcpiSdt->GetAcpiTable (InstalledTableIndex, (EFI_ACPI_SDT_HEADER **)&DescHeader, &Version, &Handle);

+        if (EFI_ERROR (Status)) {

+          break;

+        }

+

+        InstalledTableIndex++;

+      } while (DescHeader->Signature != mAcpiVerifyTables[Index].AcpiTableSignature);

+

+      if (!EFI_ERROR (Status)) {

+        mAcpiVerifyTables[Index].Presence |= ACPI_TABLE_PRESENT_INSTALLED;

+      }

+    }

+  }

+

+  // Reset the return Status value to EFI_SUCCESS. We do not fully care if the table look up has failed.

+  Status = EFI_SUCCESS;

+  for (Index = 0; Index < mAcpiVerifyTablesCount; Index++) {

+    if (mAcpiVerifyTables[Index].Presence == 0) {

+      if (mAcpiVerifyTables[Index].IsMandatory) {

+        DEBUG ((DEBUG_ERROR, "ERROR: %a Table not found.\n", mAcpiVerifyTables[Index].AcpiTableName));

+        Status = EFI_NOT_FOUND;

+      } else {

+        DEBUG ((DEBUG_WARN, "WARNING: %a Table not found.\n", mAcpiVerifyTables[Index].AcpiTableName));

+      }

+    } else if (mAcpiVerifyTables[Index].Presence ==

+               (ACPI_TABLE_PRESENT_INFO_LIST | ACPI_TABLE_PRESENT_INSTALLED))

+    {

+      DEBUG ((DEBUG_ERROR, "ERROR: %a Table found while already published.\n", mAcpiVerifyTables[Index].AcpiTableName));

+      Status = EFI_ALREADY_STARTED;

+    }

+  }

+

+  return Status;

+}

+

+/** Generate and install ACPI tables.

+

+  The function gathers the information necessary for installing the

+  ACPI tables from the Configuration Manager, invokes the generators

+  and installs them (via BuildAndInstallAcpiTable).

+

+  @param [in]  TableFactoryProtocol Pointer to the Table Factory Protocol

+                                    interface.

+  @param [in]  CfgMgrProtocol       Pointer to the Configuration Manager

+                                    Protocol Interface.

+

+  @retval EFI_SUCCESS           Success.

+  @retval EFI_NOT_FOUND         If a mandatory table or a generator is not found.

+  @retval EFI_ALREADY_STARTED   If mandatory table found in AcpiTableInfo is already installed.

+**/

+STATIC

+EFI_STATUS

+EFIAPI

+ProcessAcpiTables (

+  IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  *CONST  TableFactoryProtocol,

+  IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol

+  )

+{

+  EFI_STATUS                  Status;

+  EFI_ACPI_TABLE_PROTOCOL     *AcpiTableProtocol;

+  CM_STD_OBJ_ACPI_TABLE_INFO  *AcpiTableInfo;

+  UINT32                      AcpiTableCount;

+  UINT32                      Idx;

+

+  ASSERT (TableFactoryProtocol != NULL);

+  ASSERT (CfgMgrProtocol != NULL);

+

+  // Find the AcpiTable protocol

+  Status = gBS->LocateProtocol (

+                  &gEfiAcpiTableProtocolGuid,

+                  NULL,

+                  (VOID **)&AcpiTableProtocol

+                  );

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: Failed to find AcpiTable protocol. Status = %r\n",

+      Status

+      ));

+    return Status;

+  }

+

+  Status = GetEStdObjAcpiTableList (

+             CfgMgrProtocol,

+             CM_NULL_TOKEN,

+             &AcpiTableInfo,

+             &AcpiTableCount

+             );

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: Failed to get ACPI Table List. Status = %r\n",

+      Status

+      ));

+    return Status;

+  }

+

+  if (0 == AcpiTableCount) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: EStdObjAcpiTableList: AcpiTableCount = %d\n",

+      AcpiTableCount

+      ));

+    return EFI_NOT_FOUND;

+  }

+

+  DEBUG ((

+    DEBUG_INFO,

+    "INFO: EStdObjAcpiTableList: AcpiTableCount = %d\n",

+    AcpiTableCount

+    ));

+

+  // Check if mandatory ACPI tables are present.

+  Status = VerifyMandatoryTablesArePresent (

+             AcpiTableInfo,

+             AcpiTableCount

+             );

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: Failed to verify mandatory ACPI Table(s) presence."

+      " Status = %r\n",

+      Status

+      ));

+    return Status;

+  }

+

+  // Add the FADT Table first.

+  if ((mAcpiVerifyTablesFadtIndex >= 0) &&

+      ((mAcpiVerifyTables[mAcpiVerifyTablesFadtIndex].Presence & ACPI_TABLE_PRESENT_INSTALLED) == 0))

+  {

+    // FADT is not yet installed

+    for (Idx = 0; Idx < AcpiTableCount; Idx++) {

+      if (CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdFadt) ==

+          AcpiTableInfo[Idx].TableGeneratorId)

+      {

+        Status = BuildAndInstallAcpiTable (

+                   TableFactoryProtocol,

+                   CfgMgrProtocol,

+                   AcpiTableProtocol,

+                   &AcpiTableInfo[Idx]

+                   );

+        if (EFI_ERROR (Status)) {

+          DEBUG ((

+            DEBUG_ERROR,

+            "ERROR: Failed to find build and install ACPI FADT Table." \

+            " Status = %r\n",

+            Status

+            ));

+          return Status;

+        }

+

+        break;

+      }

+    } // for

+  }

+

+  // Add remaining ACPI Tables

+  for (Idx = 0; Idx < AcpiTableCount; Idx++) {

+    DEBUG ((

+      DEBUG_INFO,

+      "INFO: AcpiTableInfo[%d].TableGeneratorId = 0x%x\n",

+      Idx,

+      AcpiTableInfo[Idx].TableGeneratorId

+      ));

+

+    // Skip FADT Table since we have already added

+    if (CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdFadt) ==

+        AcpiTableInfo[Idx].TableGeneratorId)

+    {

+      continue;

+    }

+

+    // Skip the Reserved table Generator ID for standard generators

+    if ((IS_GENERATOR_NAMESPACE_STD (AcpiTableInfo[Idx].TableGeneratorId)) &&

+        ((CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdReserved)           >=

+          AcpiTableInfo[Idx].TableGeneratorId)                           ||

+         (CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdMax)                <=

+          AcpiTableInfo[Idx].TableGeneratorId)))

+    {

+      DEBUG ((

+        DEBUG_WARN,

+        "WARNING: Invalid ACPI Generator table ID = 0x%x, Skipping...\n",

+        AcpiTableInfo[Idx].TableGeneratorId

+        ));

+      continue;

+    }

+

+    Status = BuildAndInstallAcpiTable (

+               TableFactoryProtocol,

+               CfgMgrProtocol,

+               AcpiTableProtocol,

+               &AcpiTableInfo[Idx]

+               );

+    if (EFI_ERROR (Status)) {

+      DEBUG ((

+        DEBUG_ERROR,

+        "ERROR: Failed to find, build, and install ACPI Table." \

+        " Status = %r\n",

+        Status

+        ));

+      return Status;

+    }

+  } // for

+

+  return Status;

+}

+

+/** Entrypoint of Dynamic Table Manager Dxe.

+

+  The Dynamic Table Manager uses the Configuration Manager Protocol

+  to get the list of ACPI and SMBIOS tables to install. For each table

+  in the list it requests the corresponding ACPI/SMBIOS table factory for

+  a generator capable of building the ACPI/SMBIOS table.

+  If a suitable table generator is found, it invokes the generator interface

+  to build the table. The Dynamic Table Manager then installs the

+  table and invokes another generator interface to free any resources

+  allocated for building the table.

+

+  @param  ImageHandle

+  @param  SystemTable

+

+  @retval EFI_SUCCESS           Success.

+  @retval EFI_OUT_OF_RESOURCES  Memory allocation failed.

+  @retval EFI_NOT_FOUND         Required interface/object was not found.

+  @retval EFI_INVALID_PARAMETER Some parameter is incorrect/invalid.

+**/

+VOID

+EFIAPI

+AcpiTableProtocolReady (

+  IN  EFI_EVENT  Event,

+  IN  VOID       *Context

+  )

+{

+  EFI_STATUS                             Status;

+  EDKII_CONFIGURATION_MANAGER_PROTOCOL   *CfgMgrProtocol;

+  CM_STD_OBJ_CONFIGURATION_MANAGER_INFO  *CfgMfrInfo;

+  EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL   *TableFactoryProtocol;

+

+  // Locate the Dynamic Table Factory

+  Status = gBS->LocateProtocol (

+                  &gEdkiiDynamicTableFactoryProtocolGuid,

+                  NULL,

+                  (VOID **)&TableFactoryProtocol

+                  );

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: Failed to find Dynamic Table Factory protocol." \

+      " Status = %r\n",

+      Status

+      ));

+    return;

+  }

+

+  // Locate the Configuration Manager for the Platform

+  Status = gBS->LocateProtocol (

+                  &gEdkiiConfigurationManagerProtocolGuid,

+                  NULL,

+                  (VOID **)&CfgMgrProtocol

+                  );

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: Failed to find Configuration Manager protocol. Status = %r\n",

+      Status

+      ));

+    return;

+  }

+

+  Status = GetCgfMgrInfo (CfgMgrProtocol, &CfgMfrInfo);

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: Failed to get Configuration Manager info. Status = %r\n",

+      Status

+      ));

+    return;

+  }

+

+  DEBUG ((

+    DEBUG_INFO,

+    "INFO: Configuration Manager Version = 0x%x, OemID = %c%c%c%c%c%c\n",

+    CfgMfrInfo->Revision,

+    CfgMfrInfo->OemId[0],

+    CfgMfrInfo->OemId[1],

+    CfgMfrInfo->OemId[2],

+    CfgMfrInfo->OemId[3],

+    CfgMfrInfo->OemId[4],

+    CfgMfrInfo->OemId[5]

+    ));

+

+  Status = GetAcpiTablePresenceInfo (

+             &mAcpiVerifyTables,

+             &mAcpiVerifyTablesCount,

+             &mAcpiVerifyTablesFadtIndex

+             );

+  if (EFI_ERROR (Status)) {

+    ASSERT_EFI_ERROR (Status);

+    return;

+  }

+

+  Status = ProcessAcpiTables (TableFactoryProtocol, CfgMgrProtocol);

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: ACPI Table processing failure. Status = %r\n",

+      Status

+      ));

+  }

+}

diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.c b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.c
index 3a88b9327b..c1de3f115c 100644
--- a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.c
+++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.c
@@ -11,10 +11,6 @@
 #include <Library/UefiLib.h>

 #include <Library/PcdLib.h>

 #include <Library/UefiBootServicesTableLib.h>

-#include <Protocol/AcpiSystemDescriptionTable.h>

-#include <Protocol/AcpiTable.h>

-#include <Protocol/Smbios.h>

-#include <Library/BaseMemoryLib.h>

 

 // Module specific include files.

 #include <AcpiTableGenerator.h>

@@ -24,1321 +20,25 @@
 #include <Library/TableHelperLib.h>

 #include <Protocol/ConfigurationManagerProtocol.h>

 #include <Protocol/DynamicTableFactoryProtocol.h>

-#include <SmbiosTableGenerator.h>

-#include <SmbiosTableDispatcher.h>

 

-#include "DynamicTableManagerDxe.h"

-

-///

-/// We require the FADT, MADT, GTDT and the DSDT tables to boot.

-/// This list also include optional ACPI tables: DBG2, SPCR.

-///

-STATIC ACPI_TABLE_PRESENCE_INFO  *mAcpiVerifyTables;

-STATIC UINT32                    mAcpiVerifyTablesCount;

-STATIC INT32                     mAcpiVerifyTablesFadtIndex;

-

-/** This macro expands to a function that retrieves the ACPI Table

-    List from the Configuration Manager.

-*/

-GET_OBJECT_LIST (

-  EObjNameSpaceStandard,

-  EStdObjAcpiTableList,

-  CM_STD_OBJ_ACPI_TABLE_INFO

-  )

-

-/** This macro expands to a function that retrieves the SMBIOS Table

-    List from the Configuration Manager.

-*/

-GET_OBJECT_LIST (

-  EObjNameSpaceStandard,

-  EStdObjSmbiosTableList,

-  CM_STD_OBJ_SMBIOS_TABLE_INFO

-  )

-

-STATIC VOID *AcpiTableProtocolRegistration;

+STATIC VOID  *AcpiTableProtocolRegistration;

 STATIC VOID  *SmbiosProtocolRegistration;

 

-/** A helper function to build and install a single ACPI table.

-

-  This is a helper function that invokes the Table generator interface

-  for building an ACPI table. It uses the AcpiTableProtocol to install the

-  table, then frees the resources allocated for generating it.

-

-  @param [in]  TableFactoryProtocol Pointer to the Table Factory Protocol

-                                    interface.

-  @param [in]  CfgMgrProtocol       Pointer to the Configuration Manager

-                                    Protocol Interface.

-  @param [in]  Generator            Pointer to the AcpiTable generator.

-  @param [in]  AcpiTableProtocol    Pointer to the AcpiTable protocol.

-  @param [in]  AcpiTableInfo        Pointer to the ACPI table Info.

-

-  @retval EFI_SUCCESS           Success.

-  @retval EFI_INVALID_PARAMETER A parameter is invalid.

-  @retval EFI_NOT_FOUND         Required object is not found.

-  @retval EFI_BAD_BUFFER_SIZE   Size returned by the Configuration Manager

-                                is less than the Object size for the

-                                requested object.

-**/

-STATIC

-EFI_STATUS

-EFIAPI

-BuildAndInstallSingleAcpiTable (

-  IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  *CONST  TableFactoryProtocol,

-  IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

-  IN CONST ACPI_TABLE_GENERATOR                  *CONST  Generator,

-  IN       EFI_ACPI_TABLE_PROTOCOL                       *AcpiTableProtocol,

-  IN CONST CM_STD_OBJ_ACPI_TABLE_INFO            *CONST  AcpiTableInfo

-  )

-{

-  EFI_STATUS                   Status;

-  EFI_STATUS                   Status1;

-  EFI_ACPI_DESCRIPTION_HEADER  *AcpiTable;

-  UINTN                        TableHandle;

-

-  AcpiTable = NULL;

-  Status    = Generator->BuildAcpiTable (

-                           Generator,

-                           AcpiTableInfo,

-                           CfgMgrProtocol,

-                           &AcpiTable

-                           );

-  if (EFI_ERROR (Status)) {

-    DEBUG ((

-      DEBUG_ERROR,

-      "ERROR: Failed to Build Table." \

-      " TableGeneratorId = 0x%x. Status = %r\n",

-      AcpiTableInfo->TableGeneratorId,

-      Status

-      ));

-    // Free any allocated resources.

-    goto exit_handler;

-  }

-

-  if (AcpiTable == NULL) {

-    Status = EFI_NOT_FOUND;

-    goto exit_handler;

-  }

-

-  // Dump ACPI Table Header

-  DUMP_ACPI_TABLE_HEADER (AcpiTable);

-

-  // Install ACPI table

-  Status = AcpiTableProtocol->InstallAcpiTable (

-                                AcpiTableProtocol,

-                                AcpiTable,

-                                AcpiTable->Length,

-                                &TableHandle

-                                );

-  if (EFI_ERROR (Status)) {

-    DEBUG ((

-      DEBUG_ERROR,

-      "ERROR: Failed to Install ACPI Table. Status = %r\n",

-      Status

-      ));

-    // Free any allocated resources.

-    goto exit_handler;

-  }

-

-  DEBUG ((

-    DEBUG_INFO,

-    "INFO: ACPI Table installed. Status = %r\n",

-    Status

-    ));

-

-exit_handler:

-  // Free any resources allocated for generating the tables.

-  if (Generator->FreeTableResources != NULL) {

-    Status1 = Generator->FreeTableResources (

-                           Generator,

-                           AcpiTableInfo,

-                           CfgMgrProtocol,

-                           &AcpiTable

-                           );

-    if (EFI_ERROR (Status1)) {

-      DEBUG ((

-        DEBUG_ERROR,

-        "ERROR: Failed to Free Table Resources." \

-        "TableGeneratorId = 0x%x. Status = %r\n",

-        AcpiTableInfo->TableGeneratorId,

-        Status1

-        ));

-    }

-

-    // Return the first error status in case of failure

-    if (!EFI_ERROR (Status)) {

-      Status = Status1;

-    }

-  }

-

-  return Status;

-}

-

-/** A helper function to build and install multiple ACPI tables.

-

-  This is a helper function that invokes the Table generator interface

-  for building an ACPI table. It uses the AcpiTableProtocol to install the

-  table, then frees the resources allocated for generating it.

-

-  @param [in]  TableFactoryProtocol Pointer to the Table Factory Protocol

-                                    interface.

-  @param [in]  CfgMgrProtocol       Pointer to the Configuration Manager

-                                    Protocol Interface.

-  @param [in]  Generator            Pointer to the AcpiTable generator.

-  @param [in]  AcpiTableProtocol    Pointer to the AcpiTable protocol.

-  @param [in]  AcpiTableInfo        Pointer to the ACPI table Info.

-

-  @retval EFI_SUCCESS           Success.

-  @retval EFI_INVALID_PARAMETER A parameter is invalid.

-  @retval EFI_NOT_FOUND         Required object is not found.

-  @retval EFI_BAD_BUFFER_SIZE   Size returned by the Configuration Manager

-                                is less than the Object size for the

-                                requested object.

-**/

-STATIC

-EFI_STATUS

-EFIAPI

-BuildAndInstallMultipleAcpiTable (

-  IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  *CONST  TableFactoryProtocol,

-  IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

-  IN CONST ACPI_TABLE_GENERATOR                  *CONST  Generator,

-  IN       EFI_ACPI_TABLE_PROTOCOL                       *AcpiTableProtocol,

-  IN CONST CM_STD_OBJ_ACPI_TABLE_INFO            *CONST  AcpiTableInfo

-  )

-{

-  EFI_STATUS                   Status;

-  EFI_STATUS                   Status1;

-  EFI_ACPI_DESCRIPTION_HEADER  **AcpiTable;

-  UINTN                        TableCount;

-  UINTN                        TableHandle;

-  UINTN                        Index;

-

-  AcpiTable  = NULL;

-  TableCount = 0;

-  Status     = Generator->BuildAcpiTableEx (

-                            Generator,

-                            AcpiTableInfo,

-                            CfgMgrProtocol,

-                            &AcpiTable,

-                            &TableCount

-                            );

-  if (EFI_ERROR (Status)) {

-    DEBUG ((

-      DEBUG_ERROR,

-      "ERROR: Failed to Build Table." \

-      " TableGeneratorId = 0x%x. Status = %r\n",

-      AcpiTableInfo->TableGeneratorId,

-      Status

-      ));

-    // Free any allocated resources.

-    goto exit_handler;

-  }

-

-  if ((AcpiTable == NULL) || (TableCount == 0)) {

-    Status = EFI_NOT_FOUND;

-    goto exit_handler;

-  }

-

-  for (Index = 0; Index < TableCount; Index++) {

-    // Dump ACPI Table Header

-    DUMP_ACPI_TABLE_HEADER (AcpiTable[Index]);

-    // Install ACPI table

-    Status = AcpiTableProtocol->InstallAcpiTable (

-                                  AcpiTableProtocol,

-                                  AcpiTable[Index],

-                                  AcpiTable[Index]->Length,

-                                  &TableHandle

-                                  );

-    if (EFI_ERROR (Status)) {

-      DEBUG ((

-        DEBUG_ERROR,

-        "ERROR: Failed to Install ACPI Table. Status = %r\n",

-        Status

-        ));

-      // Free any allocated resources.

-      goto exit_handler;

-    }

-

-    DEBUG ((

-      DEBUG_INFO,

-      "INFO: ACPI Table installed. Status = %r\n",

-      Status

-      ));

-  }

-

-exit_handler:

-  // Free any resources allocated for generating the tables.

-  if (Generator->FreeTableResourcesEx != NULL) {

-    Status1 = Generator->FreeTableResourcesEx (

-                           Generator,

-                           AcpiTableInfo,

-                           CfgMgrProtocol,

-                           &AcpiTable,

-                           TableCount

-                           );

-    if (EFI_ERROR (Status1)) {

-      DEBUG ((

-        DEBUG_ERROR,

-        "ERROR: Failed to Free Table Resources." \

-        "TableGeneratorId = 0x%x. Status = %r\n",

-        AcpiTableInfo->TableGeneratorId,

-        Status1

-        ));

-    }

-

-    // Return the first error status in case of failure

-    if (!EFI_ERROR (Status)) {

-      Status = Status1;

-    }

-  }

-

-  return Status;

-}

-

-/** A helper function to invoke a Table generator

-

-  This is a helper function that invokes the Table generator interface

-  for building an ACPI table. It uses the AcpiTableProtocol to install the

-  table, then frees the resources allocated for generating it.

-

-  @param [in]  TableFactoryProtocol Pointer to the Table Factory Protocol

-                                    interface.

-  @param [in]  CfgMgrProtocol       Pointer to the Configuration Manager

-                                    Protocol Interface.

-  @param [in]  AcpiTableProtocol    Pointer to the AcpiTable protocol.

-  @param [in]  AcpiTableInfo        Pointer to the ACPI table Info.

-

-  @retval EFI_SUCCESS           Success.

-  @retval EFI_INVALID_PARAMETER A parameter is invalid.

-  @retval EFI_NOT_FOUND         Required object is not found.

-  @retval EFI_BAD_BUFFER_SIZE   Size returned by the Configuration Manager

-                                is less than the Object size for the

-                                requested object.

-**/

-STATIC

-EFI_STATUS

-EFIAPI

-BuildAndInstallAcpiTable (

-  IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  *CONST  TableFactoryProtocol,

-  IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

-  IN       EFI_ACPI_TABLE_PROTOCOL                       *AcpiTableProtocol,

-  IN CONST CM_STD_OBJ_ACPI_TABLE_INFO            *CONST  AcpiTableInfo

-  )

-{

-  EFI_STATUS                  Status;

-  CONST ACPI_TABLE_GENERATOR  *Generator;

-

-  ASSERT (TableFactoryProtocol != NULL);

-  ASSERT (CfgMgrProtocol != NULL);

-  ASSERT (AcpiTableProtocol != NULL);

-  ASSERT (AcpiTableInfo != NULL);

-

-  DEBUG ((

-    DEBUG_INFO,

-    "INFO: EStdObjAcpiTableList: Address = 0x%p," \

-    " TableGeneratorId = 0x%x\n",

-    AcpiTableInfo,

-    AcpiTableInfo->TableGeneratorId

-    ));

-

-  Generator = NULL;

-  Status    = TableFactoryProtocol->GetAcpiTableGenerator (

-                                      TableFactoryProtocol,

-                                      AcpiTableInfo->TableGeneratorId,

-                                      &Generator

-                                      );

-  if (EFI_ERROR (Status)) {

-    DEBUG ((

-      DEBUG_ERROR,

-      "ERROR: Table Generator not found." \

-      " TableGeneratorId = 0x%x. Status = %r\n",

-      AcpiTableInfo->TableGeneratorId,

-      Status

-      ));

-    return Status;

-  }

-

-  if (Generator == NULL) {

-    return EFI_NOT_FOUND;

-  }

-

-  DEBUG ((

-    DEBUG_INFO,

-    "INFO: Generator found : %s\n",

-    Generator->Description

-    ));

-

-  if (Generator->BuildAcpiTableEx != NULL) {

-    Status = BuildAndInstallMultipleAcpiTable (

-               TableFactoryProtocol,

-               CfgMgrProtocol,

-               Generator,

-               AcpiTableProtocol,

-               AcpiTableInfo

-               );

-    if (EFI_ERROR (Status)) {

-      DEBUG ((

-        DEBUG_ERROR,

-        "ERROR: Failed to find build and install ACPI Table." \

-        " Status = %r\n",

-        Status

-        ));

-    }

-  } else if (Generator->BuildAcpiTable != NULL) {

-    Status = BuildAndInstallSingleAcpiTable (

-               TableFactoryProtocol,

-               CfgMgrProtocol,

-               Generator,

-               AcpiTableProtocol,

-               AcpiTableInfo

-               );

-    if (EFI_ERROR (Status)) {

-      DEBUG ((

-        DEBUG_ERROR,

-        "ERROR: Failed to find build and install ACPI Table." \

-        " Status = %r\n",

-        Status

-        ));

-    }

-  } else {

-    Status = EFI_INVALID_PARAMETER;

-    DEBUG ((

-      DEBUG_ERROR,

-      "ERROR: Table Generator does not implement the" \

-      " ACPI_TABLE_GENERATOR_BUILD_TABLE interface." \

-      " TableGeneratorId = 0x%x. Status = %r\n",

-      AcpiTableInfo->TableGeneratorId,

-      Status

-      ));

-  }

-

-  return Status;

-}

-

-/** The function checks if the Configuration Manager has provided the

-    mandatory ACPI tables for installation.

-

-  @param [in]  AcpiTableInfo      Pointer to the ACPI Table Info list.

-  @param [in]  AcpiTableCount     Count of ACPI Table Info.

-

-  @retval EFI_SUCCESS           Success.

-  @retval EFI_NOT_FOUND         If mandatory table is not found.

-  @retval EFI_ALREADY_STARTED   If mandatory table found in AcpiTableInfo is already installed.

-**/

-STATIC

-EFI_STATUS

-EFIAPI

-VerifyMandatoryTablesArePresent (

-  IN CONST CM_STD_OBJ_ACPI_TABLE_INFO  *CONST  AcpiTableInfo,

-  IN       UINT32                              AcpiTableCount

-  )

-{

-  EFI_STATUS                   Status;

-  UINTN                        Handle;

-  UINTN                        Index;

-  UINTN                        InstalledTableIndex;

-  EFI_ACPI_DESCRIPTION_HEADER  *DescHeader;

-  EFI_ACPI_TABLE_VERSION       Version;

-  EFI_ACPI_SDT_PROTOCOL        *AcpiSdt;

-

-  ASSERT (AcpiTableInfo != NULL);

-

-  Status = EFI_SUCCESS;

-

-  // Check against the statically initialized ACPI tables to see if they are in ACPI info list

-  while (AcpiTableCount-- != 0) {

-    for (Index = 0; Index < mAcpiVerifyTablesCount; Index++) {

-      if (AcpiTableInfo[AcpiTableCount].AcpiTableSignature == mAcpiVerifyTables[Index].AcpiTableSignature) {

-        mAcpiVerifyTables[Index].Presence |= ACPI_TABLE_PRESENT_INFO_LIST;

-        // Found this table, skip the rest.

-        break;

-      }

-    }

-  }

-

-  // They also might be published already, so we can search from there

-  if (FeaturePcdGet (PcdInstallAcpiSdtProtocol)) {

-    AcpiSdt = NULL;

-    Status  = gBS->LocateProtocol (&gEfiAcpiSdtProtocolGuid, NULL, (VOID **)&AcpiSdt);

-

-    if (EFI_ERROR (Status) || (AcpiSdt == NULL)) {

-      DEBUG ((DEBUG_ERROR, "ERROR: Failed to locate ACPI SDT protocol (0x%p) - %r\n", AcpiSdt, Status));

-      return Status;

-    }

-

-    for (Index = 0; Index < mAcpiVerifyTablesCount; Index++) {

-      Handle              = 0;

-      InstalledTableIndex = 0;

-      do {

-        Status = AcpiSdt->GetAcpiTable (InstalledTableIndex, (EFI_ACPI_SDT_HEADER **)&DescHeader, &Version, &Handle);

-        if (EFI_ERROR (Status)) {

-          break;

-        }

-

-        InstalledTableIndex++;

-      } while (DescHeader->Signature != mAcpiVerifyTables[Index].AcpiTableSignature);

-

-      if (!EFI_ERROR (Status)) {

-        mAcpiVerifyTables[Index].Presence |= ACPI_TABLE_PRESENT_INSTALLED;

-      }

-    }

-  }

-

-  // Reset the return Status value to EFI_SUCCESS. We do not fully care if the table look up has failed.

-  Status = EFI_SUCCESS;

-  for (Index = 0; Index < mAcpiVerifyTablesCount; Index++) {

-    if (mAcpiVerifyTables[Index].Presence == 0) {

-      if (mAcpiVerifyTables[Index].IsMandatory) {

-        DEBUG ((DEBUG_ERROR, "ERROR: %a Table not found.\n", mAcpiVerifyTables[Index].AcpiTableName));

-        Status = EFI_NOT_FOUND;

-      } else {

-        DEBUG ((DEBUG_WARN, "WARNING: %a Table not found.\n", mAcpiVerifyTables[Index].AcpiTableName));

-      }

-    } else if (mAcpiVerifyTables[Index].Presence ==

-               (ACPI_TABLE_PRESENT_INFO_LIST | ACPI_TABLE_PRESENT_INSTALLED))

-    {

-      DEBUG ((DEBUG_ERROR, "ERROR: %a Table found while already published.\n", mAcpiVerifyTables[Index].AcpiTableName));

-      Status = EFI_ALREADY_STARTED;

-    }

-  }

-

-  return Status;

-}

-

-/** A helper function to build and install an SMBIOS table.

-

-  This is a helper function that invokes the Table generator interface

-  for building an SMBIOS table. It uses the SmbiosProtocol to install the

-  table, then frees the resources allocated for generating it.

-

-  @param [in]  TableFactoryProtocol Pointer to the Table Factory Protocol

-                                    interface.

-  @param [in]  CfgMgrProtocol       Pointer to the Configuration Manager

-                                    Protocol Interface.

-  @param [in]  SmbiosProtocol       Pointer to the SMBIOS protocol.

-  @param [in]  SmbiosTableInfo      Pointer to the SMBIOS table Info.

-

-  @retval EFI_SUCCESS           Success.

-  @retval EFI_INVALID_PARAMETER A parameter is invalid.

-  @retval EFI_NOT_FOUND         Required object is not found.

-  @retval EFI_BAD_BUFFER_SIZE   Size returned by the Configuration Manager

-                                is less than the Object size for the

-                                requested object.

-**/

-STATIC

-EFI_STATUS

-EFIAPI

-BuildAndInstallSingleSmbiosTable (

-  IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  *CONST  TableFactoryProtocol,

-  IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

-  IN CONST SMBIOS_TABLE_GENERATOR                *CONST  Generator,

-  IN       EFI_SMBIOS_PROTOCOL                           *SmbiosProtocol,

-  IN       CM_STD_OBJ_SMBIOS_TABLE_INFO          *CONST  SmbiosTableInfo

-  )

-{

-  EFI_STATUS         Status;

-  EFI_STATUS         Status1;

-  SMBIOS_STRUCTURE   *SmbiosTable;

-  CM_OBJECT_TOKEN    CmObjToken;

-  EFI_SMBIOS_HANDLE  TableHandle;

-

-  SmbiosTable = NULL;

-  Status      = Generator->BuildSmbiosTable (

-                             Generator,

-                             TableFactoryProtocol,

-                             SmbiosTableInfo,

-                             CfgMgrProtocol,

-                             &SmbiosTable,

-                             &CmObjToken

-                             );

-  if (EFI_ERROR (Status)) {

-    DEBUG ((

-      DEBUG_ERROR,

-      "ERROR: Failed to Build Table." \

-      " TableGeneratorId = 0x%x. Status = %r\n",

-      SmbiosTableInfo->TableGeneratorId,

-      Status

-      ));

-    // Free any allocated resources.

-    goto exit_handler;

-  }

-

-  if (SmbiosTable == NULL) {

-    Status = EFI_NOT_FOUND;

-    goto exit_handler;

-  }

-

-  TableHandle = SMBIOS_HANDLE_PI_RESERVED;

-  // Install SMBIOS table

-  Status = SmbiosProtocol->Add (

-                             SmbiosProtocol,

-                             NULL,

-                             &TableHandle,

-                             SmbiosTable

-                             );

-  if (EFI_ERROR (Status)) {

-    DEBUG ((

-      DEBUG_ERROR,

-      "ERROR: Failed to Install SMBIOS Table. Status = %r\n",

-      Status

-      ));

-    // Free any allocated resources.

-    goto exit_handler;

-  }

-

-  Status = TableFactoryProtocol->AddSmbiosHandle (

-                                   SmbiosProtocol,

-                                   &TableHandle,

-                                   CmObjToken,

-                                   SmbiosTableInfo->TableGeneratorId

-                                   );

-  if (EFI_ERROR (Status)) {

-    DEBUG ((

-      DEBUG_ERROR,

-      "ERROR: Failed to Add SMBIOS Handle. Status = %r\n",

-      Status

-      ));

-    // Free any allocated resources.

-    goto exit_handler;

-  }

-

-  DEBUG ((

-    DEBUG_INFO,

-    "INFO: SMBIOS Table installed. Status = %r\n",

-    Status

-    ));

-

-exit_handler:

-  // Free any resources allocated for generating the tables.

-  if (Generator->FreeTableResources != NULL) {

-    Status1 = Generator->FreeTableResources (

-                           Generator,

-                           TableFactoryProtocol,

-                           SmbiosTableInfo,

-                           CfgMgrProtocol,

-                           &SmbiosTable

-                           );

-    if (EFI_ERROR (Status1)) {

-      DEBUG ((

-        DEBUG_ERROR,

-        "ERROR: Failed to Free Table Resources." \

-        "TableGeneratorId = 0x%x. Status = %r\n",

-        SmbiosTableInfo->TableGeneratorId,

-        Status1

-        ));

-    }

-

-    // Return the first error status in case of failure

-    if (!EFI_ERROR (Status)) {

-      Status = Status1;

-    }

-  }

-

-  return Status;

-}

-

-/** A helper function to build and install multiple SMBIOS tables.

-

-  This is a helper function that invokes the Table generator interface

-  for building SMBIOS tables. It uses the SmbiosProtocol to install the

-  tables, then frees the resources allocated for generating it.

-

-  @param [in]  TableFactoryProtocol Pointer to the Table Factory Protocol

-                                    interface.

-  @param [in]  CfgMgrProtocol       Pointer to the Configuration Manager

-                                    Protocol Interface.

-  @param [in]  Generator            Pointer to the SmbiosTable generator.

-  @param [in]  SmbiosProtocol       Pointer to the Smbios protocol.

-  @param [in]  AcpiTableInfo        Pointer to the SMBIOS table Info.

-

-  @retval EFI_SUCCESS           Success.

-  @retval EFI_INVALID_PARAMETER A parameter is invalid.

-  @retval EFI_NOT_FOUND         Required object is not found.

-  @retval EFI_BAD_BUFFER_SIZE   Size returned by the Configuration Manager

-                                is less than the Object size for the

-                                requested object.

-**/

-STATIC

-EFI_STATUS

-EFIAPI

-BuildAndInstallMultipleSmbiosTables (

-  IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  *CONST  TableFactoryProtocol,

-  IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

-  IN CONST SMBIOS_TABLE_GENERATOR                *CONST  Generator,

-  IN       EFI_SMBIOS_PROTOCOL                           *SmbiosProtocol,

-  IN       CM_STD_OBJ_SMBIOS_TABLE_INFO          *CONST  SmbiosTableInfo

-  )

-{

-  EFI_STATUS         Status;

-  EFI_STATUS         Status1;

-  SMBIOS_STRUCTURE   **SmbiosTable;

-  CM_OBJECT_TOKEN    *CmObjToken;

-  EFI_SMBIOS_HANDLE  TableHandle;

-  UINTN              TableCount;

-  UINTN              Index;

-

-  TableCount = 0;

-  Status     = Generator->BuildSmbiosTableEx (

-                            Generator,

-                            TableFactoryProtocol,

-                            SmbiosTableInfo,

-                            CfgMgrProtocol,

-                            &SmbiosTable,

-                            &CmObjToken,

-                            &TableCount

-                            );

-  if (EFI_ERROR (Status)) {

-    DEBUG ((

-      DEBUG_ERROR,

-      "ERROR: Failed to Build Table." \

-      " TableGeneratorId = 0x%x. Status = %r\n",

-      SmbiosTableInfo->TableGeneratorId,

-      Status

-      ));

-    // Free any allocated resources.

-    goto exit_handler;

-  }

-

-  if ((SmbiosTable == NULL) || (TableCount == 0)) {

-    Status = EFI_NOT_FOUND;

-    DEBUG ((

-      DEBUG_ERROR,

-      "%a: TableCount %u SmbiosTable %p \n",

-      __FUNCTION__,

-      TableCount,

-      SmbiosTable

-      ));

-    goto exit_handler;

-  }

-

-  for (Index = 0; Index < TableCount; Index++) {

-    TableHandle = SMBIOS_HANDLE_PI_RESERVED;

-

-    // Install SMBIOS table

-    Status = SmbiosProtocol->Add (

-                               SmbiosProtocol,

-                               NULL,

-                               &TableHandle,

-                               SmbiosTable[Index]

-                               );

-    if (EFI_ERROR (Status)) {

-      DEBUG ((

-        DEBUG_ERROR,

-        "ERROR: Failed to Install SMBIOS Table. Status = %r\n",

-        Status

-        ));

-      // Free any allocated resources.

-      goto exit_handler;

-    }

-

-    Status = TableFactoryProtocol->AddSmbiosHandle (

-                                     SmbiosProtocol,

-                                     &TableHandle,

-                                     CmObjToken[Index],

-                                     SmbiosTableInfo->TableGeneratorId

-                                     );

-    if (EFI_ERROR (Status)) {

-      DEBUG ((

-        DEBUG_ERROR,

-        "ERROR: Failed to Add SMBIOS Handle. Status = %r\n",

-        Status

-        ));

-      // Free any allocated resources.

-      goto exit_handler;

-    }

-

-    DEBUG ((

-      DEBUG_INFO,

-      "INFO: SMBIOS Table installed. Status = %r\n",

-      Status

-      ));

-  }

-

-exit_handler:

-  // Free any resources allocated for generating the tables.

-  if (Generator->FreeTableResourcesEx != NULL) {

-    Status1 = Generator->FreeTableResourcesEx (

-                           Generator,

-                           TableFactoryProtocol,

-                           SmbiosTableInfo,

-                           CfgMgrProtocol,

-                           &SmbiosTable,

-                           &CmObjToken,

-                           TableCount

-                           );

-    if (EFI_ERROR (Status1)) {

-      DEBUG ((

-        DEBUG_ERROR,

-        "ERROR: Failed to Free Table Resources." \

-        "TableGeneratorId = 0x%x. Status = %r\n",

-        SmbiosTableInfo->TableGeneratorId,

-        Status1

-        ));

-    }

-

-    // Return the first error status in case of failure

-    if (!EFI_ERROR (Status)) {

-      Status = Status1;

-    }

-  }

-

-  DEBUG ((DEBUG_ERROR, "%a: Returning %r\n", __FUNCTION__, Status));

-  return Status;

-}

-

-/** A helper function to invoke a Table generator

-

-  This is a helper function that invokes the Table generator interface

-  for building an SMBIOS table. It uses the SmbiosProtocol to install the

-  table, then frees the resources allocated for generating it.

-

-  @param [in]  TableFactoryProtocol Pointer to the Table Factory Protocol

-                                    interface.

-  @param [in]  CfgMgrProtocol       Pointer to the Configuration Manager

-                                    Protocol Interface.

-  @param [in]  SmbiosProtocol       Pointer to the SMBIOS protocol.

-  @param [in]  SmbiosTableInfo      Pointer to the SMBIOS table Info.

-

-  @retval EFI_SUCCESS           Success.

-  @retval EFI_INVALID_PARAMETER A parameter is invalid.

-  @retval EFI_NOT_FOUND         Required object is not found.

-  @retval EFI_BAD_BUFFER_SIZE   Size returned by the Configuration Manager

-                                is less than the Object size for the

-                                requested object.

-**/

-EFI_STATUS

-EFIAPI

-BuildAndInstallSmbiosTable (

-  IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  *CONST  TableFactoryProtocol,

-  IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

-  IN       EFI_SMBIOS_PROTOCOL                           *SmbiosProtocol,

-  IN       CM_STD_OBJ_SMBIOS_TABLE_INFO          *CONST  SmbiosTableInfo

-  )

-{

-  EFI_STATUS                    Status;

-  CONST SMBIOS_TABLE_GENERATOR  *Generator;

-

-  ASSERT (TableFactoryProtocol != NULL);

-  ASSERT (CfgMgrProtocol != NULL);

-  ASSERT (SmbiosProtocol != NULL);

-  ASSERT (SmbiosTableInfo != NULL);

-

-  DEBUG ((

-    DEBUG_INFO,

-    "INFO: EStdObjSmbiosTableList: Address = 0x%p," \

-    " TableGeneratorId = 0x%x\n",

-    SmbiosTableInfo,

-    SmbiosTableInfo->TableGeneratorId

-    ));

-

-  Generator = NULL;

-  Status    = TableFactoryProtocol->GetSmbiosTableGenerator (

-                                      TableFactoryProtocol,

-                                      SmbiosTableInfo->TableGeneratorId,

-                                      &Generator

-                                      );

-  if (EFI_ERROR (Status)) {

-    DEBUG ((

-      DEBUG_ERROR,

-      "ERROR: Table Generator not found." \

-      " TableGeneratorId = 0x%x. Status = %r\n",

-      SmbiosTableInfo->TableGeneratorId,

-      Status

-      ));

-    return Status;

-  }

-

-  if (Generator == NULL) {

-    return EFI_NOT_FOUND;

-  }

-

-  DEBUG ((

-    DEBUG_INFO,

-    "INFO: Generator found : %s\n",

-    Generator->Description

-    ));

-

-  if (Generator->BuildSmbiosTableEx != NULL) {

-    Status = BuildAndInstallMultipleSmbiosTables (

-               TableFactoryProtocol,

-               CfgMgrProtocol,

-               Generator,

-               SmbiosProtocol,

-               SmbiosTableInfo

-               );

-    if (EFI_ERROR (Status)) {

-      DEBUG ((

-        DEBUG_ERROR,

-        "ERROR: Failed to find build and install SMBIOS Tables." \

-        " Status = %r\n",

-        Status

-        ));

-    }

-  } else if (Generator->BuildSmbiosTable != NULL) {

-    Status = BuildAndInstallSingleSmbiosTable (

-               TableFactoryProtocol,

-               CfgMgrProtocol,

-               Generator,

-               SmbiosProtocol,

-               SmbiosTableInfo

-               );

-    if (EFI_ERROR (Status)) {

-      DEBUG ((

-        DEBUG_ERROR,

-        "ERROR: Failed to find build and install SMBIOS Table." \

-        " Status = %r\n",

-        Status

-        ));

-    }

-  } else {

-    Status = EFI_INVALID_PARAMETER;

-    DEBUG ((

-      DEBUG_ERROR,

-      "ERROR: Table Generator does not implement the" \

-      "SMBIOS_TABLE_GENERATOR_BUILD_TABLE  interface." \

-      " TableGeneratorId = 0x%x. Status = %r\n",

-      SmbiosTableInfo->TableGeneratorId,

-      Status

-      ));

-  }

-

-  DEBUG ((DEBUG_ERROR, "%a: Returning %r\n", __FUNCTION__, Status));

-  return Status;

-}

-

-/** Generate and install SMBIOS tables.

-

-  The function gathers the information necessary for installing the

-  SMBIOS tables from the Configuration Manager, invokes the generators

-  and installs them (via BuildAndInstallAcpiTable).

-

-  @param [in]  TableFactoryProtocol Pointer to the Table Factory Protocol

-                                    interface.

-  @param [in]  CfgMgrProtocol       Pointer to the Configuration Manager

-                                    Protocol Interface.

-

-  @retval EFI_SUCCESS   Success.

-  @retval EFI_NOT_FOUND If a mandatory table or a generator is not found.

-**/

-STATIC

-EFI_STATUS

-EFIAPI

-ProcessSmbiosTables (

-  IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  *CONST  TableFactoryProtocol,

-  IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol

-  )

-{

-  EFI_STATUS                    Status;

-  EFI_SMBIOS_PROTOCOL           *SmbiosProtocol;

-  CM_STD_OBJ_SMBIOS_TABLE_INFO  *SmbiosTableInfo;

-  UINT32                        SmbiosTableCount;

-

-  Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)&SmbiosProtocol);

-  if (EFI_ERROR (Status)) {

-    DEBUG ((DEBUG_ERROR, "Could not locate SMBIOS protocol.  %r\n", Status));

-    return Status;

-  }

-

-  Status = GetEStdObjSmbiosTableList (

-             CfgMgrProtocol,

-             CM_NULL_TOKEN,

-             &SmbiosTableInfo,

-             &SmbiosTableCount

-             );

-  if (EFI_ERROR (Status)) {

-    DEBUG ((

-      DEBUG_ERROR,

-      "ERROR: Failed to get SMBIOS Table List. Status = %r\n",

-      Status

-      ));

-    return Status;

-  }

-

-  if (SmbiosTableCount == 0) {

-    DEBUG ((

-      DEBUG_ERROR,

-      "ERROR: EStdObjSmbiosTableList: SmbiosTableCount = %d\n",

-      SmbiosTableCount

-      ));

-    return EFI_NOT_FOUND;

-  }

-

-  DEBUG ((

-    DEBUG_INFO,

-    "INFO: EStdObjSmbiosTableList: SmbiosTableCount = %d\n",

-    SmbiosTableCount

-    ));

-

-  InitSmbiosTableDispatcher (SmbiosTableInfo, SmbiosTableCount);

-

-  Status = DispatchSmbiosTables (

-             TableFactoryProtocol,

-             CfgMgrProtocol,

-             SmbiosProtocol,

-             SmbiosTableInfo,

-             SmbiosTableCount

-             );

-  if (EFI_ERROR (Status)) {

-    DEBUG ((

-      DEBUG_ERROR,

-      "ERROR: Failed to install SMBIOS Tables.Status = %r\n",

-      Status

-      ));

-  }

-

-  return Status;

-}

-

-/** Generate and install ACPI tables.

-

-  The function gathers the information necessary for installing the

-  ACPI tables from the Configuration Manager, invokes the generators

-  and installs them (via BuildAndInstallAcpiTable).

-

-  @param [in]  TableFactoryProtocol Pointer to the Table Factory Protocol

-                                    interface.

-  @param [in]  CfgMgrProtocol       Pointer to the Configuration Manager

-                                    Protocol Interface.

-

-  @retval EFI_SUCCESS           Success.

-  @retval EFI_NOT_FOUND         If a mandatory table or a generator is not found.

-  @retval EFI_ALREADY_STARTED   If mandatory table found in AcpiTableInfo is already installed.

-**/

-STATIC

-EFI_STATUS

-EFIAPI

-ProcessAcpiTables (

-  IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  *CONST  TableFactoryProtocol,

-  IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol

-  )

-{

-  EFI_STATUS                  Status;

-  EFI_ACPI_TABLE_PROTOCOL     *AcpiTableProtocol;

-  CM_STD_OBJ_ACPI_TABLE_INFO  *AcpiTableInfo;

-  UINT32                      AcpiTableCount;

-  UINT32                      Idx;

-

-  ASSERT (TableFactoryProtocol != NULL);

-  ASSERT (CfgMgrProtocol != NULL);

-

-  // Find the AcpiTable protocol

-  Status = gBS->LocateProtocol (

-                  &gEfiAcpiTableProtocolGuid,

-                  NULL,

-                  (VOID **)&AcpiTableProtocol

-                  );

-  if (EFI_ERROR (Status)) {

-    DEBUG ((

-      DEBUG_ERROR,

-      "ERROR: Failed to find AcpiTable protocol. Status = %r\n",

-      Status

-      ));

-    return Status;

-  }

-

-  Status = GetEStdObjAcpiTableList (

-             CfgMgrProtocol,

-             CM_NULL_TOKEN,

-             &AcpiTableInfo,

-             &AcpiTableCount

-             );

-  if (EFI_ERROR (Status)) {

-    DEBUG ((

-      DEBUG_ERROR,

-      "ERROR: Failed to get ACPI Table List. Status = %r\n",

-      Status

-      ));

-    return Status;

-  }

-

-  if (0 == AcpiTableCount) {

-    DEBUG ((

-      DEBUG_ERROR,

-      "ERROR: EStdObjAcpiTableList: AcpiTableCount = %d\n",

-      AcpiTableCount

-      ));

-    return EFI_NOT_FOUND;

-  }

-

-  DEBUG ((

-    DEBUG_INFO,

-    "INFO: EStdObjAcpiTableList: AcpiTableCount = %d\n",

-    AcpiTableCount

-    ));

-

-  // Check if mandatory ACPI tables are present.

-  Status = VerifyMandatoryTablesArePresent (

-             AcpiTableInfo,

-             AcpiTableCount

-             );

-  if (EFI_ERROR (Status)) {

-    DEBUG ((

-      DEBUG_ERROR,

-      "ERROR: Failed to verify mandatory ACPI Table(s) presence."

-      " Status = %r\n",

-      Status

-      ));

-    return Status;

-  }

-

-  // Add the FADT Table first.

-  if ((mAcpiVerifyTablesFadtIndex >= 0) &&

-      ((mAcpiVerifyTables[mAcpiVerifyTablesFadtIndex].Presence & ACPI_TABLE_PRESENT_INSTALLED) == 0))

-  {

-    // FADT is not yet installed

-    for (Idx = 0; Idx < AcpiTableCount; Idx++) {

-      if (CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdFadt) ==

-          AcpiTableInfo[Idx].TableGeneratorId)

-      {

-        Status = BuildAndInstallAcpiTable (

-                   TableFactoryProtocol,

-                   CfgMgrProtocol,

-                   AcpiTableProtocol,

-                   &AcpiTableInfo[Idx]

-                   );

-        if (EFI_ERROR (Status)) {

-          DEBUG ((

-            DEBUG_ERROR,

-            "ERROR: Failed to find build and install ACPI FADT Table." \

-            " Status = %r\n",

-            Status

-            ));

-          return Status;

-        }

-

-        break;

-      }

-    } // for

-  }

-

-  // Add remaining ACPI Tables

-  for (Idx = 0; Idx < AcpiTableCount; Idx++) {

-    DEBUG ((

-      DEBUG_INFO,

-      "INFO: AcpiTableInfo[%d].TableGeneratorId = 0x%x\n",

-      Idx,

-      AcpiTableInfo[Idx].TableGeneratorId

-      ));

-

-    // Skip FADT Table since we have already added

-    if (CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdFadt) ==

-        AcpiTableInfo[Idx].TableGeneratorId)

-    {

-      continue;

-    }

-

-    // Skip the Reserved table Generator ID for standard generators

-    if ((IS_GENERATOR_NAMESPACE_STD (AcpiTableInfo[Idx].TableGeneratorId)) &&

-        ((CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdReserved)           >=

-          AcpiTableInfo[Idx].TableGeneratorId)                           ||

-         (CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdMax)                <=

-          AcpiTableInfo[Idx].TableGeneratorId)))

-    {

-      DEBUG ((

-        DEBUG_WARN,

-        "WARNING: Invalid ACPI Generator table ID = 0x%x, Skipping...\n",

-        AcpiTableInfo[Idx].TableGeneratorId

-        ));

-      continue;

-    }

-

-    Status = BuildAndInstallAcpiTable (

-               TableFactoryProtocol,

-               CfgMgrProtocol,

-               AcpiTableProtocol,

-               &AcpiTableInfo[Idx]

-               );

-    if (EFI_ERROR (Status)) {

-      DEBUG ((

-        DEBUG_ERROR,

-        "ERROR: Failed to find, build, and install ACPI Table." \

-        " Status = %r\n",

-        Status

-        ));

-      return Status;

-    }

-  } // for

-

-  return Status;

-}

-

-/** Callback function for ACPI Protocol .

-

-  Callback function for ACPI protocol that installs ACPI tables

-

-  @param  Event

-  @param  Context

-

-  @retval None

-**/

-STATIC

+extern

 VOID

-AcpiTableProtocolReady (

+EFIAPI

+SmbiosProtocolReady (

   IN  EFI_EVENT  Event,

   IN  VOID       *Context

-  )

-{

-  EFI_STATUS                             Status;

-  EDKII_CONFIGURATION_MANAGER_PROTOCOL   *CfgMgrProtocol;

-  CM_STD_OBJ_CONFIGURATION_MANAGER_INFO  *CfgMfrInfo;

-  EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL   *TableFactoryProtocol;

-

-  // Locate the Dynamic Table Factory

-  Status = gBS->LocateProtocol (

-                  &gEdkiiDynamicTableFactoryProtocolGuid,

-                  NULL,

-                  (VOID **)&TableFactoryProtocol

-                  );

-  if (EFI_ERROR (Status)) {

-    DEBUG ((

-      DEBUG_ERROR,

-      "ERROR: Failed to find Dynamic Table Factory protocol." \

-      " Status = %r\n",

-      Status

-      ));

-    return;

-  }

-

-  // Locate the Configuration Manager for the Platform

-  Status = gBS->LocateProtocol (

-                  &gEdkiiConfigurationManagerProtocolGuid,

-                  NULL,

-                  (VOID **)&CfgMgrProtocol

-                  );

-  if (EFI_ERROR (Status)) {

-    DEBUG ((

-      DEBUG_ERROR,

-      "ERROR: Failed to find Configuration Manager protocol. Status = %r\n",

-      Status

-      ));

-    return;

-  }

-

-  Status = GetCgfMgrInfo (CfgMgrProtocol, &CfgMfrInfo);

-  if (EFI_ERROR (Status)) {

-    DEBUG ((

-      DEBUG_ERROR,

-      "ERROR: Failed to get Configuration Manager info. Status = %r\n",

-      Status

-      ));

-    return;

-  }

-

-  DEBUG ((

-    DEBUG_INFO,

-    "INFO: Configuration Manager Version = 0x%x, OemID = %c%c%c%c%c%c\n",

-    CfgMfrInfo->Revision,

-    CfgMfrInfo->OemId[0],

-    CfgMfrInfo->OemId[1],

-    CfgMfrInfo->OemId[2],

-    CfgMfrInfo->OemId[3],

-    CfgMfrInfo->OemId[4],

-    CfgMfrInfo->OemId[5]

-    ));

+  );

 

-  Status = GetAcpiTablePresenceInfo (

-             &mAcpiVerifyTables,

-             &mAcpiVerifyTablesCount,

-             &mAcpiVerifyTablesFadtIndex

-             );

-  if (EFI_ERROR (Status)) {

-    ASSERT_EFI_ERROR (Status);

-    return Status;

-  }

-

-  Status = ProcessAcpiTables (TableFactoryProtocol, CfgMgrProtocol);

-  if (EFI_ERROR (Status)) {

-    DEBUG ((

-      DEBUG_ERROR,

-      "ERROR: ACPI Table processing failure. Status = %r\n",

-      Status

-      ));

-  }

-}

-

-/** Callback function for SMBIOS Protocol .

-

-  Callback function for SMBIOS protocol that installs SMBIOS tables

-  that use the DynamicTables Package.

-

-  @param  Event

-  @param  Context

-

-  @retval None

-**/

-STATIC

+extern

 VOID

-SmbiosProtocolReady (

+EFIAPI

+AcpiTableProtocolReady (

   IN  EFI_EVENT  Event,

   IN  VOID       *Context

-  )

-{

-  EFI_STATUS                             Status;

-  EDKII_CONFIGURATION_MANAGER_PROTOCOL   *CfgMgrProtocol;

-  CM_STD_OBJ_CONFIGURATION_MANAGER_INFO  *CfgMfrInfo;

-  EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL   *TableFactoryProtocol;

-

-  // Locate the Dynamic Table Factory

-  Status = gBS->LocateProtocol (

-                  &gEdkiiDynamicTableFactoryProtocolGuid,

-                  NULL,

-                  (VOID **)&TableFactoryProtocol

-                  );

-  if (EFI_ERROR (Status)) {

-    DEBUG ((

-      DEBUG_ERROR,

-      "ERROR: Failed to find Dynamic Table Factory protocol." \

-      " Status = %r\n",

-      Status

-      ));

-    return;

-  }

-

-  // Locate the Configuration Manager for the Platform

-  Status = gBS->LocateProtocol (

-                  &gEdkiiConfigurationManagerProtocolGuid,

-                  NULL,

-                  (VOID **)&CfgMgrProtocol

-                  );

-  if (EFI_ERROR (Status)) {

-    DEBUG ((

-      DEBUG_ERROR,

-      "ERROR: Failed to find Configuration Manager protocol. Status = %r\n",

-      Status

-      ));

-    return;

-  }

-

-  Status = GetCgfMgrInfo (CfgMgrProtocol, &CfgMfrInfo);

-  if (EFI_ERROR (Status)) {

-    DEBUG ((

-      DEBUG_ERROR,

-      "ERROR: Failed to get Configuration Manager info. Status = %r\n",

-      Status

-      ));

-    return;

-  }

-

-  DEBUG ((

-    DEBUG_INFO,

-    "INFO: Configuration Manager Version = 0x%x, OemID = %c%c%c%c%c%c\n",

-    CfgMfrInfo->Revision,

-    CfgMfrInfo->OemId[0],

-    CfgMfrInfo->OemId[1],

-    CfgMfrInfo->OemId[2],

-    CfgMfrInfo->OemId[3],

-    CfgMfrInfo->OemId[4],

-    CfgMfrInfo->OemId[5]

-    ));

-

-  Status = ProcessSmbiosTables (TableFactoryProtocol, CfgMgrProtocol);

-  if (EFI_ERROR (Status)) {

-    DEBUG ((

-      DEBUG_ERROR,

-      "ERROR: SMBIOS Table processing failure. Status = %r\n",

-      Status

-      ));

-  }

-}

+  );

 

 /** Entrypoint of Dynamic Table Manager Dxe.

 

@@ -1366,9 +66,8 @@ DynamicTableManagerDxeInitialize (
   IN  EFI_SYSTEM_TABLE  *SystemTable

   )

 {

-  EFI_STATUS  Status;

-  EFI_EVENT   AcpiEvent;

-  EFI_EVENT   SmbiosEvent;

+  EFI_EVENT  AcpiEvent;

+  EFI_EVENT  SmbiosEvent;

 

   AcpiEvent = EfiCreateProtocolNotifyEvent (

                 &gEfiAcpiTableProtocolGuid,

@@ -1395,5 +94,5 @@ DynamicTableManagerDxeInitialize (
     return EFI_OUT_OF_RESOURCES;

   }

 

-  return Status;

+  return EFI_SUCCESS;

 }

diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf
index 2a6f1e7b55..5b96269df8 100644
--- a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf
+++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf
@@ -25,6 +25,8 @@
   DynamicTableManagerDxe.h

   SmbiosTableDispatcher.c

   SmbiosTableDispatcher.h

+  AcpiTableBuilder.c

+  SmbiosTableBuilder.c

 

 [Sources.ARM, Sources.AARCH64]

   Arm/ArmDynamicTableManager.c

diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableBuilder.c b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableBuilder.c
new file mode 100644
index 0000000000..bf6e657bcf
--- /dev/null
+++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableBuilder.c
@@ -0,0 +1,605 @@
+/** @file

+  Dynamic Table Manager Dxe

+

+  Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.

+

+  SPDX-License-Identifier: BSD-2-Clause-Patent

+

+**/

+

+#include <Library/DebugLib.h>

+#include <Library/UefiLib.h>

+#include <Library/PcdLib.h>

+#include <Library/UefiBootServicesTableLib.h>

+#include <Protocol/Smbios.h>

+#include <Library/BaseMemoryLib.h>

+

+// Module specific include files.

+#include <ConfigurationManagerObject.h>

+#include <ConfigurationManagerHelper.h>

+#include <DeviceTreeTableGenerator.h>

+#include <Library/TableHelperLib.h>

+#include <Protocol/ConfigurationManagerProtocol.h>

+#include <Protocol/DynamicTableFactoryProtocol.h>

+#include <SmbiosTableGenerator.h>

+#include <SmbiosTableDispatcher.h>

+

+/** This macro expands to a function that retrieves the SMBIOS Table

+    List from the Configuration Manager.

+*/

+GET_OBJECT_LIST (

+  EObjNameSpaceStandard,

+  EStdObjSmbiosTableList,

+  CM_STD_OBJ_SMBIOS_TABLE_INFO

+  )

+

+/** A helper function to build and install an SMBIOS table.

+

+  This is a helper function that invokes the Table generator interface

+  for building an SMBIOS table. It uses the SmbiosProtocol to install the

+  table, then frees the resources allocated for generating it.

+

+  @param [in]  TableFactoryProtocol Pointer to the Table Factory Protocol

+                                    interface.

+  @param [in]  CfgMgrProtocol       Pointer to the Configuration Manager

+                                    Protocol Interface.

+  @param [in]  SmbiosProtocol       Pointer to the SMBIOS protocol.

+  @param [in]  SmbiosTableInfo      Pointer to the SMBIOS table Info.

+

+  @retval EFI_SUCCESS           Success.

+  @retval EFI_INVALID_PARAMETER A parameter is invalid.

+  @retval EFI_NOT_FOUND         Required object is not found.

+  @retval EFI_BAD_BUFFER_SIZE   Size returned by the Configuration Manager

+                                is less than the Object size for the

+                                requested object.

+**/

+STATIC

+EFI_STATUS

+EFIAPI

+BuildAndInstallSingleSmbiosTable (

+  IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  *CONST  TableFactoryProtocol,

+  IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

+  IN CONST SMBIOS_TABLE_GENERATOR                *CONST  Generator,

+  IN       EFI_SMBIOS_PROTOCOL                           *SmbiosProtocol,

+  IN       CM_STD_OBJ_SMBIOS_TABLE_INFO          *CONST  SmbiosTableInfo

+  )

+{

+  EFI_STATUS         Status;

+  EFI_STATUS         Status1;

+  SMBIOS_STRUCTURE   *SmbiosTable;

+  CM_OBJECT_TOKEN    CmObjToken;

+  EFI_SMBIOS_HANDLE  TableHandle;

+

+  SmbiosTable = NULL;

+  Status      = Generator->BuildSmbiosTable (

+                             Generator,

+                             TableFactoryProtocol,

+                             SmbiosTableInfo,

+                             CfgMgrProtocol,

+                             &SmbiosTable,

+                             &CmObjToken

+                             );

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: Failed to Build Table." \

+      " TableGeneratorId = 0x%x. Status = %r\n",

+      SmbiosTableInfo->TableGeneratorId,

+      Status

+      ));

+    // Free any allocated resources.

+    goto exit_handler;

+  }

+

+  if (SmbiosTable == NULL) {

+    Status = EFI_NOT_FOUND;

+    goto exit_handler;

+  }

+

+  TableHandle = SMBIOS_HANDLE_PI_RESERVED;

+

+  // Install SMBIOS table

+  Status = SmbiosProtocol->Add (

+                             SmbiosProtocol,

+                             NULL,

+                             &TableHandle,

+                             SmbiosTable

+                             );

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: Failed to Install SMBIOS Table. Status = %r\n",

+      Status

+      ));

+    // Free any allocated resources.

+    goto exit_handler;

+  }

+

+  Status = TableFactoryProtocol->AddSmbiosHandle (

+                                   SmbiosProtocol,

+                                   &TableHandle,

+                                   CmObjToken,

+                                   SmbiosTableInfo->TableGeneratorId

+                                   );

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: Failed to Add SMBIOS Handle. Status = %r\n",

+      Status

+      ));

+    // Free any allocated resources.

+    goto exit_handler;

+  }

+

+  DEBUG ((

+    DEBUG_INFO,

+    "INFO: SMBIOS Table installed. Status = %r\n",

+    Status

+    ));

+

+exit_handler:

+  // Free any resources allocated for generating the tables.

+  if (Generator->FreeTableResources != NULL) {

+    Status1 = Generator->FreeTableResources (

+                           Generator,

+                           TableFactoryProtocol,

+                           SmbiosTableInfo,

+                           CfgMgrProtocol,

+                           &SmbiosTable

+                           );

+    if (EFI_ERROR (Status1)) {

+      DEBUG ((

+        DEBUG_ERROR,

+        "ERROR: Failed to Free Table Resources." \

+        "TableGeneratorId = 0x%x. Status = %r\n",

+        SmbiosTableInfo->TableGeneratorId,

+        Status1

+        ));

+    }

+

+    // Return the first error status in case of failure

+    if (!EFI_ERROR (Status)) {

+      Status = Status1;

+    }

+  }

+

+  return Status;

+}

+

+/** A helper function to build and install multiple SMBIOS tables.

+

+  This is a helper function that invokes the Table generator interface

+  for building SMBIOS tables. It uses the SmbiosProtocol to install the

+  tables, then frees the resources allocated for generating it.

+

+  @param [in]  TableFactoryProtocol Pointer to the Table Factory Protocol

+                                    interface.

+  @param [in]  CfgMgrProtocol       Pointer to the Configuration Manager

+                                    Protocol Interface.

+  @param [in]  Generator            Pointer to the SmbiosTable generator.

+  @param [in]  SmbiosProtocol       Pointer to the Smbios protocol.

+  @param [in]  AcpiTableInfo        Pointer to the SMBIOS table Info.

+

+  @retval EFI_SUCCESS           Success.

+  @retval EFI_INVALID_PARAMETER A parameter is invalid.

+  @retval EFI_NOT_FOUND         Required object is not found.

+  @retval EFI_BAD_BUFFER_SIZE   Size returned by the Configuration Manager

+                                is less than the Object size for the

+                                requested object.

+**/

+STATIC

+EFI_STATUS

+EFIAPI

+BuildAndInstallMultipleSmbiosTables (

+  IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  *CONST  TableFactoryProtocol,

+  IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

+  IN CONST SMBIOS_TABLE_GENERATOR                *CONST  Generator,

+  IN       EFI_SMBIOS_PROTOCOL                           *SmbiosProtocol,

+  IN       CM_STD_OBJ_SMBIOS_TABLE_INFO          *CONST  SmbiosTableInfo

+  )

+{

+  EFI_STATUS         Status;

+  EFI_STATUS         Status1;

+  SMBIOS_STRUCTURE   **SmbiosTable;

+  CM_OBJECT_TOKEN    *CmObjToken;

+  EFI_SMBIOS_HANDLE  TableHandle;

+  UINTN              TableCount;

+  UINTN              Index;

+

+  TableCount = 0;

+  Status     = Generator->BuildSmbiosTableEx (

+                            Generator,

+                            TableFactoryProtocol,

+                            SmbiosTableInfo,

+                            CfgMgrProtocol,

+                            &SmbiosTable,

+                            &CmObjToken,

+                            &TableCount

+                            );

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: Failed to Build Table." \

+      " TableGeneratorId = 0x%x. Status = %r\n",

+      SmbiosTableInfo->TableGeneratorId,

+      Status

+      ));

+    // Free any allocated resources.

+    goto exit_handler;

+  }

+

+  if ((SmbiosTable == NULL) || (TableCount == 0)) {

+    Status = EFI_NOT_FOUND;

+    DEBUG ((

+      DEBUG_ERROR,

+      "%a: TableCount %u SmbiosTable %p \n",

+      __FUNCTION__,

+      TableCount,

+      SmbiosTable

+      ));

+    goto exit_handler;

+  }

+

+  for (Index = 0; Index < TableCount; Index++) {

+    TableHandle = SMBIOS_HANDLE_PI_RESERVED;

+

+    // Install SMBIOS table

+    Status = SmbiosProtocol->Add (

+                               SmbiosProtocol,

+                               NULL,

+                               &TableHandle,

+                               SmbiosTable[Index]

+                               );

+    if (EFI_ERROR (Status)) {

+      DEBUG ((

+        DEBUG_ERROR,

+        "ERROR: Failed to Install SMBIOS Table. Status = %r\n",

+        Status

+        ));

+      // Free any allocated resources.

+      goto exit_handler;

+    }

+

+    Status = TableFactoryProtocol->AddSmbiosHandle (

+                                     SmbiosProtocol,

+                                     &TableHandle,

+                                     CmObjToken[Index],

+                                     SmbiosTableInfo->TableGeneratorId

+                                     );

+    if (EFI_ERROR (Status)) {

+      DEBUG ((

+        DEBUG_ERROR,

+        "ERROR: Failed to Add SMBIOS Handle. Status = %r\n",

+        Status

+        ));

+      // Free any allocated resources.

+      goto exit_handler;

+    }

+

+    DEBUG ((

+      DEBUG_INFO,

+      "INFO: SMBIOS Table installed. Status = %r\n",

+      Status

+      ));

+  }

+

+exit_handler:

+  // Free any resources allocated for generating the tables.

+  if (Generator->FreeTableResourcesEx != NULL) {

+    Status1 = Generator->FreeTableResourcesEx (

+                           Generator,

+                           TableFactoryProtocol,

+                           SmbiosTableInfo,

+                           CfgMgrProtocol,

+                           &SmbiosTable,

+                           &CmObjToken,

+                           TableCount

+                           );

+    if (EFI_ERROR (Status1)) {

+      DEBUG ((

+        DEBUG_ERROR,

+        "ERROR: Failed to Free Table Resources." \

+        "TableGeneratorId = 0x%x. Status = %r\n",

+        SmbiosTableInfo->TableGeneratorId,

+        Status1

+        ));

+    }

+

+    // Return the first error status in case of failure

+    if (!EFI_ERROR (Status)) {

+      Status = Status1;

+    }

+  }

+

+  DEBUG ((DEBUG_ERROR, "%a: Returning %r\n", __FUNCTION__, Status));

+  return Status;

+}

+

+/** A helper function to invoke a Table generator

+

+  This is a helper function that invokes the Table generator interface

+  for building an SMBIOS table. It uses the SmbiosProtocol to install the

+  table, then frees the resources allocated for generating it.

+

+  @param [in]  TableFactoryProtocol Pointer to the Table Factory Protocol

+                                    interface.

+  @param [in]  CfgMgrProtocol       Pointer to the Configuration Manager

+                                    Protocol Interface.

+  @param [in]  SmbiosProtocol       Pointer to the SMBIOS protocol.

+  @param [in]  SmbiosTableInfo      Pointer to the SMBIOS table Info.

+

+  @retval EFI_SUCCESS           Success.

+  @retval EFI_INVALID_PARAMETER A parameter is invalid.

+  @retval EFI_NOT_FOUND         Required object is not found.

+  @retval EFI_BAD_BUFFER_SIZE   Size returned by the Configuration Manager

+                                is less than the Object size for the

+                                requested object.

+**/

+EFI_STATUS

+EFIAPI

+BuildAndInstallSmbiosTable (

+  IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  *CONST  TableFactoryProtocol,

+  IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

+  IN       EFI_SMBIOS_PROTOCOL                           *SmbiosProtocol,

+  IN       CM_STD_OBJ_SMBIOS_TABLE_INFO          *CONST  SmbiosTableInfo

+  )

+{

+  EFI_STATUS                    Status;

+  CONST SMBIOS_TABLE_GENERATOR  *Generator;

+

+  ASSERT (TableFactoryProtocol != NULL);

+  ASSERT (CfgMgrProtocol != NULL);

+  ASSERT (SmbiosProtocol != NULL);

+  ASSERT (SmbiosTableInfo != NULL);

+

+  DEBUG ((

+    DEBUG_INFO,

+    "INFO: EStdObjSmbiosTableList: Address = 0x%p," \

+    " TableGeneratorId = 0x%x\n",

+    SmbiosTableInfo,

+    SmbiosTableInfo->TableGeneratorId

+    ));

+

+  Generator = NULL;

+  Status    = TableFactoryProtocol->GetSmbiosTableGenerator (

+                                      TableFactoryProtocol,

+                                      SmbiosTableInfo->TableGeneratorId,

+                                      &Generator

+                                      );

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: Table Generator not found." \

+      " TableGeneratorId = 0x%x. Status = %r\n",

+      SmbiosTableInfo->TableGeneratorId,

+      Status

+      ));

+    return Status;

+  }

+

+  if (Generator == NULL) {

+    return EFI_NOT_FOUND;

+  }

+

+  DEBUG ((

+    DEBUG_INFO,

+    "INFO: Generator found : %s\n",

+    Generator->Description

+    ));

+

+  if (Generator->BuildSmbiosTableEx != NULL) {

+    Status = BuildAndInstallMultipleSmbiosTables (

+               TableFactoryProtocol,

+               CfgMgrProtocol,

+               Generator,

+               SmbiosProtocol,

+               SmbiosTableInfo

+               );

+    if (EFI_ERROR (Status)) {

+      DEBUG ((

+        DEBUG_ERROR,

+        "ERROR: Failed to find build and install SMBIOS Tables." \

+        " Status = %r\n",

+        Status

+        ));

+    }

+  } else if (Generator->BuildSmbiosTable != NULL) {

+    Status = BuildAndInstallSingleSmbiosTable (

+               TableFactoryProtocol,

+               CfgMgrProtocol,

+               Generator,

+               SmbiosProtocol,

+               SmbiosTableInfo

+               );

+    if (EFI_ERROR (Status)) {

+      DEBUG ((

+        DEBUG_ERROR,

+        "ERROR: Failed to find build and install SMBIOS Table." \

+        " Status = %r\n",

+        Status

+        ));

+    }

+  } else {

+    Status = EFI_INVALID_PARAMETER;

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: Table Generator does not implement the" \

+      "SMBIOS_TABLE_GENERATOR_BUILD_TABLE  interface." \

+      " TableGeneratorId = 0x%x. Status = %r\n",

+      SmbiosTableInfo->TableGeneratorId,

+      Status

+      ));

+  }

+

+  DEBUG ((DEBUG_ERROR, "%a: Returning %r\n", __FUNCTION__, Status));

+  return Status;

+}

+

+/** Generate and install SMBIOS tables.

+

+  The function gathers the information necessary for installing the

+  SMBIOS tables from the Configuration Manager, invokes the generators

+  and installs them (via BuildAndInstallAcpiTable).

+

+  @param [in]  TableFactoryProtocol Pointer to the Table Factory Protocol

+                                    interface.

+  @param [in]  CfgMgrProtocol       Pointer to the Configuration Manager

+                                    Protocol Interface.

+

+  @retval EFI_SUCCESS   Success.

+  @retval EFI_NOT_FOUND If a mandatory table or a generator is not found.

+**/

+STATIC

+EFI_STATUS

+EFIAPI

+ProcessSmbiosTables (

+  IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  *CONST  TableFactoryProtocol,

+  IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol

+  )

+{

+  EFI_STATUS                    Status;

+  EFI_SMBIOS_PROTOCOL           *SmbiosProtocol;

+  CM_STD_OBJ_SMBIOS_TABLE_INFO  *SmbiosTableInfo;

+  UINT32                        SmbiosTableCount;

+

+  Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)&SmbiosProtocol);

+  if (EFI_ERROR (Status)) {

+    DEBUG ((DEBUG_ERROR, "Could not locate SMBIOS protocol.  %r\n", Status));

+    return Status;

+  }

+

+  Status = GetEStdObjSmbiosTableList (

+             CfgMgrProtocol,

+             CM_NULL_TOKEN,

+             &SmbiosTableInfo,

+             &SmbiosTableCount

+             );

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: Failed to get SMBIOS Table List. Status = %r\n",

+      Status

+      ));

+    return Status;

+  }

+

+  if (SmbiosTableCount == 0) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: EStdObjSmbiosTableList: SmbiosTableCount = %d\n",

+      SmbiosTableCount

+      ));

+    return EFI_NOT_FOUND;

+  }

+

+  DEBUG ((

+    DEBUG_INFO,

+    "INFO: EStdObjSmbiosTableList: SmbiosTableCount = %d\n",

+    SmbiosTableCount

+    ));

+

+  InitSmbiosTableDispatcher (SmbiosTableInfo, SmbiosTableCount);

+

+  Status = DispatchSmbiosTables (

+             TableFactoryProtocol,

+             CfgMgrProtocol,

+             SmbiosProtocol,

+             SmbiosTableInfo,

+             SmbiosTableCount

+             );

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: Failed to install SMBIOS Tables.Status = %r\n",

+      Status

+      ));

+  }

+

+  DEBUG ((DEBUG_ERROR, "%a: Returning %r\n", __FUNCTION__, Status));

+  return Status;

+}

+

+/** Callback function for SMBIOS Protocol .

+

+  Callback function for SMBIOS protocol that installs SMBIOS tables

+  that use the DynamicTables Package.

+

+  @param  Event

+  @param  Context

+

+  @retval None

+**/

+VOID

+EFIAPI

+SmbiosProtocolReady (

+  IN  EFI_EVENT  Event,

+  IN  VOID       *Context

+  )

+{

+  EFI_STATUS                             Status;

+  EDKII_CONFIGURATION_MANAGER_PROTOCOL   *CfgMgrProtocol;

+  CM_STD_OBJ_CONFIGURATION_MANAGER_INFO  *CfgMfrInfo;

+  EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL   *TableFactoryProtocol;

+

+  // Locate the Dynamic Table Factory

+  Status = gBS->LocateProtocol (

+                  &gEdkiiDynamicTableFactoryProtocolGuid,

+                  NULL,

+                  (VOID **)&TableFactoryProtocol

+                  );

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: Failed to find Dynamic Table Factory protocol." \

+      " Status = %r\n",

+      Status

+      ));

+    return;

+  }

+

+  // Locate the Configuration Manager for the Platform

+  Status = gBS->LocateProtocol (

+                  &gEdkiiConfigurationManagerProtocolGuid,

+                  NULL,

+                  (VOID **)&CfgMgrProtocol

+                  );

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: Failed to find Configuration Manager protocol. Status = %r\n",

+      Status

+      ));

+    return;

+  }

+

+  Status = GetCgfMgrInfo (CfgMgrProtocol, &CfgMfrInfo);

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: Failed to get Configuration Manager info. Status = %r\n",

+      Status

+      ));

+    return;

+  }

+

+  DEBUG ((

+    DEBUG_INFO,

+    "INFO: Configuration Manager Version = 0x%x, OemID = %c%c%c%c%c%c\n",

+    CfgMfrInfo->Revision,

+    CfgMfrInfo->OemId[0],

+    CfgMfrInfo->OemId[1],

+    CfgMfrInfo->OemId[2],

+    CfgMfrInfo->OemId[3],

+    CfgMfrInfo->OemId[4],

+    CfgMfrInfo->OemId[5]

+    ));

+

+  Status = ProcessSmbiosTables (TableFactoryProtocol, CfgMgrProtocol);

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "ERROR: SMBIOS Table processing failure. Status = %r\n",

+      Status

+      ));

+  }

+}

-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#121093): https://edk2.groups.io/g/devel/message/121093
Mute This Topic: https://groups.io/mt/111022012/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [edk2-devel] [staging/dynamictables-reorg PATCH v0 09/12] DynamicTablesPkg: Introduce new namespace for SMBIOS Objects
  2025-02-05 22:08 [edk2-devel] [staging/dynamictables-reorg PATCH v0 00/12] DynamicTablesPkg: Add SMBIOS table generation support Girish Mahadevan via groups.io
                   ` (7 preceding siblings ...)
  2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 08/12] DynamicTablesPkg: Split the ACPI and SMBIOS table generators Girish Mahadevan via groups.io
@ 2025-02-05 22:09 ` Girish Mahadevan via groups.io
  2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 10/12] DynamicTablesPkg: Smbios Memory Device (Type 17) Girish Mahadevan via groups.io
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Girish Mahadevan via groups.io @ 2025-02-05 22:09 UTC (permalink / raw)
  To: sami.mujawar, Alexei.Fedorov, pierre.gondois, abner.chang,
	Samer.El-Haj-Mahmoud, Jose.Marinho
  Cc: gmahadevan, jbrasen, ashishsingha, nramirez, devel

Introduce a new namespace for SMBIOS related CM Objects.

Signed-off-by: Girish Mahadevan <gmahadevan@nvidia.com>
Reviewed-by: Nick Ramirez <nramirez@nvidia.com>
Reviewed-by: Jeff Brasen <jbrasen@nvidia.com>
---
 .../Include/ConfigurationManagerObject.h      | 14 ++++++-
 .../Include/SmbiosNameSpaceObjects.h          | 42 +++++++++++++++++++
 2 files changed, 55 insertions(+), 1 deletion(-)
 create mode 100644 DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h

diff --git a/DynamicTablesPkg/Include/ConfigurationManagerObject.h b/DynamicTablesPkg/Include/ConfigurationManagerObject.h
index dd730ca677..841de989a5 100644
--- a/DynamicTablesPkg/Include/ConfigurationManagerObject.h
+++ b/DynamicTablesPkg/Include/ConfigurationManagerObject.h
@@ -15,6 +15,7 @@
 #include <ArchCommonNameSpaceObjects.h>

 #include <ArmNameSpaceObjects.h>

 #include <StandardNameSpaceObjects.h>

+#include <SmbiosNameSpaceObjects.h>

 

 #pragma pack(1)

 

@@ -83,7 +84,8 @@ typedef enum ObjectNameSpaceID {
   EObjNameSpaceStandard,          ///< Standard Objects Namespace

   EObjNameSpaceArchCommon,        ///< Arch Common Objects Namespace

   EObjNameSpaceArm,               ///< ARM Objects Namespace

-  EObjNameSpaceOem = 0xF,         ///< OEM Objects Namespace

+  EObjNameSpaceOem    = 0xF,      ///< OEM Objects Namespace

+  EObjNameSpaceSmbios,            ///< SMBIOS Objects Namespace

   EObjNameSpaceMax,

 } EOBJECT_NAMESPACE_ID;

 

@@ -178,4 +180,14 @@ typedef struct CmObjDescriptor {
 #define CREATE_CM_OEM_OBJECT_ID(ObjectId) \

           (CREATE_CM_OBJECT_ID (EObjNameSpaceOem, ObjectId))

 

+/** This macro returns a Configuration Manager Object ID

+    in the SMBIOS Object Namespace.

+

+  @param [in] ObjectId    The Object ID.

+

+  @retval Returns an SMBIOS Configuration Manager Object ID.

+**/

+#define CREATE_CM_SMBIOS_OBJECT_ID(ObjectId) \

+          (CREATE_CM_OBJECT_ID (EObjNameSpaceSmbios, ObjectId))

+

 #endif // CONFIGURATION_MANAGER_OBJECT_H_

diff --git a/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h b/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h
new file mode 100644
index 0000000000..eeeb94bbb2
--- /dev/null
+++ b/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h
@@ -0,0 +1,42 @@
+/** @file

+

+  Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.

+

+  SPDX-License-Identifier: BSD-2-Clause-Patent

+

+  @par Glossary:

+    - Cm or CM   - Configuration Manager

+    - Obj or OBJ - Object

+    - Std or STD - Standard

+**/

+

+#ifndef SMBIOS_NAMESPACE_OBJECTS_H_

+#define SMBIOS_NAMESPACE_OBJECTS_H_

+

+#pragma pack(1)

+

+typedef enum SmbiosObjectID {

+  ESmbiosObjReserved,                  ///< 0  - Reserved

+  ESmbiosObjBaseboardInfo,             ///< 1  - Baseboard Information

+  ESmbiosObjSystemSlotInfo,            ///< 2  - System Slot Information

+  ESmbiosObjSystemInfo,                ///< 3  - System Information

+  ESmbiosObjTpmDeviceInfo,             ///< 4  - TPM Device Info

+  ESmbiosObjOemStrings,                ///< 5  - OEM Strings

+  ESmbiosObjPortConnectorInfo,         ///< 6  - Port connector Information

+  ESmbiosObjBiosInfo,                  ///< 7 - Bios Information

+  ESmbiosObjOnboardDeviceExInfo,       ///< 8 - Onboard Device Ex Information

+  ESmbiosObjGroupAssociations,         ///< 9 - Group Associations

+  ESmbiosObjBiosLanguageInfo,          ///< 10 - BIOS Language Information

+  ESmbiosObjEnclosureInfo,             ///< 11 - Enclosure Information

+  ESmbiosObjMemoryDeviceInfo,          ///< 12 - Memory Device Information

+  ESmbiosObjSystemBootInfo,            ///< 13 - System Boot Info

+  ESmbiosObjPhysicalMemoryArray,       ///< 14 - Physical Memory Array

+  ESmbiosObjMemoryArrayMappedAddress,  ///< 15 - Memory Mapped Address

+  ESmbiosObjPowerSupplyInfo,           ///< 16 - Power Supply Info

+  ESmbiosObjFirmwareInventoryInfo,     ///< 17 - Firmware Inventory Info

+  ESmbiosObjMax

+} ESMBIOS_OBJECT_ID;

+

+#pragma pack()

+

+#endif // SMBIOS_NAMESPACE_OBJECTS_H_

-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#121092): https://edk2.groups.io/g/devel/message/121092
Mute This Topic: https://groups.io/mt/111022010/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [edk2-devel] [staging/dynamictables-reorg PATCH v0 10/12] DynamicTablesPkg: Smbios Memory Device (Type 17)
  2025-02-05 22:08 [edk2-devel] [staging/dynamictables-reorg PATCH v0 00/12] DynamicTablesPkg: Add SMBIOS table generation support Girish Mahadevan via groups.io
                   ` (8 preceding siblings ...)
  2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 09/12] DynamicTablesPkg: Introduce new namespace for SMBIOS Objects Girish Mahadevan via groups.io
@ 2025-02-05 22:09 ` Girish Mahadevan via groups.io
  2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 11/12] DynamicTablesPkg: Smbios Physical Memory Array (Type 16) Girish Mahadevan via groups.io
  2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 12/12] DynamicTablesPkg: Smbios Memory Array Mapped Address (Type 19) Girish Mahadevan via groups.io
  11 siblings, 0 replies; 13+ messages in thread
From: Girish Mahadevan via groups.io @ 2025-02-05 22:09 UTC (permalink / raw)
  To: sami.mujawar, Alexei.Fedorov, pierre.gondois, abner.chang,
	Samer.El-Haj-Mahmoud, Jose.Marinho
  Cc: gmahadevan, jbrasen, ashishsingha, nramirez, devel

Add the Generator library for SMBIOS Table Type 17 - Memory
Device.

Signed-off-by: Girish Mahadevan <gmahadevan@nvidia.com>
Reviewed-by: Jeff Brasen <jbrasen@nvidia.com>
---
 .../Include/SmbiosNameSpaceObjects.h          |  95 ++++
 .../SmbiosType17Lib/SmbiosType17Generator.c   | 491 ++++++++++++++++++
 .../SmbiosType17Lib/SmbiosType17Lib.inf       |  37 ++
 3 files changed, 623 insertions(+)
 create mode 100644 DynamicTablesPkg/Library/Smbios/SmbiosType17Lib/SmbiosType17Generator.c
 create mode 100644 DynamicTablesPkg/Library/Smbios/SmbiosType17Lib/SmbiosType17Lib.inf

diff --git a/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h b/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h
index eeeb94bbb2..e9bde2a712 100644
--- a/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h
+++ b/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h
@@ -13,6 +13,8 @@
 #ifndef SMBIOS_NAMESPACE_OBJECTS_H_

 #define SMBIOS_NAMESPACE_OBJECTS_H_

 

+#include <IndustryStandard/SmBios.h>

+

 #pragma pack(1)

 

 typedef enum SmbiosObjectID {

@@ -37,6 +39,99 @@ typedef enum SmbiosObjectID {
   ESmbiosObjMax

 } ESMBIOS_OBJECT_ID;

 

+/** A structure that describes the physical memory device.

+

+  The physical memory devices on the system are described by this object.

+

+  SMBIOS Specification v3.5.0 Type17

+

+  ID: ESmbiosObjMemoryDeviceInfo,

+*/

+typedef struct CmSmbiosMemoryDeviceInfo {

+  /** Size of the device.

+    Size of the device in bytes.

+  */

+  UINT64                                     Size;

+

+  /** Device Set */

+  UINT8                                      DeviceSet;

+

+  /** Speed of the device

+    Speed of the device in MegaTransfers/second.

+  */

+  UINT32                                     Speed;

+

+  /** Configured speed of the memory device

+    Configured speed of the memory device in MegaTransfers/second.

+  */

+  UINT32                                     ConfiguredMemorySpeed;

+

+  /** Serial Number of device  */

+  CHAR8                                      *SerialNum;

+

+  /** AssetTag identifying the device */

+  CHAR8                                      *AssetTag;

+

+  /** Device Locator String for the device.

+   String that describes the slot or position of the device on the board.

+   */

+  CHAR8                                      *DeviceLocator;

+

+  /** Bank locator string for the device.

+   String that describes the bank where the device is located.

+   */

+  CHAR8                                      *BankLocator;

+

+  /** Firmware version of the memory device */

+  CHAR8                                      *FirmwareVersion;

+

+  /** Part number of the memory device */

+  CHAR8                                      *PartNum;

+

+  /** Manufacturer Id.

+   2 byte Manufacturer Id as per JEDEC Standard JEP106AV

+  */

+  UINT16                                     ModuleManufacturerId;

+

+  /** Manufacturer Product Id

+   2 byte Manufacturer Id as designated by Manufacturer.

+  */

+  UINT16                                     ModuleProductId;

+

+  /** Minimum voltage

+   Minimum operating voltage for this device, in millivolts.

+  */

+  UINT16                                     MinVolt;

+

+  /** Maximum voltage

+   Maximum operating voltage for this device, in millivolts.

+  */

+  UINT16                                     MaxVolt;

+

+  /** Configured voltage

+   Configured voltage for this device, in millivolts.

+  */

+  UINT16                                     ConfVolt;

+

+  CM_OBJECT_TOKEN                            MemoryDeviceInfoToken;

+  CM_OBJECT_TOKEN                            PhysicalArrayToken;

+  UINT16                                     DataWidth;

+  UINT16                                     TotalWidth;

+  UINT8                                      Rank;

+

+  MEMORY_DEVICE_TYPE                         DeviceType;

+  MEMORY_DEVICE_TYPE_DETAIL                  TypeDetail;

+  MEMORY_DEVICE_TECHNOLOGY                   DeviceTechnology;

+  MEMORY_FORM_FACTOR                         FormFactor;

+  MEMORY_DEVICE_OPERATING_MODE_CAPABILITY    MemoryOperatingModeCapability;

+  UINT16                                     MemoryErrorInformationHandle;

+} CM_SMBIOS_MEMORY_DEVICE_INFO;

+

+typedef struct {

+  CM_OBJECT_TOKEN              CmObjToken;

+  SMBIOS_TABLE_GENERATOR_ID    GeneratorId;

+} CONTAINED_CM_OBJECTS;

+

 #pragma pack()

 

 #endif // SMBIOS_NAMESPACE_OBJECTS_H_

diff --git a/DynamicTablesPkg/Library/Smbios/SmbiosType17Lib/SmbiosType17Generator.c b/DynamicTablesPkg/Library/Smbios/SmbiosType17Lib/SmbiosType17Generator.c
new file mode 100644
index 0000000000..2e8bda2aca
--- /dev/null
+++ b/DynamicTablesPkg/Library/Smbios/SmbiosType17Lib/SmbiosType17Generator.c
@@ -0,0 +1,491 @@
+/** @file

+  SMBIOS Type17 Table Generator.

+

+  Copyright (c) 2020 - 2021, Arm Limited. All rights reserved.<BR>

+  Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.

+

+  SPDX-License-Identifier: BSD-2-Clause-Patent

+**/

+

+#include <Library/BaseLib.h>

+#include <Library/BaseMemoryLib.h>

+#include <Library/DebugLib.h>

+#include <Library/PrintLib.h>

+#include <Library/MemoryAllocationLib.h>

+#include <Library/UefiBootServicesTableLib.h>

+#include <Library/SmbiosStringTableLib.h>

+#include <Library/JedecJep106Lib.h>

+

+// Module specific include files.

+#include <ConfigurationManagerObject.h>

+#include <ConfigurationManagerHelper.h>

+#include <Protocol/ConfigurationManagerProtocol.h>

+#include <Protocol/DynamicTableFactoryProtocol.h>

+#include <Protocol/Smbios.h>

+#include <IndustryStandard/SmBios.h>

+

+/** This macro expands to a function that retrieves the Memory Device

+    information from the Configuration Manager.

+*/

+GET_OBJECT_LIST (

+  EObjNameSpaceSmbios,

+  ESmbiosObjMemoryDeviceInfo,

+  CM_SMBIOS_MEMORY_DEVICE_INFO

+  )

+

+#define EXTENDED_SIZE_THRESHOLD     (0x7FFF00000LL)

+#define SIZE_GRANULARITY_THRESHOLD  (0x100000L)

+#define SIZE_GRANULARITY_BITMASK    (0x8000)

+#define EXTENDED_SPEED_THRESHOLD    (0xFFFF)

+#define SMBIOS_TYPE17_MAX_STRINGS   (7)

+#define RANK_MASK                   (0x7)

+

+STATIC

+EFI_STATUS

+FreeSmbiosType17TableEx (

+  IN      CONST SMBIOS_TABLE_GENERATOR                   *CONST  This,

+  IN      CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL     *CONST  TableFactoryProtocol,

+  IN      CONST CM_STD_OBJ_SMBIOS_TABLE_INFO             *CONST  SmbiosTableInfo,

+  IN      CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL     *CONST  CfgMgrProtocol,

+  IN      SMBIOS_STRUCTURE                             ***CONST  Table,

+  IN      CM_OBJECT_TOKEN                                        **CmObjectToken,

+  IN      CONST UINTN                                            TableCount

+  )

+{

+  UINTN             Index;

+  SMBIOS_STRUCTURE  **TableList;

+

+  TableList = *Table;

+  for (Index = 0; Index < TableCount; Index++) {

+    if (TableList[Index] != NULL) {

+      FreePool (TableList[Index]);

+    }

+  }

+

+  if (*CmObjectToken != NULL) {

+    FreePool (*CmObjectToken);

+  }

+

+  if (TableList != NULL) {

+    FreePool (TableList);

+  }

+

+  return EFI_SUCCESS;

+}

+

+STATIC

+VOID

+AddPhysArrHandle (

+  IN  CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL   *CONST  TableFactoryProtocol,

+  IN  CM_OBJECT_TOKEN                                      CmObjToken,

+  OUT SMBIOS_TABLE_TYPE17                                  *SmbiosRecord

+  )

+{

+  EFI_SMBIOS_HANDLE  PhysMemArrHandle;

+  SMBIOS_HANDLE_MAP  *HandleMap;

+

+  HandleMap = TableFactoryProtocol->GetSmbiosHandle (CmObjToken);

+  if (HandleMap == NULL) {

+    DEBUG ((DEBUG_ERROR, "%a:Failed to get SMBIOS Handle\n", __FUNCTION__));

+    PhysMemArrHandle = 0;

+  } else {

+    PhysMemArrHandle = HandleMap->SmbiosTblHandle;

+  }

+

+  SmbiosRecord->MemoryArrayHandle = PhysMemArrHandle;

+}

+

+STATIC

+VOID

+UpdateSmbiosType17Size (

+  IN  UINT64               Size,

+  OUT SMBIOS_TABLE_TYPE17  *SmbiosRecord

+  )

+{

+  if (Size < SIZE_GRANULARITY_THRESHOLD) {

+    SmbiosRecord->Size  = Size / SIZE_1KB;

+    SmbiosRecord->Size |= SIZE_GRANULARITY_BITMASK;

+  } else if (Size >= EXTENDED_SIZE_THRESHOLD) {

+    SmbiosRecord->Size         = 0x7FFF;

+    SmbiosRecord->ExtendedSize = (Size / SIZE_1MB);

+  } else {

+    SmbiosRecord->Size = (Size / SIZE_1MB);

+  }

+}

+

+STATIC

+VOID

+UpdateSmbiosType17Speed (

+  IN  UINT32               Speed,

+  IN  UINT32               ConfiguredMemoryClockSpeed,

+  OUT SMBIOS_TABLE_TYPE17  *SmbiosRecord

+  )

+{

+  if (Speed > -EXTENDED_SPEED_THRESHOLD) {

+    SmbiosRecord->Speed                         = EXTENDED_SPEED_THRESHOLD;

+    SmbiosRecord->ExtendedSpeed                 = Speed;

+    SmbiosRecord->ConfiguredMemoryClockSpeed    = EXTENDED_SPEED_THRESHOLD;

+    SmbiosRecord->ExtendedConfiguredMemorySpeed = ConfiguredMemoryClockSpeed;

+  } else {

+    SmbiosRecord->Speed                      = Speed;

+    SmbiosRecord->ConfiguredMemoryClockSpeed = ConfiguredMemoryClockSpeed;

+  }

+}

+

+STATIC

+VOID

+UpdateSmbiosType17Rank (

+  IN  UINT8                Rank,

+  OUT SMBIOS_TABLE_TYPE17  *SmbiosRecord

+  )

+{

+  if (Rank > RANK_MASK) {

+    SmbiosRecord->Attributes = 0;

+  } else {

+    SmbiosRecord->Attributes |= (Rank & RANK_MASK);

+  }

+}

+

+/** Construct SMBIOS Type17 Table describing memory devices.

+

+  If this function allocates any resources then they must be freed

+  in the FreeXXXXTableResources function.

+

+  @param [in]  This            Pointer to the SMBIOS table generator.

+  @param [in]  SmbiosTableInfo Pointer to the SMBIOS table information.

+  @param [in]  CfgMgrProtocol  Pointer to the Configuration Manager

+                               Protocol interface.

+  @param [out] Table           Pointer to the SMBIOS table.

+

+  @retval EFI_SUCCESS            Table generated successfully.

+  @retval EFI_BAD_BUFFER_SIZE    The size returned by the Configuration

+                                 Manager is less than the Object size for

+                                 the requested object.

+  @retval EFI_INVALID_PARAMETER  A parameter is invalid.

+  @retval EFI_NOT_FOUND          Could not find information.

+  @retval EFI_OUT_OF_RESOURCES   Could not allocate memory.

+  @retval EFI_UNSUPPORTED        Unsupported configuration.

+**/

+STATIC

+EFI_STATUS

+BuildSmbiosType17TableEx (

+  IN  CONST SMBIOS_TABLE_GENERATOR                         *This,

+  IN  CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL   *CONST  TableFactoryProtocol,

+  IN        CM_STD_OBJ_SMBIOS_TABLE_INFO           *CONST  SmbiosTableInfo,

+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL   *CONST  CfgMgrProtocol,

+  OUT       SMBIOS_STRUCTURE                               ***Table,

+  OUT       CM_OBJECT_TOKEN                                **CmObjectToken,

+  OUT       UINTN                                  *CONST  TableCount

+  )

+{

+  EFI_STATUS                    Status;

+  UINT32                        NumMemDevices;

+  SMBIOS_STRUCTURE              **TableList;

+  CM_OBJECT_TOKEN               *CmObjectList;

+  CM_SMBIOS_MEMORY_DEVICE_INFO  *MemoryDevicesInfo;

+  UINTN                         Index;

+  UINT8                         SerialNumRef;

+  UINT8                         AssetTagRef;

+  UINT8                         DeviceLocatorRef;

+  UINT8                         BankLocatorRef;

+  UINT8                         FirmwareVersionRef;

+  UINT8                         ManufacturerNameRef;

+  CHAR8                         *ManufacturerName;

+  UINT8                         PartNumRef;

+  CHAR8                         *OptionalStrings;

+  SMBIOS_TABLE_TYPE17           *SmbiosRecord;

+  UINTN                         SmbiosRecordSize;

+  STRING_TABLE                  StrTable;

+

+  ASSERT (This != NULL);

+  ASSERT (SmbiosTableInfo != NULL);

+  ASSERT (CfgMgrProtocol != NULL);

+  ASSERT (Table != NULL);

+  ASSERT (TableCount != NULL);

+  ASSERT (SmbiosTableInfo->TableGeneratorId == This->GeneratorID);

+

+  if ((This == NULL) || (SmbiosTableInfo == NULL) || (CfgMgrProtocol == NULL) ||

+      (Table == NULL) || (TableCount == NULL) ||

+      (SmbiosTableInfo->TableGeneratorId != This->GeneratorID))

+  {

+    DEBUG ((DEBUG_ERROR, "%a:Invalid Paramater\n ", __FUNCTION__));

+    return EFI_INVALID_PARAMETER;

+  }

+

+  *Table = NULL;

+  Status = GetESmbiosObjMemoryDeviceInfo (

+             CfgMgrProtocol,

+             CM_NULL_TOKEN,

+             &MemoryDevicesInfo,

+             &NumMemDevices

+             );

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "Failed to get Memory Devices CM Object %r\n",

+      Status

+      ));

+    return Status;

+  }

+

+  TableList = (SMBIOS_STRUCTURE **)AllocateZeroPool (sizeof (SMBIOS_STRUCTURE *) * NumMemDevices);

+  if (TableList == NULL) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "%a:Failed to alloc memory for %u devices table\n",

+      __FUNCTION__,

+      NumMemDevices

+      ));

+    Status = EFI_OUT_OF_RESOURCES;

+    goto exit;

+  }

+

+  CmObjectList = (CM_OBJECT_TOKEN *)AllocateZeroPool (sizeof (CM_OBJECT_TOKEN *) * NumMemDevices);

+  if (CmObjectList == NULL) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "%a: Failed to alloc memory for %u CM Objects\n",

+      __FUNCTION__,

+      NumMemDevices

+      ));

+    Status = EFI_OUT_OF_RESOURCES;

+    goto exit;

+  }

+

+  for (Index = 0; Index < NumMemDevices; Index++) {

+    StringTableInitialize (&StrTable, SMBIOS_TYPE17_MAX_STRINGS);

+

+    SerialNumRef       = 0;

+    AssetTagRef        = 0;

+    DeviceLocatorRef   = 0;

+    BankLocatorRef     = 0;

+    FirmwareVersionRef = 0;

+    ManufacturerNameRef = 0;

+    PartNumRef          = 0;

+    ManufacturerName    = NULL;

+

+    if (MemoryDevicesInfo[Index].DeviceLocator != NULL) {

+      Status = StringTableAddString (

+                 &StrTable,

+                 MemoryDevicesInfo[Index].DeviceLocator,

+                 &DeviceLocatorRef

+                 );

+      if (EFI_ERROR (Status)) {

+        DEBUG ((DEBUG_ERROR, "Failed to add DeviceLocator String %r \n", Status));

+      }

+    }

+

+    if (MemoryDevicesInfo[Index].BankLocator != NULL) {

+      Status = StringTableAddString (

+                 &StrTable,

+                 MemoryDevicesInfo[Index].BankLocator,

+                 &BankLocatorRef

+                 );

+      if (EFI_ERROR (Status)) {

+        DEBUG ((DEBUG_ERROR, "Failed to BankLocator String %r \n", Status));

+      }

+    }

+

+    if (MemoryDevicesInfo[Index].SerialNum != NULL) {

+      Status = StringTableAddString (

+                 &StrTable,

+                 MemoryDevicesInfo[Index].SerialNum,

+                 &SerialNumRef

+                 );

+      if (EFI_ERROR (Status)) {

+        DEBUG ((DEBUG_ERROR, "Failed to add SerialNum String %r \n", Status));

+      }

+    }

+

+    if (MemoryDevicesInfo[Index].AssetTag != NULL) {

+      Status = StringTableAddString (

+                 &StrTable,

+                 MemoryDevicesInfo[Index].AssetTag,

+                 &AssetTagRef

+                 );

+      if (EFI_ERROR (Status)) {

+        DEBUG ((DEBUG_ERROR, "Failed to add Asset Tag String %r \n", Status));

+      }

+    }

+

+    if (MemoryDevicesInfo[Index].FirmwareVersion != NULL) {

+      Status = StringTableAddString (

+                 &StrTable,

+                 MemoryDevicesInfo[Index].FirmwareVersion,

+                 &FirmwareVersionRef

+                 );

+      if (EFI_ERROR (Status)) {

+        DEBUG ((DEBUG_ERROR, "Failed to add Firmware Version String %r \n", Status));

+      }

+    }

+

+    if (MemoryDevicesInfo[Index].PartNum != NULL) {

+      Status = StringTableAddString (

+                 &StrTable,

+                 MemoryDevicesInfo[Index].PartNum,

+                 &PartNumRef

+                 );

+      if (EFI_ERROR (Status)) {

+        DEBUG ((DEBUG_ERROR, "Failed to PartNum String %r \n", Status));

+      }

+    }

+

+    ManufacturerName = (CHAR8 *)Jep106GetManufacturerName (

+                                  (MemoryDevicesInfo[Index].ModuleManufacturerId >> 8) & 0xFF,

+                                  MemoryDevicesInfo[Index].ModuleManufacturerId & 0x7F

+                                  );

+    if (ManufacturerName != NULL) {

+      Status = StringTableAddString (

+                 &StrTable,

+                 ManufacturerName,

+                 &ManufacturerNameRef

+                 );

+      if (EFI_ERROR (Status)) {

+        DEBUG ((DEBUG_ERROR, "Failed to add Manufacturer String %r \n", Status));

+      }

+    }

+

+    SmbiosRecordSize = sizeof (SMBIOS_TABLE_TYPE17) +

+                       StringTableGetStringSetSize (&StrTable);

+    SmbiosRecord = (SMBIOS_TABLE_TYPE17 *)AllocateZeroPool (SmbiosRecordSize);

+    if (SmbiosRecord == NULL) {

+      Status = EFI_OUT_OF_RESOURCES;

+      goto exit;

+    }

+

+    UpdateSmbiosType17Size (MemoryDevicesInfo[Index].Size, SmbiosRecord);

+    UpdateSmbiosType17Speed (MemoryDevicesInfo[Index].Speed, MemoryDevicesInfo[Index].ConfiguredMemorySpeed, SmbiosRecord);

+    UpdateSmbiosType17Rank (MemoryDevicesInfo[Index].Rank, SmbiosRecord);

+

+    SmbiosRecord->VolatileSize         = MemoryDevicesInfo[Index].Size;

+    SmbiosRecord->DeviceSet            = MemoryDevicesInfo[Index].DeviceSet;

+    SmbiosRecord->ModuleManufacturerID =

+      MemoryDevicesInfo[Index].ModuleManufacturerId;

+    SmbiosRecord->ModuleProductID =

+      MemoryDevicesInfo[Index].ModuleProductId;

+    SmbiosRecord->DataWidth                     = MemoryDevicesInfo[Index].DataWidth;

+    SmbiosRecord->TotalWidth                    = MemoryDevicesInfo[Index].TotalWidth;

+    SmbiosRecord->MemoryType                    = MemoryDevicesInfo[Index].DeviceType;

+    SmbiosRecord->FormFactor                    = MemoryDevicesInfo[Index].FormFactor;

+    SmbiosRecord->MinimumVoltage                = MemoryDevicesInfo[Index].MinVolt;

+    SmbiosRecord->MaximumVoltage                = MemoryDevicesInfo[Index].MaxVolt;

+    SmbiosRecord->ConfiguredVoltage             = MemoryDevicesInfo[Index].ConfVolt;

+    SmbiosRecord->MemoryTechnology              = MemoryDevicesInfo[Index].DeviceTechnology;

+    SmbiosRecord->MemoryErrorInformationHandle  = MemoryDevicesInfo[Index].MemoryErrorInformationHandle;

+    SmbiosRecord->TypeDetail                    = MemoryDevicesInfo[Index].TypeDetail;

+    SmbiosRecord->MemoryOperatingModeCapability = MemoryDevicesInfo[Index].MemoryOperatingModeCapability;

+    // Is there a reference to a Physical Array Device.

+    if (MemoryDevicesInfo[Index].PhysicalArrayToken != CM_NULL_TOKEN) {

+      AddPhysArrHandle (

+        TableFactoryProtocol,

+        MemoryDevicesInfo[Index].PhysicalArrayToken,

+        SmbiosRecord

+        );

+    }

+

+    SmbiosRecord->DeviceLocator   = DeviceLocatorRef;

+    SmbiosRecord->BankLocator     = BankLocatorRef;

+    SmbiosRecord->AssetTag        = AssetTagRef;

+    SmbiosRecord->SerialNumber    = SerialNumRef;

+    SmbiosRecord->FirmwareVersion = FirmwareVersionRef;

+    SmbiosRecord->Manufacturer    = ManufacturerNameRef;

+    SmbiosRecord->PartNumber      = PartNumRef;

+    OptionalStrings               = (CHAR8 *)(SmbiosRecord + 1);

+    // publish the string set

+    StringTablePublishStringSet (

+      &StrTable,

+      OptionalStrings,

+      (SmbiosRecordSize - sizeof (SMBIOS_TABLE_TYPE17))

+      );

+    // setup the header

+    SmbiosRecord->Hdr.Type   = EFI_SMBIOS_TYPE_MEMORY_DEVICE;

+    SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE17);

+    TableList[Index]         = (SMBIOS_STRUCTURE *)SmbiosRecord;

+    CmObjectList[Index]      = MemoryDevicesInfo[Index].MemoryDeviceInfoToken;

+    StringTableFree (&StrTable);

+  }

+

+  *Table         = TableList;

+  *CmObjectToken = CmObjectList;

+  *TableCount    = NumMemDevices;

+exit:

+  // free string table

+  return Status;

+}

+

+/** The interface for the SMBIOS Type17 Table Generator.

+*/

+STATIC

+CONST

+SMBIOS_TABLE_GENERATOR  SmbiosType17Generator = {

+  // Generator ID

+  CREATE_STD_SMBIOS_TABLE_GEN_ID (EStdSmbiosTableIdType17),

+  // Generator Description

+  L"SMBIOS.TYPE17.GENERATOR",

+  // SMBIOS Table Type

+  EFI_SMBIOS_TYPE_MEMORY_DEVICE,

+  NULL,

+  NULL,

+  // Build table function Extended.

+  BuildSmbiosType17TableEx,

+  // Free function Extended.

+  FreeSmbiosType17TableEx

+};

+

+/** Register the Generator with the SMBIOS Table Factory.

+

+  @param [in]  ImageHandle  The handle to the image.

+  @param [in]  SystemTable  Pointer to the System Table.

+

+  @retval EFI_SUCCESS           The Generator is registered.

+  @retval EFI_INVALID_PARAMETER A parameter is invalid.

+  @retval EFI_ALREADY_STARTED   The Generator for the Table ID

+                                is already registered.

+**/

+EFI_STATUS

+EFIAPI

+SmbiosType17LibConstructor (

+  IN  EFI_HANDLE        ImageHandle,

+  IN  EFI_SYSTEM_TABLE  *SystemTable

+  )

+{

+  EFI_STATUS  Status;

+

+  Status = RegisterSmbiosTableGenerator (&SmbiosType17Generator);

+  DEBUG ((

+    DEBUG_INFO,

+    "SMBIOS Type 17: Register Generator. Status = %r\n",

+    Status

+    ));

+  ASSERT_EFI_ERROR (Status);

+

+  return Status;

+}

+

+/** Deregister the Generator from the SMBIOS Table Factory.

+

+  @param [in]  ImageHandle  The handle to the image.

+  @param [in]  SystemTable  Pointer to the System Table.

+

+  @retval EFI_SUCCESS           The Generator is deregistered.

+  @retval EFI_INVALID_PARAMETER A parameter is invalid.

+  @retval EFI_NOT_FOUND         The Generator is not registered.

+**/

+EFI_STATUS

+EFIAPI

+SmbiosType17LibDestructor (

+  IN  EFI_HANDLE        ImageHandle,

+  IN  EFI_SYSTEM_TABLE  *SystemTable

+  )

+{

+  EFI_STATUS  Status;

+

+  Status = DeregisterSmbiosTableGenerator (&SmbiosType17Generator);

+  DEBUG ((

+    DEBUG_INFO,

+    "SMBIOS Type17: Deregister Generator. Status = %r\n",

+    Status

+    ));

+  ASSERT_EFI_ERROR (Status);

+  return Status;

+}

diff --git a/DynamicTablesPkg/Library/Smbios/SmbiosType17Lib/SmbiosType17Lib.inf b/DynamicTablesPkg/Library/Smbios/SmbiosType17Lib/SmbiosType17Lib.inf
new file mode 100644
index 0000000000..ea8a3310d6
--- /dev/null
+++ b/DynamicTablesPkg/Library/Smbios/SmbiosType17Lib/SmbiosType17Lib.inf
@@ -0,0 +1,37 @@
+## @file

+#  SMBIOS Type17 Table Generator

+#

+#  Copyright (c) 2019 - 2021, Arm Limited. All rights reserved.<BR>

+#  Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.

+#

+#  SPDX-License-Identifier: BSD-2-Clause-Patent

+##

+

+[Defines]

+  INF_VERSION    = 0x0001001B

+  BASE_NAME      = SmbiosType17LibArm

+  FILE_GUID      = 1f063bac-f8f1-4e08-8ffd-9aae52c75497

+  VERSION_STRING = 1.0

+  MODULE_TYPE    = DXE_DRIVER

+  LIBRARY_CLASS  = NULL|DXE_DRIVER

+  CONSTRUCTOR    = SmbiosType17LibConstructor

+  DESTRUCTOR     = SmbiosType17LibDestructor

+

+[Sources]

+  SmbiosType17Generator.c

+

+[Packages]

+  MdePkg/MdePkg.dec

+  MdeModulePkg/MdeModulePkg.dec

+  EmbeddedPkg/EmbeddedPkg.dec

+  ArmPlatformPkg/ArmPlatformPkg.dec

+  DynamicTablesPkg/DynamicTablesPkg.dec

+

+[Protocols]

+  gEfiSmbiosProtocolGuid                        # PROTOCOL ALWAYS_CONSUMED

+

+[LibraryClasses]

+  BaseLib

+  DebugLib

+  SmbiosStringTableLib

+  JedecJep106Lib

-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#121096): https://edk2.groups.io/g/devel/message/121096
Mute This Topic: https://groups.io/mt/111022016/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [edk2-devel] [staging/dynamictables-reorg PATCH v0 11/12] DynamicTablesPkg: Smbios Physical Memory Array (Type 16)
  2025-02-05 22:08 [edk2-devel] [staging/dynamictables-reorg PATCH v0 00/12] DynamicTablesPkg: Add SMBIOS table generation support Girish Mahadevan via groups.io
                   ` (9 preceding siblings ...)
  2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 10/12] DynamicTablesPkg: Smbios Memory Device (Type 17) Girish Mahadevan via groups.io
@ 2025-02-05 22:09 ` Girish Mahadevan via groups.io
  2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 12/12] DynamicTablesPkg: Smbios Memory Array Mapped Address (Type 19) Girish Mahadevan via groups.io
  11 siblings, 0 replies; 13+ messages in thread
From: Girish Mahadevan via groups.io @ 2025-02-05 22:09 UTC (permalink / raw)
  To: sami.mujawar, Alexei.Fedorov, pierre.gondois, abner.chang,
	Samer.El-Haj-Mahmoud, Jose.Marinho
  Cc: gmahadevan, jbrasen, ashishsingha, nramirez, devel

Add the Generator library for SMBIOS Table Type 16 - Physical
Memory Array.

Signed-off-by: Girish Mahadevan <gmahadevan@nvidia.com>
Reviewed-by: Jeff Brasen <jbrasen@nvidia.com>
Reviewed-by: Nick Ramirez <nramirez@nvidia.com>
---
 .../SmbiosTableBuilder.c                      |   3 -
 .../Include/SmbiosNameSpaceObjects.h          |  19 +
 .../SmbiosType16Lib/SmbiosType16Generator.c   | 361 ++++++++++++++++++
 .../SmbiosType16Lib/SmbiosType16Lib.inf       |  35 ++
 4 files changed, 415 insertions(+), 3 deletions(-)
 create mode 100644 DynamicTablesPkg/Library/Smbios/SmbiosType16Lib/SmbiosType16Generator.c
 create mode 100644 DynamicTablesPkg/Library/Smbios/SmbiosType16Lib/SmbiosType16Lib.inf

diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableBuilder.c b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableBuilder.c
index bf6e657bcf..f33213f061 100644
--- a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableBuilder.c
+++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableBuilder.c
@@ -311,7 +311,6 @@ exit_handler:
     }

   }

 

-  DEBUG ((DEBUG_ERROR, "%a: Returning %r\n", __FUNCTION__, Status));

   return Status;

 }

 

@@ -431,7 +430,6 @@ BuildAndInstallSmbiosTable (
       ));

   }

 

-  DEBUG ((DEBUG_ERROR, "%a: Returning %r\n", __FUNCTION__, Status));

   return Status;

 }

 

@@ -515,7 +513,6 @@ ProcessSmbiosTables (
       ));

   }

 

-  DEBUG ((DEBUG_ERROR, "%a: Returning %r\n", __FUNCTION__, Status));

   return Status;

 }

 

diff --git a/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h b/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h
index e9bde2a712..7e883e1b89 100644
--- a/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h
+++ b/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h
@@ -132,6 +132,25 @@ typedef struct {
   SMBIOS_TABLE_GENERATOR_ID    GeneratorId;

 } CONTAINED_CM_OBJECTS;

 

+/** A structure that describes the Physical Memory Array.

+

+  SMBIOS Specification v3.6.0 Type 16

+

+  ID: ESmbiosObjPhysicalMemoryArray

+**/

+typedef struct CmSmbiosPhysicalMemoryArray {

+  UINT8              Use;

+  UINT8              Location;

+  UINT16             MemoryErrorCorrection;

+  UINT16             MemoryErrorInformationHandle;

+  UINT16             NumberOfMemoryDevices;

+  UINT8              MemoryErrorCorrectionType;

+  UINT64             Size;

+  UINT8              NumMemDevices;

+  CM_OBJECT_TOKEN    MemoryErrInfoToken;

+  CM_OBJECT_TOKEN    PhysMemArrayToken;

+} CM_SMBIOS_PHYSICAL_MEMORY_ARRAY;

+

 #pragma pack()

 

 #endif // SMBIOS_NAMESPACE_OBJECTS_H_

diff --git a/DynamicTablesPkg/Library/Smbios/SmbiosType16Lib/SmbiosType16Generator.c b/DynamicTablesPkg/Library/Smbios/SmbiosType16Lib/SmbiosType16Generator.c
new file mode 100644
index 0000000000..37592ee560
--- /dev/null
+++ b/DynamicTablesPkg/Library/Smbios/SmbiosType16Lib/SmbiosType16Generator.c
@@ -0,0 +1,361 @@
+/** @file

+  SMBIOS Type16 Table Generator.

+

+  Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.

+  Copyright (c) 2020 - 2021, Arm 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/PrintLib.h>

+#include <Library/MemoryAllocationLib.h>

+#include <Library/UefiBootServicesTableLib.h>

+#include <Library/SmbiosStringTableLib.h>

+

+// Module specific include files.

+#include <ConfigurationManagerObject.h>

+#include <ConfigurationManagerHelper.h>

+#include <Protocol/ConfigurationManagerProtocol.h>

+#include <Protocol/DynamicTableFactoryProtocol.h>

+#include <Protocol/Smbios.h>

+#include <IndustryStandard/SmBios.h>

+

+/** This macro expands to a function that retrieves the Memory Device

+    information from the Configuration Manager.

+*/

+GET_OBJECT_LIST (

+  EObjNameSpaceSmbios,

+  ESmbiosObjPhysicalMemoryArray,

+  CM_SMBIOS_PHYSICAL_MEMORY_ARRAY

+  )

+

+#define EXTENDED_SIZE_THRESHOLD  (SIZE_2TB)

+

+/**

+ * Free any resources allocated when installing SMBIOS Type16 table.

+ *

+ * @param [in]  This                 Pointer to the SMBIOS table generator.

+ * @param [in]  TableFactoryProtocol Pointer to the SMBIOS Table Factory

+                                      Protocol interface.

+

+ * @param [in]  SmbiosTableInfo      Pointer to the SMBIOS table information.

+ * @param [in]  CfgMgrProtocol       Pointer to the Configuration Manager

+                                     Protocol interface.

+ * @param [in] Table                 Pointer to the SMBIOS table.

+ * @param [in] CmObjectToken         Pointer to the CM ObjectToken Array.

+ * @param [in] TableCount            Number of SMBIOS tables.

+

+ * @retval EFI_SUCCESS            Table generated successfully.

+ * @retval EFI_BAD_BUFFER_SIZE    The size returned by the Configuration

+                                  Manager is less than the Object size for

+                                  the requested object.

+ * @retval EFI_INVALID_PARAMETER  A parameter is invalid.

+ * @retval EFI_NOT_FOUND          Could not find information.

+ * @retval EFI_OUT_OF_RESOURCES   Could not allocate memory.

+ * @retval EFI_UNSUPPORTED        Unsupported configuration.

+**/

+STATIC

+EFI_STATUS

+FreeSmbiosType16TableEx (

+  IN      CONST SMBIOS_TABLE_GENERATOR                    *CONST   This,

+  IN      CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL      *CONST   TableFactoryProtocol,

+  IN      CONST CM_STD_OBJ_SMBIOS_TABLE_INFO              *CONST   SmbiosTableInfo,

+  IN      CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL      *CONST   CfgMgrProtocol,

+  IN      SMBIOS_STRUCTURE                               ***CONST  Table,

+  IN      CM_OBJECT_TOKEN                                          **CmObjectToken,

+  IN      CONST UINTN                                              TableCount

+  )

+{

+  UINTN             Index;

+  SMBIOS_STRUCTURE  **TableList;

+

+  TableList = *Table;

+  for (Index = 0; Index < TableCount; Index++) {

+    if (TableList[Index] != NULL) {

+      FreePool (TableList[Index]);

+    }

+  }

+

+  if (*CmObjectToken != NULL) {

+    FreePool (*CmObjectToken);

+  }

+

+  if (TableList != NULL) {

+    FreePool (TableList);

+  }

+

+  return EFI_SUCCESS;

+}

+

+/**

+ *  Update the Size encoding for Type 16.

+ *

+ *  @param [in]     SizeBytes    Size of the Memory device.

+ *  @param [out]    SmbiosRecord SMBIOS record to update.

+**/

+STATIC

+VOID

+UpdateSmbiosType16Size (

+  IN     UINT64               SizeBytes,

+  IN OUT SMBIOS_TABLE_TYPE16  *SmbiosRecord

+  )

+{

+  UINT64  SizeKb = SizeBytes / SIZE_1KB;

+

+  if (SizeBytes < EXTENDED_SIZE_THRESHOLD) {

+    SmbiosRecord->MaximumCapacity = SizeKb;

+  } else {

+    SmbiosRecord->MaximumCapacity         = 0x80000000;

+    SmbiosRecord->ExtendedMaximumCapacity = SizeKb;

+  }

+}

+

+/**

+ *  Add the SMBIOS table handle reference to the Error Tables.

+ *

+ *  @param [in]     TableFactoryProtocol   Pointer to the SMBIOS Table Factory.

+ *  @param [in]     CmObjToken             CM Token to lookup..

+ *  @param [out]    SmbiosRecord           SMBIOS record to update.

+**/

+STATIC

+VOID

+AddMemErrDeviceHandle (

+  IN  CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL   *CONST  TableFactoryProtocol,

+  IN  CM_OBJECT_TOKEN                                      CmObjToken,

+  OUT SMBIOS_TABLE_TYPE16                                  *SmbiosRecord

+  )

+{

+  EFI_SMBIOS_HANDLE  Handle;

+  SMBIOS_HANDLE_MAP  *HandleMap;

+

+  HandleMap = TableFactoryProtocol->GetSmbiosHandle (CmObjToken);

+  if (HandleMap == NULL) {

+    DEBUG ((DEBUG_ERROR, "%a:Failed to get SMBIOS Handle\n", __FUNCTION__));

+    Handle = 0xFFFF;

+  } else {

+    Handle = HandleMap->SmbiosTblHandle;

+  }

+

+  SmbiosRecord->MemoryErrorInformationHandle = Handle;

+}

+

+/** Construct SMBIOS Type16 Table describing memory devices.

+

+  If this function allocates any resources then they must be freed

+  in the FreeXXXXTableResources function.

+

+ * @param [in]  This                 Pointer to the SMBIOS table generator.

+ * @param [in]  TableFactoryProtocol Pointer to the SMBIOS Table Factory

+ *                                   Protocol interface.

+ * @param [in]  SmbiosTableInfo      Pointer to the SMBIOS table information.

+ * @param [in]  CfgMgrProtocol       Pointer to the Configuration Manager

+ *                                   Protocol interface.

+ * @param [out] Table                Pointer to the SMBIOS table.

+ * @param [out] CmObjectToken        Pointer to the CM Object Token Array.

+ * @param [out] TableCount           Number of tables installed.

+

+ * @retval EFI_SUCCESS            Table generated successfully.

+ * @retval EFI_BAD_BUFFER_SIZE    The size returned by the Configuration

+ *                                Manager is less than the Object size for

+ *                                the requested object.

+ * @retval EFI_INVALID_PARAMETER  A parameter is invalid.

+ * @retval EFI_NOT_FOUND          Could not find information.

+ * @retval EFI_OUT_OF_RESOURCES   Could not allocate memory.

+ * @retval EFI_UNSUPPORTED        Unsupported configuration.

+**/

+STATIC

+EFI_STATUS

+BuildSmbiosType16TableEx (

+  IN  CONST SMBIOS_TABLE_GENERATOR                         *This,

+  IN  CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL   *CONST  TableFactoryProtocol,

+  IN        CM_STD_OBJ_SMBIOS_TABLE_INFO           *CONST  SmbiosTableInfo,

+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL   *CONST  CfgMgrProtocol,

+  OUT       SMBIOS_STRUCTURE                               ***Table,

+  OUT       CM_OBJECT_TOKEN                                **CmObjectToken,

+  OUT       UINTN                                  *CONST  TableCount

+  )

+{

+  EFI_STATUS                       Status;

+  SMBIOS_STRUCTURE                 **TableList;

+  SMBIOS_TABLE_TYPE16              *SmbiosRecord;

+  CM_OBJECT_TOKEN                  *CmObjectList;

+  CM_SMBIOS_PHYSICAL_MEMORY_ARRAY  *PhysMemoryArray;

+  UINT32                           NumObj;

+  UINTN                            Index;

+

+  ASSERT (This != NULL);

+  ASSERT (SmbiosTableInfo != NULL);

+  ASSERT (CfgMgrProtocol != NULL);

+  ASSERT (Table != NULL);

+  ASSERT (TableCount != NULL);

+  ASSERT (SmbiosTableInfo->TableGeneratorId == This->GeneratorID);

+

+  if ((This == NULL) || (SmbiosTableInfo == NULL) || (CfgMgrProtocol == NULL) ||

+      (Table == NULL) || (TableCount == NULL) ||

+      (SmbiosTableInfo->TableGeneratorId != This->GeneratorID))

+  {

+    DEBUG ((DEBUG_ERROR, "%a:Invalid Paramater\n ", __FUNCTION__));

+    return EFI_INVALID_PARAMETER;

+  }

+

+  *Table = NULL;

+  Status = GetESmbiosObjPhysicalMemoryArray (

+             CfgMgrProtocol,

+             CM_NULL_TOKEN,

+             &PhysMemoryArray,

+             &NumObj

+             );

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "%a: Failed to get Memory Devices CM Object %r\n",

+      __FUNCTION__,

+      Status

+      ));

+    return Status;

+  }

+

+  TableList = (SMBIOS_STRUCTURE **)AllocateZeroPool (sizeof (SMBIOS_STRUCTURE *) * NumObj);

+  if (TableList == NULL) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "%a: Failed to alloc memory for %u devices table\n",

+      __FUNCTION__,

+      NumObj

+      ));

+    Status = EFI_OUT_OF_RESOURCES;

+    goto exitBuildSmbiosType16Table;

+  }

+

+  CmObjectList = (CM_OBJECT_TOKEN *)AllocateZeroPool (sizeof (CM_OBJECT_TOKEN *) * NumObj);

+  if (CmObjectList == NULL) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "%a: Failed to alloc memory for %u CM Objects.\n",

+      __FUNCTION__,

+      NumObj

+      ));

+    Status = EFI_OUT_OF_RESOURCES;

+    goto exitBuildSmbiosType16Table;

+  }

+

+  for (Index = 0; Index < NumObj; Index++) {

+    /**

+     * Per Spec each structure is terminated by a double-NULL if there are no

+     * strings.

+     */

+    SmbiosRecord = (SMBIOS_TABLE_TYPE16 *)AllocateZeroPool (sizeof (SMBIOS_TABLE_TYPE16) + 1 + 1);

+    if (SmbiosRecord == NULL) {

+      Status = EFI_OUT_OF_RESOURCES;

+      goto exitBuildSmbiosType16Table;

+    }

+

+    UpdateSmbiosType16Size (PhysMemoryArray->Size, SmbiosRecord);

+    SmbiosRecord->Location              = PhysMemoryArray[Index].Location;

+    SmbiosRecord->Use                   = PhysMemoryArray[Index].Use;

+    SmbiosRecord->MemoryErrorCorrection = PhysMemoryArray[Index].MemoryErrorCorrectionType;

+    SmbiosRecord->NumberOfMemoryDevices = PhysMemoryArray->NumMemDevices;

+    if (PhysMemoryArray[Index].MemoryErrInfoToken != CM_NULL_TOKEN) {

+      AddMemErrDeviceHandle (

+        TableFactoryProtocol,

+        PhysMemoryArray[Index].MemoryErrInfoToken,

+        SmbiosRecord

+        );

+    } else {

+      SmbiosRecord->MemoryErrorInformationHandle = 0xFFFF;

+    }

+

+    // Setup the header

+    SmbiosRecord->Hdr.Type   = EFI_SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY;

+    SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE16);

+

+    TableList[Index]    = (SMBIOS_STRUCTURE *)SmbiosRecord;

+    CmObjectList[Index] = PhysMemoryArray[Index].PhysMemArrayToken;

+  }

+

+  *Table         = TableList;

+  *CmObjectToken = CmObjectList;

+  *TableCount    = NumObj;

+exitBuildSmbiosType16Table:

+  return Status;

+}

+

+/** The interface for the SMBIOS Type16 Table Generator.

+*/

+STATIC

+CONST

+SMBIOS_TABLE_GENERATOR  SmbiosType16Generator = {

+  // Generator ID

+  CREATE_STD_SMBIOS_TABLE_GEN_ID (EStdSmbiosTableIdType16),

+  // Generator Description

+  L"SMBIOS.TYPE16.GENERATOR",

+  // SMBIOS Table Type

+  EFI_SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY,

+  NULL,

+  NULL,

+  // Build table function.

+  BuildSmbiosType16TableEx,

+  // Free function.

+  FreeSmbiosType16TableEx,

+};

+

+/** Register the Generator with the SMBIOS Table Factory.

+

+  @param [in]  ImageHandle  The handle to the image.

+  @param [in]  SystemTable  Pointer to the System Table.

+

+  @retval EFI_SUCCESS           The Generator is registered.

+  @retval EFI_INVALID_PARAMETER A parameter is invalid.

+  @retval EFI_ALREADY_STARTED   The Generator for the Table ID

+                                is already registered.

+**/

+EFI_STATUS

+EFIAPI

+SmbiosType16LibConstructor (

+  IN  EFI_HANDLE        ImageHandle,

+  IN  EFI_SYSTEM_TABLE  *SystemTable

+  )

+{

+  EFI_STATUS  Status;

+

+  Status = RegisterSmbiosTableGenerator (&SmbiosType16Generator);

+  DEBUG ((

+    DEBUG_INFO,

+    "SMBIOS Type 16: Register Generator. Status = %r\n",

+    Status

+    ));

+  ASSERT_EFI_ERROR (Status);

+

+  return Status;

+}

+

+/** Deregister the Generator from the SMBIOS Table Factory.

+

+  @param [in]  ImageHandle  The handle to the image.

+  @param [in]  SystemTable  Pointer to the System Table.

+

+  @retval EFI_SUCCESS           The Generator is deregistered.

+  @retval EFI_INVALID_PARAMETER A parameter is invalid.

+  @retval EFI_NOT_FOUND         The Generator is not registered.

+**/

+EFI_STATUS

+EFIAPI

+SmbiosType16LibDestructor (

+  IN  EFI_HANDLE        ImageHandle,

+  IN  EFI_SYSTEM_TABLE  *SystemTable

+  )

+{

+  EFI_STATUS  Status;

+

+  Status = DeregisterSmbiosTableGenerator (&SmbiosType16Generator);

+  DEBUG ((

+    DEBUG_INFO,

+    "SMBIOS Type16: Deregister Generator. Status = %r\n",

+    Status

+    ));

+  ASSERT_EFI_ERROR (Status);

+  return Status;

+}

diff --git a/DynamicTablesPkg/Library/Smbios/SmbiosType16Lib/SmbiosType16Lib.inf b/DynamicTablesPkg/Library/Smbios/SmbiosType16Lib/SmbiosType16Lib.inf
new file mode 100644
index 0000000000..4d85c88d7f
--- /dev/null
+++ b/DynamicTablesPkg/Library/Smbios/SmbiosType16Lib/SmbiosType16Lib.inf
@@ -0,0 +1,35 @@
+## @file

+#  SMBIOS Type16 Table Generator

+#

+#  Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.

+#  Copyright (c) 2019 - 2021, Arm Limited. All rights reserved.<BR>

+#

+#  SPDX-License-Identifier: BSD-2-Clause-Patent

+##

+

+[Defines]

+  INF_VERSION    = 0x0001001B

+  BASE_NAME      = SmbiosType16LibArm

+  FILE_GUID      = a256956a-de0b-4aa7-8eac-5ce13bbfbb1f

+  VERSION_STRING = 1.0

+  MODULE_TYPE    = DXE_DRIVER

+  LIBRARY_CLASS  = NULL|DXE_DRIVER

+  CONSTRUCTOR    = SmbiosType16LibConstructor

+  DESTRUCTOR     = SmbiosType16LibDestructor

+

+[Sources]

+  SmbiosType16Generator.c

+

+[Packages]

+  MdePkg/MdePkg.dec

+  MdeModulePkg/MdeModulePkg.dec

+  EmbeddedPkg/EmbeddedPkg.dec

+  ArmPlatformPkg/ArmPlatformPkg.dec

+  DynamicTablesPkg/DynamicTablesPkg.dec

+

+[Protocols]

+  gEfiSmbiosProtocolGuid                        # PROTOCOL ALWAYS_CONSUMED

+

+[LibraryClasses]

+  BaseLib

+  DebugLib

-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#121094): https://edk2.groups.io/g/devel/message/121094
Mute This Topic: https://groups.io/mt/111022014/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [edk2-devel] [staging/dynamictables-reorg PATCH v0 12/12] DynamicTablesPkg: Smbios Memory Array Mapped Address (Type 19)
  2025-02-05 22:08 [edk2-devel] [staging/dynamictables-reorg PATCH v0 00/12] DynamicTablesPkg: Add SMBIOS table generation support Girish Mahadevan via groups.io
                   ` (10 preceding siblings ...)
  2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 11/12] DynamicTablesPkg: Smbios Physical Memory Array (Type 16) Girish Mahadevan via groups.io
@ 2025-02-05 22:09 ` Girish Mahadevan via groups.io
  11 siblings, 0 replies; 13+ messages in thread
From: Girish Mahadevan via groups.io @ 2025-02-05 22:09 UTC (permalink / raw)
  To: sami.mujawar, Alexei.Fedorov, pierre.gondois, abner.chang,
	Samer.El-Haj-Mahmoud, Jose.Marinho
  Cc: gmahadevan, jbrasen, ashishsingha, nramirez, devel

Add the Generator library for SMBIOS Table Type 19 - Memory Array
Mapped Address.

Signed-off-by: Girish Mahadevan <gmahadevan@nvidia.com>
Reviewed-by: Jeff Brasen <jbrasen@nvidia.com>
---
 .../Include/SmbiosNameSpaceObjects.h          |  14 +
 .../SmbiosType19Lib/SmbiosType19Generator.c   | 364 ++++++++++++++++++
 .../SmbiosType19Lib/SmbiosType19Lib.inf       |  36 ++
 3 files changed, 414 insertions(+)
 create mode 100644 DynamicTablesPkg/Library/Smbios/SmbiosType19Lib/SmbiosType19Generator.c
 create mode 100644 DynamicTablesPkg/Library/Smbios/SmbiosType19Lib/SmbiosType19Lib.inf

diff --git a/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h b/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h
index 7e883e1b89..e6c35f1ffd 100644
--- a/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h
+++ b/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h
@@ -151,6 +151,20 @@ typedef struct CmSmbiosPhysicalMemoryArray {
   CM_OBJECT_TOKEN    PhysMemArrayToken;

 } CM_SMBIOS_PHYSICAL_MEMORY_ARRAY;

 

+/** A structure that describes the Memory Array Mapped Address.

+

+  SMBIOS Specification v3.6.0 Type 19

+

+  ID: ESmbiosObjPhysicalMemoryArray

+**/

+typedef struct CmSmbiosMemArrayMappedAddress {

+  EFI_PHYSICAL_ADDRESS    StartingAddress;

+  EFI_PHYSICAL_ADDRESS    EndingAddress;

+  CM_OBJECT_TOKEN         MemoryArrayMappedAddressToken;

+  UINT8                   NumMemDevices;

+  CM_OBJECT_TOKEN         PhysMemArrayToken;

+} CM_SMBIOS_MEMORY_ARRAY_MAPPED_ADDRESS;

+

 #pragma pack()

 

 #endif // SMBIOS_NAMESPACE_OBJECTS_H_

diff --git a/DynamicTablesPkg/Library/Smbios/SmbiosType19Lib/SmbiosType19Generator.c b/DynamicTablesPkg/Library/Smbios/SmbiosType19Lib/SmbiosType19Generator.c
new file mode 100644
index 0000000000..0ca16cb300
--- /dev/null
+++ b/DynamicTablesPkg/Library/Smbios/SmbiosType19Lib/SmbiosType19Generator.c
@@ -0,0 +1,364 @@
+/** @file

+  SMBIOS Type19 Table Generator.

+

+  Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.

+  Copyright (c) 2020 - 2021, Arm 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/PrintLib.h>

+#include <Library/MemoryAllocationLib.h>

+#include <Library/UefiBootServicesTableLib.h>

+#include <Library/SmbiosStringTableLib.h>

+

+// Module specific include files.

+#include <ConfigurationManagerObject.h>

+#include <ConfigurationManagerHelper.h>

+#include <Protocol/ConfigurationManagerProtocol.h>

+#include <Protocol/DynamicTableFactoryProtocol.h>

+#include <Protocol/Smbios.h>

+#include <IndustryStandard/SmBios.h>

+

+/** This macro expands to a function that retrieves the Memory Device

+    information from the Configuration Manager.

+*/

+GET_OBJECT_LIST (

+  EObjNameSpaceSmbios,

+  ESmbiosObjMemoryArrayMappedAddress,

+  CM_SMBIOS_MEMORY_ARRAY_MAPPED_ADDRESS

+  )

+

+#define EXTENDED_ADDRESS_THRESHOLD  (0xFFFFFFFFL)

+

+/**

+ * Free any resources allocated when installing SMBIOS Type19 table.

+ *

+ * @param [in]  This                 Pointer to the SMBIOS table generator.

+ * @param [in]  TableFactoryProtocol Pointer to the SMBIOS Table Factory

+                                      Protocol interface.

+

+ * @param [in]  SmbiosTableInfo      Pointer to the SMBIOS table information.

+ * @param [in]  CfgMgrProtocol       Pointer to the Configuration Manager

+                                     Protocol interface.

+ * @param [in] Table                 Pointer to the SMBIOS table.

+ * @param [in] CmObjectToken         Pointer to the CM ObjectToken Array.

+ * @param [in] TableCount            Number of SMBIOS tables.

+

+ * @retval EFI_SUCCESS            Table generated successfully.

+ * @retval EFI_BAD_BUFFER_SIZE    The size returned by the Configuration

+                                  Manager is less than the Object size for

+                                  the requested object.

+ * @retval EFI_INVALID_PARAMETER  A parameter is invalid.

+ * @retval EFI_NOT_FOUND          Could not find information.

+ * @retval EFI_OUT_OF_RESOURCES   Could not allocate memory.

+ * @retval EFI_UNSUPPORTED        Unsupported configuration.

+**/

+STATIC

+EFI_STATUS

+FreeSmbiosType19TableEx (

+  IN      CONST SMBIOS_TABLE_GENERATOR                   *CONST  This,

+  IN      CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL     *CONST  TableFactoryProtocol,

+  IN      CONST CM_STD_OBJ_SMBIOS_TABLE_INFO             *CONST  SmbiosTableInfo,

+  IN      CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL     *CONST  CfgMgrProtocol,

+  IN      SMBIOS_STRUCTURE                             ***CONST  Table,

+  IN      CM_OBJECT_TOKEN                                        **CmObjectToken,

+  IN      CONST UINTN                                            TableCount

+  )

+{

+  UINTN             Index;

+  SMBIOS_STRUCTURE  **TableList;

+

+  TableList = *Table;

+  for (Index = 0; Index < TableCount; Index++) {

+    if (TableList[Index] != NULL) {

+      FreePool (TableList[Index]);

+    }

+  }

+

+  if (*CmObjectToken != NULL) {

+    FreePool (*CmObjectToken);

+  }

+

+  if (TableList != NULL) {

+    FreePool (TableList);

+  }

+

+  return EFI_SUCCESS;

+}

+

+/**

+ *  Add the SMBIOS table handle reference to the Physical Array Table.

+ *

+ *  @param [in]     TableFactoryProtocol   Pointer to the SMBIOS Table Factory.

+ *  @param [in]     CmObjToken             CM Token to lookup..

+ *  @param [out]    SmbiosRecord           SMBIOS record to update.

+**/

+STATIC

+VOID

+AddPhysArrHandle (

+  IN  CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL   *CONST  TableFactoryProtocol,

+  IN  CM_OBJECT_TOKEN                                      CmObjToken,

+  OUT SMBIOS_TABLE_TYPE19                                  *SmbiosRecord

+  )

+{

+  EFI_SMBIOS_HANDLE  PhysMemArrHandle;

+  SMBIOS_HANDLE_MAP  *HandleMap;

+

+  HandleMap = TableFactoryProtocol->GetSmbiosHandle (CmObjToken);

+  if (HandleMap == NULL) {

+    DEBUG ((DEBUG_ERROR, "%a:Failed to get SMBIOS Handle\n", __FUNCTION__));

+    PhysMemArrHandle = 0;

+  } else {

+    PhysMemArrHandle = HandleMap->SmbiosTblHandle;

+  }

+

+  SmbiosRecord->MemoryArrayHandle = PhysMemArrHandle;

+}

+

+/**

+ *  Update the Address encoding for Type 19.

+ *

+ *  @param [in]    StartAddress   Starting memory address covered by the device.

+ *  @param [in]    EndAddress     Ending memory address covered by the device.

+ *  @param [out]   SmbiosRecord   SMBIOS record to update.

+**/

+STATIC

+VOID

+UpdateSmbiosType19Address (

+  IN  UINT64               StartAddress,

+  IN  UINT64               EndAddress,

+  OUT SMBIOS_TABLE_TYPE19  *SmbiosRecord

+  )

+{

+  UINT64  StartingAddressKb = StartAddress / SIZE_1KB;

+  UINT64  EndingAddressKb   = EndAddress / SIZE_1KB;

+

+  if (StartingAddressKb >= EXTENDED_ADDRESS_THRESHOLD) {

+    SmbiosRecord->StartingAddress         = EXTENDED_ADDRESS_THRESHOLD;

+    SmbiosRecord->EndingAddress           = EXTENDED_ADDRESS_THRESHOLD;

+    SmbiosRecord->ExtendedStartingAddress = StartAddress;

+    SmbiosRecord->ExtendedEndingAddress   = EndAddress;

+  } else {

+    SmbiosRecord->StartingAddress = StartingAddressKb;

+    SmbiosRecord->EndingAddress   = EndingAddressKb;

+  }

+}

+

+/** Construct SMBIOS Type19 Table describing memory devices.

+

+  If this function allocates any resources then they must be freed

+  in the FreeXXXXTableResources function.

+

+  @param [in]  This            Pointer to the SMBIOS table generator.

+  @param [in]  SmbiosTableInfo Pointer to the SMBIOS table information.

+  @param [in]  CfgMgrProtocol  Pointer to the Configuration Manager

+                               Protocol interface.

+  @param [out] Table           Pointer to the SMBIOS table.

+  @param [out] CmObjectToken        Pointer to the CM Object Token Array.

+  @param [out] TableCount           Number of tables installed.

+

+  @retval EFI_SUCCESS            Table generated successfully.

+  @retval EFI_BAD_BUFFER_SIZE    The size returned by the Configuration

+                                 Manager is less than the Object size for

+                                 the requested object.

+  @retval EFI_INVALID_PARAMETER  A parameter is invalid.

+  @retval EFI_NOT_FOUND          Could not find information.

+  @retval EFI_OUT_OF_RESOURCES   Could not allocate memory.

+  @retval EFI_UNSUPPORTED        Unsupported configuration.

+**/

+STATIC

+EFI_STATUS

+BuildSmbiosType19TableEx (

+  IN  CONST SMBIOS_TABLE_GENERATOR                         *This,

+  IN  CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL   *CONST  TableFactoryProtocol,

+  IN        CM_STD_OBJ_SMBIOS_TABLE_INFO           *CONST  SmbiosTableInfo,

+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL   *CONST  CfgMgrProtocol,

+  OUT       SMBIOS_STRUCTURE                               ***Table,

+  OUT       CM_OBJECT_TOKEN                                **CmObjectToken,

+  OUT       UINTN                                  *CONST  TableCount

+  )

+{

+  EFI_STATUS                             Status;

+  UINT32                                 NumMemMap;

+  SMBIOS_STRUCTURE                       **TableList;

+  CM_OBJECT_TOKEN                        *CmObjectList;

+  CM_SMBIOS_MEMORY_ARRAY_MAPPED_ADDRESS  *MemoryMapInfo;

+  SMBIOS_TABLE_TYPE19                    *SmbiosRecord;

+  UINTN                                  Index;

+

+  ASSERT (This != NULL);

+  ASSERT (SmbiosTableInfo != NULL);

+  ASSERT (CfgMgrProtocol != NULL);

+  ASSERT (Table != NULL);

+  ASSERT (TableCount != NULL);

+  ASSERT (SmbiosTableInfo->TableGeneratorId == This->GeneratorID);

+

+  if ((This == NULL) || (SmbiosTableInfo == NULL) || (CfgMgrProtocol == NULL) ||

+      (Table == NULL) || (TableCount == NULL) ||

+      (SmbiosTableInfo->TableGeneratorId != This->GeneratorID))

+  {

+    DEBUG ((DEBUG_ERROR, "%a:Invalid Paramater\n ", __FUNCTION__));

+    return EFI_INVALID_PARAMETER;

+  }

+

+  *Table = NULL;

+  Status = GetESmbiosObjMemoryArrayMappedAddress (

+             CfgMgrProtocol,

+             CM_NULL_TOKEN,

+             &MemoryMapInfo,

+             &NumMemMap

+             );

+  if (EFI_ERROR (Status)) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "Failed to get Memory Devices CM Object %r\n",

+      Status

+      ));

+    return Status;

+  }

+

+  TableList = (SMBIOS_STRUCTURE **)AllocateZeroPool (sizeof (SMBIOS_STRUCTURE *) * NumMemMap);

+  if (TableList == NULL) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "%a: Failed to alloc memory for %u devices table\n",

+      __FUNCTION__,

+      NumMemMap

+      ));

+    Status = EFI_OUT_OF_RESOURCES;

+    goto exitBuildSmbiosType19TableEx;

+  }

+

+  CmObjectList = (CM_OBJECT_TOKEN *)AllocateZeroPool (sizeof (CM_OBJECT_TOKEN *) * NumMemMap);

+  if (CmObjectList == NULL) {

+    DEBUG ((

+      DEBUG_ERROR,

+      "%a: Failed to alloc memory for %u CMObjects\n",

+      __FUNCTION__,

+      NumMemMap

+      ));

+    Status = EFI_OUT_OF_RESOURCES;

+    goto exitBuildSmbiosType19TableEx;

+  }

+

+  for (Index = 0; Index < NumMemMap; Index++) {

+    /**

+     * Per Spec each structure is terminated by a double-NULL if there are no

+     * strings.

+     */

+    SmbiosRecord = (SMBIOS_TABLE_TYPE19 *)AllocateZeroPool (sizeof (SMBIOS_TABLE_TYPE19) + 1 + 1);

+    if (SmbiosRecord == NULL) {

+      Status = EFI_OUT_OF_RESOURCES;

+      goto exitBuildSmbiosType19TableEx;

+    }

+

+    UpdateSmbiosType19Address (

+      MemoryMapInfo[Index].StartingAddress,

+      MemoryMapInfo[Index].EndingAddress,

+      SmbiosRecord

+      );

+    SmbiosRecord->PartitionWidth = MemoryMapInfo[Index].NumMemDevices;

+    // Is there a reference to a Physical Array Device.

+    if (MemoryMapInfo[Index].PhysMemArrayToken != CM_NULL_TOKEN) {

+      AddPhysArrHandle (

+        TableFactoryProtocol,

+        MemoryMapInfo[Index].PhysMemArrayToken,

+        SmbiosRecord

+        );

+    }

+

+    // setup the header

+    SmbiosRecord->Hdr.Type   = EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS;

+    SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE19);

+    TableList[Index]         = (SMBIOS_STRUCTURE *)SmbiosRecord;

+    CmObjectList[Index]      = MemoryMapInfo[Index].MemoryArrayMappedAddressToken;

+  }

+

+  *Table         = TableList;

+  *CmObjectToken = CmObjectList;

+  *TableCount    = NumMemMap;

+

+exitBuildSmbiosType19TableEx:

+  return Status;

+}

+

+/** The interface for the SMBIOS Type17 Table Generator.

+*/

+STATIC

+CONST

+SMBIOS_TABLE_GENERATOR  SmbiosType19Generator = {

+  // Generator ID

+  CREATE_STD_SMBIOS_TABLE_GEN_ID (EStdSmbiosTableIdType19),

+  // Generator Description

+  L"SMBIOS.TYPE19.GENERATOR",

+  // SMBIOS Table Type

+  EFI_SMBIOS_TYPE_MEMORY_DEVICE,

+  NULL,

+  NULL,

+  // Build table function Extended.

+  BuildSmbiosType19TableEx,

+  // Free function Extended.

+  FreeSmbiosType19TableEx

+};

+

+/** Register the Generator with the SMBIOS Table Factory.

+

+  @param [in]  ImageHandle  The handle to the image.

+  @param [in]  SystemTable  Pointer to the System Table.

+

+  @retval EFI_SUCCESS           The Generator is registered.

+  @retval EFI_INVALID_PARAMETER A parameter is invalid.

+  @retval EFI_ALREADY_STARTED   The Generator for the Table ID

+                                is already registered.

+**/

+EFI_STATUS

+EFIAPI

+SmbiosType19LibConstructor (

+  IN  EFI_HANDLE        ImageHandle,

+  IN  EFI_SYSTEM_TABLE  *SystemTable

+  )

+{

+  EFI_STATUS  Status;

+

+  Status = RegisterSmbiosTableGenerator (&SmbiosType19Generator);

+  DEBUG ((

+    DEBUG_INFO,

+    "SMBIOS Type 19: Register Generator. Status = %r\n",

+    Status

+    ));

+  ASSERT_EFI_ERROR (Status);

+

+  return Status;

+}

+

+/** Deregister the Generator from the SMBIOS Table Factory.

+

+  @param [in]  ImageHandle  The handle to the image.

+  @param [in]  SystemTable  Pointer to the System Table.

+

+  @retval EFI_SUCCESS           The Generator is deregistered.

+  @retval EFI_INVALID_PARAMETER A parameter is invalid.

+  @retval EFI_NOT_FOUND         The Generator is not registered.

+**/

+EFI_STATUS

+EFIAPI

+SmbiosType19LibDestructor (

+  IN  EFI_HANDLE        ImageHandle,

+  IN  EFI_SYSTEM_TABLE  *SystemTable

+  )

+{

+  EFI_STATUS  Status;

+

+  Status = DeregisterSmbiosTableGenerator (&SmbiosType19Generator);

+  DEBUG ((

+    DEBUG_INFO,

+    "SMBIOS Type19: Deregister Generator. Status = %r\n",

+    Status

+    ));

+  ASSERT_EFI_ERROR (Status);

+  return Status;

+}

diff --git a/DynamicTablesPkg/Library/Smbios/SmbiosType19Lib/SmbiosType19Lib.inf b/DynamicTablesPkg/Library/Smbios/SmbiosType19Lib/SmbiosType19Lib.inf
new file mode 100644
index 0000000000..0043e71d1c
--- /dev/null
+++ b/DynamicTablesPkg/Library/Smbios/SmbiosType19Lib/SmbiosType19Lib.inf
@@ -0,0 +1,36 @@
+## @file

+#  SMBIOS Type19 Table Generator

+#

+#  Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.

+#  Copyright (c) 2019 - 2021, Arm Limited. All rights reserved.<BR>

+#

+#  SPDX-License-Identifier: BSD-2-Clause-Patent

+##

+

+[Defines]

+  INF_VERSION    = 0x0001001B

+  BASE_NAME      = SmbiosType19LibArm

+  FILE_GUID      = 36da84ff-2c7d-4983-99a0-c9e1a8675fb4

+  VERSION_STRING = 1.0

+  MODULE_TYPE    = DXE_DRIVER

+  LIBRARY_CLASS  = NULL|DXE_DRIVER

+  CONSTRUCTOR    = SmbiosType19LibConstructor

+  DESTRUCTOR     = SmbiosType19LibDestructor

+

+[Sources]

+  SmbiosType19Generator.c

+

+[Packages]

+  MdePkg/MdePkg.dec

+  MdeModulePkg/MdeModulePkg.dec

+  EmbeddedPkg/EmbeddedPkg.dec

+  ArmPlatformPkg/ArmPlatformPkg.dec

+  DynamicTablesPkg/DynamicTablesPkg.dec

+

+[Protocols]

+  gEfiSmbiosProtocolGuid                        # PROTOCOL ALWAYS_CONSUMED

+

+[LibraryClasses]

+  BaseLib

+  DebugLib

+  SmbiosStringTableLib

-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#121095): https://edk2.groups.io/g/devel/message/121095
Mute This Topic: https://groups.io/mt/111022015/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2025-02-05 22:09 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-05 22:08 [edk2-devel] [staging/dynamictables-reorg PATCH v0 00/12] DynamicTablesPkg: Add SMBIOS table generation support Girish Mahadevan via groups.io
2025-02-05 22:08 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 01/12] DynamicTablesPkg: SmbiosStringLib: Add new helper macro Girish Mahadevan via groups.io
2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 02/12] DynamicTablesPkg: Define a SMBIOS Structure/Table type Girish Mahadevan via groups.io
2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 03/12] DynamicTablesPkg: Add SMBIOS table dispatcher Girish Mahadevan via groups.io
2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 04/12] DynamicTablesPkg: Add extern call to build SMBIOS table Girish Mahadevan via groups.io
2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 05/12] DynamicTablesPkg: Update SMBIOS dispatcher dependency table Girish Mahadevan via groups.io
2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 06/12] DynamicTablesPkg: Add Ordered dispatch support for SMBIOS tables Girish Mahadevan via groups.io
2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 07/12] DynamicTablesPkg: Add SMBIOS table generation Girish Mahadevan via groups.io
2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 08/12] DynamicTablesPkg: Split the ACPI and SMBIOS table generators Girish Mahadevan via groups.io
2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 09/12] DynamicTablesPkg: Introduce new namespace for SMBIOS Objects Girish Mahadevan via groups.io
2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 10/12] DynamicTablesPkg: Smbios Memory Device (Type 17) Girish Mahadevan via groups.io
2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 11/12] DynamicTablesPkg: Smbios Physical Memory Array (Type 16) Girish Mahadevan via groups.io
2025-02-05 22:09 ` [edk2-devel] [staging/dynamictables-reorg PATCH v0 12/12] DynamicTablesPkg: Smbios Memory Array Mapped Address (Type 19) Girish Mahadevan via groups.io

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox