TableGenerator.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. /** @file
  2. Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
  3. SPDX-License-Identifier: BSD-2-Clause-Patent
  4. @par Glossary:
  5. - ACPI - Advanced Configuration and Power Interface
  6. - SMBIOS - System Management BIOS
  7. - DT - Device Tree
  8. **/
  9. #ifndef TABLE_GENERATOR_H_
  10. #define TABLE_GENERATOR_H_
  11. /** The TABLE_GENERATOR_ID type describes the Table Generator ID
  12. Table Generator ID
  13. _______________________________________________________________________________
  14. | 31 | 30 |29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17| 16|
  15. -------------------------------------------------------------------------------
  16. |TNSID| 0 | TT | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0| 0|
  17. _______________________________________________________________________________
  18. _______________________________________________________________________________
  19. |15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0|
  20. -------------------------------------------------------------------------------
  21. | Table ID |
  22. _______________________________________________________________________________
  23. Bit [31] - Table NameSpace ID (TNSID)
  24. 0 - Standard
  25. 1 - Custom/OEM
  26. Bit [30] - Reserved, Must be Zero
  27. Bit [29:28] - Table Type (TT)
  28. 0 - ACPI Table
  29. 1 - SMBIOS Table
  30. 2 - DT (Device Tree) Table
  31. 3 - Reserved (INVALID)
  32. Bit [27:16] - Reserved, Must Be Zero
  33. Bit [15:0] - Table ID
  34. Standard ACPI Table IDs:
  35. 0 - Reserved
  36. 1 - RAW
  37. 2 - FADT
  38. 3 - DSDT
  39. 4 - SSDT
  40. 5 - MADT
  41. 6 - GTDT
  42. 7 - DBG2
  43. 8 - SPCR
  44. 9 - MCFG
  45. 10 - PPTT
  46. Standard SMBIOS Table IDs:
  47. 0 - Reserved
  48. 1 - RAW
  49. 2 - Table Type00
  50. 3 - Table Type01
  51. 4 - Table Type02
  52. 5 - Table Type03
  53. 6 - Table Type04
  54. 7 - Table Type05
  55. 8 - Table Type06
  56. 9 - Table Type07
  57. 10 - Table Type08
  58. 11 - Table Type09
  59. 12 - Table Type10
  60. 13 - Table Type11
  61. 14 - Table Type12
  62. 15 - Table Type13
  63. 16 - Table Type14
  64. 17 - Table Type15
  65. 18 - Table Type16
  66. 19 - Table Type17
  67. 20 - Table Type18
  68. 21 - Table Type19
  69. 22 - Table Type20
  70. 23 - Table Type21
  71. 24 - Table Type22
  72. 25 - Table Type23
  73. 26 - Table Type24
  74. 27 - Table Type25
  75. 28 - Table Type26
  76. 29 - Table Type27
  77. 30 - Table Type28
  78. 31 - Table Type29
  79. 32 - Table Type30
  80. 33 - Table Type31
  81. 34 - Table Type32
  82. 35 - Table Type33
  83. 36 - Table Type34
  84. 37 - Table Type35
  85. 38 - Table Type36
  86. 39 - Table Type37
  87. 40 - Table Type38
  88. 41 - Table Type39
  89. 42 - Table Type40
  90. 43 - Table Type41
  91. 44 - Table Type42
  92. 45-127 - Reserved
  93. 128 - Table Type126
  94. 129 - Table Type127
  95. **/
  96. typedef UINT32 TABLE_GENERATOR_ID;
  97. /** This enum lists the Table Generator Types.
  98. */
  99. typedef enum TableGeneratorType {
  100. ETableGeneratorTypeAcpi = 0, ///< ACPI Table Generator Type.
  101. ETableGeneratorTypeSmbios, ///< SMBIOS Table Generator Type.
  102. ETableGeneratorTypeDt, ///< Device Tree Table Generator Type.
  103. ETableGeneratorTypeReserved
  104. } ETABLE_GENERATOR_TYPE;
  105. /** This enum lists the namespaces for the Table Generators.
  106. */
  107. typedef enum TableGeneratorNameSpace {
  108. ETableGeneratorNameSpaceStd = 0, ///< Standard Namespace.
  109. ETableGeneratorNameSpaceOem ///< OEM Namespace.
  110. } ETABLE_GENERATOR_NAMESPACE;
  111. /** A mask for the Table ID bits of TABLE_GENERATOR_ID.
  112. */
  113. #define TABLE_ID_MASK 0xFF
  114. /** A mask for the Namespace ID bits of TABLE_GENERATOR_ID.
  115. */
  116. #define TABLE_NAMESPACEID_MASK (BIT31)
  117. /** A mask for the Table Type bits of TABLE_GENERATOR_ID.
  118. */
  119. #define TABLE_TYPE_MASK (BIT29 | BIT28)
  120. /** Starting bit position for the Table Type bits
  121. */
  122. #define TABLE_TYPE_BIT_SHIFT 28
  123. /** Starting bit position for the Table Namespace ID bit
  124. */
  125. #define TABLE_NAMESPACE_ID_BIT_SHIFT 31
  126. /** This macro returns the Table ID from the TableGeneratorId.
  127. @param [in] TableGeneratorId The table generator ID.
  128. @return the Table ID described by the TableGeneratorId.
  129. **/
  130. #define GET_TABLE_ID(TableGeneratorId) \
  131. ((TableGeneratorId) & TABLE_ID_MASK)
  132. /** This macro returns the Table type from the TableGeneratorId.
  133. @param [in] TableGeneratorId The table generator ID.
  134. @return the Table type described by the TableGeneratorId.
  135. **/
  136. #define GET_TABLE_TYPE(TableGeneratorId) \
  137. (((TableGeneratorId) & TABLE_TYPE_MASK) >> TABLE_TYPE_BIT_SHIFT)
  138. /** This macro returns the Namespace ID from the TableGeneratorId.
  139. @param [in] TableGeneratorId The table generator ID.
  140. @return the Namespace described by the TableGeneratorId.
  141. **/
  142. #define GET_TABLE_NAMESPACEID(TableGeneratorId) \
  143. (((TableGeneratorId) & TABLE_NAMESPACEID_MASK) >> \
  144. TABLE_NAMESPACE_ID_BIT_SHIFT)
  145. /** This macro checks if the TableGeneratorId is in the Standard Namespace.
  146. @param [in] TableGeneratorId The table generator ID.
  147. @return TRUE if the TableGeneratorId is in the Standard Namespace.
  148. **/
  149. #define IS_GENERATOR_NAMESPACE_STD(TableGeneratorId) \
  150. ( \
  151. GET_TABLE_NAMESPACEID(TableGeneratorId) == \
  152. ETableGeneratorNameSpaceStd \
  153. )
  154. /** This macro creates a TableGeneratorId
  155. @param [in] TableType The table type.
  156. @param [in] TableNameSpaceId The namespace ID for the table.
  157. @param [in] TableId The table ID.
  158. @return a TableGeneratorId calculated from the inputs.
  159. **/
  160. #define CREATE_TABLE_GEN_ID(TableType, TableNameSpaceId, TableId) \
  161. ((((TableType) << TABLE_TYPE_BIT_SHIFT) & TABLE_TYPE_MASK) | \
  162. (((TableNameSpaceId) << TABLE_NAMESPACE_ID_BIT_SHIFT) & \
  163. TABLE_NAMESPACEID_MASK) | ((TableId) & TABLE_ID_MASK))
  164. /** Starting bit position for MAJOR revision
  165. */
  166. #define MAJOR_REVISION_BIT_SHIFT 16
  167. /** A mask for Major revision.
  168. */
  169. #define MAJOR_REVISION_MASK 0xFFFF
  170. /** A mask for Minor revision.
  171. */
  172. #define MINOR_REVISION_MASK 0xFFFF
  173. /** This macro generates a Major.Minor version
  174. where the Major and Minor fields are 16 bit.
  175. @param [in] Major The Major revision.
  176. @param [in] Minor The Minor revision.
  177. @return a 32 bit representation of the type Major.Minor.
  178. **/
  179. #define CREATE_REVISION(Major, Minor) \
  180. ((((Major) & MAJOR_REVISION_MASK) << MAJOR_REVISION_BIT_SHIFT) | \
  181. ((Minor) & MINOR_REVISION_MASK))
  182. /** This macro returns the Major revision
  183. Extracts Major from the 32 bit representation of the type Major.Minor
  184. @param [in] Revision The Revision value which is 32 bit.
  185. @return the Major part of the revision.
  186. **/
  187. #define GET_MAJOR_REVISION(Revision) \
  188. (((Revision) >> MAJOR_REVISION_BIT_SHIFT) & MAJOR_REVISION_MASK)
  189. /** This macro returns the Minor revision
  190. Extracts Minor from the 32 bit representation of the type Major.Minor
  191. @param [in] Revision The Revision value which is 32 bit.
  192. @return the Minor part of the revision.
  193. **/
  194. #define GET_MINOR_REVISION(Revision) ((Revision) & MINOR_REVISION_MASK)
  195. #endif // TABLE_GENERATOR_H_