acresrc.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. /******************************************************************************
  2. *
  3. * Name: acresrc.h - Resource Manager function prototypes
  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. #ifndef __ACRESRC_H__
  43. #define __ACRESRC_H__
  44. /* Need the AML resource descriptor structs */
  45. #include "amlresrc.h"
  46. /*
  47. * If possible, pack the following structures to byte alignment, since we
  48. * don't care about performance for debug output
  49. */
  50. #ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED
  51. #pragma pack(1)
  52. #endif
  53. /*
  54. * Individual entry for the resource conversion tables
  55. */
  56. typedef const struct acpi_rsconvert_info {
  57. u8 opcode;
  58. u8 resource_offset;
  59. u8 aml_offset;
  60. u8 value;
  61. } acpi_rsconvert_info;
  62. /* Resource conversion opcodes */
  63. #define ACPI_RSC_INITGET 0
  64. #define ACPI_RSC_INITSET 1
  65. #define ACPI_RSC_FLAGINIT 2
  66. #define ACPI_RSC_1BITFLAG 3
  67. #define ACPI_RSC_2BITFLAG 4
  68. #define ACPI_RSC_COUNT 5
  69. #define ACPI_RSC_COUNT16 6
  70. #define ACPI_RSC_LENGTH 7
  71. #define ACPI_RSC_MOVE8 8
  72. #define ACPI_RSC_MOVE16 9
  73. #define ACPI_RSC_MOVE32 10
  74. #define ACPI_RSC_MOVE64 11
  75. #define ACPI_RSC_SET8 12
  76. #define ACPI_RSC_DATA8 13
  77. #define ACPI_RSC_ADDRESS 14
  78. #define ACPI_RSC_SOURCE 15
  79. #define ACPI_RSC_SOURCEX 16
  80. #define ACPI_RSC_BITMASK 17
  81. #define ACPI_RSC_BITMASK16 18
  82. #define ACPI_RSC_EXIT_NE 19
  83. #define ACPI_RSC_EXIT_LE 20
  84. /* Resource Conversion sub-opcodes */
  85. #define ACPI_RSC_COMPARE_AML_LENGTH 0
  86. #define ACPI_RSC_COMPARE_VALUE 1
  87. #define ACPI_RSC_TABLE_SIZE(d) (sizeof (d) / sizeof (struct acpi_rsconvert_info))
  88. #define ACPI_RS_OFFSET(f) (u8) ACPI_OFFSET (struct acpi_resource,f)
  89. #define AML_OFFSET(f) (u8) ACPI_OFFSET (union aml_resource,f)
  90. /*
  91. * Resource dispatch and info tables
  92. */
  93. typedef const struct acpi_resource_info {
  94. u8 length_type;
  95. u8 minimum_aml_resource_length;
  96. u8 minimum_internal_struct_length;
  97. } acpi_resource_info;
  98. /* Types for length_type above */
  99. #define ACPI_FIXED_LENGTH 0
  100. #define ACPI_VARIABLE_LENGTH 1
  101. #define ACPI_SMALL_VARIABLE_LENGTH 2
  102. typedef const struct acpi_rsdump_info {
  103. u8 opcode;
  104. u8 offset;
  105. char *name;
  106. const void *pointer;
  107. } acpi_rsdump_info;
  108. /* Values for the Opcode field above */
  109. #define ACPI_RSD_TITLE 0
  110. #define ACPI_RSD_LITERAL 1
  111. #define ACPI_RSD_STRING 2
  112. #define ACPI_RSD_UINT8 3
  113. #define ACPI_RSD_UINT16 4
  114. #define ACPI_RSD_UINT32 5
  115. #define ACPI_RSD_UINT64 6
  116. #define ACPI_RSD_1BITFLAG 7
  117. #define ACPI_RSD_2BITFLAG 8
  118. #define ACPI_RSD_SHORTLIST 9
  119. #define ACPI_RSD_LONGLIST 10
  120. #define ACPI_RSD_DWORDLIST 11
  121. #define ACPI_RSD_ADDRESS 12
  122. #define ACPI_RSD_SOURCE 13
  123. /* restore default alignment */
  124. #pragma pack()
  125. /* Resource tables indexed by internal resource type */
  126. extern const u8 acpi_gbl_aml_resource_sizes[];
  127. extern struct acpi_rsconvert_info *acpi_gbl_set_resource_dispatch[];
  128. /* Resource tables indexed by raw AML resource descriptor type */
  129. extern struct acpi_resource_info acpi_gbl_sm_resource_info[];
  130. extern struct acpi_resource_info acpi_gbl_lg_resource_info[];
  131. extern struct acpi_rsconvert_info *acpi_gbl_sm_get_resource_dispatch[];
  132. extern struct acpi_rsconvert_info *acpi_gbl_lg_get_resource_dispatch[];
  133. /*
  134. * rscreate
  135. */
  136. acpi_status
  137. acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer,
  138. struct acpi_buffer *output_buffer);
  139. acpi_status
  140. acpi_rs_create_aml_resources(struct acpi_resource *linked_list_buffer,
  141. struct acpi_buffer *output_buffer);
  142. acpi_status
  143. acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
  144. struct acpi_buffer *output_buffer);
  145. /*
  146. * rsutils
  147. */
  148. acpi_status
  149. acpi_rs_get_prt_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer);
  150. acpi_status
  151. acpi_rs_get_crs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer);
  152. #ifdef ACPI_FUTURE_USAGE
  153. acpi_status
  154. acpi_rs_get_prs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer);
  155. #endif /* ACPI_FUTURE_USAGE */
  156. acpi_status
  157. acpi_rs_get_method_data(acpi_handle handle,
  158. char *path, struct acpi_buffer *ret_buffer);
  159. acpi_status
  160. acpi_rs_set_srs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer);
  161. /*
  162. * rscalc
  163. */
  164. acpi_status
  165. acpi_rs_get_list_length(u8 * aml_buffer,
  166. u32 aml_buffer_length, acpi_size * size_needed);
  167. acpi_status
  168. acpi_rs_get_aml_length(struct acpi_resource *linked_list_buffer,
  169. acpi_size * size_needed);
  170. acpi_status
  171. acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object,
  172. acpi_size * buffer_size_needed);
  173. acpi_status
  174. acpi_rs_convert_aml_to_resources(u8 * aml_buffer,
  175. u32 aml_buffer_length, u8 * output_buffer);
  176. acpi_status
  177. acpi_rs_convert_resources_to_aml(struct acpi_resource *resource,
  178. acpi_size aml_size_needed, u8 * output_buffer);
  179. /*
  180. * rsaddr
  181. */
  182. void
  183. acpi_rs_set_address_common(union aml_resource *aml,
  184. struct acpi_resource *resource);
  185. u8
  186. acpi_rs_get_address_common(struct acpi_resource *resource,
  187. union aml_resource *aml);
  188. /*
  189. * rsmisc
  190. */
  191. acpi_status
  192. acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
  193. union aml_resource *aml,
  194. struct acpi_rsconvert_info *info);
  195. acpi_status
  196. acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
  197. union aml_resource *aml,
  198. struct acpi_rsconvert_info *info);
  199. /*
  200. * rsutils
  201. */
  202. void
  203. acpi_rs_move_data(void *destination,
  204. void *source, u16 item_count, u8 move_type);
  205. u8 acpi_rs_decode_bitmask(u16 mask, u8 * list);
  206. u16 acpi_rs_encode_bitmask(u8 * list, u8 count);
  207. acpi_rs_length
  208. acpi_rs_get_resource_source(acpi_rs_length resource_length,
  209. acpi_rs_length minimum_length,
  210. struct acpi_resource_source *resource_source,
  211. union aml_resource *aml, char *string_ptr);
  212. acpi_rsdesc_size
  213. acpi_rs_set_resource_source(union aml_resource *aml,
  214. acpi_rs_length minimum_length,
  215. struct acpi_resource_source *resource_source);
  216. void
  217. acpi_rs_set_resource_header(u8 descriptor_type,
  218. acpi_rsdesc_size total_length,
  219. union aml_resource *aml);
  220. void
  221. acpi_rs_set_resource_length(acpi_rsdesc_size total_length,
  222. union aml_resource *aml);
  223. struct acpi_resource_info *acpi_rs_get_resource_info(u8 resource_type);
  224. /*
  225. * rsdump
  226. */
  227. void acpi_rs_dump_resource_list(struct acpi_resource *resource);
  228. void acpi_rs_dump_irq_list(u8 * route_table);
  229. /*
  230. * Resource conversion tables
  231. */
  232. extern struct acpi_rsconvert_info acpi_rs_convert_dma[];
  233. extern struct acpi_rsconvert_info acpi_rs_convert_end_dpf[];
  234. extern struct acpi_rsconvert_info acpi_rs_convert_io[];
  235. extern struct acpi_rsconvert_info acpi_rs_convert_fixed_io[];
  236. extern struct acpi_rsconvert_info acpi_rs_convert_end_tag[];
  237. extern struct acpi_rsconvert_info acpi_rs_convert_memory24[];
  238. extern struct acpi_rsconvert_info acpi_rs_convert_generic_reg[];
  239. extern struct acpi_rsconvert_info acpi_rs_convert_memory32[];
  240. extern struct acpi_rsconvert_info acpi_rs_convert_fixed_memory32[];
  241. extern struct acpi_rsconvert_info acpi_rs_convert_address32[];
  242. extern struct acpi_rsconvert_info acpi_rs_convert_address16[];
  243. extern struct acpi_rsconvert_info acpi_rs_convert_ext_irq[];
  244. extern struct acpi_rsconvert_info acpi_rs_convert_address64[];
  245. extern struct acpi_rsconvert_info acpi_rs_convert_ext_address64[];
  246. /* These resources require separate get/set tables */
  247. extern struct acpi_rsconvert_info acpi_rs_get_irq[];
  248. extern struct acpi_rsconvert_info acpi_rs_get_start_dpf[];
  249. extern struct acpi_rsconvert_info acpi_rs_get_vendor_small[];
  250. extern struct acpi_rsconvert_info acpi_rs_get_vendor_large[];
  251. extern struct acpi_rsconvert_info acpi_rs_set_irq[];
  252. extern struct acpi_rsconvert_info acpi_rs_set_start_dpf[];
  253. extern struct acpi_rsconvert_info acpi_rs_set_vendor[];
  254. #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
  255. /*
  256. * rsinfo
  257. */
  258. extern struct acpi_rsdump_info *acpi_gbl_dump_resource_dispatch[];
  259. /*
  260. * rsdump
  261. */
  262. extern struct acpi_rsdump_info acpi_rs_dump_irq[];
  263. extern struct acpi_rsdump_info acpi_rs_dump_dma[];
  264. extern struct acpi_rsdump_info acpi_rs_dump_start_dpf[];
  265. extern struct acpi_rsdump_info acpi_rs_dump_end_dpf[];
  266. extern struct acpi_rsdump_info acpi_rs_dump_io[];
  267. extern struct acpi_rsdump_info acpi_rs_dump_fixed_io[];
  268. extern struct acpi_rsdump_info acpi_rs_dump_vendor[];
  269. extern struct acpi_rsdump_info acpi_rs_dump_end_tag[];
  270. extern struct acpi_rsdump_info acpi_rs_dump_memory24[];
  271. extern struct acpi_rsdump_info acpi_rs_dump_memory32[];
  272. extern struct acpi_rsdump_info acpi_rs_dump_fixed_memory32[];
  273. extern struct acpi_rsdump_info acpi_rs_dump_address16[];
  274. extern struct acpi_rsdump_info acpi_rs_dump_address32[];
  275. extern struct acpi_rsdump_info acpi_rs_dump_address64[];
  276. extern struct acpi_rsdump_info acpi_rs_dump_ext_address64[];
  277. extern struct acpi_rsdump_info acpi_rs_dump_ext_irq[];
  278. extern struct acpi_rsdump_info acpi_rs_dump_generic_reg[];
  279. #endif
  280. #endif /* __ACRESRC_H__ */