public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Chang, Abner" <abner.chang@amd.com>
To: Sami Mujawar <sami.mujawar@arm.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Alexei.Fedorov@arm.com" <Alexei.Fedorov@arm.com>,
	"pierre.gondois@arm.com" <pierre.gondois@arm.com>,
	"gmahadevan@nvidia.com" <gmahadevan@nvidia.com>,
	"jbrasen@nvidia.com" <jbrasen@nvidia.com>,
	"ashishsingha@nvidia.com" <ashishsingha@nvidia.com>,
	"nramirez@nvidia.com" <nramirez@nvidia.com>,
	"wwatson@nvidia.com" <wwatson@nvidia.com>,
	"Matteo.Carlini@arm.com" <Matteo.Carlini@arm.com>,
	"Akanksha.Jain2@arm.com" <Akanksha.Jain2@arm.com>,
	"Ben.Adderson@arm.com" <Ben.Adderson@arm.com>,
	"Samer.El-Haj-Mahmoud@arm.com" <Samer.El-Haj-Mahmoud@arm.com>,
	"nd@arm.com" <nd@arm.com>
Subject: Re: [PATCH v1 2/2] DynamicTablesPkg: Add SMBIOS table dispatcher
Date: Tue, 25 Oct 2022 00:54:19 +0000	[thread overview]
Message-ID: <MN2PR12MB396624CD19E9A9E2D5EEC7EAEA319@MN2PR12MB3966.namprd12.prod.outlook.com> (raw)
In-Reply-To: <20221018153344.16876-3-sami.mujawar@arm.com>

[AMD Official Use Only - General]



> -----Original Message-----
> From: Sami Mujawar <sami.mujawar@arm.com>
> Sent: Tuesday, October 18, 2022 11:34 PM
> To: devel@edk2.groups.io
> Cc: Sami Mujawar <sami.mujawar@arm.com>; Alexei.Fedorov@arm.com;
> pierre.gondois@arm.com; gmahadevan@nvidia.com; Chang, Abner
> <Abner.Chang@amd.com>; jbrasen@nvidia.com; ashishsingha@nvidia.com;
> nramirez@nvidia.com; wwatson@nvidia.com; Matteo.Carlini@arm.com;
> Akanksha.Jain2@arm.com; Ben.Adderson@arm.com; Samer.El-Haj-
> Mahmoud@arm.com; nd@arm.com
> Subject: [PATCH v1 2/2] DynamicTablesPkg: Add SMBIOS table dispatcher
> 
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
> 
> 
> 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>
> ---
> 
> DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManag
> erDxe.inf |   4 +-
> 
> DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatch
> er.c    | 304 ++++++++++++++++++++
> 
> DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispatch
> er.h    | 133 +++++++++
>  3 files changed, 440 insertions(+), 1 deletion(-)
> 
> diff --git
> a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableMan
> agerDxe.inf
> b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableMan
> agerDxe.inf
> index
> ad8b3d037c169ca848b5ea84fd1086b83f37876f..b09272d883c6f4f05eb03dcdab
> 3efeda92b2fbb6 100644
> ---
> a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableMan
> agerDxe.inf
> +++
> b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableMan
> age
> +++ rDxe.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/SmbiosTableDispat
> cher.c
> b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispat
> cher.c
> new file mode 100644
> index
> 0000000000000000000000000000000000000000..88907fecdde5e36d40ac22cd4
> 86391abbb853e38
> --- /dev/null
> +++
> b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispat
> c
> +++ her.c
> @@ -0,0 +1,304 @@
> +/** @file
> +  Dynamic Smbios Table Dispatcher
> +
> +  Copyright (c) 2022, 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>
> +
> +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
> +  );
You can move above external reference to the header file.

> +
> +#if !defined (MDEPKG_NDEBUG)
> +
> +/**
> +  A string table describing the SMBIOS dispatcher states.
> +*/
> +STATIC
> +CONST CHAR8  *SmbiosTableStateTxt[] = {
> +  "StUnknown",
> +  "StNotPresent",
> +  "StPresent",
> +  "StDispatched"
> +};
> +
> +#endif
You can merge above #if block with below #if !defined (MDEPKG_NDEBUG).

Other looks good to me.
Abner
> +
> +/**
> +  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)
> +};
I'm not quite sure but is it possible a circular dependence? (for example, the cross reference handle)

> +
> +#if !defined (MDEPKG_NDEBUG)
> +
> +/**
> +  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 < StPresent)) {
> +      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;
> +
> +  // First 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;  }
> +
> +  // Mark the remaining tables as not presented for installation  for
> + (Index = 0; Index < ARRAY_SIZE (mSmBiosDispatcher); Index++) {
> +    if (mSmBiosDispatcher[Index].State == StUnknown) {
> +      mSmBiosDispatcher[Index].State = StNotPresent;
> +    }
> +  }
> +
> +  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 < StPresent) {
> +    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/SmbiosTableDispat
> cher.h
> b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispat
> cher.h
> new file mode 100644
> index
> 0000000000000000000000000000000000000000..420e16f62d58cf295b27174ce7
> 8ce9e2697918cb
> --- /dev/null
> +++
> b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableDispat
> c
> +++ her.h
> @@ -0,0 +1,133 @@
> +/** @file
> +
> +  Copyright (c) 2022, 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, \
> +    StUnknown, \
> +    { Dep1, Dep2, Dep3, Dep4, Dep5 } \
> +  }
> +
> +/**
> +  An enum desribing the states of the SMBIOS table dispatcher.
> +*/
> +typedef enum SmbiosTableState {
> +  StUnknown,      ///< Initial state.
> +  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;
> +
> +/**
> +  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)'

  reply	other threads:[~2022-10-25  0:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-18 15:33 [PATCH v1 0/2] DynamicTablesPkg: Introduce SMBIOS dispatcher Sami Mujawar
2022-10-18 15:33 ` [PATCH v1 1/2] DynamicTablesPkg: Define a SMBIOS Structure/Table type Sami Mujawar
2022-10-25  0:56   ` Chang, Abner
2022-10-18 15:33 ` [PATCH v1 2/2] DynamicTablesPkg: Add SMBIOS table dispatcher Sami Mujawar
2022-10-25  0:54   ` Chang, Abner [this message]
2022-10-25 12:29 ` [PATCH v1 0/2] DynamicTablesPkg: Introduce SMBIOS dispatcher PierreGondois

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=MN2PR12MB396624CD19E9A9E2D5EEC7EAEA319@MN2PR12MB3966.namprd12.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox