AcpiPciUpdate.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. /** @file
  2. Update the _PRT and _PRW method for pci devices
  3. Copyright (c) 2013-2015 Intel Corporation.
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef _ACPI_PCI_UPDATE_H_
  7. #define _ACPI_PCI_UPDATE_H_
  8. //
  9. // Primary OpCode
  10. //
  11. #define AML_ZERO_OP 0x00
  12. #define AML_ONE_OP 0x01
  13. #define AML_ALIAS_OP 0x06
  14. #define AML_NAME_OP 0x08
  15. #define AML_BYTE_PREFIX 0x0a
  16. #define AML_WORD_PREFIX 0x0b
  17. #define AML_DWORD_PREFIX 0x0c
  18. #define AML_STRING_PREFIX 0x0d
  19. #define AML_QWORD_PREFIX 0x0e
  20. #define AML_SCOPE_OP 0x10
  21. #define AML_BUFFER_OP 0x11
  22. #define AML_PACKAGE_OP 0x12
  23. #define AML_VAR_PACKAGE_OP 0x13
  24. #define AML_METHOD_OP 0x14
  25. #define AML_DUAL_NAME_PREFIX 0x2e
  26. #define AML_MULTI_NAME_PREFIX 0x2f
  27. #define AML_NAME_CHAR_A 0x41
  28. #define AML_NAME_CHAR_B 0x42
  29. #define AML_NAME_CHAR_C 0x43
  30. #define AML_NAME_CHAR_D 0x44
  31. #define AML_NAME_CHAR_E 0x45
  32. #define AML_NAME_CHAR_F 0x46
  33. #define AML_NAME_CHAR_G 0x47
  34. #define AML_NAME_CHAR_H 0x48
  35. #define AML_NAME_CHAR_I 0x49
  36. #define AML_NAME_CHAR_J 0x4a
  37. #define AML_NAME_CHAR_K 0x4b
  38. #define AML_NAME_CHAR_L 0x4c
  39. #define AML_NAME_CHAR_M 0x4d
  40. #define AML_NAME_CHAR_N 0x4e
  41. #define AML_NAME_CHAR_O 0x4f
  42. #define AML_NAME_CHAR_P 0x50
  43. #define AML_NAME_CHAR_Q 0x51
  44. #define AML_NAME_CHAR_R 0x52
  45. #define AML_NAME_CHAR_S 0x53
  46. #define AML_NAME_CHAR_T 0x54
  47. #define AML_NAME_CHAR_U 0x55
  48. #define AML_NAME_CHAR_V 0x56
  49. #define AML_NAME_CHAR_W 0x57
  50. #define AML_NAME_CHAR_X 0x58
  51. #define AML_NAME_CHAR_Y 0x59
  52. #define AML_NAME_CHAR_Z 0x5a
  53. #define AML_ROOT_CHAR 0x5c
  54. #define AML_PARENT_PREFIX_CHAR 0x5e
  55. #define AML_NAME_CHAR__ 0x5f
  56. #define AML_LOCAL0 0x60
  57. #define AML_LOCAL1 0x61
  58. #define AML_LOCAL2 0x62
  59. #define AML_LOCAL3 0x63
  60. #define AML_LOCAL4 0x64
  61. #define AML_LOCAL5 0x65
  62. #define AML_LOCAL6 0x66
  63. #define AML_LOCAL7 0x67
  64. #define AML_ARG0 0x68
  65. #define AML_ARG1 0x69
  66. #define AML_ARG2 0x6a
  67. #define AML_ARG3 0x6b
  68. #define AML_ARG4 0x6c
  69. #define AML_ARG5 0x6d
  70. #define AML_ARG6 0x6e
  71. #define AML_STORE_OP 0x70
  72. #define AML_REF_OF_OP 0x71
  73. #define AML_ADD_OP 0x72
  74. #define AML_CONCAT_OP 0x73
  75. #define AML_SUBTRACT_OP 0x74
  76. #define AML_INCREMENT_OP 0x75
  77. #define AML_DECREMENT_OP 0x76
  78. #define AML_MULTIPLY_OP 0x77
  79. #define AML_DIVIDE_OP 0x78
  80. #define AML_SHIFT_LEFT_OP 0x79
  81. #define AML_SHIFT_RIGHT_OP 0x7a
  82. #define AML_AND_OP 0x7b
  83. #define AML_NAND_OP 0x7c
  84. #define AML_OR_OP 0x7d
  85. #define AML_NOR_OP 0x7e
  86. #define AML_XOR_OP 0x7f
  87. #define AML_NOT_OP 0x80
  88. #define AML_FIND_SET_LEFT_BIT_OP 0x81
  89. #define AML_FIND_SET_RIGHT_BIT_OP 0x82
  90. #define AML_DEREF_OF_OP 0x83
  91. #define AML_CONCAT_RES_OP 0x84
  92. #define AML_MOD_OP 0x85
  93. #define AML_NOTIFY_OP 0x86
  94. #define AML_SIZE_OF_OP 0x87
  95. #define AML_INDEX_OP 0x88
  96. #define AML_MATCH_OP 0x89
  97. #define AML_CREATE_DWORD_FIELD_OP 0x8a
  98. #define AML_CREATE_WORD_FIELD_OP 0x8b
  99. #define AML_CREATE_BYTE_FIELD_OP 0x8c
  100. #define AML_CREATE_BIT_FIELD_OP 0x8d
  101. #define AML_OBJECT_TYPE_OP 0x8e
  102. #define AML_CREATE_QWORD_FIELD_OP 0x8f
  103. #define AML_LAND_OP 0x90
  104. #define AML_LOR_OP 0x91
  105. #define AML_LNOT_OP 0x92
  106. #define AML_LEQUAL_OP 0x93
  107. #define AML_LGREATER_OP 0x94
  108. #define AML_LLESS_OP 0x95
  109. #define AML_TO_BUFFER_OP 0x96
  110. #define AML_TO_DEC_STRING_OP 0x97
  111. #define AML_TO_HEX_STRING_OP 0x98
  112. #define AML_TO_INTEGER_OP 0x99
  113. #define AML_TO_STRING_OP 0x9c
  114. #define AML_COPY_OBJECT_OP 0x9d
  115. #define AML_MID_OP 0x9e
  116. #define AML_CONTINUE_OP 0x9f
  117. #define AML_IF_OP 0xa0
  118. #define AML_ELSE_OP 0xa1
  119. #define AML_WHILE_OP 0xa2
  120. #define AML_NOOP_OP 0xa3
  121. #define AML_RETURN_OP 0xa4
  122. #define AML_BREAK_OP 0xa5
  123. #define AML_BREAK_POINT_OP 0xcc
  124. #define AML_ONES_OP 0xff
  125. //
  126. // Extended OpCode
  127. //
  128. #define AML_EXT_OP 0x5b
  129. #define AML_EXT_MUTEX_OP 0x01
  130. #define AML_EXT_EVENT_OP 0x02
  131. #define AML_EXT_COND_REF_OF_OP 0x12
  132. #define AML_EXT_CREATE_FIELD_OP 0x13
  133. #define AML_EXT_LOAD_TABLE_OP 0x1f
  134. #define AML_EXT_LOAD_OP 0x20
  135. #define AML_EXT_STALL_OP 0x21
  136. #define AML_EXT_SLEEP_OP 0x22
  137. #define AML_EXT_ACQUIRE_OP 0x23
  138. #define AML_EXT_SIGNAL_OP 0x24
  139. #define AML_EXT_WAIT_OP 0x25
  140. #define AML_EXT_RESET_OP 0x26
  141. #define AML_EXT_RELEASE_OP 0x27
  142. #define AML_EXT_FROM_BCD_OP 0x28
  143. #define AML_EXT_TO_BCD_OP 0x29
  144. #define AML_EXT_UNLOAD_OP 0x2a
  145. #define AML_EXT_REVISION_OP 0x30
  146. #define AML_EXT_DEBUG_OP 0x31
  147. #define AML_EXT_FATAL_OP 0x32
  148. #define AML_EXT_TIMER_OP 0x33
  149. #define AML_EXT_REGION_OP 0x80
  150. #define AML_EXT_FIELD_OP 0x81
  151. #define AML_EXT_DEVICE_OP 0x82
  152. #define AML_EXT_PROCESSOR_OP 0x83
  153. #define AML_EXT_POWER_RES_OP 0x84
  154. #define AML_EXT_THERMAL_ZONE_OP 0x85
  155. #define AML_EXT_INDEX_FIELD_OP 0x86
  156. #define AML_EXT_BANK_FIELD_OP 0x87
  157. #define AML_EXT_DATA_REGION_OP 0x88
  158. #pragma pack(1)
  159. typedef struct {
  160. UINT32 BridgeAddress;
  161. UINT32 DeviceAddress;
  162. UINT8 INTA[2]; // the first member record the 8259 link, the second member record the io apic irq number
  163. UINT8 INTB[2];
  164. UINT8 INTC[2];
  165. UINT8 INTD[2];
  166. UINT8 GPEPin;
  167. UINT8 SxNum;
  168. } PCI_DEVICE_INFO;
  169. #pragma pack()
  170. #define PCI_DEVICE_INFO_MAX_NUM 50
  171. #define CURRENT_PCI_DEVICE_NUM 13
  172. #define PIRQ_LINKA 1
  173. #define PIRQ_LINKB 2
  174. #define PIRQ_LINKC 3
  175. #define PIRQ_LINKD 4
  176. #define PIRQ_LINKE 5
  177. #define PIRQ_LINKF 6
  178. #define PIRQ_LINKG 7
  179. #define PIRQ_LINKH 8
  180. #define PIRQ_INVALID 0xFF
  181. typedef struct _PCI_DEVICE_SETTING{
  182. UINT8 PciDeviceInfoNumber;
  183. PCI_DEVICE_INFO PciDeviceInfo[PCI_DEVICE_INFO_MAX_NUM];
  184. }PCI_DEVICE_SETTING;
  185. typedef struct _AML_BYTE_ENCODING AML_BYTE_ENCODING;
  186. //
  187. // AML Handle Entry definition.
  188. //
  189. // Signature must be set to EFI_AML_HANDLE_SIGNATURE or EFI_AML_ROOT_HANDLE_SIGNATURE
  190. // Buffer is the ACPI node buffer pointer, the first/second bytes are opcode.
  191. // This buffer should not be freed.
  192. // Size is the total size of this ACPI node buffer.
  193. //
  194. typedef struct {
  195. UINT32 Signature;
  196. UINT8 *Buffer;
  197. UINTN Size;
  198. AML_BYTE_ENCODING *AmlByteEncoding;
  199. BOOLEAN Modified;
  200. } EFI_AML_HANDLE;
  201. typedef UINT32 AML_OP_PARSE_INDEX;
  202. typedef UINT32 AML_OP_PARSE_FORMAT;
  203. typedef UINT32 AML_OP_ATTRIBUTE;
  204. struct _AML_BYTE_ENCODING {
  205. UINT8 OpCode;
  206. UINT8 SubOpCode;
  207. AML_OP_PARSE_INDEX MaxIndex;
  208. AML_OP_PARSE_FORMAT Format[6];
  209. AML_OP_ATTRIBUTE Attribute;
  210. };
  211. //
  212. // Check device info fucntion prototype
  213. //
  214. typedef
  215. BOOLEAN
  216. (* CHECK_HANDLE_INFO) (
  217. IN EFI_ACPI_SDT_PROTOCOL *AcpiSdt,
  218. IN EFI_ACPI_HANDLE CheckHandle,
  219. IN VOID *Context
  220. );
  221. extern EFI_ACPI_HANDLE mDsdtHandle;
  222. extern EFI_ACPI_SDT_PROTOCOL *mAcpiSdt;
  223. /**
  224. Init Pci Device Structure
  225. @param mConfigData - Pointer of Pci Device information Structure
  226. **/
  227. VOID
  228. InitPciDeviceInfoStructure (
  229. PCI_DEVICE_SETTING *mConfigData
  230. );
  231. /**
  232. update pci routing information in acpi table based on pcd settings
  233. @param AcpiSdt Pointer to Acpi SDT protocol
  234. @param DsdtHandle ACPI root handle
  235. @param PciDeviceInfo Pointer to PCI_DEVICE_INFO
  236. **/
  237. EFI_STATUS
  238. SdtUpdatePciRouting (
  239. IN EFI_ACPI_SDT_PROTOCOL *AcpiSdt,
  240. IN EFI_ACPI_HANDLE DsdtHandle,
  241. IN PCI_DEVICE_INFO *PciDeviceInfo
  242. );
  243. /**
  244. update power resource wake up information in acpi table based on pcd settings
  245. @param AcpiSdt Pointer to Acpi SDT protocol
  246. @param DsdtHandle ACPI root handle
  247. @param PciDeviceInfo Pointer to PCI_DEVICE_INFO
  248. **/
  249. EFI_STATUS
  250. SdtUpdatePowerWake (
  251. IN EFI_ACPI_SDT_PROTOCOL *AcpiSdt,
  252. IN EFI_ACPI_HANDLE DsdtHandle,
  253. IN PCI_DEVICE_INFO *PciDeviceInfo
  254. );
  255. /**
  256. Get the root bridge handle by scanning the acpi table
  257. @param AcpiSdt Pointer to Acpi SDT protocol
  258. @param DsdtHandle ACPI root handle
  259. @retval EFI_ACPI_HANDLE the handle of the root bridge
  260. **/
  261. EFI_ACPI_HANDLE
  262. SdtGetRootBridgeHandle (
  263. IN EFI_ACPI_SDT_PROTOCOL *AcpiSdt,
  264. IN EFI_ACPI_HANDLE DsdtHandle
  265. );
  266. /**
  267. Check input Pci device info is changed from the default values
  268. @param PciDeviceInfo Pointer to PCI_DEVICE_INFO
  269. @param UpdatePRT Pointer to BOOLEAN
  270. @param UpdatePRW Pointer to BOOLEAN
  271. **/
  272. VOID
  273. SdtCheckPciDeviceInfoChanged (
  274. IN PCI_DEVICE_INFO *PciDeviceInfo,
  275. IN BOOLEAN *UpdatePRT,
  276. IN BOOLEAN *UpdatePRW
  277. );
  278. #endif