AcpiTableGenerator.h 17 KB

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