rsio.c 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. /*******************************************************************************
  2. *
  3. * Module Name: rsio - IO and DMA resource descriptors
  4. *
  5. ******************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2006, R. Byron Moore
  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 <acpi/acresrc.h>
  44. #define _COMPONENT ACPI_RESOURCES
  45. ACPI_MODULE_NAME("rsio")
  46. /*******************************************************************************
  47. *
  48. * acpi_rs_convert_io
  49. *
  50. ******************************************************************************/
  51. struct acpi_rsconvert_info acpi_rs_convert_io[5] = {
  52. {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IO,
  53. ACPI_RS_SIZE(struct acpi_resource_io),
  54. ACPI_RSC_TABLE_SIZE(acpi_rs_convert_io)},
  55. {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IO,
  56. sizeof(struct aml_resource_io),
  57. 0},
  58. /* Decode flag */
  59. {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.io.io_decode),
  60. AML_OFFSET(io.flags),
  61. 0},
  62. /*
  63. * These fields are contiguous in both the source and destination:
  64. * Address Alignment
  65. * Length
  66. * Minimum Base Address
  67. * Maximum Base Address
  68. */
  69. {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.io.alignment),
  70. AML_OFFSET(io.alignment),
  71. 2},
  72. {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.io.minimum),
  73. AML_OFFSET(io.minimum),
  74. 2}
  75. };
  76. /*******************************************************************************
  77. *
  78. * acpi_rs_convert_fixed_io
  79. *
  80. ******************************************************************************/
  81. struct acpi_rsconvert_info acpi_rs_convert_fixed_io[4] = {
  82. {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_IO,
  83. ACPI_RS_SIZE(struct acpi_resource_fixed_io),
  84. ACPI_RSC_TABLE_SIZE(acpi_rs_convert_fixed_io)},
  85. {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_IO,
  86. sizeof(struct aml_resource_fixed_io),
  87. 0},
  88. /*
  89. * These fields are contiguous in both the source and destination:
  90. * Base Address
  91. * Length
  92. */
  93. {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.fixed_io.address_length),
  94. AML_OFFSET(fixed_io.address_length),
  95. 1},
  96. {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.fixed_io.address),
  97. AML_OFFSET(fixed_io.address),
  98. 1}
  99. };
  100. /*******************************************************************************
  101. *
  102. * acpi_rs_convert_generic_reg
  103. *
  104. ******************************************************************************/
  105. struct acpi_rsconvert_info acpi_rs_convert_generic_reg[4] = {
  106. {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_GENERIC_REGISTER,
  107. ACPI_RS_SIZE(struct acpi_resource_generic_register),
  108. ACPI_RSC_TABLE_SIZE(acpi_rs_convert_generic_reg)},
  109. {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_GENERIC_REGISTER,
  110. sizeof(struct aml_resource_generic_register),
  111. 0},
  112. /*
  113. * These fields are contiguous in both the source and destination:
  114. * Address Space ID
  115. * Register Bit Width
  116. * Register Bit Offset
  117. * Access Size
  118. */
  119. {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.generic_reg.space_id),
  120. AML_OFFSET(generic_reg.address_space_id),
  121. 4},
  122. /* Get the Register Address */
  123. {ACPI_RSC_MOVE64, ACPI_RS_OFFSET(data.generic_reg.address),
  124. AML_OFFSET(generic_reg.address),
  125. 1}
  126. };
  127. /*******************************************************************************
  128. *
  129. * acpi_rs_convert_end_dpf
  130. *
  131. ******************************************************************************/
  132. struct acpi_rsconvert_info acpi_rs_convert_end_dpf[2] = {
  133. {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_DEPENDENT,
  134. ACPI_RS_SIZE_MIN,
  135. ACPI_RSC_TABLE_SIZE(acpi_rs_convert_end_dpf)},
  136. {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_DEPENDENT,
  137. sizeof(struct aml_resource_end_dependent),
  138. 0}
  139. };
  140. /*******************************************************************************
  141. *
  142. * acpi_rs_convert_end_tag
  143. *
  144. ******************************************************************************/
  145. struct acpi_rsconvert_info acpi_rs_convert_end_tag[2] = {
  146. {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_TAG,
  147. ACPI_RS_SIZE_MIN,
  148. ACPI_RSC_TABLE_SIZE(acpi_rs_convert_end_tag)},
  149. /*
  150. * Note: The checksum field is set to zero, meaning that the resource
  151. * data is treated as if the checksum operation succeeded.
  152. * (ACPI Spec 1.0b Section 6.4.2.8)
  153. */
  154. {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_TAG,
  155. sizeof(struct aml_resource_end_tag),
  156. 0}
  157. };
  158. /*******************************************************************************
  159. *
  160. * acpi_rs_get_start_dpf
  161. *
  162. ******************************************************************************/
  163. struct acpi_rsconvert_info acpi_rs_get_start_dpf[5] = {
  164. {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_START_DEPENDENT,
  165. ACPI_RS_SIZE(struct acpi_resource_start_dependent),
  166. ACPI_RSC_TABLE_SIZE(acpi_rs_get_start_dpf)},
  167. /* Defaults for Compatibility and Performance priorities */
  168. {ACPI_RSC_SET8, ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
  169. ACPI_ACCEPTABLE_CONFIGURATION,
  170. 2},
  171. /* All done if there is no flag byte present in the descriptor */
  172. {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 1},
  173. /* Flag byte is present, get the flags */
  174. {ACPI_RSC_2BITFLAG,
  175. ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
  176. AML_OFFSET(start_dpf.flags),
  177. 0},
  178. {ACPI_RSC_2BITFLAG,
  179. ACPI_RS_OFFSET(data.start_dpf.performance_robustness),
  180. AML_OFFSET(start_dpf.flags),
  181. 2}
  182. };
  183. /*******************************************************************************
  184. *
  185. * acpi_rs_set_start_dpf
  186. *
  187. ******************************************************************************/
  188. struct acpi_rsconvert_info acpi_rs_set_start_dpf[6] = {
  189. {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_START_DEPENDENT,
  190. sizeof(struct aml_resource_start_dependent),
  191. ACPI_RSC_TABLE_SIZE(acpi_rs_set_start_dpf)},
  192. /* Set the default flag values */
  193. {ACPI_RSC_2BITFLAG,
  194. ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
  195. AML_OFFSET(start_dpf.flags),
  196. 0},
  197. {ACPI_RSC_2BITFLAG,
  198. ACPI_RS_OFFSET(data.start_dpf.performance_robustness),
  199. AML_OFFSET(start_dpf.flags),
  200. 2},
  201. /*
  202. * All done if flags byte is necessary -- if either priority value
  203. * is not ACPI_ACCEPTABLE_CONFIGURATION
  204. */
  205. {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
  206. ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
  207. ACPI_ACCEPTABLE_CONFIGURATION},
  208. {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
  209. ACPI_RS_OFFSET(data.start_dpf.performance_robustness),
  210. ACPI_ACCEPTABLE_CONFIGURATION},
  211. /* Flag byte is not necessary */
  212. {ACPI_RSC_LENGTH, 0, 0,
  213. sizeof(struct aml_resource_start_dependent_noprio)}
  214. };