acresrc.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. /******************************************************************************
  2. *
  3. * Name: acresrc.h - Resource Manager function prototypes
  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. #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. Two cases where we cannot
  49. * pack the structures:
  50. *
  51. * 1) Hardware does not support misaligned memory transfers
  52. * 2) Compiler does not support pointers within packed structures
  53. */
  54. #if (!defined(ACPI_MISALIGNMENT_NOT_SUPPORTED) && !defined(ACPI_PACKED_POINTERS_NOT_SUPPORTED))
  55. #pragma pack(1)
  56. #endif
  57. /*
  58. * Individual entry for the resource conversion tables
  59. */
  60. typedef const struct acpi_rsconvert_info {
  61. u8 opcode;
  62. u8 resource_offset;
  63. u8 aml_offset;
  64. u8 value;
  65. } acpi_rsconvert_info;
  66. /* Resource conversion opcodes */
  67. typedef enum {
  68. ACPI_RSC_INITGET = 0,
  69. ACPI_RSC_INITSET,
  70. ACPI_RSC_FLAGINIT,
  71. ACPI_RSC_1BITFLAG,
  72. ACPI_RSC_2BITFLAG,
  73. ACPI_RSC_3BITFLAG,
  74. ACPI_RSC_ADDRESS,
  75. ACPI_RSC_BITMASK,
  76. ACPI_RSC_BITMASK16,
  77. ACPI_RSC_COUNT,
  78. ACPI_RSC_COUNT16,
  79. ACPI_RSC_COUNT_GPIO_PIN,
  80. ACPI_RSC_COUNT_GPIO_RES,
  81. ACPI_RSC_COUNT_GPIO_VEN,
  82. ACPI_RSC_COUNT_SERIAL_RES,
  83. ACPI_RSC_COUNT_SERIAL_VEN,
  84. ACPI_RSC_DATA8,
  85. ACPI_RSC_EXIT_EQ,
  86. ACPI_RSC_EXIT_LE,
  87. ACPI_RSC_EXIT_NE,
  88. ACPI_RSC_LENGTH,
  89. ACPI_RSC_MOVE_GPIO_PIN,
  90. ACPI_RSC_MOVE_GPIO_RES,
  91. ACPI_RSC_MOVE_SERIAL_RES,
  92. ACPI_RSC_MOVE_SERIAL_VEN,
  93. ACPI_RSC_MOVE8,
  94. ACPI_RSC_MOVE16,
  95. ACPI_RSC_MOVE32,
  96. ACPI_RSC_MOVE64,
  97. ACPI_RSC_SET8,
  98. ACPI_RSC_SOURCE,
  99. ACPI_RSC_SOURCEX
  100. } ACPI_RSCONVERT_OPCODES;
  101. /* Resource Conversion sub-opcodes */
  102. #define ACPI_RSC_COMPARE_AML_LENGTH 0
  103. #define ACPI_RSC_COMPARE_VALUE 1
  104. #define ACPI_RSC_TABLE_SIZE(d) (sizeof (d) / sizeof (struct acpi_rsconvert_info))
  105. #define ACPI_RS_OFFSET(f) (u8) ACPI_OFFSET (struct acpi_resource,f)
  106. #define AML_OFFSET(f) (u8) ACPI_OFFSET (union aml_resource,f)
  107. /*
  108. * Individual entry for the resource dump tables
  109. */
  110. typedef const struct acpi_rsdump_info {
  111. u8 opcode;
  112. u8 offset;
  113. char *name;
  114. const char **pointer;
  115. } acpi_rsdump_info;
  116. /* Values for the Opcode field above */
  117. typedef enum {
  118. ACPI_RSD_TITLE = 0,
  119. ACPI_RSD_1BITFLAG,
  120. ACPI_RSD_2BITFLAG,
  121. ACPI_RSD_3BITFLAG,
  122. ACPI_RSD_ADDRESS,
  123. ACPI_RSD_DWORDLIST,
  124. ACPI_RSD_LITERAL,
  125. ACPI_RSD_LONGLIST,
  126. ACPI_RSD_SHORTLIST,
  127. ACPI_RSD_SHORTLISTX,
  128. ACPI_RSD_SOURCE,
  129. ACPI_RSD_STRING,
  130. ACPI_RSD_UINT8,
  131. ACPI_RSD_UINT16,
  132. ACPI_RSD_UINT32,
  133. ACPI_RSD_UINT64,
  134. ACPI_RSD_WORDLIST
  135. } ACPI_RSDUMP_OPCODES;
  136. /* restore default alignment */
  137. #pragma pack()
  138. /* Resource tables indexed by internal resource type */
  139. extern const u8 acpi_gbl_aml_resource_sizes[];
  140. extern const u8 acpi_gbl_aml_resource_serial_bus_sizes[];
  141. extern struct acpi_rsconvert_info *acpi_gbl_set_resource_dispatch[];
  142. /* Resource tables indexed by raw AML resource descriptor type */
  143. extern const u8 acpi_gbl_resource_struct_sizes[];
  144. extern const u8 acpi_gbl_resource_struct_serial_bus_sizes[];
  145. extern struct acpi_rsconvert_info *acpi_gbl_get_resource_dispatch[];
  146. extern struct acpi_rsconvert_info
  147. *acpi_gbl_convert_resource_serial_bus_dispatch[];
  148. struct acpi_vendor_walk_info {
  149. struct acpi_vendor_uuid *uuid;
  150. struct acpi_buffer *buffer;
  151. acpi_status status;
  152. };
  153. /*
  154. * rscreate
  155. */
  156. acpi_status
  157. acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer,
  158. struct acpi_buffer *output_buffer);
  159. acpi_status
  160. acpi_rs_create_aml_resources(struct acpi_resource *linked_list_buffer,
  161. struct acpi_buffer *output_buffer);
  162. acpi_status
  163. acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
  164. struct acpi_buffer *output_buffer);
  165. /*
  166. * rsutils
  167. */
  168. acpi_status
  169. acpi_rs_get_prt_method_data(struct acpi_namespace_node *node,
  170. struct acpi_buffer *ret_buffer);
  171. acpi_status
  172. acpi_rs_get_crs_method_data(struct acpi_namespace_node *node,
  173. struct acpi_buffer *ret_buffer);
  174. acpi_status
  175. acpi_rs_get_prs_method_data(struct acpi_namespace_node *node,
  176. struct acpi_buffer *ret_buffer);
  177. acpi_status
  178. acpi_rs_get_method_data(acpi_handle handle,
  179. char *path, struct acpi_buffer *ret_buffer);
  180. acpi_status
  181. acpi_rs_set_srs_method_data(struct acpi_namespace_node *node,
  182. struct acpi_buffer *ret_buffer);
  183. acpi_status
  184. acpi_rs_get_aei_method_data(struct acpi_namespace_node *node,
  185. struct acpi_buffer *ret_buffer);
  186. /*
  187. * rscalc
  188. */
  189. acpi_status
  190. acpi_rs_get_list_length(u8 * aml_buffer,
  191. u32 aml_buffer_length, acpi_size * size_needed);
  192. acpi_status
  193. acpi_rs_get_aml_length(struct acpi_resource *linked_list_buffer,
  194. acpi_size * size_needed);
  195. acpi_status
  196. acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object,
  197. acpi_size * buffer_size_needed);
  198. acpi_status
  199. acpi_rs_convert_aml_to_resources(u8 * aml,
  200. u32 length,
  201. u32 offset, u8 resource_index, void **context);
  202. acpi_status
  203. acpi_rs_convert_resources_to_aml(struct acpi_resource *resource,
  204. acpi_size aml_size_needed, u8 * output_buffer);
  205. /*
  206. * rsaddr
  207. */
  208. void
  209. acpi_rs_set_address_common(union aml_resource *aml,
  210. struct acpi_resource *resource);
  211. u8
  212. acpi_rs_get_address_common(struct acpi_resource *resource,
  213. union aml_resource *aml);
  214. /*
  215. * rsmisc
  216. */
  217. acpi_status
  218. acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
  219. union aml_resource *aml,
  220. struct acpi_rsconvert_info *info);
  221. acpi_status
  222. acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
  223. union aml_resource *aml,
  224. struct acpi_rsconvert_info *info);
  225. /*
  226. * rsutils
  227. */
  228. void
  229. acpi_rs_move_data(void *destination,
  230. void *source, u16 item_count, u8 move_type);
  231. u8 acpi_rs_decode_bitmask(u16 mask, u8 * list);
  232. u16 acpi_rs_encode_bitmask(u8 * list, u8 count);
  233. acpi_rs_length
  234. acpi_rs_get_resource_source(acpi_rs_length resource_length,
  235. acpi_rs_length minimum_length,
  236. struct acpi_resource_source *resource_source,
  237. union aml_resource *aml, char *string_ptr);
  238. acpi_rsdesc_size
  239. acpi_rs_set_resource_source(union aml_resource *aml,
  240. acpi_rs_length minimum_length,
  241. struct acpi_resource_source *resource_source);
  242. void
  243. acpi_rs_set_resource_header(u8 descriptor_type,
  244. acpi_rsdesc_size total_length,
  245. union aml_resource *aml);
  246. void
  247. acpi_rs_set_resource_length(acpi_rsdesc_size total_length,
  248. union aml_resource *aml);
  249. /*
  250. * rsdump
  251. */
  252. void acpi_rs_dump_resource_list(struct acpi_resource *resource);
  253. void acpi_rs_dump_irq_list(u8 * route_table);
  254. /*
  255. * Resource conversion tables
  256. */
  257. extern struct acpi_rsconvert_info acpi_rs_convert_dma[];
  258. extern struct acpi_rsconvert_info acpi_rs_convert_end_dpf[];
  259. extern struct acpi_rsconvert_info acpi_rs_convert_io[];
  260. extern struct acpi_rsconvert_info acpi_rs_convert_fixed_io[];
  261. extern struct acpi_rsconvert_info acpi_rs_convert_end_tag[];
  262. extern struct acpi_rsconvert_info acpi_rs_convert_memory24[];
  263. extern struct acpi_rsconvert_info acpi_rs_convert_generic_reg[];
  264. extern struct acpi_rsconvert_info acpi_rs_convert_memory32[];
  265. extern struct acpi_rsconvert_info acpi_rs_convert_fixed_memory32[];
  266. extern struct acpi_rsconvert_info acpi_rs_convert_address32[];
  267. extern struct acpi_rsconvert_info acpi_rs_convert_address16[];
  268. extern struct acpi_rsconvert_info acpi_rs_convert_ext_irq[];
  269. extern struct acpi_rsconvert_info acpi_rs_convert_address64[];
  270. extern struct acpi_rsconvert_info acpi_rs_convert_ext_address64[];
  271. extern struct acpi_rsconvert_info acpi_rs_convert_gpio[];
  272. extern struct acpi_rsconvert_info acpi_rs_convert_fixed_dma[];
  273. extern struct acpi_rsconvert_info acpi_rs_convert_i2c_serial_bus[];
  274. extern struct acpi_rsconvert_info acpi_rs_convert_spi_serial_bus[];
  275. extern struct acpi_rsconvert_info acpi_rs_convert_uart_serial_bus[];
  276. /* These resources require separate get/set tables */
  277. extern struct acpi_rsconvert_info acpi_rs_get_irq[];
  278. extern struct acpi_rsconvert_info acpi_rs_get_start_dpf[];
  279. extern struct acpi_rsconvert_info acpi_rs_get_vendor_small[];
  280. extern struct acpi_rsconvert_info acpi_rs_get_vendor_large[];
  281. extern struct acpi_rsconvert_info acpi_rs_set_irq[];
  282. extern struct acpi_rsconvert_info acpi_rs_set_start_dpf[];
  283. extern struct acpi_rsconvert_info acpi_rs_set_vendor[];
  284. #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
  285. /*
  286. * rsinfo
  287. */
  288. extern struct acpi_rsdump_info *acpi_gbl_dump_resource_dispatch[];
  289. extern struct acpi_rsdump_info *acpi_gbl_dump_serial_bus_dispatch[];
  290. /*
  291. * rsdump
  292. */
  293. extern struct acpi_rsdump_info acpi_rs_dump_irq[];
  294. extern struct acpi_rsdump_info acpi_rs_dump_dma[];
  295. extern struct acpi_rsdump_info acpi_rs_dump_start_dpf[];
  296. extern struct acpi_rsdump_info acpi_rs_dump_end_dpf[];
  297. extern struct acpi_rsdump_info acpi_rs_dump_io[];
  298. extern struct acpi_rsdump_info acpi_rs_dump_fixed_io[];
  299. extern struct acpi_rsdump_info acpi_rs_dump_vendor[];
  300. extern struct acpi_rsdump_info acpi_rs_dump_end_tag[];
  301. extern struct acpi_rsdump_info acpi_rs_dump_memory24[];
  302. extern struct acpi_rsdump_info acpi_rs_dump_memory32[];
  303. extern struct acpi_rsdump_info acpi_rs_dump_fixed_memory32[];
  304. extern struct acpi_rsdump_info acpi_rs_dump_address16[];
  305. extern struct acpi_rsdump_info acpi_rs_dump_address32[];
  306. extern struct acpi_rsdump_info acpi_rs_dump_address64[];
  307. extern struct acpi_rsdump_info acpi_rs_dump_ext_address64[];
  308. extern struct acpi_rsdump_info acpi_rs_dump_ext_irq[];
  309. extern struct acpi_rsdump_info acpi_rs_dump_generic_reg[];
  310. extern struct acpi_rsdump_info acpi_rs_dump_gpio[];
  311. extern struct acpi_rsdump_info acpi_rs_dump_fixed_dma[];
  312. extern struct acpi_rsdump_info acpi_rs_dump_common_serial_bus[];
  313. extern struct acpi_rsdump_info acpi_rs_dump_i2c_serial_bus[];
  314. extern struct acpi_rsdump_info acpi_rs_dump_spi_serial_bus[];
  315. extern struct acpi_rsdump_info acpi_rs_dump_uart_serial_bus[];
  316. #endif
  317. #endif /* __ACRESRC_H__ */