mirror of
https://github.com/tianocore/edk2
synced 2026-08-27 00:23:19 -04:00
DynamicTablesPkg: Add SMBIOS System Reset (Type 23) generator
Add a Configuration Manager object and parser for SMBIOS Type 23 System Reset information. Add a Type 23 SMBIOS generator that creates the System Reset structure from the System Reset CM object. The generator expects a single CM object, fills the system reset capabilities and watchdog reset fields, and registers the generated table with the SMBIOS table factory. Signed-off-by: Varshit Pandya <varshit.pandya@arm.com>
This commit is contained in:
parent
dc23931fac
commit
019a537496
5 changed files with 345 additions and 0 deletions
|
|
@ -115,6 +115,7 @@
|
|||
DynamicTablesPkg/Library/Smbios/SmbiosType16Lib/SmbiosType16Lib.inf
|
||||
DynamicTablesPkg/Library/Smbios/SmbiosType17Lib/SmbiosType17Lib.inf
|
||||
DynamicTablesPkg/Library/Smbios/SmbiosType19Lib/SmbiosType19Lib.inf
|
||||
DynamicTablesPkg/Library/Smbios/SmbiosType23Lib/SmbiosType23Lib.inf
|
||||
DynamicTablesPkg/Library/Smbios/SmbiosType26Lib/SmbiosType26Lib.inf
|
||||
DynamicTablesPkg/Library/Smbios/SmbiosType27Lib/SmbiosType27Lib.inf
|
||||
DynamicTablesPkg/Library/Smbios/SmbiosType28Lib/SmbiosType28Lib.inf
|
||||
|
|
@ -169,6 +170,7 @@
|
|||
NULL|DynamicTablesPkg/Library/Smbios/SmbiosType16Lib/SmbiosType16Lib.inf
|
||||
NULL|DynamicTablesPkg/Library/Smbios/SmbiosType17Lib/SmbiosType17Lib.inf
|
||||
NULL|DynamicTablesPkg/Library/Smbios/SmbiosType19Lib/SmbiosType19Lib.inf
|
||||
NULL|DynamicTablesPkg/Library/Smbios/SmbiosType23Lib/SmbiosType23Lib.inf
|
||||
NULL|DynamicTablesPkg/Library/Smbios/SmbiosType26Lib/SmbiosType26Lib.inf
|
||||
NULL|DynamicTablesPkg/Library/Smbios/SmbiosType27Lib/SmbiosType27Lib.inf
|
||||
NULL|DynamicTablesPkg/Library/Smbios/SmbiosType28Lib/SmbiosType28Lib.inf
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@ typedef enum ArchCommonObjectID {
|
|||
EArchCommonObjTemperatureProbeInfo, ///< 59 - Temperature Probe Info
|
||||
EArchCommonObjVoltageProbeInfo, ///< 60 - Voltage Probe Info
|
||||
EArchCommonObjElectricalCurrentProbeInfo, ///< 61 - Electrical Current Probe Info
|
||||
EArchCommonObjSystemResetInfo, ///< 62 - System Reset Info
|
||||
EArchCommonObjMax
|
||||
} EARCH_COMMON_OBJECT_ID;
|
||||
|
||||
|
|
@ -1612,4 +1613,30 @@ typedef struct CmArchCommonElectricalCurrentProbeInfo {
|
|||
UINT16 NominalValue;
|
||||
} CM_ARCH_COMMON_ELECTRICAL_CURRENT_PROBE_INFO;
|
||||
|
||||
/** A structure that describes system reset information.
|
||||
|
||||
SMBIOS Specification v3.9.0 Type 23
|
||||
|
||||
ID: EArchCommonObjSystemResetInfo
|
||||
**/
|
||||
typedef struct CmArchCommonSystemResetInfo {
|
||||
/// Token identifying this system reset CM object.
|
||||
CM_OBJECT_TOKEN SystemResetToken;
|
||||
|
||||
/// System reset capability flags as defined by SMBIOS Type 23.
|
||||
UINT8 Capabilities;
|
||||
|
||||
/// Number of automatic system resets since the last intentional reset.
|
||||
UINT16 ResetCount;
|
||||
|
||||
/// Number of consecutive automatic reset attempts allowed.
|
||||
UINT16 ResetLimit;
|
||||
|
||||
/// Watchdog timer interval.
|
||||
UINT16 TimerInterval;
|
||||
|
||||
/// Timeout value used by the watchdog timer.
|
||||
UINT16 Timeout;
|
||||
} CM_ARCH_COMMON_SYSTEM_RESET_INFO;
|
||||
|
||||
#pragma pack()
|
||||
|
|
|
|||
|
|
@ -1280,6 +1280,17 @@ STATIC CONST CM_OBJ_PARSER CmArchCommonElectricalCurrentProbeInfoParser[] = {
|
|||
{ "NominalValue", sizeof (UINT16), "0x%x", NULL },
|
||||
};
|
||||
|
||||
/** A parser for EArchCommonObjSystemResetInfo.
|
||||
*/
|
||||
STATIC CONST CM_OBJ_PARSER CmArchCommonSystemResetInfoParser[] = {
|
||||
{ "SystemResetToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL },
|
||||
{ "Capabilities", sizeof (UINT8), "0x%x", NULL },
|
||||
{ "ResetCount", sizeof (UINT16), "0x%x", NULL },
|
||||
{ "ResetLimit", sizeof (UINT16), "0x%x", NULL },
|
||||
{ "TimerInterval", sizeof (UINT16), "0x%x", NULL },
|
||||
{ "Timeout", sizeof (UINT16), "0x%x", NULL },
|
||||
};
|
||||
|
||||
/** A parser for Arch Common namespace objects.
|
||||
*/
|
||||
STATIC CONST CM_OBJ_PARSER_ARRAY ArchCommonNamespaceObjectParser[] = {
|
||||
|
|
@ -1346,6 +1357,7 @@ STATIC CONST CM_OBJ_PARSER_ARRAY ArchCommonNamespaceObjectParser[] = {
|
|||
CM_PARSER_ADD_OBJECT (EArchCommonObjTemperatureProbeInfo, CmArchCommonTemperatureProbeInfoParser),
|
||||
CM_PARSER_ADD_OBJECT (EArchCommonObjVoltageProbeInfo, CmArchCommonVoltageProbeInfoParser),
|
||||
CM_PARSER_ADD_OBJECT (EArchCommonObjElectricalCurrentProbeInfo, CmArchCommonElectricalCurrentProbeInfoParser),
|
||||
CM_PARSER_ADD_OBJECT (EArchCommonObjSystemResetInfo, CmArchCommonSystemResetInfoParser),
|
||||
CM_PARSER_ADD_OBJECT_RESERVED (EArchCommonObjMax)
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,275 @@
|
|||
/** @file
|
||||
SMBIOS Type23 Table Generator.
|
||||
|
||||
@par Reference(s):
|
||||
- SMBIOS Specification 3.9.0
|
||||
|
||||
Copyright (c) 2026, Arm Limited. All rights reserved.<BR>
|
||||
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
**/
|
||||
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/SmbiosStringTableLib.h>
|
||||
|
||||
// Module specific include files.
|
||||
#include <ConfigurationManagerObject.h>
|
||||
#include <ConfigurationManagerHelper.h>
|
||||
#include <Protocol/ConfigurationManagerProtocol.h>
|
||||
#include <Protocol/DynamicTableFactoryProtocol.h>
|
||||
#include <IndustryStandard/SmBios.h>
|
||||
|
||||
/** SMBIOS Type 23 System Reset Generator
|
||||
|
||||
Requirements:
|
||||
The following Configuration Manager Object(s) are required by
|
||||
this Generator:
|
||||
- EArchCommonObjSystemResetInfo
|
||||
*/
|
||||
|
||||
/**
|
||||
This macro expands to a function that retrieves the System Reset
|
||||
information from the Configuration Manager.
|
||||
*/
|
||||
GET_OBJECT_LIST (
|
||||
EObjNameSpaceArchCommon,
|
||||
EArchCommonObjSystemResetInfo,
|
||||
CM_ARCH_COMMON_SYSTEM_RESET_INFO
|
||||
);
|
||||
|
||||
/**
|
||||
SMBIOS Type 23 Capabilities bits 7:6 are reserved and must be 00b.
|
||||
*/
|
||||
#define SMBIOS_TYPE23_CAPABILITIES_RESERVED_MASK 0xC0
|
||||
|
||||
/**
|
||||
Free any resources allocated when installing SMBIOS Type 23 table.
|
||||
|
||||
@param [in] This Pointer to the SMBIOS table generator.
|
||||
@param [in] TableFactoryProtocol Pointer to the SMBIOS Table Factory
|
||||
Protocol interface.
|
||||
@param [in] SmbiosTableInfo Pointer to the SMBIOS table information.
|
||||
@param [in] CfgMgrProtocol Pointer to the Configuration Manager
|
||||
Protocol interface.
|
||||
@param [in] Table Pointer to the generated SMBIOS table.
|
||||
|
||||
@retval EFI_SUCCESS Resources were freed successfully.
|
||||
**/
|
||||
STATIC
|
||||
EFI_STATUS
|
||||
FreeSmbiosType23Table (
|
||||
IN CONST SMBIOS_TABLE_GENERATOR *CONST This,
|
||||
IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST TableFactoryProtocol,
|
||||
IN CONST CM_STD_OBJ_SMBIOS_TABLE_INFO *CONST SmbiosTableInfo,
|
||||
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol,
|
||||
IN SMBIOS_STRUCTURE **CONST Table
|
||||
)
|
||||
{
|
||||
FreePool (*Table);
|
||||
*Table = NULL;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/** Construct SMBIOS Type 23 Table describing system reset information.
|
||||
|
||||
If this function allocates any resources then they must be freed
|
||||
in the FreeSmbiosType23Table function.
|
||||
|
||||
@param [in] This Pointer to the SMBIOS table generator.
|
||||
@param [in] TableFactoryProtocol Pointer to the SMBIOS Table Factory
|
||||
Protocol interface.
|
||||
@param [in] SmbiosTableInfo Pointer to the SMBIOS table information.
|
||||
@param [in] CfgMgrProtocol Pointer to the Configuration Manager
|
||||
Protocol interface.
|
||||
@param [out] Table Pointer to the generated SMBIOS table.
|
||||
@param [out] CmObjectToken Pointer to the CM Object Token for the
|
||||
generated SMBIOS table.
|
||||
|
||||
@retval EFI_SUCCESS Table generated successfully.
|
||||
@retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration
|
||||
Manager is less than the Object size for
|
||||
the requested object.
|
||||
@retval EFI_INVALID_PARAMETER A parameter is invalid.
|
||||
@retval EFI_NOT_FOUND Could not find information.
|
||||
@retval EFI_OUT_OF_RESOURCES Could not allocate memory.
|
||||
@retval EFI_UNSUPPORTED Unsupported configuration.
|
||||
**/
|
||||
STATIC
|
||||
EFI_STATUS
|
||||
BuildSmbiosType23Table (
|
||||
IN CONST SMBIOS_TABLE_GENERATOR *This,
|
||||
IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST TableFactoryProtocol,
|
||||
IN CM_STD_OBJ_SMBIOS_TABLE_INFO *CONST SmbiosTableInfo,
|
||||
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol,
|
||||
OUT SMBIOS_STRUCTURE **Table,
|
||||
OUT CM_OBJECT_TOKEN *CONST CmObjectToken
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT32 SystemResetCount;
|
||||
SMBIOS_TABLE_TYPE23 *SmbiosRecord;
|
||||
CM_ARCH_COMMON_SYSTEM_RESET_INFO *SystemResetInfo;
|
||||
|
||||
ASSERT (This != NULL);
|
||||
ASSERT (SmbiosTableInfo != NULL);
|
||||
ASSERT (CfgMgrProtocol != NULL);
|
||||
ASSERT (CmObjectToken != NULL);
|
||||
ASSERT (Table != NULL);
|
||||
ASSERT (SmbiosTableInfo->TableGeneratorId == This->GeneratorID);
|
||||
|
||||
if ((This == NULL) || (SmbiosTableInfo == NULL) || (CfgMgrProtocol == NULL) ||
|
||||
(Table == NULL) || (CmObjectToken == NULL) ||
|
||||
(SmbiosTableInfo->TableGeneratorId != This->GeneratorID))
|
||||
{
|
||||
DEBUG ((DEBUG_ERROR, "%a: Invalid Parameter\n", __func__));
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
*Table = NULL;
|
||||
*CmObjectToken = CM_NULL_TOKEN;
|
||||
SmbiosRecord = NULL;
|
||||
|
||||
Status = GetEArchCommonObjSystemResetInfo (
|
||||
CfgMgrProtocol,
|
||||
CM_NULL_TOKEN,
|
||||
&SystemResetInfo,
|
||||
&SystemResetCount
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: Failed to get system reset info. Status = %r\n",
|
||||
__func__,
|
||||
Status
|
||||
));
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (SystemResetCount != 1) {
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: Expected 1 System Reset CM Object, got %u\n",
|
||||
__func__,
|
||||
SystemResetCount
|
||||
));
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if ((SystemResetInfo[0].Capabilities & SMBIOS_TYPE23_CAPABILITIES_RESERVED_MASK) != 0) {
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: Invalid System Reset Capabilities 0x%x. Bits 7:6 must be zero.\n",
|
||||
__func__,
|
||||
SystemResetInfo[0].Capabilities
|
||||
));
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
SmbiosRecord = (SMBIOS_TABLE_TYPE23 *)AllocateSmbiosRecord (
|
||||
sizeof (SMBIOS_TABLE_TYPE23),
|
||||
NULL
|
||||
);
|
||||
if (SmbiosRecord == NULL) {
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: Failed to allocate memory for System Reset table\n",
|
||||
__func__
|
||||
));
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_RESET;
|
||||
SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE23);
|
||||
|
||||
SmbiosRecord->Capabilities = SystemResetInfo[0].Capabilities;
|
||||
SmbiosRecord->ResetCount = SystemResetInfo[0].ResetCount;
|
||||
SmbiosRecord->ResetLimit = SystemResetInfo[0].ResetLimit;
|
||||
SmbiosRecord->TimerInterval = SystemResetInfo[0].TimerInterval;
|
||||
SmbiosRecord->Timeout = SystemResetInfo[0].Timeout;
|
||||
|
||||
*Table = (SMBIOS_STRUCTURE *)SmbiosRecord;
|
||||
*CmObjectToken = SystemResetInfo[0].SystemResetToken;
|
||||
SmbiosRecord = NULL;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/** The interface for the SMBIOS Type23 Table Generator.
|
||||
*/
|
||||
STATIC
|
||||
CONST
|
||||
SMBIOS_TABLE_GENERATOR SmbiosType23Generator = {
|
||||
// Generator ID
|
||||
CREATE_STD_SMBIOS_TABLE_GEN_ID (EStdSmbiosTableIdType23),
|
||||
// Generator Description
|
||||
L"SMBIOS.TYPE23.GENERATOR",
|
||||
// SMBIOS Table Type
|
||||
EFI_SMBIOS_TYPE_SYSTEM_RESET,
|
||||
// Build table function.
|
||||
BuildSmbiosType23Table,
|
||||
// Free function.
|
||||
FreeSmbiosType23Table,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
/** Register the Generator with the SMBIOS Table Factory.
|
||||
|
||||
@param [in] ImageHandle The handle to the image.
|
||||
@param [in] SystemTable Pointer to the System Table.
|
||||
|
||||
@retval EFI_SUCCESS The Generator is registered.
|
||||
@retval EFI_INVALID_PARAMETER A parameter is invalid.
|
||||
@retval EFI_ALREADY_STARTED The Generator for the Table ID
|
||||
is already registered.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmbiosType23LibConstructor (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = RegisterSmbiosTableGenerator (&SmbiosType23Generator);
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"SMBIOS Type 23: Register Generator. Status = %r\n",
|
||||
Status
|
||||
));
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/** Deregister the Generator from the SMBIOS Table Factory.
|
||||
|
||||
@param [in] ImageHandle The handle to the image.
|
||||
@param [in] SystemTable Pointer to the System Table.
|
||||
|
||||
@retval EFI_SUCCESS The Generator is deregistered.
|
||||
@retval EFI_INVALID_PARAMETER A parameter is invalid.
|
||||
@retval EFI_NOT_FOUND The Generator is not registered.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmbiosType23LibDestructor (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = DeregisterSmbiosTableGenerator (&SmbiosType23Generator);
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"SMBIOS Type 23: Deregister Generator. Status = %r\n",
|
||||
Status
|
||||
));
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
return Status;
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
## @file
|
||||
# SMBIOS Type23 Table Generator
|
||||
#
|
||||
# Copyright (c) 2026, Arm Limited. All rights reserved.<BR>
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
##
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 0x0001001B
|
||||
BASE_NAME = SmbiosType23LibArm
|
||||
FILE_GUID = 7227274f-7684-4744-bca9-2f8c113dbc72
|
||||
VERSION_STRING = 1.0
|
||||
MODULE_TYPE = DXE_DRIVER
|
||||
LIBRARY_CLASS = NULL|DXE_DRIVER
|
||||
CONSTRUCTOR = SmbiosType23LibConstructor
|
||||
DESTRUCTOR = SmbiosType23LibDestructor
|
||||
|
||||
[Sources]
|
||||
SmbiosType23Generator.c
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
DynamicTablesPkg/DynamicTablesPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
DebugLib
|
||||
MemoryAllocationLib
|
||||
SmbiosStringTableLib
|
||||
Loading…
Add table
Add a link
Reference in a new issue