3 Copyright (c) 2017 - 2021, Arm Limited. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
8 - Cm or CM - Configuration Manager
10 - Std or STD - Standard
13 #ifndef ACPI_TABLE_GENERATOR_H_
14 #define ACPI_TABLE_GENERATOR_H_
16 #include <IndustryStandard/Acpi.h>
18 // Module specific include files.
19 #include <TableGenerator.h>
24 The Dynamic Tables Framework provisions two classes of ACPI table
26 - Standard generators: The ACPI table generators implemented by the
27 Dynamic Tables Framework.
28 - OEM generators: The ACPI table generators customized by the OEM.
30 The Dynamic Tables Framework implements the following ACPI table generators:
31 - RAW : This is the simplest ACPI table generator. It simply installs
32 the ACPI table provided in the AcpiTableData member of the
33 CM_STD_OBJ_ACPI_TABLE_INFO. The ACPI table data is provided by
34 the Configuration Manager and is generated using an implementation
36 - DSDT : The DSDT generator is a clone of the RAW generator. The difference
37 is in the way the ACPI Table Data is generated from an AML file.
38 - SSDT : The SSDT generator is a clone of the RAW generator. The difference
39 is in the way the ACPI Table Data is generated from an AML file.
40 - FADT : The FADT generator collates the required platform information from
41 the Configuration Manager and builds the FADT table.
42 - MADT : The MADT generator collates the GIC information from the
43 Configuration Manager and builds the MADT table.
44 - GTDT : The GTDT generator collates the Timer information from the
45 Configuration Manager and builds the GTDT table.
46 - DBG2 : The DBG2 generator collates the debug serial port information from
47 the Configuration Manager and builds the DBG2 table.
48 - SPCR : The SPCR generator collates the serial port information from the
49 Configuration Manager and builds the SPCR table.
50 - MCFG : The MCFG generator collates the PCI configuration space information
51 from the Configuration Manager and builds the MCFG table.
52 - IORT : The IORT generator collates the IO Topology information from the
53 Configuration Manager and builds the IORT table.
54 - PPTT : The PPTT generator collates the processor topology information from
55 the Configuration Manager and builds the PPTT table.
56 - SRAT : The SRAT generator collates the system resource affinity information
57 from the Configuration Manager and builds the SRAT table.
59 The SSDT Serial generator collates the Serial port information
60 from the Configuration Manager and patches the SSDT Serial Port
61 template to build the SSDT Serial port table.
63 The SSDT CMN-600 generator collates the CMN-600 information
64 from the Configuration Manager and patches the SSDT CMN-600
65 template to build the SSDT CMN-600 table.
67 The SSDT Cpu-Topology generator collates the cpu and LPI
68 information from the Configuration Manager and generates a
69 SSDT table describing the CPU hierarchy.
71 The SSDT Pci Express generator collates the Pci Express
72 information from the Configuration Manager and generates a
73 SSDT table describing a Pci Express bus.
76 /** The ACPI_TABLE_GENERATOR_ID type describes ACPI table generator ID.
78 typedef TABLE_GENERATOR_ID ACPI_TABLE_GENERATOR_ID
;
80 /** The ESTD_ACPI_TABLE_ID enum describes the ACPI table IDs reserved for
81 the standard generators.
83 typedef enum StdAcpiTableId
{
84 EStdAcpiTableIdReserved
= 0x0000, ///< Reserved
85 EStdAcpiTableIdRaw
, ///< RAW Generator
86 EStdAcpiTableIdDsdt
= EStdAcpiTableIdRaw
, ///< DSDT Generator
87 EStdAcpiTableIdSsdt
= EStdAcpiTableIdRaw
, ///< SSDT Generator
88 EStdAcpiTableIdFadt
, ///< FADT Generator
89 EStdAcpiTableIdMadt
, ///< MADT Generator
90 EStdAcpiTableIdGtdt
, ///< GTDT Generator
91 EStdAcpiTableIdDbg2
, ///< DBG2 Generator
92 EStdAcpiTableIdSpcr
, ///< SPCR Generator
93 EStdAcpiTableIdMcfg
, ///< MCFG Generator
94 EStdAcpiTableIdIort
, ///< IORT Generator
95 EStdAcpiTableIdPptt
, ///< PPTT Generator
96 EStdAcpiTableIdSrat
, ///< SRAT Generator
97 EStdAcpiTableIdSsdtSerialPort
, ///< SSDT Serial-Port Generator
98 EStdAcpiTableIdSsdtCmn600
, ///< SSDT Cmn-600 Generator
99 EStdAcpiTableIdSsdtCpuTopology
, ///< SSDT Cpu Topology
100 EStdAcpiTableIdSsdtPciExpress
, ///< SSDT Pci Express Generator
102 } ESTD_ACPI_TABLE_ID
;
104 /** This macro checks if the Table Generator ID is for an ACPI Table Generator.
106 @param [in] TableGeneratorId The table generator ID.
108 @return TRUE if the table generator ID is for an ACPI Table
111 #define IS_GENERATOR_TYPE_ACPI(TableGeneratorId) \
112 (GET_TABLE_TYPE (TableGeneratorId) == ETableGeneratorTypeAcpi)
114 /** This macro checks if the Table Generator ID is for a standard ACPI
117 @param [in] TableGeneratorId The table generator ID.
119 @return TRUE if the table generator ID is for a standard ACPI
122 #define IS_VALID_STD_ACPI_GENERATOR_ID(TableGeneratorId) \
124 IS_GENERATOR_NAMESPACE_STD (TableGeneratorId) && \
125 IS_GENERATOR_TYPE_ACPI (TableGeneratorId) && \
126 ((GET_TABLE_ID (GeneratorId) >= EStdAcpiTableIdRaw) && \
127 (GET_TABLE_ID (GeneratorId) < EStdAcpiTableIdMax)) \
130 /** This macro creates a standard ACPI Table Generator ID.
132 @param [in] TableId The table generator ID.
134 @return a standard ACPI table generator ID.
136 #define CREATE_STD_ACPI_TABLE_GEN_ID(TableId) \
137 CREATE_TABLE_GEN_ID ( \
138 ETableGeneratorTypeAcpi, \
139 ETableGeneratorNameSpaceStd, \
143 /** This macro creates an OEM ACPI Table Generator ID.
145 @param [in] TableId The table generator ID.
147 @return an OEM ACPI table generator ID.
149 #define CREATE_OEM_ACPI_TABLE_GEN_ID(TableId) \
150 CREATE_TABLE_GEN_ID ( \
151 ETableGeneratorTypeAcpi, \
152 ETableGeneratorNameSpaceOem, \
156 /** The Creator ID for the ACPI tables generated using
157 the standard ACPI table generators.
159 #define TABLE_GENERATOR_CREATOR_ID_ARM SIGNATURE_32('A', 'R', 'M', 'H')
161 /** A macro to initialise the common header part of EFI ACPI tables as
162 defined by the EFI_ACPI_DESCRIPTION_HEADER structure.
164 @param [in] Signature The ACPI table signature.
165 @param [in] Type The ACPI table structure.
166 @param [in] Revision The ACPI table revision.
168 #define ACPI_HEADER(Signature, Type, Revision) { \
169 Signature, /* UINT32 Signature */ \
170 sizeof (Type), /* UINT32 Length */ \
171 Revision, /* UINT8 Revision */ \
172 0, /* UINT8 Checksum */ \
173 { 0, 0, 0, 0, 0, 0 }, /* UINT8 OemId[6] */ \
174 0, /* UINT64 OemTableId */ \
175 0, /* UINT32 OemRevision */ \
176 0, /* UINT32 CreatorId */ \
177 0 /* UINT32 CreatorRevision */ \
180 /** A macro to dump the common header part of EFI ACPI tables as
181 defined by the EFI_ACPI_DESCRIPTION_HEADER structure.
183 @param [in] AcpiHeader The pointer to the ACPI table header.
185 #define DUMP_ACPI_TABLE_HEADER(AcpiHeader) \
188 "ACPI TABLE %c%c%c%c : Rev 0x%x : Length : 0x%x\n", \
189 (AcpiHeader->Signature & 0xFF), \
190 ((AcpiHeader->Signature >> 8) & 0xFF), \
191 ((AcpiHeader->Signature >> 16) & 0xFF), \
192 ((AcpiHeader->Signature >> 24) & 0xFF), \
193 AcpiHeader->Revision, \
197 /** Forward declarations.
199 typedef struct ConfigurationManagerProtocol EDKII_CONFIGURATION_MANAGER_PROTOCOL
;
200 typedef struct CmAStdObjAcpiTableInfo CM_STD_OBJ_ACPI_TABLE_INFO
;
201 typedef struct AcpiTableGenerator ACPI_TABLE_GENERATOR
;
203 /** This function pointer describes the interface to ACPI table build
204 functions provided by the ACPI table generator and called by the
205 Table Manager to build an ACPI table.
207 @param [in] This Pointer to the ACPI table generator.
208 @param [in] AcpiTableInfo Pointer to the ACPI table information.
209 @param [in] CfgMgrProtocol Pointer to the Configuration Manager
211 @param [out] Table Pointer to the generated ACPI table.
213 @return EFI_SUCCESS If the table is generated successfully or other
214 failure codes as returned by the generator.
216 typedef EFI_STATUS (*ACPI_TABLE_GENERATOR_BUILD_TABLE
) (
217 IN CONST ACPI_TABLE_GENERATOR
*This
,
218 IN CONST CM_STD_OBJ_ACPI_TABLE_INFO
*CONST AcpiTableInfo
,
219 IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL
*CONST CfgMgrProtocol
,
220 OUT EFI_ACPI_DESCRIPTION_HEADER
**Table
223 /** This function pointer describes the interface used by the
224 Table Manager to give the generator an opportunity to free
225 any resources allocated for building the ACPI table.
227 @param [in] This Pointer to the ACPI table generator.
228 @param [in] AcpiTableInfo Pointer to the ACPI Table Info.
229 @param [in] CfgMgrProtocol Pointer to the Configuration Manager
231 @param [in, out] Table Pointer to the ACPI Table.
233 @return EFI_SUCCESS If freed successfully or other failure codes
234 as returned by the generator.
236 typedef EFI_STATUS (*ACPI_TABLE_GENERATOR_FREE_TABLE
) (
237 IN CONST ACPI_TABLE_GENERATOR
*CONST This
,
238 IN CONST CM_STD_OBJ_ACPI_TABLE_INFO
*CONST AcpiTableInfo
,
239 IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL
*CONST CfgMgrProtocol
,
240 IN OUT EFI_ACPI_DESCRIPTION_HEADER
**CONST Table
243 /** This function pointer describes an extended interface to build
244 ACPI Tables. The ACPI table generator can generate multiple
245 ACPI Tables and return a pointer to the list of ACPI tables.
246 The FreeTableResourcesEx() must be called to free any resources
247 that may have been allocated using this interface.
249 @param [in] This Pointer to the ACPI table generator.
250 @param [in] AcpiTableInfo Pointer to the ACPI table information.
251 @param [in] CfgMgrProtocol Pointer to the Configuration Manager
253 @param [out] Table Pointer to a list of generated ACPI table(s).
254 @param [out] TableCount Number of generated ACPI table(s).
256 @return EFI_SUCCESS If the table is generated successfully or other
257 failure codes as returned by the generator.
259 typedef EFI_STATUS (*ACPI_TABLE_GENERATOR_BUILD_TABLEEX
) (
260 IN CONST ACPI_TABLE_GENERATOR
*This
,
261 IN CONST CM_STD_OBJ_ACPI_TABLE_INFO
*CONST AcpiTableInfo
,
262 IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL
*CONST CfgMgrProtocol
,
263 OUT EFI_ACPI_DESCRIPTION_HEADER
***Table
,
264 OUT UINTN
*CONST TableCount
267 /** This function pointer describes an extended interface used by the
268 Table Manager to give the generator an opportunity to free
269 any resources allocated for building the ACPI table. This interface
270 must be used in conjunction with the BuildAcpiTableEx interface.
272 @param [in] This Pointer to the ACPI table generator.
273 @param [in] AcpiTableInfo Pointer to the ACPI Table Info.
274 @param [in] CfgMgrProtocol Pointer to the Configuration Manager
276 @param [in, out] Table Pointer to the list of ACPI Table(s).
277 @param [in] TableCount Number of ACPI table(s).
279 @return EFI_SUCCESS If freed successfully or other failure codes
280 as returned by the generator.
282 typedef EFI_STATUS (*ACPI_TABLE_GENERATOR_FREE_TABLEEX
) (
283 IN CONST ACPI_TABLE_GENERATOR
*CONST This
,
284 IN CONST CM_STD_OBJ_ACPI_TABLE_INFO
*CONST AcpiTableInfo
,
285 IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL
*CONST CfgMgrProtocol
,
286 IN OUT EFI_ACPI_DESCRIPTION_HEADER
***CONST Table
,
287 IN CONST UINTN TableCount
290 /** The ACPI_TABLE_GENERATOR structure provides an interface that the
291 Table Manager can use to invoke the functions to build ACPI tables.
293 Note: Although the Generator is required to implement at least
294 one pair of interfaces (BuildAcpiTable & FreeTableResources or
295 BuildAcpiTableEx & FreeTableResourcesEx) for generating the ACPI
296 table(s), if both pair of interfaces are implemented the extended
297 version will take precedence.
299 typedef struct AcpiTableGenerator
{
300 /// The ACPI table generator ID.
301 ACPI_TABLE_GENERATOR_ID GeneratorID
;
303 /// String describing the ACPI table generator.
304 CONST CHAR16
*Description
;
306 /// The ACPI table signature.
307 UINT32 AcpiTableSignature
;
309 /// The ACPI table revision.
310 UINT8 AcpiTableRevision
;
312 /// The minimum supported ACPI table revision.
313 UINT8 MinAcpiTableRevision
;
315 /// The ACPI table creator ID.
318 /// The ACPI table creator revision.
319 UINT32 CreatorRevision
;
321 /// ACPI table build function pointer.
322 ACPI_TABLE_GENERATOR_BUILD_TABLE BuildAcpiTable
;
324 /** The function to free any resources
325 allocated for building the ACPI table.
327 ACPI_TABLE_GENERATOR_FREE_TABLE FreeTableResources
;
329 /// ACPI table extended build function pointer.
330 ACPI_TABLE_GENERATOR_BUILD_TABLEEX BuildAcpiTableEx
;
332 /** The function to free any resources
333 allocated for building the ACPI table
334 using the extended interface.
336 ACPI_TABLE_GENERATOR_FREE_TABLEEX FreeTableResourcesEx
;
337 } ACPI_TABLE_GENERATOR
;
339 /** Register ACPI table factory generator.
341 The ACPI table factory maintains a list of the Standard and OEM ACPI
344 @param [in] Generator Pointer to the ACPI table generator.
346 @retval EFI_SUCCESS The Generator was registered
348 @retval EFI_INVALID_PARAMETER The Generator ID is invalid or
349 the Generator pointer is NULL.
350 @retval EFI_ALREADY_STARTED The Generator for the Table ID is
355 RegisterAcpiTableGenerator (
356 IN CONST ACPI_TABLE_GENERATOR
*CONST Generator
359 /** Deregister ACPI generator.
361 This function is called by the ACPI table generator to deregister itself
362 from the ACPI table factory.
364 @param [in] Generator Pointer to the ACPI table generator.
366 @retval EFI_SUCCESS Success.
367 @retval EFI_INVALID_PARAMETER The generator is invalid.
368 @retval EFI_NOT_FOUND The requested generator is not found
369 in the list of registered generators.
373 DeregisterAcpiTableGenerator (
374 IN CONST ACPI_TABLE_GENERATOR
*CONST Generator
379 #endif // ACPI_TABLE_GENERATOR_H_