amlresrc.h 9.7 KB

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