rsinfo.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. /*******************************************************************************
  2. *
  3. * Module Name: rsinfo - Dispatch and Info tables
  4. *
  5. ******************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2005, 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("rsinfo")
  46. /*
  47. * Resource dispatch and information tables. Any new resource types (either
  48. * Large or Small) must be reflected in each of these tables, so they are here
  49. * in one place.
  50. *
  51. * The tables for Large descriptors are indexed by bits 6:0 of the AML
  52. * descriptor type byte. The tables for Small descriptors are indexed by
  53. * bits 6:3 of the descriptor byte. The tables for internal resource
  54. * descriptors are indexed by the acpi_resource_type field.
  55. */
  56. /* Dispatch table for resource-to-AML (Set Resource) conversion functions */
  57. ACPI_SET_RESOURCE_HANDLER acpi_gbl_set_resource_dispatch[] = {
  58. acpi_rs_set_irq, /* 0x00, ACPI_RESOURCE_TYPE_IRQ */
  59. acpi_rs_set_dma, /* 0x01, ACPI_RESOURCE_TYPE_DMA */
  60. acpi_rs_set_start_dpf, /* 0x02, ACPI_RESOURCE_TYPE_START_DEPENDENT */
  61. acpi_rs_set_end_dpf, /* 0x03, ACPI_RESOURCE_TYPE_END_DEPENDENT */
  62. acpi_rs_set_io, /* 0x04, ACPI_RESOURCE_TYPE_IO */
  63. acpi_rs_set_fixed_io, /* 0x05, ACPI_RESOURCE_TYPE_FIXED_IO */
  64. acpi_rs_set_vendor, /* 0x06, ACPI_RESOURCE_TYPE_VENDOR */
  65. acpi_rs_set_end_tag, /* 0x07, ACPI_RESOURCE_TYPE_END_TAG */
  66. acpi_rs_set_memory24, /* 0x08, ACPI_RESOURCE_TYPE_MEMORY24 */
  67. acpi_rs_set_memory32, /* 0x09, ACPI_RESOURCE_TYPE_MEMORY32 */
  68. acpi_rs_set_fixed_memory32, /* 0x0A, ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */
  69. acpi_rs_set_address16, /* 0x0B, ACPI_RESOURCE_TYPE_ADDRESS16 */
  70. acpi_rs_set_address32, /* 0x0C, ACPI_RESOURCE_TYPE_ADDRESS32 */
  71. acpi_rs_set_address64, /* 0x0D, ACPI_RESOURCE_TYPE_ADDRESS64 */
  72. acpi_rs_set_ext_address64, /* 0x0E, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
  73. acpi_rs_set_ext_irq, /* 0x0F, ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
  74. acpi_rs_set_generic_reg /* 0x10, ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
  75. };
  76. /* Dispatch tables for AML-to-resource (Get Resource) conversion functions */
  77. ACPI_GET_RESOURCE_HANDLER acpi_gbl_sm_get_resource_dispatch[] = {
  78. NULL, /* 0x00, Reserved */
  79. NULL, /* 0x01, Reserved */
  80. NULL, /* 0x02, Reserved */
  81. NULL, /* 0x03, Reserved */
  82. acpi_rs_get_irq, /* 0x04, ACPI_RESOURCE_NAME_IRQ */
  83. acpi_rs_get_dma, /* 0x05, ACPI_RESOURCE_NAME_DMA */
  84. acpi_rs_get_start_dpf, /* 0x06, ACPI_RESOURCE_NAME_START_DEPENDENT */
  85. acpi_rs_get_end_dpf, /* 0x07, ACPI_RESOURCE_NAME_END_DEPENDENT */
  86. acpi_rs_get_io, /* 0x08, ACPI_RESOURCE_NAME_IO */
  87. acpi_rs_get_fixed_io, /* 0x09, ACPI_RESOURCE_NAME_FIXED_IO */
  88. NULL, /* 0x0A, Reserved */
  89. NULL, /* 0x0B, Reserved */
  90. NULL, /* 0x0C, Reserved */
  91. NULL, /* 0x0D, Reserved */
  92. acpi_rs_get_vendor, /* 0x0E, ACPI_RESOURCE_NAME_VENDOR_SMALL */
  93. acpi_rs_get_end_tag /* 0x0F, ACPI_RESOURCE_NAME_END_TAG */
  94. };
  95. ACPI_GET_RESOURCE_HANDLER acpi_gbl_lg_get_resource_dispatch[] = {
  96. NULL, /* 0x00, Reserved */
  97. acpi_rs_get_memory24, /* 0x01, ACPI_RESOURCE_NAME_MEMORY24 */
  98. acpi_rs_get_generic_reg, /* 0x02, ACPI_RESOURCE_NAME_GENERIC_REGISTER */
  99. NULL, /* 0x03, Reserved */
  100. acpi_rs_get_vendor, /* 0x04, ACPI_RESOURCE_NAME_VENDOR_LARGE */
  101. acpi_rs_get_memory32, /* 0x05, ACPI_RESOURCE_NAME_MEMORY32 */
  102. acpi_rs_get_fixed_memory32, /* 0x06, ACPI_RESOURCE_NAME_FIXED_MEMORY32 */
  103. acpi_rs_get_address32, /* 0x07, ACPI_RESOURCE_NAME_ADDRESS32 */
  104. acpi_rs_get_address16, /* 0x08, ACPI_RESOURCE_NAME_ADDRESS16 */
  105. acpi_rs_get_ext_irq, /* 0x09, ACPI_RESOURCE_NAME_EXTENDED_IRQ */
  106. acpi_rs_get_address64, /* 0x0A, ACPI_RESOURCE_NAME_ADDRESS64 */
  107. acpi_rs_get_ext_address64 /* 0x0B, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 */
  108. };
  109. #ifdef ACPI_FUTURE_USAGE
  110. #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
  111. /* Dispatch table for resource dump functions */
  112. ACPI_DUMP_RESOURCE_HANDLER acpi_gbl_dump_resource_dispatch[] = {
  113. acpi_rs_dump_irq, /* ACPI_RESOURCE_TYPE_IRQ */
  114. acpi_rs_dump_dma, /* ACPI_RESOURCE_TYPE_DMA */
  115. acpi_rs_dump_start_dpf, /* ACPI_RESOURCE_TYPE_START_DEPENDENT */
  116. acpi_rs_dump_end_dpf, /* ACPI_RESOURCE_TYPE_END_DEPENDENT */
  117. acpi_rs_dump_io, /* ACPI_RESOURCE_TYPE_IO */
  118. acpi_rs_dump_fixed_io, /* ACPI_RESOURCE_TYPE_FIXED_IO */
  119. acpi_rs_dump_vendor, /* ACPI_RESOURCE_TYPE_VENDOR */
  120. acpi_rs_dump_end_tag, /* ACPI_RESOURCE_TYPE_END_TAG */
  121. acpi_rs_dump_memory24, /* ACPI_RESOURCE_TYPE_MEMORY24 */
  122. acpi_rs_dump_memory32, /* ACPI_RESOURCE_TYPE_MEMORY32 */
  123. acpi_rs_dump_fixed_memory32, /* ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */
  124. acpi_rs_dump_address16, /* ACPI_RESOURCE_TYPE_ADDRESS16 */
  125. acpi_rs_dump_address32, /* ACPI_RESOURCE_TYPE_ADDRESS32 */
  126. acpi_rs_dump_address64, /* ACPI_RESOURCE_TYPE_ADDRESS64 */
  127. acpi_rs_dump_ext_address64, /* ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
  128. acpi_rs_dump_ext_irq, /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
  129. acpi_rs_dump_generic_reg /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
  130. };
  131. #endif
  132. #endif /* ACPI_FUTURE_USAGE */
  133. /*
  134. * Base sizes for external AML resource descriptors, indexed by internal type.
  135. * Includes size of the descriptor header (1 byte for small descriptors,
  136. * 3 bytes for large descriptors)
  137. */
  138. u8 acpi_gbl_aml_resource_sizes[] = {
  139. sizeof(struct aml_resource_irq), /* ACPI_RESOURCE_TYPE_IRQ (optional Byte 3 always created) */
  140. sizeof(struct aml_resource_dma), /* ACPI_RESOURCE_TYPE_DMA */
  141. sizeof(struct aml_resource_start_dependent), /* ACPI_RESOURCE_TYPE_START_DEPENDENT (optional Byte 1 always created) */
  142. sizeof(struct aml_resource_end_dependent), /* ACPI_RESOURCE_TYPE_END_DEPENDENT */
  143. sizeof(struct aml_resource_io), /* ACPI_RESOURCE_TYPE_IO */
  144. sizeof(struct aml_resource_fixed_io), /* ACPI_RESOURCE_TYPE_FIXED_IO */
  145. sizeof(struct aml_resource_vendor_small), /* ACPI_RESOURCE_TYPE_VENDOR */
  146. sizeof(struct aml_resource_end_tag), /* ACPI_RESOURCE_TYPE_END_TAG */
  147. sizeof(struct aml_resource_memory24), /* ACPI_RESOURCE_TYPE_MEMORY24 */
  148. sizeof(struct aml_resource_memory32), /* ACPI_RESOURCE_TYPE_MEMORY32 */
  149. sizeof(struct aml_resource_fixed_memory32), /* ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */
  150. sizeof(struct aml_resource_address16), /* ACPI_RESOURCE_TYPE_ADDRESS16 */
  151. sizeof(struct aml_resource_address32), /* ACPI_RESOURCE_TYPE_ADDRESS32 */
  152. sizeof(struct aml_resource_address64), /* ACPI_RESOURCE_TYPE_ADDRESS64 */
  153. sizeof(struct aml_resource_extended_address64), /*ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
  154. sizeof(struct aml_resource_extended_irq), /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
  155. sizeof(struct aml_resource_generic_register) /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
  156. };
  157. /* Macros used in the tables below */
  158. #define ACPI_RLARGE(r) sizeof (r) - sizeof (struct aml_resource_large_header)
  159. #define ACPI_RSMALL(r) sizeof (r) - sizeof (struct aml_resource_small_header)
  160. /*
  161. * Base sizes of resource descriptors, both the AML stream resource length
  162. * (minus size of header and length fields),and the size of the internal
  163. * struct representation.
  164. */
  165. struct acpi_resource_info acpi_gbl_sm_resource_info[] = {
  166. {0, 0, 0},
  167. {0, 0, 0},
  168. {0, 0, 0},
  169. {0, 0, 0},
  170. {2, ACPI_RSMALL(struct aml_resource_irq),
  171. ACPI_SIZEOF_RESOURCE(struct acpi_resource_irq)},
  172. {0, ACPI_RSMALL(struct aml_resource_dma),
  173. ACPI_SIZEOF_RESOURCE(struct acpi_resource_dma)},
  174. {2, ACPI_RSMALL(struct aml_resource_start_dependent),
  175. ACPI_SIZEOF_RESOURCE(struct acpi_resource_start_dependent)},
  176. {0, ACPI_RSMALL(struct aml_resource_end_dependent),
  177. ACPI_RESOURCE_LENGTH},
  178. {0, ACPI_RSMALL(struct aml_resource_io),
  179. ACPI_SIZEOF_RESOURCE(struct acpi_resource_io)},
  180. {0, ACPI_RSMALL(struct aml_resource_fixed_io),
  181. ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_io)},
  182. {0, 0, 0},
  183. {0, 0, 0},
  184. {0, 0, 0},
  185. {0, 0, 0},
  186. {1, ACPI_RSMALL(struct aml_resource_vendor_small),
  187. ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor)},
  188. {0, ACPI_RSMALL(struct aml_resource_end_tag), ACPI_RESOURCE_LENGTH}
  189. };
  190. struct acpi_resource_info acpi_gbl_lg_resource_info[] = {
  191. {0, 0, 0},
  192. {0, ACPI_RLARGE(struct aml_resource_memory24),
  193. ACPI_SIZEOF_RESOURCE(struct acpi_resource_memory24)},
  194. {0, ACPI_RLARGE(struct aml_resource_generic_register),
  195. ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_registerister)},
  196. {0, 0, 0},
  197. {1, ACPI_RLARGE(struct aml_resource_vendor_large),
  198. ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor)},
  199. {0, ACPI_RLARGE(struct aml_resource_memory32),
  200. ACPI_SIZEOF_RESOURCE(struct acpi_resource_memory32)},
  201. {0, ACPI_RLARGE(struct aml_resource_fixed_memory32),
  202. ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_memory32)},
  203. {1, ACPI_RLARGE(struct aml_resource_address32),
  204. ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32)},
  205. {1, ACPI_RLARGE(struct aml_resource_address16),
  206. ACPI_SIZEOF_RESOURCE(struct acpi_resource_address16)},
  207. {1, ACPI_RLARGE(struct aml_resource_extended_irq),
  208. ACPI_SIZEOF_RESOURCE(struct acpi_resource_extended_irq)},
  209. {1, ACPI_RLARGE(struct aml_resource_address64),
  210. ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64)},
  211. {0, ACPI_RLARGE(struct aml_resource_extended_address64),
  212. ACPI_SIZEOF_RESOURCE(struct acpi_resource_extended_address64)}
  213. };