public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v2 0/4] DynamicTablesPkg: Introduce SMBIOS dispatcher
@ 2023-03-08  8:16 Sami Mujawar
  2023-03-08  8:16 ` [PATCH v2 1/4] DynamicTablesPkg: Define a SMBIOS Structure/Table type Sami Mujawar
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Sami Mujawar @ 2023-03-08  8:16 UTC (permalink / raw)
  To: devel
  Cc: Sami Mujawar, Alexei.Fedorov, pierre.gondois, gmahadevan,
	abner.chang, jbrasen, ashishsingha, nramirez, wwatson,
	Matteo.Carlini, Akanksha.Jain2, Ben.Adderson,
	Samer.El-Haj-Mahmoud, Jose.Marinho, nd

Some SMBIOS tables have dependencies on other SMBIOS tables. These
dependencies are established using handles pointing to the dependent
SMBIOS tables.
This requires the dependent SMBIOS table to be installed before the
parent SMBIOS table can be installed.

To facilitate dynamic SMBIOS table generation, a SMBIOS table
dispatcher has been introduced. The SMBIOS table dispatcher
schedules the installation of dependent SMBIOS tables before
the parent SMBIOS table is installed.

This v2 series addresses the feedback received for the v1 series
and also introduces ordered dispatch for SMBIOS tables. 

The SMBIOS dispatcher categorises the SMBIOS tables as:
 - default ordered
 - ordered.

The default ordered SMBIOS tables have a fixed defined dependency
i.e. their dependency list can be traversed by the dispatcher to
schedule their dispatch.

Ordered SMBIOS tables do not have a well defined dependency and
could depend on any SMBIOS table, for e.g. the SMBIOS table Group
Associations (Type 14) does not have a well defined dependency as
it can be used to associate any two SMBIOS tables.
Therefore, ordered SMBIOS tables are scheduled for dispatch after
the default ordered SMBIOS tables are dispatched. The ordered SMBIOS
tables can also have a level that allows the dispatcher to sequence
their dispatch.

The changes can be seen at:
https://github.com/samimujawar/edk2/tree/2406_smbios_dispatcher_v2

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

 DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf |   4 +-
 DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c    | 669 ++++++++++++++++++++
 DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.h    | 181 ++++++
 DynamicTablesPkg/Include/StandardNameSpaceObjects.h                        |  17 +
 4 files changed, 870 insertions(+), 1 deletion(-)
 create mode 100644 DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c
 create mode 100644 DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.h

-- 
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'


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

* [PATCH v2 1/4] DynamicTablesPkg: Define a SMBIOS Structure/Table type
  2023-03-08  8:16 [PATCH v2 0/4] DynamicTablesPkg: Introduce SMBIOS dispatcher Sami Mujawar
@ 2023-03-08  8:16 ` Sami Mujawar
  2023-03-08  8:16 ` [PATCH v2 2/4] DynamicTablesPkg: Add SMBIOS table dispatcher Sami Mujawar
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 13+ messages in thread
From: Sami Mujawar @ 2023-03-08  8:16 UTC (permalink / raw)
  To: devel
  Cc: Sami Mujawar, Alexei.Fedorov, pierre.gondois, gmahadevan,
	abner.chang, jbrasen, ashishsingha, nramirez, wwatson,
	Matteo.Carlini, Akanksha.Jain2, Ben.Adderson,
	Samer.El-Haj-Mahmoud, Jose.Marinho, nd

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>
---

Notes:
    v2:
     - No code change from v1.                                   [SAMI]
       Ref: https://edk2.groups.io/g/devel/topic/94410913#95544

 DynamicTablesPkg/Include/StandardNameSpaceObjects.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/DynamicTablesPkg/Include/StandardNameSpaceObjects.h b/DynamicTablesPkg/Include/StandardNameSpaceObjects.h
index 8ec3238225abe4fc16a7337c29ecd655590b408f..c81efbc237779c305abc3c4dd07f6b705563e2a1 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;
 
-- 
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'


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

* [PATCH v2 2/4] DynamicTablesPkg: Add SMBIOS table dispatcher
  2023-03-08  8:16 [PATCH v2 0/4] DynamicTablesPkg: Introduce SMBIOS dispatcher Sami Mujawar
  2023-03-08  8:16 ` [PATCH v2 1/4] DynamicTablesPkg: Define a SMBIOS Structure/Table type Sami Mujawar
@ 2023-03-08  8:16 ` Sami Mujawar
  2023-03-08 17:41   ` Girish Mahadevan
  2023-03-08  8:16 ` [PATCH v2 3/4] DynamicTablesPkg: Update SMBIOS dispatcher dependency table Sami Mujawar
  2023-03-08  8:16 ` [PATCH v2 4/4] DynamicTablesPkg: Add Ordered dispatch support for SMBIOS tables Sami Mujawar
  3 siblings, 1 reply; 13+ messages in thread
From: Sami Mujawar @ 2023-03-08  8:16 UTC (permalink / raw)
  To: devel
  Cc: Sami Mujawar, Alexei.Fedorov, pierre.gondois, gmahadevan,
	abner.chang, jbrasen, ashishsingha, nramirez, wwatson,
	Matteo.Carlini, Akanksha.Jain2, Ben.Adderson,
	Samer.El-Haj-Mahmoud, Jose.Marinho, nd

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>
---

Notes:
    v2:
     - Update dispatcher state machine to remove StUnknown.    [SAMI]
     - Move extern function to header file and move debug      [ABNER]
       code together.
     - Updated code based on review feedback to move extern    [SAMI]
       function to header file and also moved the debug code
       together.
       Ref: https://edk2.groups.io/g/devel/message/95341

 DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf |   4 +-
 DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c    | 282 ++++++++++++++++++++
 DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.h    | 159 +++++++++++
 3 files changed, 444 insertions(+), 1 deletion(-)

diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf
index ad8b3d037c169ca848b5ea84fd1086b83f37876f..b09272d883c6f4f05eb03dcdab3efeda92b2fbb6 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
 ##
@@ -22,6 +22,8 @@ [Defines]
 
 [Sources]
   DynamicTableManagerDxe.c
+  SmbiosTableDispatcher.c
+  SmbiosTableDispatcher.h
 
 [Packages]
   MdePkg/MdePkg.dec
diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c
new file mode 100644
index 0000000000000000000000000000000000000000..0e728538d9f6eb0b164fea3a160d3233db833f8d
--- /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 0000000000000000000000000000000000000000..d59eab4223c142293bdaf4905588f08e7a4a467f
--- /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_
-- 
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'


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

* [PATCH v2 3/4] DynamicTablesPkg: Update SMBIOS dispatcher dependency table
  2023-03-08  8:16 [PATCH v2 0/4] DynamicTablesPkg: Introduce SMBIOS dispatcher Sami Mujawar
  2023-03-08  8:16 ` [PATCH v2 1/4] DynamicTablesPkg: Define a SMBIOS Structure/Table type Sami Mujawar
  2023-03-08  8:16 ` [PATCH v2 2/4] DynamicTablesPkg: Add SMBIOS table dispatcher Sami Mujawar
@ 2023-03-08  8:16 ` Sami Mujawar
  2023-03-08  8:16 ` [PATCH v2 4/4] DynamicTablesPkg: Add Ordered dispatch support for SMBIOS tables Sami Mujawar
  3 siblings, 0 replies; 13+ messages in thread
From: Sami Mujawar @ 2023-03-08  8:16 UTC (permalink / raw)
  To: devel
  Cc: Sami Mujawar, Alexei.Fedorov, pierre.gondois, gmahadevan,
	abner.chang, jbrasen, ashishsingha, nramirez, wwatson,
	Matteo.Carlini, Akanksha.Jain2, Ben.Adderson,
	Samer.El-Haj-Mahmoud, Jose.Marinho, nd

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>
---

Notes:
    v2:
     - New patch in v2 series.                                [SAMI]

 DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c | 94 ++++++++++----------
 DynamicTablesPkg/Drivers/DynamicTableManagerDxe/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 0e728538d9f6eb0b164fea3a160d3233db833f8d..384a0a9adcd5f11fc73f42b90cfb1c9a6ba2fc73 100644
