3 Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #ifndef SMBIOS_TABLE_GENERATOR_H_
10 #define SMBIOS_TABLE_GENERATOR_H_
12 #include <IndustryStandard/SmBios.h>
14 #include <TableGenerator.h>
18 /** The SMBIOS_TABLE_GENERATOR_ID type describes SMBIOS table generator ID.
20 typedef TABLE_GENERATOR_ID SMBIOS_TABLE_GENERATOR_ID
;
22 /** The ESTD_SMBIOS_TABLE_ID enum describes the SMBIOS table IDs reserved for
23 the standard generators.
25 NOTE: The SMBIOS Generator IDs do not match the table type numbers!
26 This allows 0 to be used to catch invalid parameters.
28 typedef enum StdSmbiosTableGeneratorId
{
29 EStdSmbiosTableIdReserved
= 0x0000,
31 EStdSmbiosTableIdType00
,
32 EStdSmbiosTableIdType01
,
33 EStdSmbiosTableIdType02
,
34 EStdSmbiosTableIdType03
,
35 EStdSmbiosTableIdType04
,
36 EStdSmbiosTableIdType05
,
37 EStdSmbiosTableIdType06
,
38 EStdSmbiosTableIdType07
,
39 EStdSmbiosTableIdType08
,
40 EStdSmbiosTableIdType09
,
41 EStdSmbiosTableIdType10
,
42 EStdSmbiosTableIdType11
,
43 EStdSmbiosTableIdType12
,
44 EStdSmbiosTableIdType13
,
45 EStdSmbiosTableIdType14
,
46 EStdSmbiosTableIdType15
,
47 EStdSmbiosTableIdType16
,
48 EStdSmbiosTableIdType17
,
49 EStdSmbiosTableIdType18
,
50 EStdSmbiosTableIdType19
,
51 EStdSmbiosTableIdType20
,
52 EStdSmbiosTableIdType21
,
53 EStdSmbiosTableIdType22
,
54 EStdSmbiosTableIdType23
,
55 EStdSmbiosTableIdType24
,
56 EStdSmbiosTableIdType25
,
57 EStdSmbiosTableIdType26
,
58 EStdSmbiosTableIdType27
,
59 EStdSmbiosTableIdType28
,
60 EStdSmbiosTableIdType29
,
61 EStdSmbiosTableIdType30
,
62 EStdSmbiosTableIdType31
,
63 EStdSmbiosTableIdType32
,
64 EStdSmbiosTableIdType33
,
65 EStdSmbiosTableIdType34
,
66 EStdSmbiosTableIdType35
,
67 EStdSmbiosTableIdType36
,
68 EStdSmbiosTableIdType37
,
69 EStdSmbiosTableIdType38
,
70 EStdSmbiosTableIdType39
,
71 EStdSmbiosTableIdType40
,
72 EStdSmbiosTableIdType41
,
73 EStdSmbiosTableIdType42
,
75 // IDs 43 - 125 are reserved
77 EStdSmbiosTableIdType126
= (EStdSmbiosTableIdType00
+ 126),
78 EStdSmbiosTableIdType127
,
80 } ESTD_SMBIOS_TABLE_ID
;
82 /** This macro checks if the Table Generator ID is for an SMBIOS Table
85 @param [in] TableGeneratorId The table generator ID.
87 @return TRUE if the table generator ID is for an SMBIOS Table
90 #define IS_GENERATOR_TYPE_SMBIOS(TableGeneratorId) \
92 GET_TABLE_TYPE (TableGeneratorId) == \
93 ETableGeneratorTypeSmbios \
96 /** This macro checks if the Table Generator ID is for a standard SMBIOS
99 @param [in] TableGeneratorId The table generator ID.
101 @return TRUE if the table generator ID is for a standard SMBIOS
104 #define IS_VALID_STD_SMBIOS_GENERATOR_ID(TableGeneratorId) \
106 IS_GENERATOR_NAMESPACE_STD(TableGeneratorId) && \
107 IS_GENERATOR_TYPE_SMBIOS(TableGeneratorId) && \
108 ((GET_TABLE_ID(GeneratorId) >= EStdSmbiosTableIdRaw) && \
109 (GET_TABLE_ID(GeneratorId) < EStdSmbiosTableIdMax)) \
112 /** This macro creates a standard SMBIOS Table Generator ID.
114 @param [in] TableId The table generator ID.
116 @return a standard SMBIOS table generator ID.
118 #define CREATE_STD_SMBIOS_TABLE_GEN_ID(TableId) \
119 CREATE_TABLE_GEN_ID ( \
120 ETableGeneratorTypeSmbios, \
121 ETableGeneratorNameSpaceStd, \
125 /** Forward declarations.
127 typedef struct ConfigurationManagerProtocol EDKII_CONFIGURATION_MANAGER_PROTOCOL
;
128 typedef struct CmStdObjSmbiosTableInfo CM_STD_OBJ_SMBIOS_TABLE_INFO
;
129 typedef struct SmbiosTableGenerator SMBIOS_TABLE_GENERATOR
;
131 /** This function pointer describes the interface to SMBIOS table build
132 functions provided by the SMBIOS table generator and called by the
133 Table Manager to build an SMBIOS table.
135 @param [in] Generator Pointer to the SMBIOS table generator.
136 @param [in] SmbiosTableInfo Pointer to the SMBIOS table information.
137 @param [in] CfgMgrProtocol Pointer to the Configuration Manager
139 @param [out] Table Pointer to the generated SMBIOS table.
141 @return EFI_SUCCESS If the table is generated successfully or other
142 failure codes as returned by the generator.
144 typedef EFI_STATUS (*SMBIOS_TABLE_GENERATOR_BUILD_TABLE
) (
145 IN CONST SMBIOS_TABLE_GENERATOR
* Generator
,
146 IN CM_STD_OBJ_SMBIOS_TABLE_INFO
* CONST SmbiosTableInfo
,
147 IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL
* CONST CfgMgrProtocol
,
148 OUT SMBIOS_STRUCTURE
** Table
151 /** This function pointer describes the interface to used by the
152 Table Manager to give the generator an opportunity to free
153 any resources allocated for building the SMBIOS table.
155 @param [in] Generator Pointer to the SMBIOS table generator.
156 @param [in] SmbiosTableInfo Pointer to the SMBIOS table information.
157 @param [in] CfgMgrProtocol Pointer to the Configuration Manager
159 @param [in] Table Pointer to the generated SMBIOS table.
161 @return EFI_SUCCESS If freed successfully or other failure codes
162 as returned by the generator.
164 typedef EFI_STATUS (*SMBIOS_TABLE_GENERATOR_FREE_TABLE
) (
165 IN CONST SMBIOS_TABLE_GENERATOR
* Generator
,
166 IN CONST CM_STD_OBJ_SMBIOS_TABLE_INFO
* CONST SmbiosTableInfo
,
167 IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL
* CONST CfgMgrProtocol
,
168 IN SMBIOS_STRUCTURE
** Table
171 /** The SMBIOS_TABLE_GENERATOR structure provides an interface that the
172 Table Manager can use to invoke the functions to build SMBIOS tables.
174 typedef struct SmbiosTableGenerator
{
175 /// The SMBIOS table generator ID.
176 SMBIOS_TABLE_GENERATOR_ID GeneratorID
;
178 /// String describing the DT table
180 CONST CHAR16
* Description
;
182 /// The SMBIOS table type.
185 /// SMBIOS table build function pointer.
186 SMBIOS_TABLE_GENERATOR_BUILD_TABLE BuildSmbiosTable
;
188 /** The function to free any resources
189 allocated for building the SMBIOS table.
191 SMBIOS_TABLE_GENERATOR_FREE_TABLE FreeTableResources
;
192 } SMBIOS_TABLE_GENERATOR
;
194 /** Register SMBIOS table factory generator.
196 The SMBIOS table factory maintains a list of the Standard and OEM SMBIOS
199 @param [in] Generator Pointer to the SMBIOS table generator.
201 @retval EFI_SUCCESS The Generator was registered
203 @retval EFI_INVALID_PARAMETER The Generator ID is invalid or
204 the Generator pointer is NULL.
205 @retval EFI_ALREADY_STARTED The Generator for the Table ID is
210 RegisterSmbiosTableGenerator (
211 IN CONST SMBIOS_TABLE_GENERATOR
* CONST Generator
214 /** Deregister SMBIOS generator.
216 This function is called by the SMBIOS table generator to deregister itself
217 from the SMBIOS table factory.
219 @param [in] Generator Pointer to the SMBIOS table generator.
221 @retval EFI_SUCCESS Success.
222 @retval EFI_INVALID_PARAMETER The generator is invalid.
223 @retval EFI_NOT_FOUND The requested generator is not found
224 in the list of registered generators.
228 DeregisterSmbiosTableGenerator (
229 IN CONST SMBIOS_TABLE_GENERATOR
* CONST Generator
233 #endif // SMBIOS_TABLE_GENERATOR_H_