amlresrc.h 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. /******************************************************************************
  2. *
  3. * Module Name: amlresrc.h - AML 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. /* acpisrc:struct_defs -- for acpisrc conversion */
  43. #ifndef __AMLRESRC_H
  44. #define __AMLRESRC_H
  45. /*! [Begin] no source code translation */
  46. /*
  47. * Resource descriptor tags, as defined in the ACPI specification.
  48. * Used to symbolically reference fields within a descriptor.
  49. */
  50. #define ACPI_RESTAG_ADDRESS "_ADR"
  51. #define ACPI_RESTAG_ALIGNMENT "_ALN"
  52. #define ACPI_RESTAG_ADDRESSSPACE "_ASI"
  53. #define ACPI_RESTAG_ACCESSSIZE "_ASZ"
  54. #define ACPI_RESTAG_TYPESPECIFICATTRIBUTES "_ATT"
  55. #define ACPI_RESTAG_BASEADDRESS "_BAS"
  56. #define ACPI_RESTAG_BUSMASTER "_BM_" /* Master(1), Slave(0) */
  57. #define ACPI_RESTAG_DECODE "_DEC"
  58. #define ACPI_RESTAG_DMA "_DMA"
  59. #define ACPI_RESTAG_DMATYPE "_TYP" /* Compatible(0), A(1), B(2), F(3) */
  60. #define ACPI_RESTAG_GRANULARITY "_GRA"
  61. #define ACPI_RESTAG_INTERRUPT "_INT"
  62. #define ACPI_RESTAG_INTERRUPTLEVEL "_LL_" /* ActiveLo(1), ActiveHi(0) */
  63. #define ACPI_RESTAG_INTERRUPTSHARE "_SHR" /* Shareable(1), NoShare(0) */
  64. #define ACPI_RESTAG_INTERRUPTTYPE "_HE_" /* Edge(1), Level(0) */
  65. #define ACPI_RESTAG_LENGTH "_LEN"
  66. #define ACPI_RESTAG_MEMATTRIBUTES "_MTP" /* Memory(0), Reserved(1), ACPI(2), NVS(3) */
  67. #define ACPI_RESTAG_MEMTYPE "_MEM" /* NonCache(0), Cacheable(1) Cache+combine(2), Cache+prefetch(3) */
  68. #define ACPI_RESTAG_MAXADDR "_MAX"
  69. #define ACPI_RESTAG_MINADDR "_MIN"
  70. #define ACPI_RESTAG_MAXTYPE "_MAF"
  71. #define ACPI_RESTAG_MINTYPE "_MIF"
  72. #define ACPI_RESTAG_REGISTERBITOFFSET "_RBO"
  73. #define ACPI_RESTAG_REGISTERBITWIDTH "_RBW"
  74. #define ACPI_RESTAG_RANGETYPE "_RNG"
  75. #define ACPI_RESTAG_READWRITETYPE "_RW_" /* ReadOnly(0), Writeable (1) */
  76. #define ACPI_RESTAG_TRANSLATION "_TRA"
  77. #define ACPI_RESTAG_TRANSTYPE "_TRS" /* Sparse(1), Dense(0) */
  78. #define ACPI_RESTAG_TYPE "_TTP" /* Translation(1), Static (0) */
  79. #define ACPI_RESTAG_XFERTYPE "_SIZ" /* 8(0), 8And16(1), 16(2) */
  80. /*! [End] no source code translation !*/
  81. /* Default sizes for "small" resource descriptors */
  82. #define ASL_RDESC_IRQ_SIZE 0x02
  83. #define ASL_RDESC_DMA_SIZE 0x02
  84. #define ASL_RDESC_ST_DEPEND_SIZE 0x00
  85. #define ASL_RDESC_END_DEPEND_SIZE 0x00
  86. #define ASL_RDESC_IO_SIZE 0x07
  87. #define ASL_RDESC_FIXED_IO_SIZE 0x03
  88. #define ASL_RDESC_END_TAG_SIZE 0x01
  89. struct asl_resource_node {
  90. u32 buffer_length;
  91. void *buffer;
  92. struct asl_resource_node *next;
  93. };
  94. /* Macros used to generate AML resource length fields */
  95. #define ACPI_AML_SIZE_LARGE(r) (sizeof (r) - sizeof (struct aml_resource_large_header))
  96. #define ACPI_AML_SIZE_SMALL(r) (sizeof (r) - sizeof (struct aml_resource_small_header))
  97. /*
  98. * Resource descriptors defined in the ACPI specification.
  99. *
  100. * Packing/alignment must be BYTE because these descriptors
  101. * are used to overlay the raw AML byte stream.
  102. */
  103. #pragma pack(1)
  104. /*
  105. * SMALL descriptors
  106. */
  107. #define AML_RESOURCE_SMALL_HEADER_COMMON \
  108. u8 descriptor_type;
  109. struct aml_resource_small_header {
  110. AML_RESOURCE_SMALL_HEADER_COMMON};
  111. struct aml_resource_irq {
  112. AML_RESOURCE_SMALL_HEADER_COMMON u16 irq_mask;
  113. u8 flags;
  114. };
  115. struct aml_resource_irq_noflags {
  116. AML_RESOURCE_SMALL_HEADER_COMMON u16 irq_mask;
  117. };
  118. struct aml_resource_dma {
  119. AML_RESOURCE_SMALL_HEADER_COMMON u8 dma_channel_mask;
  120. u8 flags;
  121. };
  122. struct aml_resource_start_dependent {
  123. AML_RESOURCE_SMALL_HEADER_COMMON u8 flags;
  124. };
  125. struct aml_resource_start_dependent_noprio {
  126. AML_RESOURCE_SMALL_HEADER_COMMON};
  127. struct aml_resource_end_dependent {
  128. AML_RESOURCE_SMALL_HEADER_COMMON};
  129. struct aml_resource_io {
  130. AML_RESOURCE_SMALL_HEADER_COMMON u8 flags;
  131. u16 minimum;
  132. u16 maximum;
  133. u8 alignment;
  134. u8 address_length;
  135. };
  136. struct aml_resource_fixed_io {
  137. AML_RESOURCE_SMALL_HEADER_COMMON u16 address;
  138. u8 address_length;
  139. };
  140. struct aml_resource_vendor_small {
  141. AML_RESOURCE_SMALL_HEADER_COMMON};
  142. struct aml_resource_end_tag {
  143. AML_RESOURCE_SMALL_HEADER_COMMON u8 checksum;
  144. };
  145. /*
  146. * LARGE descriptors
  147. */
  148. #define AML_RESOURCE_LARGE_HEADER_COMMON \
  149. u8 descriptor_type;\
  150. u16 resource_length;
  151. struct aml_resource_large_header {
  152. AML_RESOURCE_LARGE_HEADER_COMMON};
  153. struct aml_resource_memory24 {
  154. AML_RESOURCE_LARGE_HEADER_COMMON u8 flags;
  155. u16 minimum;
  156. u16 maximum;
  157. u16 alignment;
  158. u16 address_length;
  159. };
  160. struct aml_resource_vendor_large {
  161. AML_RESOURCE_LARGE_HEADER_COMMON};
  162. struct aml_resource_memory32 {
  163. AML_RESOURCE_LARGE_HEADER_COMMON u8 flags;
  164. u32 minimum;
  165. u32 maximum;
  166. u32 alignment;
  167. u32 address_length;
  168. };
  169. struct aml_resource_fixed_memory32 {
  170. AML_RESOURCE_LARGE_HEADER_COMMON u8 flags;
  171. u32 address;
  172. u32 address_length;
  173. };
  174. #define AML_RESOURCE_ADDRESS_COMMON \
  175. u8 resource_type; \
  176. u8 flags; \
  177. u8 specific_flags;
  178. struct aml_resource_address {
  179. AML_RESOURCE_LARGE_HEADER_COMMON AML_RESOURCE_ADDRESS_COMMON};
  180. struct aml_resource_extended_address64 {
  181. AML_RESOURCE_LARGE_HEADER_COMMON
  182. AML_RESOURCE_ADDRESS_COMMON u8 revision_iD;
  183. u8 reserved;
  184. u64 granularity;
  185. u64 minimum;
  186. u64 maximum;
  187. u64 translation_offset;
  188. u64 address_length;
  189. u64 type_specific;
  190. };
  191. #define AML_RESOURCE_EXTENDED_ADDRESS_REVISION 1 /* ACPI 3.0 */
  192. struct aml_resource_address64 {
  193. AML_RESOURCE_LARGE_HEADER_COMMON
  194. AML_RESOURCE_ADDRESS_COMMON u64 granularity;
  195. u64 minimum;
  196. u64 maximum;
  197. u64 translation_offset;
  198. u64 address_length;
  199. };
  200. struct aml_resource_address32 {
  201. AML_RESOURCE_LARGE_HEADER_COMMON
  202. AML_RESOURCE_ADDRESS_COMMON u32 granularity;
  203. u32 minimum;
  204. u32 maximum;
  205. u32 translation_offset;
  206. u32 address_length;
  207. };
  208. struct aml_resource_address16 {
  209. AML_RESOURCE_LARGE_HEADER_COMMON
  210. AML_RESOURCE_ADDRESS_COMMON u16 granularity;
  211. u16 minimum;
  212. u16 maximum;
  213. u16 translation_offset;
  214. u16 address_length;
  215. };
  216. struct aml_resource_extended_irq {
  217. AML_RESOURCE_LARGE_HEADER_COMMON u8 flags;
  218. u8 interrupt_count;
  219. u32 interrupts[1];
  220. /* res_source_index, res_source optional fields follow */
  221. };
  222. struct aml_resource_generic_register {
  223. AML_RESOURCE_LARGE_HEADER_COMMON u8 address_space_id;
  224. u8 bit_width;
  225. u8 bit_offset;
  226. u8 access_size; /* ACPI 3.0, was previously Reserved */
  227. u64 address;
  228. };
  229. /* restore default alignment */
  230. #pragma pack()
  231. /* Union of all resource descriptors, so we can allocate the worst case */
  232. union aml_resource {
  233. /* Descriptor headers */
  234. u8 descriptor_type;
  235. struct aml_resource_small_header small_header;
  236. struct aml_resource_large_header large_header;
  237. /* Small resource descriptors */
  238. struct aml_resource_irq irq;
  239. struct aml_resource_dma dma;
  240. struct aml_resource_start_dependent start_dpf;
  241. struct aml_resource_end_dependent end_dpf;
  242. struct aml_resource_io io;
  243. struct aml_resource_fixed_io fixed_io;
  244. struct aml_resource_vendor_small vendor_small;
  245. struct aml_resource_end_tag end_tag;
  246. /* Large resource descriptors */
  247. struct aml_resource_memory24 memory24;
  248. struct aml_resource_generic_register generic_reg;
  249. struct aml_resource_vendor_large vendor_large;
  250. struct aml_resource_memory32 memory32;
  251. struct aml_resource_fixed_memory32 fixed_memory32;
  252. struct aml_resource_address16 address16;
  253. struct aml_resource_address32 address32;
  254. struct aml_resource_address64 address64;
  255. struct aml_resource_extended_address64 ext_address64;
  256. struct aml_resource_extended_irq extended_irq;
  257. /* Utility overlays */
  258. struct aml_resource_address address;
  259. u32 u32_item;
  260. u16 u16_item;
  261. u8 U8item;
  262. };
  263. #endif