--- a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c
+++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c
@@ -30,53 +30,53 @@
 */
 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 d59eab4223c142293bdaf4905588f08e7a4a467f..e98ac18c7ddc31b8d03a3a83f9bd66ab23278136 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 } \
   }
 
 /**
-- 
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'


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

* [PATCH v2 4/4] DynamicTablesPkg: Add Ordered dispatch support for SMBIOS tables
  2023-03-08  8:16 [PATCH v2 0/4] DynamicTablesPkg: Introduce SMBIOS dispatcher Sami Mujawar
                   ` (2 preceding siblings ...)
  2023-03-08  8:16 ` [PATCH v2 3/4] DynamicTablesPkg: Update SMBIOS dispatcher dependency table Sami Mujawar
@ 2023-03-08  8:16 ` Sami Mujawar
  3 siblings, 0 replies; 13+ messages in thread
From: Sami Mujawar @ 2023-03-08  8:16 UTC (permalink / raw)
  To: devel
  Cc: Sami Mujawar, Alexei.Fedorov, pierre.gondois, gmahadevan,
	abner.chang, jbrasen, ashishsingha, nramirez, wwatson,
	Matteo.Carlini, Akanksha.Jain2, Ben.Adderson,
	Samer.El-Haj-Mahmoud, Jose.Marinho, nd

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>
---

Notes:
    v2:
     - New patch in v2 series.                                [SAMI]

 DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c | 531 +++++++++++++++++---
 DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.h |  34 +-
 2 files changed, 487 insertions(+), 78 deletions(-)

diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c
index 384a0a9adcd5f11fc73f42b90cfb1c9a6ba2fc73..6da711d7290a868997f7016ac8a04e759c2c4441 100644
--- a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c
+++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c
@@ -27,56 +27,65 @@
     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)
@@ -159,7 +168,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
@@ -190,10 +275,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,
@@ -205,28 +297,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,
@@ -234,44 +354,51 @@ 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 - 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 (
+  // All dependencies satisfied - dispatch SMBIOS table
+  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
       ));
   }
@@ -280,3 +407,263 @@ DispatchSmbiosTable (
   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 = 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
+      ));
+  }
+
+  DEBUG_PRINT_DISPATCHER_STATUS (FALSE);
+  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 e98ac18c7ddc31b8d03a3a83f9bd66ab23278136..471570e57f00392c45d6f478f06c72ef6bbc57bc 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,
-- 
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'


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

* Re: [PATCH v2 2/4] DynamicTablesPkg: Add SMBIOS table dispatcher
  2023-03-08  8:16 ` [PATCH v2 2/4] DynamicTablesPkg: Add SMBIOS table dispatcher Sami Mujawar
@ 2023-03-08 17:41   ` Girish Mahadevan
  2023-03-09 10:41     ` Sami Mujawar
  0 siblings, 1 reply; 13+ messages in thread
From: Girish Mahadevan @ 2023-03-08 17:41 UTC (permalink / raw)
  To: Sami Mujawar, devel
  Cc: Alexei.Fedorov, pierre.gondois, abner.chang, jbrasen,
	ashishsingha, nramirez, wwatson, Matteo.Carlini, Akanksha.Jain2,
	Ben.Adderson, Samer.El-Haj-Mahmoud, Jose.Marinho, nd

Hi Sami

Thanks for v2, I will apply these to my tree and test it out.
One small comment before I review/test the patch train inline (prefixed 
by [GM])

Best Regards
Girish

On 3/8/2023 1:16 AM, Sami Mujawar wrote:
> External email: Use caution opening links or attachments
> 
> 
> 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>
> ---
> 
> Notes:
>      v2:
>       - Update dispatcher state machine to remove StUnknown.    [SAMI]
>       - Move extern function to header file and move debug      [ABNER]
>         code together.
>       - Updated code based on review feedback to move extern    [SAMI]
>         function to header file and also moved the debug code
>         together.
>         Ref: https://edk2.groups.io/g/devel/message/95341
> 
>   DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf |   4 +-
>   DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c    | 282 ++++++++++++++++++++
>   DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.h    | 159 +++++++++++
>   3 files changed, 444 insertions(+), 1 deletion(-)
> 
> diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf
> index ad8b3d037c169ca848b5ea84fd1086b83f37876f..b09272d883c6f4f05eb03dcdab3efeda92b2fbb6 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
>   ##
> @@ -22,6 +22,8 @@ [Defines]
> 
>   [Sources]
>     DynamicTableManagerDxe.c
> +  SmbiosTableDispatcher.c
> +  SmbiosTableDispatcher.h
> 
>   [Packages]
>     MdePkg/MdePkg.dec
> diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c
> new file mode 100644
> index 0000000000000000000000000000000000000000..0e728538d9f6eb0b164fea3a160d3233db833f8d
> --- /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);

[GM]
This ASSERT will be hit even if we have multiple SMBIOS CM objects of 
the same type which is legal (for e.g there are multiple tables for 
type17/19 )

Best Regards
Girish

> +    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 0000000000000000000000000000000000000000..d59eab4223c142293bdaf4905588f08e7a4a467f
> --- /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_
> --
> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
> 

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

* Re: [PATCH v2 2/4] DynamicTablesPkg: Add SMBIOS table dispatcher
  2023-03-08 17:41   ` Girish Mahadevan
@ 2023-03-09 10:41     ` Sami Mujawar
  2023-03-10 16:23       ` Girish Mahadevan
  0 siblings, 1 reply; 13+ messages in thread
From: Sami Mujawar @ 2023-03-09 10:41 UTC (permalink / raw)
  To: Girish Mahadevan, devel@edk2.groups.io
  Cc: Alexei Fedorov, Pierre Gondois, abner.chang@amd.com,
	Jeff Brasen (jbrasen@nvidia.com), ashishsingha@nvidia.com,
	nramirez@nvidia.com, wwatson@nvidia.com, Matteo Carlini,
	Akanksha Jain, Ben Adderson, Samer El-Haj-Mahmoud, Jose Marinho,
	nd

Hi Girish,

Thank you for your feedback.

Please find my response inline marked [SAMI].

Regards,

Sami Mujawar

On 08/03/2023, 17:41, "Girish Mahadevan" <gmahadevan@nvidia.com <mailto:gmahadevan@nvidia.com>> wrote:


Hi Sami


Thanks for v2, I will apply these to my tree and test it out.
One small comment before I review/test the patch train inline (prefixed 
by [GM])


Best Regards
Girish


On 3/8/2023 1:16 AM, Sami Mujawar wrote:
> External email: Use caution opening links or attachments
> 
> 
> 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 <mailto:sami.mujawar@arm.com>>
> Cc: Alexei Fedorov <Alexei.Fedorov@arm.com <mailto:Alexei.Fedorov@arm.com>>
> Cc: Pierre Gondois <pierre.gondois@arm.com <mailto:pierre.gondois@arm.com>>
> Cc: Girish Mahadevan <gmahadevan@nvidia.com <mailto:gmahadevan@nvidia.com>>
> Cc: Jeff Brasen <jbrasen@nvidia.com <mailto:jbrasen@nvidia.com>>
> Cc: Ashish Singhal <ashishsingha@nvidia.com <mailto:ashishsingha@nvidia.com>>
> Cc: Nick Ramirez <nramirez@nvidia.com <mailto:nramirez@nvidia.com>>
> Cc: William Watson <wwatson@nvidia.com <mailto:wwatson@nvidia.com>>
> Cc: Abner Chang <abner.chang@amd.com <mailto:abner.chang@amd.com>>
> Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com <mailto:Samer.El-Haj-Mahmoud@arm.com>>
> Cc: Jose Marinho <Jose.Marinho@arm.com <mailto:Jose.Marinho@arm.com>>
> ---
> 
> Notes:
> v2:
> - Update dispatcher state machine to remove StUnknown. [SAMI]
> - Move extern function to header file and move debug [ABNER]
> code together.
> - Updated code based on review feedback to move extern [SAMI]
> function to header file and also moved the debug code
> together.
> Ref: https://edk2.groups.io/g/devel/message/95341 <https://edk2.groups.io/g/devel/message/95341>
> 
> DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf | 4 +-
> DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c | 282 ++++++++++++++++++++
> DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.h | 159 +++++++++++
> 3 files changed, 444 insertions(+), 1 deletion(-)
> 
> diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf
> index ad8b3d037c169ca848b5ea84fd1086b83f37876f..b09272d883c6f4f05eb03dcdab3efeda92b2fbb6 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
> ##
> @@ -22,6 +22,8 @@ [Defines]
> 
> [Sources]
> DynamicTableManagerDxe.c
> + SmbiosTableDispatcher.c
> + SmbiosTableDispatcher.h
> 
> [Packages]
> MdePkg/MdePkg.dec
> diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c
> new file mode 100644
> index 0000000000000000000000000000000000000000..0e728538d9f6eb0b164fea3a160d3233db833f8d
> --- /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);


[GM]
This ASSERT will be hit even if we have multiple SMBIOS CM objects of 
the same type which is legal (for e.g there are multiple tables for 
type17/19 )

[SAMI] The understanding is that SmbiosTableInfo[] will only contain one entry for a given TableType as it is used to indicate which generators are to be instantiated. 

Following is the sequence of operations:
- The dispatcher is initialised in InitSmbiosTableDispatcher(), which will set the mSmBiosDispatcher[<Table_Type>].State to StPresent if SmbiosTableInfo[] contains a table of Table_Type.
- SmbiosTableInfo[] will only contain one entry for each table type, e.g. even if there are multiple Type17/Type19 tables to be installed. This entry indicates that table(s) of Type17/Type19 is/are requested to be installed and that the corresponding generator must be instantiated.
- Once the SMBIOS table generator is instantiated, it will then request for the object(s) of the required type from the Configuration Manager that are required to construct the table.
- The generator can then decide if multiple SMBIOS tables are to be constructed based on the objects returned by the Configuration Manager. e.g. if multiple Cm_Type17_objects are returned then the corresponding number of Type17 tables will be built by the generator.

Therefore, I think we should not hit the above assert. 

However, the code that may need to change/extend is the call to BuildAndInstallSmbiosTable(). I am not sure if we need to indicate that there could be multiple SMBIOS tables that may be installed. For now, BuildAndInstallSmbiosTable() implies that a generator of the specified type is to be instantiated for building the SMBIOS table of the specified type.

Hope this clarifies the scenario and please do let me know if I am missing something.

Also, I have only tested this patch with simulated data and there may be some issues that we may find when the full stack is integrated.
So, thank you for going through the patch in detail.

[SAMI]

Best Regards
Girish


> + 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 0000000000000000000000000000000000000000..d59eab4223c142293bdaf4905588f08e7a4a467f
> --- /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_
> --
> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
> 




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

* Re: [PATCH v2 2/4] DynamicTablesPkg: Add SMBIOS table dispatcher
  2023-03-09 10:41     ` Sami Mujawar
@ 2023-03-10 16:23       ` Girish Mahadevan
  2023-03-10 16:28         ` Sami Mujawar
  0 siblings, 1 reply; 13+ messages in thread
From: Girish Mahadevan @ 2023-03-10 16:23 UTC (permalink / raw)
  To: Sami Mujawar, devel@edk2.groups.io
  Cc: Alexei Fedorov, Pierre Gondois, abner.chang@amd.com,
	Jeff Brasen (jbrasen@nvidia.com), ashishsingha@nvidia.com,
	nramirez@nvidia.com, wwatson@nvidia.com, Matteo Carlini,
	Akanksha Jain, Ben Adderson, Samer El-Haj-Mahmoud, Jose Marinho,
	nd

Hi Sami

Response inline.[GM]

Best Regards
Girish

On 3/9/2023 3:41 AM, Sami Mujawar wrote:
> External email: Use caution opening links or attachments
> 
> 
> Hi Girish,
> 
> Thank you for your feedback.
> 
> Please find my response inline marked [SAMI].
> 
> Regards,
> 
> Sami Mujawar
> 
> On 08/03/2023, 17:41, "Girish Mahadevan" <gmahadevan@nvidia.com <mailto:gmahadevan@nvidia.com>> wrote:
> 
> 
> Hi Sami
> 
> 
> Thanks for v2, I will apply these to my tree and test it out.
> One small comment before I review/test the patch train inline (prefixed
> by [GM])
> 
> 
> Best Regards
> Girish
> 
> 
> On 3/8/2023 1:16 AM, Sami Mujawar wrote:
>> External email: Use caution opening links or attachments
>>
>>
>> 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 <mailto:sami.mujawar@arm.com>>
>> Cc: Alexei Fedorov <Alexei.Fedorov@arm.com <mailto:Alexei.Fedorov@arm.com>>
>> Cc: Pierre Gondois <pierre.gondois@arm.com <mailto:pierre.gondois@arm.com>>
>> Cc: Girish Mahadevan <gmahadevan@nvidia.com <mailto:gmahadevan@nvidia.com>>
>> Cc: Jeff Brasen <jbrasen@nvidia.com <mailto:jbrasen@nvidia.com>>
>> Cc: Ashish Singhal <ashishsingha@nvidia.com <mailto:ashishsingha@nvidia.com>>
>> Cc: Nick Ramirez <nramirez@nvidia.com <mailto:nramirez@nvidia.com>>
>> Cc: William Watson <wwatson@nvidia.com <mailto:wwatson@nvidia.com>>
>> Cc: Abner Chang <abner.chang@amd.com <mailto:abner.chang@amd.com>>
>> Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com <mailto:Samer.El-Haj-Mahmoud@arm.com>>
>> Cc: Jose Marinho <Jose.Marinho@arm.com <mailto:Jose.Marinho@arm.com>>
>> ---
>>
>> Notes:
>> v2:
>> - Update dispatcher state machine to remove StUnknown. [SAMI]
>> - Move extern function to header file and move debug [ABNER]
>> code together.
>> - Updated code based on review feedback to move extern [SAMI]
>> function to header file and also moved the debug code
>> together.
>> Ref: https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk2.groups.io%2Fg%2Fdevel%2Fmessage%2F95341&data=05%7C01%7Cgmahadevan%40nvidia.com%7C57205f56a9f84d2470b408db208ade8b%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C638139553079754853%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Jab1Rf4UjvIJybcAXFAVXRZBxGaOQki%2BC1KxnPjaxGE%3D&reserved=0 <https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk2.groups.io%2Fg%2Fdevel%2Fmessage%2F95341&data=05%7C01%7Cgmahadevan%40nvidia.com%7C57205f56a9f84d2470b408db208ade8b%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C638139553079754853%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Jab1Rf4UjvIJybcAXFAVXRZBxGaOQki%2BC1KxnPjaxGE%3D&reserved=0>
>>
>> DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf | 4 +-
>> DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c | 282 ++++++++++++++++++++
>> DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.h | 159 +++++++++++
>> 3 files changed, 444 insertions(+), 1 deletion(-)
>>
>> diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf
>> index ad8b3d037c169ca848b5ea84fd1086b83f37876f..b09272d883c6f4f05eb03dcdab3efeda92b2fbb6 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
>> ##
>> @@ -22,6 +22,8 @@ [Defines]
>>
>> [Sources]
>> DynamicTableManagerDxe.c
>> + SmbiosTableDispatcher.c
>> + SmbiosTableDispatcher.h
>>
>> [Packages]
>> MdePkg/MdePkg.dec
>> diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c
>> new file mode 100644
>> index 0000000000000000000000000000000000000000..0e728538d9f6eb0b164fea3a160d3233db833f8d
>> --- /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);
> 
> 
> [GM]
> This ASSERT will be hit even if we have multiple SMBIOS CM objects of
> the same type which is legal (for e.g there are multiple tables for
> type17/19 )
> 
> [SAMI] The understanding is that SmbiosTableInfo[] will only contain one entry for a given TableType as it is used to indicate which generators are to be instantiated.
> 
> Following is the sequence of operations:
> - The dispatcher is initialised in InitSmbiosTableDispatcher(), which will set the mSmBiosDispatcher[<Table_Type>].State to StPresent if SmbiosTableInfo[] contains a table of Table_Type.
> - SmbiosTableInfo[] will only contain one entry for each table type, e.g. even if there are multiple Type17/Type19 tables to be installed. This entry indicates that table(s) of Type17/Type19 is/are requested to be installed and that the corresponding generator must be instantiated.
> - Once the SMBIOS table generator is instantiated, it will then request for the object(s) of the required type from the Configuration Manager that are required to construct the table.
> - The generator can then decide if multiple SMBIOS tables are to be constructed based on the objects returned by the Configuration Manager. e.g. if multiple Cm_Type17_objects are returned then the corresponding number of Type17 tables will be built by the generator.
> 
> Therefore, I think we should not hit the above assert.
> 

[GM]
That sounds right, I'd made a mistake when installing the CM objects.

I should be installing one of each SMBIOS table so that 
GetEStdObjSmbiosTableList gets the list of the available tables and each 
generator should install multiple tables of a given type based on the 
number of CM objects available.

I did expand the existing SMBIOS factory code to install multiple tables.

Thanks for the clarification.

Best Regards
Girish


> However, the code that may need to change/extend is the call to BuildAndInstallSmbiosTable(). I am not sure if we need to indicate that there could be multiple SMBIOS tables that may be installed. For now, BuildAndInstallSmbiosTable() implies that a generator of the specified type is to be instantiated for building the SMBIOS table of the specified type.
> 
> Hope this clarifies the scenario and please do let me know if I am missing something.
> 
> Also, I have only tested this patch with simulated data and there may be some issues that we may find when the full stack is integrated.
> So, thank you for going through the patch in detail.
> 
> [SAMI]
> 
> Best Regards
> Girish
> 
> 
>> + 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 0000000000000000000000000000000000000000..d59eab4223c142293bdaf4905588f08e7a4a467f
>> --- /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_
>> --
>> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
>>
> 
> 
> 

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

* Re: [PATCH v2 2/4] DynamicTablesPkg: Add SMBIOS table dispatcher
  2023-03-10 16:23       ` Girish Mahadevan
@ 2023-03-10 16:28         ` Sami Mujawar
  2023-07-21 23:14           ` [edk2-devel] " Girish Mahadevan via groups.io
  0 siblings, 1 reply; 13+ messages in thread
From: Sami Mujawar @ 2023-03-10 16:28 UTC (permalink / raw)
  To: Girish Mahadevan, devel@edk2.groups.io
  Cc: Alexei Fedorov, Pierre Gondois, abner.chang@amd.com,
	Jeff Brasen (jbrasen@nvidia.com), ashishsingha@nvidia.com,
	nramirez@nvidia.com, wwatson@nvidia.com, Matteo Carlini,
	Akanksha Jain, Ben Adderson, Samer El-Haj-Mahmoud, Jose Marinho,
	nd

Hi Girish,

On 10/03/2023 04:23 pm, Girish Mahadevan wrote:
> Hi Sami
>
> Response inline.[GM]
>
> Best Regards
> Girish
>
> On 3/9/2023 3:41 AM, Sami Mujawar wrote:
>> External email: Use caution opening links or attachments
>>
>>
>> Hi Girish,
>>
>> Thank you for your feedback.
>>
>> Please find my response inline marked [SAMI].
>>
>> Regards,
>>
>> Sami Mujawar
>>
>> On 08/03/2023, 17:41, "Girish Mahadevan" <gmahadevan@nvidia.com 
>> <mailto:gmahadevan@nvidia.com>> wrote:
>>
>>
>> Hi Sami
>>
>>
>> Thanks for v2, I will apply these to my tree and test it out.
>> One small comment before I review/test the patch train inline (prefixed
>> by [GM])
>>
>>
>> Best Regards
>> Girish
>>
>>
>> On 3/8/2023 1:16 AM, Sami Mujawar wrote:
>>> External email: Use caution opening links or attachments
>>>
>>>
>>> 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 
>>> <mailto:sami.mujawar@arm.com>>
>>> Cc: Alexei Fedorov <Alexei.Fedorov@arm.com 
>>> <mailto:Alexei.Fedorov@arm.com>>
>>> Cc: Pierre Gondois <pierre.gondois@arm.com 
>>> <mailto:pierre.gondois@arm.com>>
>>> Cc: Girish Mahadevan <gmahadevan@nvidia.com 
>>> <mailto:gmahadevan@nvidia.com>>
>>> Cc: Jeff Brasen <jbrasen@nvidia.com <mailto:jbrasen@nvidia.com>>
>>> Cc: Ashish Singhal <ashishsingha@nvidia.com 
>>> <mailto:ashishsingha@nvidia.com>>
>>> Cc: Nick Ramirez <nramirez@nvidia.com <mailto:nramirez@nvidia.com>>
>>> Cc: William Watson <wwatson@nvidia.com <mailto:wwatson@nvidia.com>>
>>> Cc: Abner Chang <abner.chang@amd.com <mailto:abner.chang@amd.com>>
>>> Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com 
>>> <mailto:Samer.El-Haj-Mahmoud@arm.com>>
>>> Cc: Jose Marinho <Jose.Marinho@arm.com <mailto:Jose.Marinho@arm.com>>
>>> ---
>>>
>>> Notes:
>>> v2:
>>> - Update dispatcher state machine to remove StUnknown. [SAMI]
>>> - Move extern function to header file and move debug [ABNER]
>>> code together.
>>> - Updated code based on review feedback to move extern [SAMI]
>>> function to header file and also moved the debug code
>>> together.
>>> Ref: 
>>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk2.groups.io%2Fg%2Fdevel%2Fmessage%2F95341&data=05%7C01%7Cgmahadevan%40nvidia.com%7C57205f56a9f84d2470b408db208ade8b%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C638139553079754853%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Jab1Rf4UjvIJybcAXFAVXRZBxGaOQki%2BC1KxnPjaxGE%3D&reserved=0 
>>> <https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk2.groups.io%2Fg%2Fdevel%2Fmessage%2F95341&data=05%7C01%7Cgmahadevan%40nvidia.com%7C57205f56a9f84d2470b408db208ade8b%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C638139553079754853%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Jab1Rf4UjvIJybcAXFAVXRZBxGaOQki%2BC1KxnPjaxGE%3D&reserved=0> 
>>>
>>>
>>> DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf 
>>> | 4 +-
>>> DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c 
>>> | 282 ++++++++++++++++++++
>>> DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.h 
>>> | 159 +++++++++++
>>> 3 files changed, 444 insertions(+), 1 deletion(-)
>>>
>>> diff --git 
>>> a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf 
>>> b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf 
>>>
>>> index 
>>> ad8b3d037c169ca848b5ea84fd1086b83f37876f..b09272d883c6f4f05eb03dcdab3efeda92b2fbb6 
>>> 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
>>> ##
>>> @@ -22,6 +22,8 @@ [Defines]
>>>
>>> [Sources]
>>> DynamicTableManagerDxe.c
>>> + SmbiosTableDispatcher.c
>>> + SmbiosTableDispatcher.h
>>>
>>> [Packages]
>>> MdePkg/MdePkg.dec
>>> diff --git 
>>> a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c 
>>> b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c 
>>>
>>> new file mode 100644
>>> index 
>>> 0000000000000000000000000000000000000000..0e728538d9f6eb0b164fea3a160d3233db833f8d
>>> --- /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);
>>
>>
>> [GM]
>> This ASSERT will be hit even if we have multiple SMBIOS CM objects of
>> the same type which is legal (for e.g there are multiple tables for
>> type17/19 )
>>
>> [SAMI] The understanding is that SmbiosTableInfo[] will only contain 
>> one entry for a given TableType as it is used to indicate which 
>> generators are to be instantiated.
>>
>> Following is the sequence of operations:
>> - The dispatcher is initialised in InitSmbiosTableDispatcher(), which 
>> will set the mSmBiosDispatcher[<Table_Type>].State to StPresent if 
>> SmbiosTableInfo[] contains a table of Table_Type.
>> - SmbiosTableInfo[] will only contain one entry for each table type, 
>> e.g. even if there are multiple Type17/Type19 tables to be installed. 
>> This entry indicates that table(s) of Type17/Type19 is/are requested 
>> to be installed and that the corresponding generator must be 
>> instantiated.
>> - Once the SMBIOS table generator is instantiated, it will then 
>> request for the object(s) of the required type from the Configuration 
>> Manager that are required to construct the table.
>> - The generator can then decide if multiple SMBIOS tables are to be 
>> constructed based on the objects returned by the Configuration 
>> Manager. e.g. if multiple Cm_Type17_objects are returned then the 
>> corresponding number of Type17 tables will be built by the generator.
>>
>> Therefore, I think we should not hit the above assert.
>>
>
> [GM]
> That sounds right, I'd made a mistake when installing the CM objects.
>
> I should be installing one of each SMBIOS table so that 
> GetEStdObjSmbiosTableList gets the list of the available tables and 
> each generator should install multiple tables of a given type based on 
> the number of CM objects available.
>
> I did expand the existing SMBIOS factory code to install multiple tables.
>
> Thanks for the clarification.
>
> Best Regards
> Girish
>
[SAMI] No worries. Please let me know if you face any issues with the 
dispatcher or if you identify any problem during integration.

Regards,

Sami Mujawar

>
>> However, the code that may need to change/extend is the call to 
>> BuildAndInstallSmbiosTable(). I am not sure if we need to indicate 
>> that there could be multiple SMBIOS tables that may be installed. For 
>> now, BuildAndInstallSmbiosTable() implies that a generator of the 
>> specified type is to be instantiated for building the SMBIOS table of 
>> the specified type.
>>
>> Hope this clarifies the scenario and please do let me know if I am 
>> missing something.
>>
>> Also, I have only tested this patch with simulated data and there may 
>> be some issues that we may find when the full stack is integrated.
>> So, thank you for going through the patch in detail.
>>
>> [SAMI]
>>
>> Best Regards
>> Girish
>>
>>
>>> + 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 
>>> 0000000000000000000000000000000000000000..d59eab4223c142293bdaf4905588f08e7a4a467f
>>> --- /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_
>>> -- 
>>> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
>>>
>>
>>
>>

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

* Re: [edk2-devel] [PATCH v2 2/4] DynamicTablesPkg: Add SMBIOS table dispatcher
  2023-03-10 16:28         ` Sami Mujawar
@ 2023-07-21 23:14           ` Girish Mahadevan via groups.io
  2023-07-24 17:48             ` Sami Mujawar
  0 siblings, 1 reply; 13+ messages in thread
From: Girish Mahadevan via groups.io @ 2023-07-21 23:14 UTC (permalink / raw)
  To: Sami Mujawar, devel@edk2.groups.io
  Cc: Alexei Fedorov, Pierre Gondois, abner.chang@amd.com,
	Jeff Brasen (jbrasen@nvidia.com), ashishsingha@nvidia.com,
	nramirez@nvidia.com, wwatson@nvidia.com, Matteo Carlini,
	Akanksha Jain, Ben Adderson, Samer El-Haj-Mahmoud, Jose Marinho,
	nd

Hi Sami

Your patches worked. There was just one thing I had to add to get 
compile to work. (inline with [GM]), other than that I think you can get 
this in.

We've implemented about 18 table generators. (Types  0, 1, 2, 3, 8, 9, 
11, 13, 14, 16, 17, 19, 32, 38, 39, 41, 43, 45)
Two more are under way (Type 4.7).

I've setup a github repo here
https://github.com/tianocore/edk2/compare/master...gmahadevan:edk2-upstream:RFC/smbios-dyntables-v2?expand=1

I could send you one massive patch train (22 patches or so) or split it 
up into smaller chunks perhaps just the table generation stuff first and 
then each generator library.

Let me know.

Best Regards
Girish


On 3/10/2023 9:28 AM, Sami Mujawar wrote:
> External email: Use caution opening links or attachments
> 
> 
> Hi Girish,
> 
> On 10/03/2023 04:23 pm, Girish Mahadevan wrote:
>> Hi Sami
>>
>> Response inline.[GM]
>>
>> Best Regards
>> Girish
>>
>> On 3/9/2023 3:41 AM, Sami Mujawar wrote:
>>> External email: Use caution opening links or attachments
>>>
>>>
>>> Hi Girish,
>>>
>>> Thank you for your feedback.
>>>
>>> Please find my response inline marked [SAMI].
>>>
>>> Regards,
>>>
>>> Sami Mujawar
>>>
>>> On 08/03/2023, 17:41, "Girish Mahadevan" <gmahadevan@nvidia.com
>>> <mailto:gmahadevan@nvidia.com>> wrote:
>>>
>>>
>>> Hi Sami
>>>
>>>
>>> Thanks for v2, I will apply these to my tree and test it out.
>>> One small comment before I review/test the patch train inline (prefixed
>>> by [GM])
>>>
>>>
>>> Best Regards
>>> Girish
>>>
>>>
>>> On 3/8/2023 1:16 AM, Sami Mujawar wrote:
>>>> External email: Use caution opening links or attachments
>>>>
>>>>
>>>> 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
>>>> <mailto:sami.mujawar@arm.com>>
>>>> Cc: Alexei Fedorov <Alexei.Fedorov@arm.com
>>>> <mailto:Alexei.Fedorov@arm.com>>
>>>> Cc: Pierre Gondois <pierre.gondois@arm.com
>>>> <mailto:pierre.gondois@arm.com>>
>>>> Cc: Girish Mahadevan <gmahadevan@nvidia.com
>>>> <mailto:gmahadevan@nvidia.com>>
>>>> Cc: Jeff Brasen <jbrasen@nvidia.com <mailto:jbrasen@nvidia.com>>
>>>> Cc: Ashish Singhal <ashishsingha@nvidia.com
>>>> <mailto:ashishsingha@nvidia.com>>
>>>> Cc: Nick Ramirez <nramirez@nvidia.com <mailto:nramirez@nvidia.com>>
>>>> Cc: William Watson <wwatson@nvidia.com <mailto:wwatson@nvidia.com>>
>>>> Cc: Abner Chang <abner.chang@amd.com <mailto:abner.chang@amd.com>>
>>>> Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com
>>>> <mailto:Samer.El-Haj-Mahmoud@arm.com>>
>>>> Cc: Jose Marinho <Jose.Marinho@arm.com <mailto:Jose.Marinho@arm.com>>
>>>> ---
>>>>
>>>> Notes:
>>>> v2:
>>>> - Update dispatcher state machine to remove StUnknown. [SAMI]
>>>> - Move extern function to header file and move debug [ABNER]
>>>> code together.
>>>> - Updated code based on review feedback to move extern [SAMI]
>>>> function to header file and also moved the debug code
>>>> together.
>>>> Ref:
>>>> https://edk2.groups.io/g/devel/message/95341
>>>> <https://edk2.groups.io/g/devel/message/95341>
>>>>
>>>>
>>>> DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf
>>>> | 4 +-
>>>> DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c
>>>> | 282 ++++++++++++++++++++
>>>> DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.h
>>>> | 159 +++++++++++
>>>> 3 files changed, 444 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git
>>>> a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf
>>>> b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf
>>>>
>>>> index
>>>> ad8b3d037c169ca848b5ea84fd1086b83f37876f..b09272d883c6f4f05eb03dcdab3efeda92b2fbb6
>>>> 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
>>>> ##
>>>> @@ -22,6 +22,8 @@ [Defines]
>>>>
>>>> [Sources]
>>>> DynamicTableManagerDxe.c
>>>> + SmbiosTableDispatcher.c
>>>> + SmbiosTableDispatcher.h
>>>>
>>>> [Packages]
>>>> MdePkg/MdePkg.dec
>>>> diff --git
>>>> a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c
>>>> b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c
>>>>
>>>> new file mode 100644
>>>> index
>>>> 0000000000000000000000000000000000000000..0e728538d9f6eb0b164fea3a160d3233db833f8d
>>>> --- /dev/null
>>>> +++
>>>> b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c
>>>> @@ -0,0 +1,282 @@
>>>> +/** @file
>>>> + Dynamic Smbios Table Dispatcher
>>>> +
[GM]
Not sure if it was an oversight, but you missed adding the extern to 
BuildAndInstallSmbiosTable

>>>> + 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),
[GM]:
We've made changes to this and to the Firmware inventory


>>>> + 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);
>>>
>>>
>>> [GM]
>>> This ASSERT will be hit even if we have multiple SMBIOS CM objects of
>>> the same type which is legal (for e.g there are multiple tables for
>>> type17/19 )
>>>
>>> [SAMI] The understanding is that SmbiosTableInfo[] will only contain
>>> one entry for a given TableType as it is used to indicate which
>>> generators are to be instantiated.
>>>
>>> Following is the sequence of operations:
>>> - The dispatcher is initialised in InitSmbiosTableDispatcher(), which
>>> will set the mSmBiosDispatcher[<Table_Type>].State to StPresent if
>>> SmbiosTableInfo[] contains a table of Table_Type.
>>> - SmbiosTableInfo[] will only contain one entry for each table type,
>>> e.g. even if there are multiple Type17/Type19 tables to be installed.
>>> This entry indicates that table(s) of Type17/Type19 is/are requested
>>> to be installed and that the corresponding generator must be
>>> instantiated.
>>> - Once the SMBIOS table generator is instantiated, it will then
>>> request for the object(s) of the required type from the Configuration
>>> Manager that are required to construct the table.
>>> - The generator can then decide if multiple SMBIOS tables are to be
>>> constructed based on the objects returned by the Configuration
>>> Manager. e.g. if multiple Cm_Type17_objects are returned then the
>>> corresponding number of Type17 tables will be built by the generator.
>>>
>>> Therefore, I think we should not hit the above assert.
>>>
>>
>> [GM]
>> That sounds right, I'd made a mistake when installing the CM objects.
>>
>> I should be installing one of each SMBIOS table so that
>> GetEStdObjSmbiosTableList gets the list of the available tables and
>> each generator should install multiple tables of a given type based on
>> the number of CM objects available.
>>
>> I did expand the existing SMBIOS factory code to install multiple tables.
>>
>> Thanks for the clarification.
>>
>> Best Regards
>> Girish
>>
> [SAMI] No worries. Please let me know if you face any issues with the
> dispatcher or if you identify any problem during integration.
> 
> Regards,
> 
> Sami Mujawar
> 
>>
>>> However, the code that may need to change/extend is the call to
>>> BuildAndInstallSmbiosTable(). I am not sure if we need to indicate
>>> that there could be multiple SMBIOS tables that may be installed. For
>>> now, BuildAndInstallSmbiosTable() implies that a generator of the
>>> specified type is to be instantiated for building the SMBIOS table of
>>> the specified type.
>>>
>>> Hope this clarifies the scenario and please do let me know if I am
>>> missing something.
>>>
>>> Also, I have only tested this patch with simulated data and there may
>>> be some issues that we may find when the full stack is integrated.
>>> So, thank you for going through the patch in detail.
>>>
>>> [SAMI]
>>>
>>> Best Regards
>>> Girish
>>>
>>>
>>>> + 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
>>>> 0000000000000000000000000000000000000000..d59eab4223c142293bdaf4905588f08e7a4a467f
>>>> --- /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_
>>>> -- 
>>>> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
>>>>
>>>
>>>
>>>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107135): https://edk2.groups.io/g/devel/message/107135
Mute This Topic: https://groups.io/mt/97468481/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

* Re: [edk2-devel] [PATCH v2 2/4] DynamicTablesPkg: Add SMBIOS table dispatcher
  2023-07-21 23:14           ` [edk2-devel] " Girish Mahadevan via groups.io
@ 2023-07-24 17:48             ` Sami Mujawar
  2023-07-25 23:29               ` Girish Mahadevan via groups.io
       [not found]               ` <1775402AB0EAA56A.16579@groups.io>
  0 siblings, 2 replies; 13+ messages in thread
From: Sami Mujawar @ 2023-07-24 17:48 UTC (permalink / raw)
  To: Girish Mahadevan, devel@edk2.groups.io
  Cc: Alexei Fedorov, Pierre Gondois, abner.chang@amd.com,
	Jeff Brasen (jbrasen@nvidia.com), ashishsingha@nvidia.com,
	nramirez@nvidia.com, wwatson@nvidia.com, Matteo Carlini,
	Akanksha Jain, Sibel.Allinson, Samer El-Haj-Mahmoud, Jose Marinho,
	nd

Hi Girish,

Thank you for taking this effort forward

Please find my response inline marked [SAMI].

Regards,

Sami Mujawar

On 22/07/2023 12:14 am, Girish Mahadevan wrote:
> Hi Sami
>
> Your patches worked. There was just one thing I had to add to get 
> compile to work. (inline with [GM]), other than that I think you can 
> get this in.
[SAMI] Thanks for testing these patches.
>
> We've implemented about 18 table generators. (Types  0, 1, 2, 3, 8, 9, 
> 11, 13, 14, 16, 17, 19, 32, 38, 39, 41, 43, 45)
> Two more are under way (Type 4.7).
[SAMI] I would be keen to understand how the Type 4 and 7 generators 
would work as I would prefer to avoid duplication of data.
>
> I've setup a github repo here
> https://github.com/tianocore/edk2/compare/master...gmahadevan:edk2-upstream:RFC/smbios-dyntables-v2?expand=1 
>
[SAMI] Thanks for sharing the github branch. Please also share a github 
branch when you send out your patches for review.
>
> I could send you one massive patch train (22 patches or so) or split 
> it up into smaller chunks perhaps just the table generation stuff 
> first and then each generator library.
>
[SAMI] I think it may be good to split the patch series to include table 
generation and then 1 or 2 generators to understand the code flow. The 
remaining generators can follow later. I think Type 4 and 7 would be 
really interesting, but you can send what you already have.

> Let me know.
>
> Best Regards
> Girish
>
>
> On 3/10/2023 9:28 AM, Sami Mujawar wrote:
>> External email: Use caution opening links or attachments
>>
>>
>> Hi Girish,
>>
>> On 10/03/2023 04:23 pm, Girish Mahadevan wrote:
>>> Hi Sami
>>>
>>> Response inline.[GM]
>>>
>>> Best Regards
>>> Girish
>>>
>>> On 3/9/2023 3:41 AM, Sami Mujawar wrote:
>>>> External email: Use caution opening links or attachments
>>>>
>>>>
>>>> Hi Girish,
>>>>
>>>> Thank you for your feedback.
>>>>
>>>> Please find my response inline marked [SAMI].
>>>>
>>>> Regards,
>>>>
>>>> Sami Mujawar
>>>>
>>>> On 08/03/2023, 17:41, "Girish Mahadevan" <gmahadevan@nvidia.com
>>>> <mailto:gmahadevan@nvidia.com>> wrote:
>>>>
>>>>
>>>> Hi Sami
>>>>
>>>>
>>>> Thanks for v2, I will apply these to my tree and test it out.
>>>> One small comment before I review/test the patch train inline 
>>>> (prefixed
>>>> by [GM])
>>>>
>>>>
>>>> Best Regards
>>>> Girish
>>>>
>>>>
>>>> On 3/8/2023 1:16 AM, Sami Mujawar wrote:
>>>>> External email: Use caution opening links or attachments
>>>>>
>>>>>
>>>>> 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
>>>>> <mailto:sami.mujawar@arm.com>>
>>>>> Cc: Alexei Fedorov <Alexei.Fedorov@arm.com
>>>>> <mailto:Alexei.Fedorov@arm.com>>
>>>>> Cc: Pierre Gondois <pierre.gondois@arm.com
>>>>> <mailto:pierre.gondois@arm.com>>
>>>>> Cc: Girish Mahadevan <gmahadevan@nvidia.com
>>>>> <mailto:gmahadevan@nvidia.com>>
>>>>> Cc: Jeff Brasen <jbrasen@nvidia.com <mailto:jbrasen@nvidia.com>>
>>>>> Cc: Ashish Singhal <ashishsingha@nvidia.com
>>>>> <mailto:ashishsingha@nvidia.com>>
>>>>> Cc: Nick Ramirez <nramirez@nvidia.com <mailto:nramirez@nvidia.com>>
>>>>> Cc: William Watson <wwatson@nvidia.com <mailto:wwatson@nvidia.com>>
>>>>> Cc: Abner Chang <abner.chang@amd.com <mailto:abner.chang@amd.com>>
>>>>> Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com
>>>>> <mailto:Samer.El-Haj-Mahmoud@arm.com>>
>>>>> Cc: Jose Marinho <Jose.Marinho@arm.com <mailto:Jose.Marinho@arm.com>>
>>>>> ---
>>>>>
>>>>> Notes:
>>>>> v2:
>>>>> - Update dispatcher state machine to remove StUnknown. [SAMI]
>>>>> - Move extern function to header file and move debug [ABNER]
>>>>> code together.
>>>>> - Updated code based on review feedback to move extern [SAMI]
>>>>> function to header file and also moved the debug code
>>>>> together.
>>>>> Ref:
>>>>> https://edk2.groups.io/g/devel/message/95341
>>>>> <https://edk2.groups.io/g/devel/message/95341>
>>>>>
>>>>>
>>>>> DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf 
>>>>>
>>>>> | 4 +-
>>>>> DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c 
>>>>>
>>>>> | 282 ++++++++++++++++++++
>>>>> DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.h 
>>>>>
>>>>> | 159 +++++++++++
>>>>> 3 files changed, 444 insertions(+), 1 deletion(-)
>>>>>
>>>>> diff --git
>>>>> a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf 
>>>>>
>>>>> b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf 
>>>>>
>>>>>
>>>>> index
>>>>> ad8b3d037c169ca848b5ea84fd1086b83f37876f..b09272d883c6f4f05eb03dcdab3efeda92b2fbb6 
>>>>>
>>>>> 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
>>>>> ##
>>>>> @@ -22,6 +22,8 @@ [Defines]
>>>>>
>>>>> [Sources]
>>>>> DynamicTableManagerDxe.c
>>>>> + SmbiosTableDispatcher.c
>>>>> + SmbiosTableDispatcher.h
>>>>>
>>>>> [Packages]
>>>>> MdePkg/MdePkg.dec
>>>>> diff --git
>>>>> a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c 
>>>>>
>>>>> b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c 
>>>>>
>>>>>
>>>>> new file mode 100644
>>>>> index
>>>>> 0000000000000000000000000000000000000000..0e728538d9f6eb0b164fea3a160d3233db833f8d 
>>>>>
>>>>> --- /dev/null
>>>>> +++
>>>>> b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c 
>>>>>
>>>>> @@ -0,0 +1,282 @@
>>>>> +/** @file
>>>>> + Dynamic Smbios Table Dispatcher
>>>>> +
> [GM]
> Not sure if it was an oversight, but you missed adding the extern to 
> BuildAndInstallSmbiosTable
[SAMI] Yes, you are correct. I had tested my changes only using 
simulation so may have removed the stub function when posting the patches.
>
>>>>> + 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),
> [GM]:
> We've made changes to this and to the Firmware inventory
[SAMI] Did I get something wrong or missed something here? Can you let 
me know, please?
>
>
>>>>> + 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);
>>>>
>>>>
>>>> [GM]
>>>> This ASSERT will be hit even if we have multiple SMBIOS CM objects of
>>>> the same type which is legal (for e.g there are multiple tables for
>>>> type17/19 )
>>>>
>>>> [SAMI] The understanding is that SmbiosTableInfo[] will only contain
>>>> one entry for a given TableType as it is used to indicate which
>>>> generators are to be instantiated.
>>>>
>>>> Following is the sequence of operations:
>>>> - The dispatcher is initialised in InitSmbiosTableDispatcher(), which
>>>> will set the mSmBiosDispatcher[<Table_Type>].State to StPresent if
>>>> SmbiosTableInfo[] contains a table of Table_Type.
>>>> - SmbiosTableInfo[] will only contain one entry for each table type,
>>>> e.g. even if there are multiple Type17/Type19 tables to be installed.
>>>> This entry indicates that table(s) of Type17/Type19 is/are requested
>>>> to be installed and that the corresponding generator must be
>>>> instantiated.
>>>> - Once the SMBIOS table generator is instantiated, it will then
>>>> request for the object(s) of the required type from the Configuration
>>>> Manager that are required to construct the table.
>>>> - The generator can then decide if multiple SMBIOS tables are to be
>>>> constructed based on the objects returned by the Configuration
>>>> Manager. e.g. if multiple Cm_Type17_objects are returned then the
>>>> corresponding number of Type17 tables will be built by the generator.
>>>>
>>>> Therefore, I think we should not hit the above assert.
>>>>
>>>
>>> [GM]
>>> That sounds right, I'd made a mistake when installing the CM objects.
>>>
>>> I should be installing one of each SMBIOS table so that
>>> GetEStdObjSmbiosTableList gets the list of the available tables and
>>> each generator should install multiple tables of a given type based on
>>> the number of CM objects available.
>>>
>>> I did expand the existing SMBIOS factory code to install multiple 
>>> tables.
>>>
>>> Thanks for the clarification.
>>>
>>> Best Regards
>>> Girish
>>>
>> [SAMI] No worries. Please let me know if you face any issues with the
>> dispatcher or if you identify any problem during integration.
>>
>> Regards,
>>
>> Sami Mujawar
>>
>>>
>>>> However, the code that may need to change/extend is the call to
>>>> BuildAndInstallSmbiosTable(). I am not sure if we need to indicate
>>>> that there could be multiple SMBIOS tables that may be installed. For
>>>> now, BuildAndInstallSmbiosTable() implies that a generator of the
>>>> specified type is to be instantiated for building the SMBIOS table of
>>>> the specified type.
>>>>
>>>> Hope this clarifies the scenario and please do let me know if I am
>>>> missing something.
>>>>
>>>> Also, I have only tested this patch with simulated data and there may
>>>> be some issues that we may find when the full stack is integrated.
>>>> So, thank you for going through the patch in detail.
>>>>
>>>> [SAMI]
>>>>
>>>> Best Regards
>>>> Girish
>>>>
>>>>
>>>>> + 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
>>>>> 0000000000000000000000000000000000000000..d59eab4223c142293bdaf4905588f08e7a4a467f 
>>>>>
>>>>> --- /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_
>>>>> -- 
>>>>> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
>>>>>
>>>>
>>>>
>>>>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107186): https://edk2.groups.io/g/devel/message/107186
Mute This Topic: https://groups.io/mt/97468481/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

* Re: [edk2-devel] [PATCH v2 2/4] DynamicTablesPkg: Add SMBIOS table dispatcher
  2023-07-24 17:48             ` Sami Mujawar
@ 2023-07-25 23:29               ` Girish Mahadevan via groups.io
       [not found]               ` <1775402AB0EAA56A.16579@groups.io>
  1 sibling, 0 replies; 13+ messages in thread
From: Girish Mahadevan via groups.io @ 2023-07-25 23:29 UTC (permalink / raw)
  To: Sami Mujawar, devel@edk2.groups.io
  Cc: Alexei Fedorov, Pierre Gondois, abner.chang@amd.com,
	Jeff Brasen (jbrasen@nvidia.com), ashishsingha@nvidia.com,
	nramirez@nvidia.com, wwatson@nvidia.com, Matteo Carlini,
	Akanksha Jain, Sibel.Allinson, Samer El-Haj-Mahmoud, Jose Marinho,
	nd

Hi Sami

My responses inline [GM]

Best Regards
Girish

On 7/24/2023 11:48 AM, Sami Mujawar wrote:
> External email: Use caution opening links or attachments
> 
> 
> Hi Girish,
> 
> Thank you for taking this effort forward
> 
> Please find my response inline marked [SAMI].
> 
> Regards,
> 
> Sami Mujawar
> 
> On 22/07/2023 12:14 am, Girish Mahadevan wrote:
>> Hi Sami
>>
>> Your patches worked. There was just one thing I had to add to get
>> compile to work. (inline with [GM]), other than that I think you can
>> get this in.
> [SAMI] Thanks for testing these patches.
>>
>> We've implemented about 18 table generators. (Types  0, 1, 2, 3, 8, 9,
>> 11, 13, 14, 16, 17, 19, 32, 38, 39, 41, 43, 45)
>> Two more are under way (Type 4.7).
> [SAMI] I would be keen to understand how the Type 4 and 7 generators
> would work as I would prefer to avoid duplication of data.
>>

[GM]
As a first pass we're setting up the generators to just blindly use 
SMBIOS specific CM objects to setup these tables.

Second pass could be to have the generators try to rely on ACPI objects 
(PPTT) or fallback to Architecture specific libraries to figure out how 
to populate these tables. Honestly we need to think about this a little 
more, we'd love to swap notes.
(We are in the prelim stages of these so haven't gotten very far)


>> I've setup a github repo here
>> https://github.com/tianocore/edk2/compare/master...gmahadevan:edk2-upstream:RFC/smbios-dyntables-v2?expand=1
>>
> [SAMI] Thanks for sharing the github branch. Please also share a github
> branch when you send out your patches for review.
>>

[GM]
Will do.

>> I could send you one massive patch train (22 patches or so) or split
>> it up into smaller chunks perhaps just the table generation stuff
>> first and then each generator library.
>>
> [SAMI] I think it may be good to split the patch series to include table
> generation and then 1 or 2 generators to understand the code flow. The
> remaining generators can follow later. I think Type 4 and 7 would be
> really interesting, but you can send what you already have.
> 
[GM]
ok, I will send out a patch train for the core generator code and 2 of 
the Generators.

Best Regards
Girish

>> Let me know.
>>
>> Best Regards
>> Girish
>>
>>
>> On 3/10/2023 9:28 AM, Sami Mujawar wrote:
>>> External email: Use caution opening links or attachments
>>>
>>>
>>> Hi Girish,
>>>
>>> On 10/03/2023 04:23 pm, Girish Mahadevan wrote:
>>>> Hi Sami
>>>>
>>>> Response inline.[GM]
>>>>
>>>> Best Regards
>>>> Girish
>>>>
>>>> On 3/9/2023 3:41 AM, Sami Mujawar wrote:
>>>>> External email: Use caution opening links or attachments
>>>>>
>>>>>
>>>>> Hi Girish,
>>>>>
>>>>> Thank you for your feedback.
>>>>>
>>>>> Please find my response inline marked [SAMI].
>>>>>
>>>>> Regards,
>>>>>
>>>>> Sami Mujawar
>>>>>
>>>>> On 08/03/2023, 17:41, "Girish Mahadevan" <gmahadevan@nvidia.com
>>>>> <mailto:gmahadevan@nvidia.com>> wrote:
>>>>>
>>>>>
>>>>> Hi Sami
>>>>>
>>>>>
>>>>> Thanks for v2, I will apply these to my tree and test it out.
>>>>> One small comment before I review/test the patch train inline
>>>>> (prefixed
>>>>> by [GM])
>>>>>
>>>>>
>>>>> Best Regards
>>>>> Girish
>>>>>
>>>>>
>>>>> On 3/8/2023 1:16 AM, Sami Mujawar wrote:
>>>>>> External email: Use caution opening links or attachments
>>>>>>
>>>>>>
>>>>>> 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
>>>>>> <mailto:sami.mujawar@arm.com>>
>>>>>> Cc: Alexei Fedorov <Alexei.Fedorov@arm.com
>>>>>> <mailto:Alexei.Fedorov@arm.com>>
>>>>>> Cc: Pierre Gondois <pierre.gondois@arm.com
>>>>>> <mailto:pierre.gondois@arm.com>>
>>>>>> Cc: Girish Mahadevan <gmahadevan@nvidia.com
>>>>>> <mailto:gmahadevan@nvidia.com>>
>>>>>> Cc: Jeff Brasen <jbrasen@nvidia.com <mailto:jbrasen@nvidia.com>>
>>>>>> Cc: Ashish Singhal <ashishsingha@nvidia.com
>>>>>> <mailto:ashishsingha@nvidia.com>>
>>>>>> Cc: Nick Ramirez <nramirez@nvidia.com <mailto:nramirez@nvidia.com>>
>>>>>> Cc: William Watson <wwatson@nvidia.com <mailto:wwatson@nvidia.com>>
>>>>>> Cc: Abner Chang <abner.chang@amd.com <mailto:abner.chang@amd.com>>
>>>>>> Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com
>>>>>> <mailto:Samer.El-Haj-Mahmoud@arm.com>>
>>>>>> Cc: Jose Marinho <Jose.Marinho@arm.com <mailto:Jose.Marinho@arm.com>>
>>>>>> ---
>>>>>>
>>>>>> Notes:
>>>>>> v2:
>>>>>> - Update dispatcher state machine to remove StUnknown. [SAMI]
>>>>>> - Move extern function to header file and move debug [ABNER]
>>>>>> code together.
>>>>>> - Updated code based on review feedback to move extern [SAMI]
>>>>>> function to header file and also moved the debug code
>>>>>> together.
>>>>>> Ref:
>>>>>> https://edk2.groups.io/g/devel/message/95341
>>>>>> <https://edk2.groups.io/g/devel/message/95341>
>>>>>>
>>>>>>
>>>>>> DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf
>>>>>>
>>>>>> | 4 +-
>>>>>> DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c
>>>>>>
>>>>>> | 282 ++++++++++++++++++++
>>>>>> DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.h
>>>>>>
>>>>>> | 159 +++++++++++
>>>>>> 3 files changed, 444 insertions(+), 1 deletion(-)
>>>>>>
>>>>>> diff --git
>>>>>> a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf
>>>>>>
>>>>>> b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf
>>>>>>
>>>>>>
>>>>>> index
>>>>>> ad8b3d037c169ca848b5ea84fd1086b83f37876f..b09272d883c6f4f05eb03dcdab3efeda92b2fbb6
>>>>>>
>>>>>> 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
>>>>>> ##
>>>>>> @@ -22,6 +22,8 @@ [Defines]
>>>>>>
>>>>>> [Sources]
>>>>>> DynamicTableManagerDxe.c
>>>>>> + SmbiosTableDispatcher.c
>>>>>> + SmbiosTableDispatcher.h
>>>>>>
>>>>>> [Packages]
>>>>>> MdePkg/MdePkg.dec
>>>>>> diff --git
>>>>>> a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c
>>>>>>
>>>>>> b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c
>>>>>>
>>>>>>
>>>>>> new file mode 100644
>>>>>> index
>>>>>> 0000000000000000000000000000000000000000..0e728538d9f6eb0b164fea3a160d3233db833f8d
>>>>>>
>>>>>> --- /dev/null
>>>>>> +++
>>>>>> b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c
>>>>>>
>>>>>> @@ -0,0 +1,282 @@
>>>>>> +/** @file
>>>>>> + Dynamic Smbios Table Dispatcher
>>>>>> +
>> [GM]
>> Not sure if it was an oversight, but you missed adding the extern to
>> BuildAndInstallSmbiosTable
> [SAMI] Yes, you are correct. I had tested my changes only using
> simulation so may have removed the stub function when posting the patches.
>>
>>>>>> + 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),
>> [GM]:
>> We've made changes to this and to the Firmware inventory
> [SAMI] Did I get something wrong or missed something here? Can you let
> me know, please?
>>
>>
>>>>>> + 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);
>>>>>
>>>>>
>>>>> [GM]
>>>>> This ASSERT will be hit even if we have multiple SMBIOS CM objects of
>>>>> the same type which is legal (for e.g there are multiple tables for
>>>>> type17/19 )
>>>>>
>>>>> [SAMI] The understanding is that SmbiosTableInfo[] will only contain
>>>>> one entry for a given TableType as it is used to indicate which
>>>>> generators are to be instantiated.
>>>>>
>>>>> Following is the sequence of operations:
>>>>> - The dispatcher is initialised in InitSmbiosTableDispatcher(), which
>>>>> will set the mSmBiosDispatcher[<Table_Type>].State to StPresent if
>>>>> SmbiosTableInfo[] contains a table of Table_Type.
>>>>> - SmbiosTableInfo[] will only contain one entry for each table type,
>>>>> e.g. even if there are multiple Type17/Type19 tables to be installed.
>>>>> This entry indicates that table(s) of Type17/Type19 is/are requested
>>>>> to be installed and that the corresponding generator must be
>>>>> instantiated.
>>>>> - Once the SMBIOS table generator is instantiated, it will then
>>>>> request for the object(s) of the required type from the Configuration
>>>>> Manager that are required to construct the table.
>>>>> - The generator can then decide if multiple SMBIOS tables are to be
>>>>> constructed based on the objects returned by the Configuration
>>>>> Manager. e.g. if multiple Cm_Type17_objects are returned then the
>>>>> corresponding number of Type17 tables will be built by the generator.
>>>>>
>>>>> Therefore, I think we should not hit the above assert.
>>>>>
>>>>
>>>> [GM]
>>>> That sounds right, I'd made a mistake when installing the CM objects.
>>>>
>>>> I should be installing one of each SMBIOS table so that
>>>> GetEStdObjSmbiosTableList gets the list of the available tables and
>>>> each generator should install multiple tables of a given type based on
>>>> the number of CM objects available.
>>>>
>>>> I did expand the existing SMBIOS factory code to install multiple
>>>> tables.
>>>>
>>>> Thanks for the clarification.
>>>>
>>>> Best Regards
>>>> Girish
>>>>
>>> [SAMI] No worries. Please let me know if you face any issues with the
>>> dispatcher or if you identify any problem during integration.
>>>
>>> Regards,
>>>
>>> Sami Mujawar
>>>
>>>>
>>>>> However, the code that may need to change/extend is the call to
>>>>> BuildAndInstallSmbiosTable(). I am not sure if we need to indicate
>>>>> that there could be multiple SMBIOS tables that may be installed. For
>>>>> now, BuildAndInstallSmbiosTable() implies that a generator of the
>>>>> specified type is to be instantiated for building the SMBIOS table of
>>>>> the specified type.
>>>>>
>>>>> Hope this clarifies the scenario and please do let me know if I am
>>>>> missing something.
>>>>>
>>>>> Also, I have only tested this patch with simulated data and there may
>>>>> be some issues that we may find when the full stack is integrated.
>>>>> So, thank you for going through the patch in detail.
>>>>>
>>>>> [SAMI]
>>>>>
>>>>> Best Regards
>>>>> Girish
>>>>>
>>>>>
>>>>>> + 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
>>>>>> 0000000000000000000000000000000000000000..d59eab4223c142293bdaf4905588f08e7a4a467f
>>>>>>
>>>>>> --- /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_
>>>>>> -- 
>>>>>> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
>>>>>>
>>>>>
>>>>>
>>>>>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107253): https://edk2.groups.io/g/devel/message/107253
Mute This Topic: https://groups.io/mt/97468481/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

* Re: [edk2-devel] [PATCH v2 2/4] DynamicTablesPkg: Add SMBIOS table dispatcher
       [not found]               ` <1775402AB0EAA56A.16579@groups.io>
@ 2023-08-09 16:13                 ` Girish Mahadevan via groups.io
  0 siblings, 0 replies; 13+ messages in thread
From: Girish Mahadevan via groups.io @ 2023-08-09 16:13 UTC (permalink / raw)
  To: devel, Sami Mujawar
  Cc: Alexei Fedorov, Pierre Gondois, abner.chang@amd.com,
	Jeff Brasen (jbrasen@nvidia.com), ashishsingha@nvidia.com,
	nramirez@nvidia.com, wwatson@nvidia.com, Matteo Carlini,
	Akanksha Jain, Sibel.Allinson, Samer El-Haj-Mahmoud, Jose Marinho,
	nd

Hi Sami,

Any chance we can try to get your dispatcher patches in for the upcoming 
release.(if there are no other comments).

Best Regards
Girish

On 7/25/2023 5:29 PM, Girish Mahadevan via groups.io wrote:
> External email: Use caution opening links or attachments
> 
> 
> Hi Sami
> 
> My responses inline [GM]
> 
> Best Regards
> Girish
> 
> On 7/24/2023 11:48 AM, Sami Mujawar wrote:
>> External email: Use caution opening links or attachments
>>
>>
>> Hi Girish,
>>
>> Thank you for taking this effort forward
>>
>> Please find my response inline marked [SAMI].
>>
>> Regards,
>>
>> Sami Mujawar
>>
>> On 22/07/2023 12:14 am, Girish Mahadevan wrote:
>>> Hi Sami
>>>
>>> Your patches worked. There was just one thing I had to add to get
>>> compile to work. (inline with [GM]), other than that I think you can
>>> get this in.
>> [SAMI] Thanks for testing these patches.
>>>
>>> We've implemented about 18 table generators. (Types  0, 1, 2, 3, 8, 9,
>>> 11, 13, 14, 16, 17, 19, 32, 38, 39, 41, 43, 45)
>>> Two more are under way (Type 4.7).
>> [SAMI] I would be keen to understand how the Type 4 and 7 generators
>> would work as I would prefer to avoid duplication of data.
>>>
> 
> [GM]
> As a first pass we're setting up the generators to just blindly use
> SMBIOS specific CM objects to setup these tables.
> 
> Second pass could be to have the generators try to rely on ACPI objects
> (PPTT) or fallback to Architecture specific libraries to figure out how
> to populate these tables. Honestly we need to think about this a little
> more, we'd love to swap notes.
> (We are in the prelim stages of these so haven't gotten very far)
> 
> 
>>> I've setup a github repo here
>>> https://github.com/tianocore/edk2/compare/master...gmahadevan:edk2-upstream:RFC/smbios-dyntables-v2?expand=1
>>>
>> [SAMI] Thanks for sharing the github branch. Please also share a github
>> branch when you send out your patches for review.
>>>
> 
> [GM]
> Will do.
> 
>>> I could send you one massive patch train (22 patches or so) or split
>>> it up into smaller chunks perhaps just the table generation stuff
>>> first and then each generator library.
>>>
>> [SAMI] I think it may be good to split the patch series to include table
>> generation and then 1 or 2 generators to understand the code flow. The
>> remaining generators can follow later. I think Type 4 and 7 would be
>> really interesting, but you can send what you already have.
>>
> [GM]
> ok, I will send out a patch train for the core generator code and 2 of
> the Generators.
> 
> Best Regards
> Girish
> 
>>> Let me know.
>>>
>>> Best Regards
>>> Girish
>>>
>>>
>>> On 3/10/2023 9:28 AM, Sami Mujawar wrote:
>>>> External email: Use caution opening links or attachments
>>>>
>>>>
>>>> Hi Girish,
>>>>
>>>> On 10/03/2023 04:23 pm, Girish Mahadevan wrote:
>>>>> Hi Sami
>>>>>
>>>>> Response inline.[GM]
>>>>>
>>>>> Best Regards
>>>>> Girish
>>>>>
>>>>> On 3/9/2023 3:41 AM, Sami Mujawar wrote:
>>>>>> External email: Use caution opening links or attachments
>>>>>>
>>>>>>
>>>>>> Hi Girish,
>>>>>>
>>>>>> Thank you for your feedback.
>>>>>>
>>>>>> Please find my response inline marked [SAMI].
>>>>>>
>>>>>> Regards,
>>>>>>
>>>>>> Sami Mujawar
>>>>>>
>>>>>> On 08/03/2023, 17:41, "Girish Mahadevan" <gmahadevan@nvidia.com
>>>>>> <mailto:gmahadevan@nvidia.com>> wrote:
>>>>>>
>>>>>>
>>>>>> Hi Sami
>>>>>>
>>>>>>
>>>>>> Thanks for v2, I will apply these to my tree and test it out.
>>>>>> One small comment before I review/test the patch train inline
>>>>>> (prefixed
>>>>>> by [GM])
>>>>>>
>>>>>>
>>>>>> Best Regards
>>>>>> Girish
>>>>>>
>>>>>>
>>>>>> On 3/8/2023 1:16 AM, Sami Mujawar wrote:
>>>>>>> External email: Use caution opening links or attachments
>>>>>>>
>>>>>>>
>>>>>>> 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
>>>>>>> <mailto:sami.mujawar@arm.com>>
>>>>>>> Cc: Alexei Fedorov <Alexei.Fedorov@arm.com
>>>>>>> <mailto:Alexei.Fedorov@arm.com>>
>>>>>>> Cc: Pierre Gondois <pierre.gondois@arm.com
>>>>>>> <mailto:pierre.gondois@arm.com>>
>>>>>>> Cc: Girish Mahadevan <gmahadevan@nvidia.com
>>>>>>> <mailto:gmahadevan@nvidia.com>>
>>>>>>> Cc: Jeff Brasen <jbrasen@nvidia.com <mailto:jbrasen@nvidia.com>>
>>>>>>> Cc: Ashish Singhal <ashishsingha@nvidia.com
>>>>>>> <mailto:ashishsingha@nvidia.com>>
>>>>>>> Cc: Nick Ramirez <nramirez@nvidia.com <mailto:nramirez@nvidia.com>>
>>>>>>> Cc: William Watson <wwatson@nvidia.com <mailto:wwatson@nvidia.com>>
>>>>>>> Cc: Abner Chang <abner.chang@amd.com <mailto:abner.chang@amd.com>>
>>>>>>> Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com
>>>>>>> <mailto:Samer.El-Haj-Mahmoud@arm.com>>
>>>>>>> Cc: Jose Marinho <Jose.Marinho@arm.com 
>>>>>>> <mailto:Jose.Marinho@arm.com>>
>>>>>>> ---
>>>>>>>
>>>>>>> Notes:
>>>>>>> v2:
>>>>>>> - Update dispatcher state machine to remove StUnknown. [SAMI]
>>>>>>> - Move extern function to header file and move debug [ABNER]
>>>>>>> code together.
>>>>>>> - Updated code based on review feedback to move extern [SAMI]
>>>>>>> function to header file and also moved the debug code
>>>>>>> together.
>>>>>>> Ref:
>>>>>>> https://edk2.groups.io/g/devel/message/95341
>>>>>>> <https://edk2.groups.io/g/devel/message/95341>
>>>>>>>
>>>>>>>
>>>>>>> DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf
>>>>>>>
>>>>>>> | 4 +-
>>>>>>> DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c
>>>>>>>
>>>>>>> | 282 ++++++++++++++++++++
>>>>>>> DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.h
>>>>>>>
>>>>>>> | 159 +++++++++++
>>>>>>> 3 files changed, 444 insertions(+), 1 deletion(-)
>>>>>>>
>>>>>>> diff --git
>>>>>>> a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf
>>>>>>>
>>>>>>> b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf
>>>>>>>
>>>>>>>
>>>>>>> index
>>>>>>> ad8b3d037c169ca848b5ea84fd1086b83f37876f..b09272d883c6f4f05eb03dcdab3efeda92b2fbb6
>>>>>>>
>>>>>>> 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
>>>>>>> ##
>>>>>>> @@ -22,6 +22,8 @@ [Defines]
>>>>>>>
>>>>>>> [Sources]
>>>>>>> DynamicTableManagerDxe.c
>>>>>>> + SmbiosTableDispatcher.c
>>>>>>> + SmbiosTableDispatcher.h
>>>>>>>
>>>>>>> [Packages]
>>>>>>> MdePkg/MdePkg.dec
>>>>>>> diff --git
>>>>>>> a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c
>>>>>>>
>>>>>>> b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c
>>>>>>>
>>>>>>>
>>>>>>> new file mode 100644
>>>>>>> index
>>>>>>> 0000000000000000000000000000000000000000..0e728538d9f6eb0b164fea3a160d3233db833f8d
>>>>>>>
>>>>>>> --- /dev/null
>>>>>>> +++
>>>>>>> b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatcher.c
>>>>>>>
>>>>>>> @@ -0,0 +1,282 @@
>>>>>>> +/** @file
>>>>>>> + Dynamic Smbios Table Dispatcher
>>>>>>> +
>>> [GM]
>>> Not sure if it was an oversight, but you missed adding the extern to
>>> BuildAndInstallSmbiosTable
>> [SAMI] Yes, you are correct. I had tested my changes only using
>> simulation so may have removed the stub function when posting the 
>> patches.
>>>
>>>>>>> + 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),
>>> [GM]:
>>> We've made changes to this and to the Firmware inventory
>> [SAMI] Did I get something wrong or missed something here? Can you let
>> me know, please?
>>>
>>>
>>>>>>> + 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);
>>>>>>
>>>>>>
>>>>>> [GM]
>>>>>> This ASSERT will be hit even if we have multiple SMBIOS CM objects of
>>>>>> the same type which is legal (for e.g there are multiple tables for
>>>>>> type17/19 )
>>>>>>
>>>>>> [SAMI] The understanding is that SmbiosTableInfo[] will only contain
>>>>>> one entry for a given TableType as it is used to indicate which
>>>>>> generators are to be instantiated.
>>>>>>
>>>>>> Following is the sequence of operations:
>>>>>> - The dispatcher is initialised in InitSmbiosTableDispatcher(), which
>>>>>> will set the mSmBiosDispatcher[<Table_Type>].State to StPresent if
>>>>>> SmbiosTableInfo[] contains a table of Table_Type.
>>>>>> - SmbiosTableInfo[] will only contain one entry for each table type,
>>>>>> e.g. even if there are multiple Type17/Type19 tables to be installed.
>>>>>> This entry indicates that table(s) of Type17/Type19 is/are requested
>>>>>> to be installed and that the corresponding generator must be
>>>>>> instantiated.
>>>>>> - Once the SMBIOS table generator is instantiated, it will then
>>>>>> request for the object(s) of the required type from the Configuration
>>>>>> Manager that are required to construct the table.
>>>>>> - The generator can then decide if multiple SMBIOS tables are to be
>>>>>> constructed based on the objects returned by the Configuration
>>>>>> Manager. e.g. if multiple Cm_Type17_objects are returned then the
>>>>>> corresponding number of Type17 tables will be built by the generator.
>>>>>>
>>>>>> Therefore, I think we should not hit the above assert.
>>>>>>
>>>>>
>>>>> [GM]
>>>>> That sounds right, I'd made a mistake when installing the CM objects.
>>>>>
>>>>> I should be installing one of each SMBIOS table so that
>>>>> GetEStdObjSmbiosTableList gets the list of the available tables and
>>>>> each generator should install multiple tables of a given type based on
>>>>> the number of CM objects available.
>>>>>
>>>>> I did expand the existing SMBIOS factory code to install multiple
>>>>> tables.
>>>>>
>>>>> Thanks for the clarification.
>>>>>
>>>>> Best Regards
>>>>> Girish
>>>>>
>>>> [SAMI] No worries. Please let me know if you face any issues with the
>>>> dispatcher or if you identify any problem during integration.
>>>>
>>>> Regards,
>>>>
>>>> Sami Mujawar
>>>>
>>>>>
>>>>>> However, the code that may need to change/extend is the call to
>>>>>> BuildAndInstallSmbiosTable(). I am not sure if we need to indicate
>>>>>> that there could be multiple SMBIOS tables that may be installed. For
>>>>>> now, BuildAndInstallSmbiosTable() implies that a generator of the
>>>>>> specified type is to be instantiated for building the SMBIOS table of
>>>>>> the specified type.
>>>>>>
>>>>>> Hope this clarifies the scenario and please do let me know if I am
>>>>>> missing something.
>>>>>>
>>>>>> Also, I have only tested this patch with simulated data and there may
>>>>>> be some issues that we may find when the full stack is integrated.
>>>>>> So, thank you for going through the patch in detail.
>>>>>>
>>>>>> [SAMI]
>>>>>>
>>>>>> Best Regards
>>>>>> Girish
>>>>>>
>>>>>>
>>>>>>> + 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
>>>>>>> 0000000000000000000000000000000000000000..d59eab4223c142293bdaf4905588f08e7a4a467f
>>>>>>>
>>>>>>> --- /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_
>>>>>>> -- 
>>>>>>> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
> 
> 
> 
> 
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107655): https://edk2.groups.io/g/devel/message/107655
Mute This Topic: https://groups.io/mt/97468481/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

end of thread, other threads:[~2023-08-09 16:14 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-08  8:16 [PATCH v2 0/4] DynamicTablesPkg: Introduce SMBIOS dispatcher Sami Mujawar
2023-03-08  8:16 ` [PATCH v2 1/4] DynamicTablesPkg: Define a SMBIOS Structure/Table type Sami Mujawar
2023-03-08  8:16 ` [PATCH v2 2/4] DynamicTablesPkg: Add SMBIOS table dispatcher Sami Mujawar
2023-03-08 17:41   ` Girish Mahadevan
2023-03-09 10:41     ` Sami Mujawar
2023-03-10 16:23       ` Girish Mahadevan
2023-03-10 16:28         ` Sami Mujawar
2023-07-21 23:14           ` [edk2-devel] " Girish Mahadevan via groups.io
2023-07-24 17:48             ` Sami Mujawar
2023-07-25 23:29               ` Girish Mahadevan via groups.io
     [not found]               ` <1775402AB0EAA56A.16579@groups.io>
2023-08-09 16:13                 ` Girish Mahadevan via groups.io
2023-03-08  8:16 ` [PATCH v2 3/4] DynamicTablesPkg: Update SMBIOS dispatcher dependency table Sami Mujawar
2023-03-08  8:16 ` [PATCH v2 4/4] DynamicTablesPkg: Add Ordered dispatch support for SMBIOS tables Sami Mujawar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox