3 Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef SMBIOS_TABLE_GENERATOR_H_
16 #define SMBIOS_TABLE_GENERATOR_H_
18 #include <IndustryStandard/SmBios.h>
20 #include <TableGenerator.h>
24 /** The SMBIOS_TABLE_GENERATOR_ID type describes SMBIOS table generator ID.
26 typedef TABLE_GENERATOR_ID SMBIOS_TABLE_GENERATOR_ID
;
28 /** The ESTD_SMBIOS_TABLE_ID enum describes the SMBIOS table IDs reserved for
29 the standard generators.
31 NOTE: The SMBIOS Generator IDs do not match the table type numbers!
32 This allows 0 to be used to catch invalid parameters.
34 typedef enum StdSmbiosTableGeneratorId
{
35 EStdSmbiosTableIdReserved
= 0x0000,
37 EStdSmbiosTableIdType00
,
38 EStdSmbiosTableIdType01
,
39 EStdSmbiosTableIdType02
,
40 EStdSmbiosTableIdType03
,
41 EStdSmbiosTableIdType04
,
42 EStdSmbiosTableIdType05
,
43 EStdSmbiosTableIdType06
,
44 EStdSmbiosTableIdType07
,
45 EStdSmbiosTableIdType08
,
46 EStdSmbiosTableIdType09
,
47 EStdSmbiosTableIdType10
,
48 EStdSmbiosTableIdType11
,
49 EStdSmbiosTableIdType12
,
50 EStdSmbiosTableIdType13
,
51 EStdSmbiosTableIdType14
,
52 EStdSmbiosTableIdType15
,
53 EStdSmbiosTableIdType16
,
54 EStdSmbiosTableIdType17
,
55 EStdSmbiosTableIdType18
,
56 EStdSmbiosTableIdType19
,
57 EStdSmbiosTableIdType20
,
58 EStdSmbiosTableIdType21
,
59 EStdSmbiosTableIdType22
,
60 EStdSmbiosTableIdType23
,
61 EStdSmbiosTableIdType24
,
62 EStdSmbiosTableIdType25
,
63 EStdSmbiosTableIdType26
,
64 EStdSmbiosTableIdType27
,
65 EStdSmbiosTableIdType28
,
66 EStdSmbiosTableIdType29
,
67 EStdSmbiosTableIdType30
,
68 EStdSmbiosTableIdType31
,
69 EStdSmbiosTableIdType32
,
70 EStdSmbiosTableIdType33
,
71 EStdSmbiosTableIdType34
,
72 EStdSmbiosTableIdType35
,
73 EStdSmbiosTableIdType36
,
74 EStdSmbiosTableIdType37
,
75 EStdSmbiosTableIdType38
,
76 EStdSmbiosTableIdType39
,
77 EStdSmbiosTableIdType40
,
78 EStdSmbiosTableIdType41
,
79 EStdSmbiosTableIdType42
,
81 // IDs 43 - 125 are reserved
83 EStdSmbiosTableIdType126
= (EStdSmbiosTableIdType00
+ 126),
84 EStdSmbiosTableIdType127
,
86 } ESTD_SMBIOS_TABLE_ID
;
88 /** This macro checks if the Table Generator ID is for an SMBIOS Table
91 @param [in] TableGeneratorId The table generator ID.
93 @return TRUE if the table generator ID is for an SMBIOS Table
96 #define IS_GENERATOR_TYPE_SMBIOS(TableGeneratorId) \
98 GET_TABLE_TYPE (TableGeneratorId) == \
99 ETableGeneratorTypeSmbios \
102 /** This macro checks if the Table Generator ID is for a standard SMBIOS
105 @param [in] TableGeneratorId The table generator ID.
107 @return TRUE if the table generator ID is for a standard SMBIOS
110 #define IS_VALID_STD_SMBIOS_GENERATOR_ID(TableGeneratorId) \
112 IS_GENERATOR_NAMESPACE_STD(TableGeneratorId) && \
113 IS_GENERATOR_TYPE_SMBIOS(TableGeneratorId) && \
114 ((GET_TABLE_ID(GeneratorId) >= EStdSmbiosTableIdRaw) && \
115 (GET_TABLE_ID(GeneratorId) < EStdSmbiosTableIdMax)) \
118 /** This macro creates a standard SMBIOS Table Generator ID.
120 @param [in] TableId The table generator ID.
122 @return a standard SMBIOS table generator ID.
124 #define CREATE_STD_SMBIOS_TABLE_GEN_ID(TableId) \
125 CREATE_TABLE_GEN_ID ( \
126 ETableGeneratorTypeSmbios, \
127 ETableGeneratorNameSpaceStd, \
131 /** Forward declarations.
133 typedef struct ConfigurationManagerProtocol EDKII_CONFIGURATION_MANAGER_PROTOCOL
;
134 typedef struct CmStdObjSmbiosTableInfo CM_STD_OBJ_SMBIOS_TABLE_INFO
;
135 typedef struct SmbiosTableGenerator SMBIOS_TABLE_GENERATOR
;
137 /** This function pointer describes the interface to SMBIOS table build
138 functions provided by the SMBIOS table generator and called by the
139 Table Manager to build an SMBIOS table.
141 @param [in] Generator Pointer to the SMBIOS table generator.
142 @param [in] SmbiosTableInfo Pointer to the SMBIOS table information.
143 @param [in] CfgMgrProtocol Pointer to the Configuration Manager
145 @param [out] Table Pointer to the generated SMBIOS table.
147 @return EFI_SUCCESS If the table is generated successfully or other
148 failure codes as returned by the generator.
150 typedef EFI_STATUS (*SMBIOS_TABLE_GENERATOR_BUILD_TABLE
) (
151 IN CONST SMBIOS_TABLE_GENERATOR
* Generator
,
152 IN CM_STD_OBJ_SMBIOS_TABLE_INFO
* CONST SmbiosTableInfo
,
153 IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL
* CONST CfgMgrProtocol
,
154 OUT SMBIOS_STRUCTURE
** Table
157 /** This function pointer describes the interface to used by the
158 Table Manager to give the generator an opportunity to free
159 any resources allocated for building the SMBIOS table.
161 @param [in] Generator Pointer to the SMBIOS table generator.
162 @param [in] SmbiosTableInfo Pointer to the SMBIOS table information.
163 @param [in] CfgMgrProtocol Pointer to the Configuration Manager
165 @param [in] Table Pointer to the generated SMBIOS table.
167 @return EFI_SUCCESS If freed successfully or other failure codes
168 as returned by the generator.
170 typedef EFI_STATUS (*SMBIOS_TABLE_GENERATOR_FREE_TABLE
) (
171 IN CONST SMBIOS_TABLE_GENERATOR
* Generator
,
172 IN CONST CM_STD_OBJ_SMBIOS_TABLE_INFO
* CONST SmbiosTableInfo
,
173 IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL
* CONST CfgMgrProtocol
,
174 IN SMBIOS_STRUCTURE
** Table
177 /** The SMBIOS_TABLE_GENERATOR structure provides an interface that the
178 Table Manager can use to invoke the functions to build SMBIOS tables.
180 typedef struct SmbiosTableGenerator
{
181 /// The SMBIOS table generator ID.
182 SMBIOS_TABLE_GENERATOR_ID GeneratorID
;
184 /// String describing the DT table
186 CONST CHAR16
* Description
;
188 /// The SMBIOS table type.
191 /// SMBIOS table build function pointer.
192 SMBIOS_TABLE_GENERATOR_BUILD_TABLE BuildSmbiosTable
;
194 /** The function to free any resources
195 allocated for building the SMBIOS table.
197 SMBIOS_TABLE_GENERATOR_FREE_TABLE FreeTableResources
;
198 } SMBIOS_TABLE_GENERATOR
;
200 /** Register SMBIOS table factory generator.
202 The SMBIOS table factory maintains a list of the Standard and OEM SMBIOS
205 @param [in] Generator Pointer to the SMBIOS table generator.
207 @retval EFI_SUCCESS The Generator was registered
209 @retval EFI_INVALID_PARAMETER The Generator ID is invalid or
210 the Generator pointer is NULL.
211 @retval EFI_ALREADY_STARTED The Generator for the Table ID is
216 RegisterSmbiosTableGenerator (
217 IN CONST SMBIOS_TABLE_GENERATOR
* CONST Generator
220 /** Deregister SMBIOS generator.
222 This function is called by the SMBIOS table generator to deregister itself
223 from the SMBIOS table factory.
225 @param [in] Generator Pointer to the SMBIOS table generator.
227 @retval EFI_SUCCESS Success.
228 @retval EFI_INVALID_PARAMETER The generator is invalid.
229 @retval EFI_NOT_FOUND The requested generator is not found
230 in the list of registered generators.
234 DeregisterSmbiosTableGenerator (
235 IN CONST SMBIOS_TABLE_GENERATOR
* CONST Generator
239 #endif // SMBIOS_TABLE_GENERATOR_H_