Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamictables: Add SMBIOS dispatcher and generators #510

Open
wants to merge 11 commits into
base: dynamictables-reorg
Choose a base branch
from

Conversation

gmahadevan
Copy link

Initial set of changes to add support for SMBIOS table generation that has the mods to the DynamicTablesPkg framework to install SMBIOS tables and 3 SMBIOS table generators for Type 16/17/19

DynamicTablesPkg: Smbios Memory Array Mapped Address (Type 19)
DynamicTablesPkg: Smbios Physical Memory Array (Type 16)
DynamicTablesPkg: Smbios Memory Device (Type 17)
DynamicTablesPkg: Introduce new namespace for SMBIOS Objects
DynamicTablesPkg: Split the ACPI and SMBIOS table generators
DynamicTablesPkg: Add SMBIOS table generation
DynamicTablesPkg: Add Ordered dispatch support for SMBIOS tables
DynamicTablesPkg: Update SMBIOS dispatcher dependency table
DynamicTablesPkg: Add extern call to build SMBIOS table
DynamicTablesPkg: Add SMBIOS table dispatcher
DynamicTablesPkg: Define a SMBIOS Structure/Table type
DynamicTablesPkg: SmbiosStringLib: Add new helper macro

@@ -83,7 +84,8 @@ typedef enum ObjectNameSpaceID {
EObjNameSpaceStandard, ///< Standard Objects Namespace
EObjNameSpaceArchCommon, ///< Arch Common Objects Namespace
EObjNameSpaceArm, ///< ARM Objects Namespace
EObjNameSpaceOem = 0xF, ///< OEM Objects Namespace
EObjNameSpaceOem = 0xF, ///< OEM Objects Namespace
EObjNameSpaceSmbios, ///< SMBIOS Objects Namespace

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CM_OBJECT_ID name space ID (as defined at the top of this file) is 4 bits wide. So this addition causes an overflow.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will change this.

@param [IN] Str Pointer to the string
@param [OUT] StrRef The string field reference of the added string
**/
#define STRING_TABLE_ADD_STRING(StrTable, String, StringRef) \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This macro isn't used anywhere in this patchset.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, this patchset doesn't include the generators that use this macro.
I will drop it from the patchset and bring it back when I introduce the other generators (type3/13 etc).

samimujawar and others added 11 commits February 19, 2025 10:28
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>
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>
Add an extern call to build SMBIOS table as this seemed to have
been removed during v2.

Signed-off-by: Girish Mahadevan <gmahadevan@nvidia.com>
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>
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>
Add the SMBIOS Table generator code to the DynamicTablesPkg.

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

Change-Id: Icc090108c16e87657260af6daf856f3d69b602e3
Signed-off-by: Girish Mahadevan <gmahadevan@nvidia.com>
Reviewed-by: Jeff Brasen <jbrasen@nvidia.com>
Split the SMBIOS and ACPI table generators into their own files.

Signed-off-by: Girish Mahadevan <gmahadevan@nvidia.com>
Reviewed-by: Jeff Brasen <jbrasen@nvidia.com>
Introduce a new namespace for SMBIOS related CM Objects.

Signed-off-by: Girish Mahadevan <gmahadevan@nvidia.com>
Reviewed-by: Nick Ramirez <nramirez@nvidia.com>
Reviewed-by: Jeff Brasen <jbrasen@nvidia.com>
Add the Generator library for SMBIOS Table Type 17 - Memory
Device.

Signed-off-by: Girish Mahadevan <gmahadevan@nvidia.com>
Reviewed-by: Jeff Brasen <jbrasen@nvidia.com>
Add the Generator library for SMBIOS Table Type 16 - Physical
Memory Array.

Signed-off-by: Girish Mahadevan <gmahadevan@nvidia.com>
Reviewed-by: Jeff Brasen <jbrasen@nvidia.com>
Reviewed-by: Nick Ramirez <nramirez@nvidia.com>
Add the Generator library for SMBIOS Table Type 19 - Memory Array
Mapped Address.

Signed-off-by: Girish Mahadevan <gmahadevan@nvidia.com>
Reviewed-by: Jeff Brasen <jbrasen@nvidia.com>
@gmahadevan gmahadevan force-pushed the dynamictables-reorg-upto19 branch from 58f8eb2 to 777b9c1 Compare February 19, 2025 17:35
@samimujawar
Copy link

@gmahadevan Thanks a lot for driving this effort and for this patch series.
Other than the last 3 patches in the series i.e. the generators, I have reviewed the rest of the patches. I think it would be best to review the generators once we have concluded the discussion about the introduction of the new SMBIOS Object namespace. Please see my inputs as to why I think we should not introduce a new SMBIOS object namespace. If we need to distinguish SMBIOS specific objects, it would be best to add comments to the arch common objects.

#pragma pack(1)

typedef enum SmbiosObjectID {
ESmbiosObjReserved, ///< 0 - Reserved

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can these just be an extension to EARCH_COMMON_OBJECT_ID, please?

@@ -83,7 +84,8 @@ typedef enum ObjectNameSpaceID {
EObjNameSpaceStandard, ///< Standard Objects Namespace
EObjNameSpaceArchCommon, ///< Arch Common Objects Namespace
EObjNameSpaceArm, ///< ARM Objects Namespace
EObjNameSpaceOem = 0xF, ///< OEM Objects Namespace
EObjNameSpaceOem = 0xF, ///< OEM Objects Namespace
EObjNameSpaceSmbios, ///< SMBIOS Objects Namespace

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not introduce a new namespace. Can we use EObjNameSpaceArchCommon instead?

The reason for this is that we do not want duplication of information between some common ACPI and SMBIOS objects.

A good example is the information required for generating Type4 and Type7 SMBIOS tables. Most of the information therein is already available with the CM objects that we have defined for supporting PPTT table generation.
I understand that there is some additional information required for Type4 and Type7, but that can be added to the existing CM objects wherever necessary. These additional fields can remain unpopulated should
an implementation desire only ACPI tables.

@@ -311,7 +311,6 @@ BuildAndInstallMultipleSmbiosTables (
}
}

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe these logs could be changed to DEBUG_VERBOSE. Also these log changes should be a separate patch.

/// 0FFFFh is used to indicate that the referenced handle is not applicable or does not
/// exist.
///
#define SMBIOS_HANDLE_INVALID 0xFFFF

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be a separate patch.

@@ -121,12 +121,21 @@ typedef enum StdSmbiosTableGeneratorId {
ETableGeneratorNameSpaceStd, \
TableId \
)
#define MAX_SMBIOS_HANDLES (255)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we introduce a PCD PcdMaxSmbiosHandles to configure this? If so, please add a note to indicate that a large value may degrade the performance.

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

@param [in] Smbios SMBIOS Protocol pointer.
@param [in] SmbiosHandle SMBIOS Handle to be added, if the value SMBIOS_HANDLE_PI_RESERVED

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the documentation for the SmbiosHandle parameter is out of sync with the code. Also, do we need a pointer to the SMBIOS handle?

If the intention is that we might need to extend the functionality to generate the handle in this function and return, then please add a comment to that effect. Then again the order of invocation of the table installation and handle generation would need to change in BuildXXX functions.
Which brings us back to should we support the handle generation in this function in the first place?

IN EFI_SYSTEM_TABLE *SystemTable
STATIC
VOID
AcpiTableProtocolReady (

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be part of another patch (may be before this patch)?
Also can you explain why we need this notification? Can we not use the DEPEX dependency to dispatch?
Or is this required to satisfy the dispatch for a use case wherein only ACPI tables are present and SMBIOS support is not provided ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also can we keep the code from line 1186 to 1237 as part of the original DynamicTableManagerDxeInitialize() ?
I see that should not need changing, right?
Furthermore, the same code is again repeated in SmbiosProtocolReady(), see line 1281 to 1332.

typedef struct DynamicTableFactoryProtocol EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL;
typedef UINTN CM_OBJECT_TOKEN;

typedef struct SmbiosHandleCmObjMap {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation, please?

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

@param [in] Smbios Pointer to the SMBIOS protocol.
@param [in] SmbiosHandle Pointer to an SMBIOS handle (either generated by

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see my comment in SmbiosTableFactory::AddSmbiosHandle()

@return SMBIOS handle of the table associated with SmbiosTableId and
CmObjectToken if found. Otherwise, returns 0xFFFF.
**/
typedef UINT16 (EFIAPI *EDKII_DYNAMIC_TABLE_FACTORY_SMBIOS_TABLE_GET_HANDLE_EX)(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use SMBIOS_HANDLE as the return type? If so please also update the implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants