rsio.c 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. /*******************************************************************************
  2. *
  3. * Module Name: rsio - IO and DMA resource descriptors
  4. *
  5. ******************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2012, Intel Corp.
  8. * All rights reserved.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions, and the following disclaimer,
  15. * without modification.
  16. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  17. * substantially similar to the "NO WARRANTY" disclaimer below
  18. * ("Disclaimer") and any redistribution must be conditioned upon
  19. * including a substantially similar Disclaimer requirement for further
  20. * binary redistribution.
  21. * 3. Neither the names of the above-listed copyright holders nor the names
  22. * of any contributors may be used to endorse or promote products derived
  23. * from this software without specific prior written permission.
  24. *
  25. * Alternatively, this software may be distributed under the terms of the
  26. * GNU General Public License ("GPL") version 2 as published by the Free
  27. * Software Foundation.
  28. *
  29. * NO WARRANTY
  30. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  31. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  32. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  33. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  34. * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  35. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  36. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  37. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  38. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  39. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  40. * POSSIBILITY OF SUCH DAMAGES.
  41. */
  42. #include <acpi/acpi.h>
  43. #include "accommon.h"
  44. #include "acresrc.h"
  45. #define _COMPONENT ACPI_RESOURCES
  46. ACPI_MODULE_NAME("rsio")
  47. /*******************************************************************************
  48. *
  49. * acpi_rs_convert_io
  50. *
  51. ******************************************************************************/
  52. struct acpi_rsconvert_info acpi_rs_convert_io[5] = {
  53. {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IO,
  54. ACPI_RS_SIZE(struct acpi_resource_io),
  55. ACPI_RSC_TABLE_SIZE(acpi_rs_convert_io)},
  56. {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IO,
  57. sizeof(struct aml_resource_io),
  58. 0},
  59. /* Decode flag */
  60. {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.io.io_decode),
  61. AML_OFFSET(io.flags),
  62. 0},
  63. /*
  64. * These fields are contiguous in both the source and destination:
  65. * Address Alignment
  66. * Length
  67. * Minimum Base Address
  68. * Maximum Base Address
  69. */
  70. {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.io.alignment),
  71. AML_OFFSET(io.alignment),
  72. 2},
  73. {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.io.minimum),
  74. AML_OFFSET(io.minimum),
  75. 2}
  76. };
  77. /*******************************************************************************
  78. *
  79. * acpi_rs_convert_fixed_io
  80. *
  81. ******************************************************************************/
  82. struct acpi_rsconvert_info acpi_rs_convert_fixed_io[4] = {
  83. {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_IO,
  84. ACPI_RS_SIZE(struct acpi_resource_fixed_io),
  85. ACPI_RSC_TABLE_SIZE(acpi_rs_convert_fixed_io)},
  86. {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_IO,
  87. sizeof(struct aml_resource_fixed_io),
  88. 0},
  89. /*
  90. * These fields are contiguous in both the source and destination:
  91. * Base Address
  92. * Length
  93. */
  94. {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.fixed_io.address_length),
  95. AML_OFFSET(fixed_io.address_length),
  96. 1},
  97. {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.fixed_io.address),
  98. AML_OFFSET(fixed_io.address),
  99. 1}
  100. };
  101. /*******************************************************************************
  102. *
  103. * acpi_rs_convert_generic_reg
  104. *
  105. ******************************************************************************/
  106. struct acpi_rsconvert_info acpi_rs_convert_generic_reg[4] = {
  107. {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_GENERIC_REGISTER,
  108. ACPI_RS_SIZE(struct acpi_resource_generic_register),
  109. ACPI_RSC_TABLE_SIZE(acpi_rs_convert_generic_reg)},
  110. {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_GENERIC_REGISTER,
  111. sizeof(struct aml_resource_generic_register),
  112. 0},
  113. /*
  114. * These fields are contiguous in both the source and destination:
  115. * Address Space ID
  116. * Register Bit Width
  117. * Register Bit Offset
  118. * Access Size
  119. */
  120. {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.generic_reg.space_id),
  121. AML_OFFSET(generic_reg.address_space_id),
  122. 4},
  123. /* Get the Register Address */
  124. {ACPI_RSC_MOVE64, ACPI_RS_OFFSET(data.generic_reg.address),
  125. AML_OFFSET(generic_reg.address),
  126. 1}
  127. };
  128. /*******************************************************************************
  129. *
  130. * acpi_rs_convert_end_dpf
  131. *
  132. ******************************************************************************/
  133. struct acpi_rsconvert_info acpi_rs_convert_end_dpf[2] = {
  134. {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_DEPENDENT,
  135. ACPI_RS_SIZE_MIN,
  136. ACPI_RSC_TABLE_SIZE(acpi_rs_convert_end_dpf)},
  137. {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_DEPENDENT,
  138. sizeof(struct aml_resource_end_dependent),
  139. 0}
  140. };
  141. /*******************************************************************************
  142. *
  143. * acpi_rs_convert_end_tag
  144. *
  145. ******************************************************************************/
  146. struct acpi_rsconvert_info acpi_rs_convert_end_tag[2] = {
  147. {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_TAG,
  148. ACPI_RS_SIZE_MIN,
  149. ACPI_RSC_TABLE_SIZE(acpi_rs_convert_end_tag)},
  150. /*
  151. * Note: The checksum field is set to zero, meaning that the resource
  152. * data is treated as if the checksum operation succeeded.
  153. * (ACPI Spec 1.0b Section 6.4.2.8)
  154. */
  155. {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_TAG,
  156. sizeof(struct aml_resource_end_tag),
  157. 0}
  158. };
  159. /*******************************************************************************
  160. *
  161. * acpi_rs_get_start_dpf
  162. *
  163. ******************************************************************************/
  164. struct acpi_rsconvert_info acpi_rs_get_start_dpf[6] = {
  165. {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_START_DEPENDENT,
  166. ACPI_RS_SIZE(struct acpi_resource_start_dependent),
  167. ACPI_RSC_TABLE_SIZE(acpi_rs_get_start_dpf)},
  168. /* Defaults for Compatibility and Performance priorities */
  169. {ACPI_RSC_SET8, ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
  170. ACPI_ACCEPTABLE_CONFIGURATION,
  171. 2},
  172. /* Get the descriptor length (0 or 1 for Start Dpf descriptor) */
  173. {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.start_dpf.descriptor_length),
  174. AML_OFFSET(start_dpf.descriptor_type),
  175. 0},
  176. /* All done if there is no flag byte present in the descriptor */
  177. {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 1},
  178. /* Flag byte is present, get the flags */
  179. {ACPI_RSC_2BITFLAG,
  180. ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
  181. AML_OFFSET(start_dpf.flags),
  182. 0},
  183. {ACPI_RSC_2BITFLAG,
  184. ACPI_RS_OFFSET(data.start_dpf.performance_robustness),
  185. AML_OFFSET(start_dpf.flags),
  186. 2}
  187. };
  188. /*******************************************************************************
  189. *
  190. * acpi_rs_set_start_dpf
  191. *
  192. ******************************************************************************/
  193. struct acpi_rsconvert_info acpi_rs_set_start_dpf[10] = {
  194. /* Start with a default descriptor of length 1 */
  195. {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_START_DEPENDENT,
  196. sizeof(struct aml_resource_start_dependent),
  197. ACPI_RSC_TABLE_SIZE(acpi_rs_set_start_dpf)},
  198. /* Set the default flag values */
  199. {ACPI_RSC_2BITFLAG,
  200. ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
  201. AML_OFFSET(start_dpf.flags),
  202. 0},
  203. {ACPI_RSC_2BITFLAG,
  204. ACPI_RS_OFFSET(data.start_dpf.performance_robustness),
  205. AML_OFFSET(start_dpf.flags),
  206. 2},
  207. /*
  208. * All done if the output descriptor length is required to be 1
  209. * (i.e., optimization to 0 bytes cannot be attempted)
  210. */
  211. {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE,
  212. ACPI_RS_OFFSET(data.start_dpf.descriptor_length),
  213. 1},
  214. /* Set length to 0 bytes (no flags byte) */
  215. {ACPI_RSC_LENGTH, 0, 0,
  216. sizeof(struct aml_resource_start_dependent_noprio)},
  217. /*
  218. * All done if the output descriptor length is required to be 0.
  219. *
  220. * TBD: Perhaps we should check for error if input flags are not
  221. * compatible with a 0-byte descriptor.
  222. */
  223. {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE,
  224. ACPI_RS_OFFSET(data.start_dpf.descriptor_length),
  225. 0},
  226. /* Reset length to 1 byte (descriptor with flags byte) */
  227. {ACPI_RSC_LENGTH, 0, 0, sizeof(struct aml_resource_start_dependent)},
  228. /*
  229. * All done if flags byte is necessary -- if either priority value
  230. * is not ACPI_ACCEPTABLE_CONFIGURATION
  231. */
  232. {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
  233. ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
  234. ACPI_ACCEPTABLE_CONFIGURATION},
  235. {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
  236. ACPI_RS_OFFSET(data.start_dpf.performance_robustness),
  237. ACPI_ACCEPTABLE_CONFIGURATION},
  238. /* Flag byte is not necessary */
  239. {ACPI_RSC_LENGTH, 0, 0,
  240. sizeof(struct aml_resource_start_dependent_noprio)}
  241. };