rsio.c 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
  2. /*******************************************************************************
  3. *
  4. * Module Name: rsio - IO and DMA resource descriptors
  5. *
  6. ******************************************************************************/
  7. #include <acpi/acpi.h>
  8. #include "accommon.h"
  9. #include "acresrc.h"
  10. #define _COMPONENT ACPI_RESOURCES
  11. ACPI_MODULE_NAME("rsio")
  12. /*******************************************************************************
  13. *
  14. * acpi_rs_convert_io
  15. *
  16. ******************************************************************************/
  17. struct acpi_rsconvert_info acpi_rs_convert_io[5] = {
  18. {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IO,
  19. ACPI_RS_SIZE(struct acpi_resource_io),
  20. ACPI_RSC_TABLE_SIZE(acpi_rs_convert_io)},
  21. {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IO,
  22. sizeof(struct aml_resource_io),
  23. 0},
  24. /* Decode flag */
  25. {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.io.io_decode),
  26. AML_OFFSET(io.flags),
  27. 0},
  28. /*
  29. * These fields are contiguous in both the source and destination:
  30. * Address Alignment
  31. * Length
  32. * Minimum Base Address
  33. * Maximum Base Address
  34. */
  35. {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.io.alignment),
  36. AML_OFFSET(io.alignment),
  37. 2},
  38. {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.io.minimum),
  39. AML_OFFSET(io.minimum),
  40. 2}
  41. };
  42. /*******************************************************************************
  43. *
  44. * acpi_rs_convert_fixed_io
  45. *
  46. ******************************************************************************/
  47. struct acpi_rsconvert_info acpi_rs_convert_fixed_io[4] = {
  48. {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_IO,
  49. ACPI_RS_SIZE(struct acpi_resource_fixed_io),
  50. ACPI_RSC_TABLE_SIZE(acpi_rs_convert_fixed_io)},
  51. {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_IO,
  52. sizeof(struct aml_resource_fixed_io),
  53. 0},
  54. /*
  55. * These fields are contiguous in both the source and destination:
  56. * Base Address
  57. * Length
  58. */
  59. {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.fixed_io.address_length),
  60. AML_OFFSET(fixed_io.address_length),
  61. 1},
  62. {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.fixed_io.address),
  63. AML_OFFSET(fixed_io.address),
  64. 1}
  65. };
  66. /*******************************************************************************
  67. *
  68. * acpi_rs_convert_generic_reg
  69. *
  70. ******************************************************************************/
  71. struct acpi_rsconvert_info acpi_rs_convert_generic_reg[4] = {
  72. {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_GENERIC_REGISTER,
  73. ACPI_RS_SIZE(struct acpi_resource_generic_register),
  74. ACPI_RSC_TABLE_SIZE(acpi_rs_convert_generic_reg)},
  75. {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_GENERIC_REGISTER,
  76. sizeof(struct aml_resource_generic_register),
  77. 0},
  78. /*
  79. * These fields are contiguous in both the source and destination:
  80. * Address Space ID
  81. * Register Bit Width
  82. * Register Bit Offset
  83. * Access Size
  84. */
  85. {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.generic_reg.space_id),
  86. AML_OFFSET(generic_reg.address_space_id),
  87. 4},
  88. /* Get the Register Address */
  89. {ACPI_RSC_MOVE64, ACPI_RS_OFFSET(data.generic_reg.address),
  90. AML_OFFSET(generic_reg.address),
  91. 1}
  92. };
  93. /*******************************************************************************
  94. *
  95. * acpi_rs_convert_end_dpf
  96. *
  97. ******************************************************************************/
  98. struct acpi_rsconvert_info acpi_rs_convert_end_dpf[2] = {
  99. {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_DEPENDENT,
  100. ACPI_RS_SIZE_MIN,
  101. ACPI_RSC_TABLE_SIZE(acpi_rs_convert_end_dpf)},
  102. {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_DEPENDENT,
  103. sizeof(struct aml_resource_end_dependent),
  104. 0}
  105. };
  106. /*******************************************************************************
  107. *
  108. * acpi_rs_convert_end_tag
  109. *
  110. ******************************************************************************/
  111. struct acpi_rsconvert_info acpi_rs_convert_end_tag[2] = {
  112. {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_TAG,
  113. ACPI_RS_SIZE_MIN,
  114. ACPI_RSC_TABLE_SIZE(acpi_rs_convert_end_tag)},
  115. /*
  116. * Note: The checksum field is set to zero, meaning that the resource
  117. * data is treated as if the checksum operation succeeded.
  118. * (ACPI Spec 1.0b Section 6.4.2.8)
  119. */
  120. {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_TAG,
  121. sizeof(struct aml_resource_end_tag),
  122. 0}
  123. };
  124. /*******************************************************************************
  125. *
  126. * acpi_rs_get_start_dpf
  127. *
  128. ******************************************************************************/
  129. struct acpi_rsconvert_info acpi_rs_get_start_dpf[6] = {
  130. {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_START_DEPENDENT,
  131. ACPI_RS_SIZE(struct acpi_resource_start_dependent),
  132. ACPI_RSC_TABLE_SIZE(acpi_rs_get_start_dpf)},
  133. /* Defaults for Compatibility and Performance priorities */
  134. {ACPI_RSC_SET8, ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
  135. ACPI_ACCEPTABLE_CONFIGURATION,
  136. 2},
  137. /* Get the descriptor length (0 or 1 for Start Dpf descriptor) */
  138. {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.start_dpf.descriptor_length),
  139. AML_OFFSET(start_dpf.descriptor_type),
  140. 0},
  141. /* All done if there is no flag byte present in the descriptor */
  142. {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 1},
  143. /* Flag byte is present, get the flags */
  144. {ACPI_RSC_2BITFLAG,
  145. ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
  146. AML_OFFSET(start_dpf.flags),
  147. 0},
  148. {ACPI_RSC_2BITFLAG,
  149. ACPI_RS_OFFSET(data.start_dpf.performance_robustness),
  150. AML_OFFSET(start_dpf.flags),
  151. 2}
  152. };
  153. /*******************************************************************************
  154. *
  155. * acpi_rs_set_start_dpf
  156. *
  157. ******************************************************************************/
  158. struct acpi_rsconvert_info acpi_rs_set_start_dpf[10] = {
  159. /* Start with a default descriptor of length 1 */
  160. {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_START_DEPENDENT,
  161. sizeof(struct aml_resource_start_dependent),
  162. ACPI_RSC_TABLE_SIZE(acpi_rs_set_start_dpf)},
  163. /* Set the default flag values */
  164. {ACPI_RSC_2BITFLAG,
  165. ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
  166. AML_OFFSET(start_dpf.flags),
  167. 0},
  168. {ACPI_RSC_2BITFLAG,
  169. ACPI_RS_OFFSET(data.start_dpf.performance_robustness),
  170. AML_OFFSET(start_dpf.flags),
  171. 2},
  172. /*
  173. * All done if the output descriptor length is required to be 1
  174. * (i.e., optimization to 0 bytes cannot be attempted)
  175. */
  176. {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE,
  177. ACPI_RS_OFFSET(data.start_dpf.descriptor_length),
  178. 1},
  179. /* Set length to 0 bytes (no flags byte) */
  180. {ACPI_RSC_LENGTH, 0, 0,
  181. sizeof(struct aml_resource_start_dependent_noprio)},
  182. /*
  183. * All done if the output descriptor length is required to be 0.
  184. *
  185. * TBD: Perhaps we should check for error if input flags are not
  186. * compatible with a 0-byte descriptor.
  187. */
  188. {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE,
  189. ACPI_RS_OFFSET(data.start_dpf.descriptor_length),
  190. 0},
  191. /* Reset length to 1 byte (descriptor with flags byte) */
  192. {ACPI_RSC_LENGTH, 0, 0, sizeof(struct aml_resource_start_dependent)},
  193. /*
  194. * All done if flags byte is necessary -- if either priority value
  195. * is not ACPI_ACCEPTABLE_CONFIGURATION
  196. */
  197. {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
  198. ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
  199. ACPI_ACCEPTABLE_CONFIGURATION},
  200. {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
  201. ACPI_RS_OFFSET(data.start_dpf.performance_robustness),
  202. ACPI_ACCEPTABLE_CONFIGURATION},
  203. /* Flag byte is not necessary */
  204. {ACPI_RSC_LENGTH, 0, 0,
  205. sizeof(struct aml_resource_start_dependent_noprio)}
  206. };