1 | /** @file
|
---|
2 |
|
---|
3 | Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
|
---|
4 |
|
---|
5 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
6 |
|
---|
7 | @par Glossary:
|
---|
8 | - Cm or CM - Configuration Manager
|
---|
9 | - Obj or OBJ - Object
|
---|
10 | - Std or STD - Standard
|
---|
11 | **/
|
---|
12 |
|
---|
13 | #ifndef ACPI_TABLE_GENERATOR_H_
|
---|
14 | #define ACPI_TABLE_GENERATOR_H_
|
---|
15 |
|
---|
16 | #include <IndustryStandard/Acpi.h>
|
---|
17 |
|
---|
18 | // Module specific include files.
|
---|
19 | #include <TableGenerator.h>
|
---|
20 |
|
---|
21 | #pragma pack(1)
|
---|
22 |
|
---|
23 | /**
|
---|
24 | The Dynamic Tables Framework provisions two classes of ACPI table
|
---|
25 | generators.
|
---|
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.
|
---|
29 |
|
---|
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
|
---|
35 | defined mechanism.
|
---|
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.
|
---|
58 | */
|
---|
59 |
|
---|
60 | /** The ACPI_TABLE_GENERATOR_ID type describes ACPI table generator ID.
|
---|
61 | */
|
---|
62 | typedef TABLE_GENERATOR_ID ACPI_TABLE_GENERATOR_ID;
|
---|
63 |
|
---|
64 | /** The ESTD_ACPI_TABLE_ID enum describes the ACPI table IDs reserved for
|
---|
65 | the standard generators.
|
---|
66 | */
|
---|
67 | typedef enum StdAcpiTableId {
|
---|
68 | EStdAcpiTableIdReserved = 0x0000, ///< Reserved
|
---|
69 | EStdAcpiTableIdRaw, ///< RAW Generator
|
---|
70 | EStdAcpiTableIdDsdt = EStdAcpiTableIdRaw, ///< DSDT Generator
|
---|
71 | EStdAcpiTableIdSsdt = EStdAcpiTableIdRaw, ///< SSDT Generator
|
---|
72 | EStdAcpiTableIdFadt, ///< FADT Generator
|
---|
73 | EStdAcpiTableIdMadt, ///< MADT Generator
|
---|
74 | EStdAcpiTableIdGtdt, ///< GTDT Generator
|
---|
75 | EStdAcpiTableIdDbg2, ///< DBG2 Generator
|
---|
76 | EStdAcpiTableIdSpcr, ///< SPCR Generator
|
---|
77 | EStdAcpiTableIdMcfg, ///< MCFG Generator
|
---|
78 | EStdAcpiTableIdIort, ///< IORT Generator
|
---|
79 | EStdAcpiTableIdPptt, ///< PPTT Generator
|
---|
80 | EStdAcpiTableIdSrat, ///< SRAT Generator
|
---|
81 | EStdAcpiTableIdMax
|
---|
82 | } ESTD_ACPI_TABLE_ID;
|
---|
83 |
|
---|
84 | /** This macro checks if the Table Generator ID is for an ACPI Table Generator.
|
---|
85 |
|
---|
86 | @param [in] TableGeneratorId The table generator ID.
|
---|
87 |
|
---|
88 | @return TRUE if the table generator ID is for an ACPI Table
|
---|
89 | Generator.
|
---|
90 | **/
|
---|
91 | #define IS_GENERATOR_TYPE_ACPI(TableGeneratorId) \
|
---|
92 | (GET_TABLE_TYPE (TableGeneratorId) == ETableGeneratorTypeAcpi)
|
---|
93 |
|
---|
94 | /** This macro checks if the Table Generator ID is for a standard ACPI
|
---|
95 | Table Generator.
|
---|
96 |
|
---|
97 | @param [in] TableGeneratorId The table generator ID.
|
---|
98 |
|
---|
99 | @return TRUE if the table generator ID is for a standard ACPI
|
---|
100 | Table Generator.
|
---|
101 | **/
|
---|
102 | #define IS_VALID_STD_ACPI_GENERATOR_ID(TableGeneratorId) \
|
---|
103 | ( \
|
---|
104 | IS_GENERATOR_NAMESPACE_STD (TableGeneratorId) && \
|
---|
105 | IS_GENERATOR_TYPE_ACPI (TableGeneratorId) && \
|
---|
106 | ((GET_TABLE_ID (GeneratorId) >= EStdAcpiTableIdRaw) && \
|
---|
107 | (GET_TABLE_ID (GeneratorId) < EStdAcpiTableIdMax)) \
|
---|
108 | )
|
---|
109 |
|
---|
110 | /** This macro creates a standard ACPI Table Generator ID.
|
---|
111 |
|
---|
112 | @param [in] TableId The table generator ID.
|
---|
113 |
|
---|
114 | @return a standard ACPI table generator ID.
|
---|
115 | **/
|
---|
116 | #define CREATE_STD_ACPI_TABLE_GEN_ID(TableId) \
|
---|
117 | CREATE_TABLE_GEN_ID ( \
|
---|
118 | ETableGeneratorTypeAcpi, \
|
---|
119 | ETableGeneratorNameSpaceStd, \
|
---|
120 | TableId \
|
---|
121 | )
|
---|
122 |
|
---|
123 | /** This macro creates an OEM ACPI Table Generator ID.
|
---|
124 |
|
---|
125 | @param [in] TableId The table generator ID.
|
---|
126 |
|
---|
127 | @return an OEM ACPI table generator ID.
|
---|
128 | **/
|
---|
129 | #define CREATE_OEM_ACPI_TABLE_GEN_ID(TableId) \
|
---|
130 | CREATE_TABLE_GEN_ID ( \
|
---|
131 | ETableGeneratorTypeAcpi, \
|
---|
132 | ETableGeneratorNameSpaceOem, \
|
---|
133 | TableId \
|
---|
134 | )
|
---|
135 |
|
---|
136 | /** The Creator ID for the ACPI tables generated using
|
---|
137 | the standard ACPI table generators.
|
---|
138 | */
|
---|
139 | #define TABLE_GENERATOR_CREATOR_ID_ARM SIGNATURE_32('A', 'R', 'M', 'H')
|
---|
140 |
|
---|
141 | /** A macro to initialise the common header part of EFI ACPI tables as
|
---|
142 | defined by the EFI_ACPI_DESCRIPTION_HEADER structure.
|
---|
143 |
|
---|
144 | @param [in] Signature The ACPI table signature.
|
---|
145 | @param [in] Type The ACPI table structure.
|
---|
146 | @param [in] Revision The ACPI table revision.
|
---|
147 | **/
|
---|
148 | #define ACPI_HEADER(Signature, Type, Revision) { \
|
---|
149 | Signature, /* UINT32 Signature */ \
|
---|
150 | sizeof (Type), /* UINT32 Length */ \
|
---|
151 | Revision, /* UINT8 Revision */ \
|
---|
152 | 0, /* UINT8 Checksum */ \
|
---|
153 | { 0, 0, 0, 0, 0, 0 }, /* UINT8 OemId[6] */ \
|
---|
154 | 0, /* UINT64 OemTableId */ \
|
---|
155 | 0, /* UINT32 OemRevision */ \
|
---|
156 | 0, /* UINT32 CreatorId */ \
|
---|
157 | 0 /* UINT32 CreatorRevision */\
|
---|
158 | }
|
---|
159 |
|
---|
160 | /** A macro to dump the common header part of EFI ACPI tables as
|
---|
161 | defined by the EFI_ACPI_DESCRIPTION_HEADER structure.
|
---|
162 |
|
---|
163 | @param [in] AcpiHeader The pointer to the ACPI table header.
|
---|
164 | **/
|
---|
165 | #define DUMP_ACPI_TABLE_HEADER(AcpiHeader) \
|
---|
166 | DEBUG (( \
|
---|
167 | DEBUG_INFO, \
|
---|
168 | "ACPI TABLE %c%c%c%c : Rev 0x%x : Length : 0x%x\n", \
|
---|
169 | (AcpiHeader->Signature & 0xFF), \
|
---|
170 | ((AcpiHeader->Signature >> 8) & 0xFF), \
|
---|
171 | ((AcpiHeader->Signature >> 16) & 0xFF), \
|
---|
172 | ((AcpiHeader->Signature >> 24) & 0xFF), \
|
---|
173 | AcpiHeader->Revision, \
|
---|
174 | AcpiHeader->Length \
|
---|
175 | ));
|
---|
176 |
|
---|
177 | /** Forward declarations.
|
---|
178 | */
|
---|
179 | typedef struct ConfigurationManagerProtocol EDKII_CONFIGURATION_MANAGER_PROTOCOL;
|
---|
180 | typedef struct CmAStdObjAcpiTableInfo CM_STD_OBJ_ACPI_TABLE_INFO;
|
---|
181 | typedef struct AcpiTableGenerator ACPI_TABLE_GENERATOR;
|
---|
182 |
|
---|
183 | /** This function pointer describes the interface to ACPI table build
|
---|
184 | functions provided by the ACPI table generator and called by the
|
---|
185 | Table Manager to build an ACPI table.
|
---|
186 |
|
---|
187 | @param [in] This Pointer to the ACPI table generator.
|
---|
188 | @param [in] AcpiTableInfo Pointer to the ACPI table information.
|
---|
189 | @param [in] CfgMgrProtocol Pointer to the Configuration Manager
|
---|
190 | Protocol interface.
|
---|
191 | @param [out] Table Pointer to the generated ACPI table.
|
---|
192 |
|
---|
193 | @return EFI_SUCCESS If the table is generated successfully or other
|
---|
194 | failure codes as returned by the generator.
|
---|
195 | **/
|
---|
196 | typedef EFI_STATUS (*ACPI_TABLE_GENERATOR_BUILD_TABLE) (
|
---|
197 | IN CONST ACPI_TABLE_GENERATOR * This,
|
---|
198 | IN CONST CM_STD_OBJ_ACPI_TABLE_INFO * CONST AcpiTableInfo,
|
---|
199 | IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol,
|
---|
200 | OUT EFI_ACPI_DESCRIPTION_HEADER ** Table
|
---|
201 | );
|
---|
202 |
|
---|
203 | /** This function pointer describes the interface used by the
|
---|
204 | Table Manager to give the generator an opportunity to free
|
---|
205 | any resources allocated for building the ACPI table.
|
---|
206 |
|
---|
207 | @param [in] This Pointer to the ACPI table generator.
|
---|
208 | @param [in] AcpiTableInfo Pointer to the ACPI Table Info.
|
---|
209 | @param [in] CfgMgrProtocol Pointer to the Configuration Manager
|
---|
210 | Protocol Interface.
|
---|
211 | @param [in, out] Table Pointer to the ACPI Table.
|
---|
212 |
|
---|
213 | @return EFI_SUCCESS If freed successfully or other failure codes
|
---|
214 | as returned by the generator.
|
---|
215 | **/
|
---|
216 | typedef EFI_STATUS (*ACPI_TABLE_GENERATOR_FREE_TABLE) (
|
---|
217 | IN CONST ACPI_TABLE_GENERATOR * CONST This,
|
---|
218 | IN CONST CM_STD_OBJ_ACPI_TABLE_INFO * CONST AcpiTableInfo,
|
---|
219 | IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol,
|
---|
220 | IN OUT EFI_ACPI_DESCRIPTION_HEADER ** CONST Table
|
---|
221 | );
|
---|
222 |
|
---|
223 | /** This function pointer describes an extended interface to build
|
---|
224 | ACPI Tables. The ACPI table generator can generate multiple
|
---|
225 | ACPI Tables and return a pointer to the list of ACPI tables.
|
---|
226 | The FreeTableResourcesEx() must be called to free any resources
|
---|
227 | that may have been allocated using this interface.
|
---|
228 |
|
---|
229 | @param [in] This Pointer to the ACPI table generator.
|
---|
230 | @param [in] AcpiTableInfo Pointer to the ACPI table information.
|
---|
231 | @param [in] CfgMgrProtocol Pointer to the Configuration Manager
|
---|
232 | Protocol interface.
|
---|
233 | @param [out] Table Pointer to a list of generated ACPI table(s).
|
---|
234 | @param [out] TableCount Number of generated ACPI table(s).
|
---|
235 |
|
---|
236 | @return EFI_SUCCESS If the table is generated successfully or other
|
---|
237 | failure codes as returned by the generator.
|
---|
238 | **/
|
---|
239 | typedef EFI_STATUS (*ACPI_TABLE_GENERATOR_BUILD_TABLEEX) (
|
---|
240 | IN CONST ACPI_TABLE_GENERATOR * This,
|
---|
241 | IN CONST CM_STD_OBJ_ACPI_TABLE_INFO * CONST AcpiTableInfo,
|
---|
242 | IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol,
|
---|
243 | OUT EFI_ACPI_DESCRIPTION_HEADER *** Table,
|
---|
244 | OUT UINTN * CONST TableCount
|
---|
245 | );
|
---|
246 |
|
---|
247 | /** This function pointer describes an extended interface used by the
|
---|
248 | Table Manager to give the generator an opportunity to free
|
---|
249 | any resources allocated for building the ACPI table. This interface
|
---|
250 | must be used in conjunction with the BuildAcpiTableEx interface.
|
---|
251 |
|
---|
252 | @param [in] This Pointer to the ACPI table generator.
|
---|
253 | @param [in] AcpiTableInfo Pointer to the ACPI Table Info.
|
---|
254 | @param [in] CfgMgrProtocol Pointer to the Configuration Manager
|
---|
255 | Protocol Interface.
|
---|
256 | @param [in, out] Table Pointer to the list of ACPI Table(s).
|
---|
257 | @param [in] TableCount Number of ACPI table(s).
|
---|
258 |
|
---|
259 | @return EFI_SUCCESS If freed successfully or other failure codes
|
---|
260 | as returned by the generator.
|
---|
261 | **/
|
---|
262 | typedef EFI_STATUS (*ACPI_TABLE_GENERATOR_FREE_TABLEEX) (
|
---|
263 | IN CONST ACPI_TABLE_GENERATOR * CONST This,
|
---|
264 | IN CONST CM_STD_OBJ_ACPI_TABLE_INFO * CONST AcpiTableInfo,
|
---|
265 | IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol,
|
---|
266 | IN OUT EFI_ACPI_DESCRIPTION_HEADER *** CONST Table,
|
---|
267 | IN CONST UINTN TableCount
|
---|
268 | );
|
---|
269 |
|
---|
270 | /** The ACPI_TABLE_GENERATOR structure provides an interface that the
|
---|
271 | Table Manager can use to invoke the functions to build ACPI tables.
|
---|
272 |
|
---|
273 | Note: Although the Generator is required to implement at least
|
---|
274 | one pair of interfaces (BuildAcpiTable & FreeTableResources or
|
---|
275 | BuildAcpiTableEx & FreeTableResourcesEx) for generating the ACPI
|
---|
276 | table(s), if both pair of interfaces are implemented the extended
|
---|
277 | version will take precedence.
|
---|
278 | **/
|
---|
279 | typedef struct AcpiTableGenerator {
|
---|
280 | /// The ACPI table generator ID.
|
---|
281 | ACPI_TABLE_GENERATOR_ID GeneratorID;
|
---|
282 |
|
---|
283 | /// String describing the ACPI table generator.
|
---|
284 | CONST CHAR16 * Description;
|
---|
285 |
|
---|
286 | /// The ACPI table signature.
|
---|
287 | UINT32 AcpiTableSignature;
|
---|
288 |
|
---|
289 | /// The ACPI table revision.
|
---|
290 | UINT8 AcpiTableRevision;
|
---|
291 |
|
---|
292 | /// The minimum supported ACPI table revision.
|
---|
293 | UINT8 MinAcpiTableRevision;
|
---|
294 |
|
---|
295 | /// The ACPI table creator ID.
|
---|
296 | UINT32 CreatorId;
|
---|
297 |
|
---|
298 | /// The ACPI table creator revision.
|
---|
299 | UINT32 CreatorRevision;
|
---|
300 |
|
---|
301 | /// ACPI table build function pointer.
|
---|
302 | ACPI_TABLE_GENERATOR_BUILD_TABLE BuildAcpiTable;
|
---|
303 |
|
---|
304 | /** The function to free any resources
|
---|
305 | allocated for building the ACPI table.
|
---|
306 | */
|
---|
307 | ACPI_TABLE_GENERATOR_FREE_TABLE FreeTableResources;
|
---|
308 |
|
---|
309 | /// ACPI table extended build function pointer.
|
---|
310 | ACPI_TABLE_GENERATOR_BUILD_TABLEEX BuildAcpiTableEx;
|
---|
311 |
|
---|
312 | /** The function to free any resources
|
---|
313 | allocated for building the ACPI table
|
---|
314 | using the extended interface.
|
---|
315 | */
|
---|
316 | ACPI_TABLE_GENERATOR_FREE_TABLEEX FreeTableResourcesEx;
|
---|
317 | } ACPI_TABLE_GENERATOR;
|
---|
318 |
|
---|
319 | /** Register ACPI table factory generator.
|
---|
320 |
|
---|
321 | The ACPI table factory maintains a list of the Standard and OEM ACPI
|
---|
322 | table generators.
|
---|
323 |
|
---|
324 | @param [in] Generator Pointer to the ACPI table generator.
|
---|
325 |
|
---|
326 | @retval EFI_SUCCESS The Generator was registered
|
---|
327 | successfully.
|
---|
328 | @retval EFI_INVALID_PARAMETER The Generator ID is invalid or
|
---|
329 | the Generator pointer is NULL.
|
---|
330 | @retval EFI_ALREADY_STARTED The Generator for the Table ID is
|
---|
331 | already registered.
|
---|
332 | **/
|
---|
333 | EFI_STATUS
|
---|
334 | EFIAPI
|
---|
335 | RegisterAcpiTableGenerator (
|
---|
336 | IN CONST ACPI_TABLE_GENERATOR * CONST Generator
|
---|
337 | );
|
---|
338 |
|
---|
339 | /** Deregister ACPI generator.
|
---|
340 |
|
---|
341 | This function is called by the ACPI table generator to deregister itself
|
---|
342 | from the ACPI table factory.
|
---|
343 |
|
---|
344 | @param [in] Generator Pointer to the ACPI table generator.
|
---|
345 |
|
---|
346 | @retval EFI_SUCCESS Success.
|
---|
347 | @retval EFI_INVALID_PARAMETER The generator is invalid.
|
---|
348 | @retval EFI_NOT_FOUND The requested generator is not found
|
---|
349 | in the list of registered generators.
|
---|
350 | **/
|
---|
351 | EFI_STATUS
|
---|
352 | EFIAPI
|
---|
353 | DeregisterAcpiTableGenerator (
|
---|
354 | IN CONST ACPI_TABLE_GENERATOR * CONST Generator
|
---|
355 | );
|
---|
356 |
|
---|
357 | #pragma pack()
|
---|
358 |
|
---|
359 | #endif // ACPI_TABLE_GENERATOR_H_
|
---|
360 |
|
---|