xref: /titanic_51/usr/src/uts/intel/sys/acpi/amlresrc.h (revision 45e662eb8429b38c18931ebeed30f2e5287ae51b)
1 
2 /******************************************************************************
3  *
4  * Module Name: amlresrc.h - AML resource descriptors
5  *
6  *****************************************************************************/
7 
8 /*
9  * Copyright (C) 2000 - 2011, Intel Corp.
10  * All rights reserved.
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  * 1. Redistributions of source code must retain the above copyright
16  *    notice, this list of conditions, and the following disclaimer,
17  *    without modification.
18  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19  *    substantially similar to the "NO WARRANTY" disclaimer below
20  *    ("Disclaimer") and any redistribution must be conditioned upon
21  *    including a substantially similar Disclaimer requirement for further
22  *    binary redistribution.
23  * 3. Neither the names of the above-listed copyright holders nor the names
24  *    of any contributors may be used to endorse or promote products derived
25  *    from this software without specific prior written permission.
26  *
27  * Alternatively, this software may be distributed under the terms of the
28  * GNU General Public License ("GPL") version 2 as published by the Free
29  * Software Foundation.
30  *
31  * NO WARRANTY
32  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42  * POSSIBILITY OF SUCH DAMAGES.
43  */
44 
45 /* acpisrc:StructDefs -- for acpisrc conversion */
46 
47 #ifndef __AMLRESRC_H
48 #define __AMLRESRC_H
49 
50 
51 /*
52  * Resource descriptor tags, as defined in the ACPI specification.
53  * Used to symbolically reference fields within a descriptor.
54  */
55 #define ACPI_RESTAG_ADDRESS                     "_ADR"
56 #define ACPI_RESTAG_ALIGNMENT                   "_ALN"
57 #define ACPI_RESTAG_ADDRESSSPACE                "_ASI"
58 #define ACPI_RESTAG_ACCESSSIZE                  "_ASZ"
59 #define ACPI_RESTAG_TYPESPECIFICATTRIBUTES      "_ATT"
60 #define ACPI_RESTAG_BASEADDRESS                 "_BAS"
61 #define ACPI_RESTAG_BUSMASTER                   "_BM_"  /* Master(1), Slave(0) */
62 #define ACPI_RESTAG_DECODE                      "_DEC"
63 #define ACPI_RESTAG_DMA                         "_DMA"
64 #define ACPI_RESTAG_DMATYPE                     "_TYP"  /* Compatible(0), A(1), B(2), F(3) */
65 #define ACPI_RESTAG_GRANULARITY                 "_GRA"
66 #define ACPI_RESTAG_INTERRUPT                   "_INT"
67 #define ACPI_RESTAG_INTERRUPTLEVEL              "_LL_"  /* ActiveLo(1), ActiveHi(0) */
68 #define ACPI_RESTAG_INTERRUPTSHARE              "_SHR"  /* Shareable(1), NoShare(0) */
69 #define ACPI_RESTAG_INTERRUPTTYPE               "_HE_"  /* Edge(1), Level(0) */
70 #define ACPI_RESTAG_LENGTH                      "_LEN"
71 #define ACPI_RESTAG_MEMATTRIBUTES               "_MTP"  /* Memory(0), Reserved(1), ACPI(2), NVS(3) */
72 #define ACPI_RESTAG_MEMTYPE                     "_MEM"  /* NonCache(0), Cacheable(1) Cache+combine(2), Cache+prefetch(3) */
73 #define ACPI_RESTAG_MAXADDR                     "_MAX"
74 #define ACPI_RESTAG_MINADDR                     "_MIN"
75 #define ACPI_RESTAG_MAXTYPE                     "_MAF"
76 #define ACPI_RESTAG_MINTYPE                     "_MIF"
77 #define ACPI_RESTAG_REGISTERBITOFFSET           "_RBO"
78 #define ACPI_RESTAG_REGISTERBITWIDTH            "_RBW"
79 #define ACPI_RESTAG_RANGETYPE                   "_RNG"
80 #define ACPI_RESTAG_READWRITETYPE               "_RW_"  /* ReadOnly(0), Writeable (1) */
81 #define ACPI_RESTAG_TRANSLATION                 "_TRA"
82 #define ACPI_RESTAG_TRANSTYPE                   "_TRS"  /* Sparse(1), Dense(0) */
83 #define ACPI_RESTAG_TYPE                        "_TTP"  /* Translation(1), Static (0) */
84 #define ACPI_RESTAG_XFERTYPE                    "_SIZ"  /* 8(0), 8And16(1), 16(2) */
85 
86 
87 /* Default sizes for "small" resource descriptors */
88 
89 #define ASL_RDESC_IRQ_SIZE                      0x02
90 #define ASL_RDESC_DMA_SIZE                      0x02
91 #define ASL_RDESC_ST_DEPEND_SIZE                0x00
92 #define ASL_RDESC_END_DEPEND_SIZE               0x00
93 #define ASL_RDESC_IO_SIZE                       0x07
94 #define ASL_RDESC_FIXED_IO_SIZE                 0x03
95 #define ASL_RDESC_END_TAG_SIZE                  0x01
96 
97 
98 typedef struct asl_resource_node
99 {
100     UINT32                          BufferLength;
101     void                            *Buffer;
102     struct asl_resource_node        *Next;
103 
104 } ASL_RESOURCE_NODE;
105 
106 
107 /* Macros used to generate AML resource length fields */
108 
109 #define ACPI_AML_SIZE_LARGE(r)      (sizeof (r) - sizeof (AML_RESOURCE_LARGE_HEADER))
110 #define ACPI_AML_SIZE_SMALL(r)      (sizeof (r) - sizeof (AML_RESOURCE_SMALL_HEADER))
111 
112 /*
113  * Resource descriptors defined in the ACPI specification.
114  *
115  * Packing/alignment must be BYTE because these descriptors
116  * are used to overlay the raw AML byte stream.
117  */
118 #pragma pack(1)
119 
120 /*
121  * SMALL descriptors
122  */
123 #define AML_RESOURCE_SMALL_HEADER_COMMON \
124     UINT8                           DescriptorType;
125 
126 typedef struct aml_resource_small_header
127 {
128     AML_RESOURCE_SMALL_HEADER_COMMON
129 
130 } AML_RESOURCE_SMALL_HEADER;
131 
132 
133 typedef struct aml_resource_irq
134 {
135     AML_RESOURCE_SMALL_HEADER_COMMON
136     UINT16                          IrqMask;
137     UINT8                           Flags;
138 
139 } AML_RESOURCE_IRQ;
140 
141 
142 typedef struct aml_resource_irq_noflags
143 {
144     AML_RESOURCE_SMALL_HEADER_COMMON
145     UINT16                          IrqMask;
146 
147 } AML_RESOURCE_IRQ_NOFLAGS;
148 
149 
150 typedef struct aml_resource_dma
151 {
152     AML_RESOURCE_SMALL_HEADER_COMMON
153     UINT8                           DmaChannelMask;
154     UINT8                           Flags;
155 
156 } AML_RESOURCE_DMA;
157 
158 
159 typedef struct aml_resource_start_dependent
160 {
161     AML_RESOURCE_SMALL_HEADER_COMMON
162     UINT8                           Flags;
163 
164 } AML_RESOURCE_START_DEPENDENT;
165 
166 
167 typedef struct aml_resource_start_dependent_noprio
168 {
169     AML_RESOURCE_SMALL_HEADER_COMMON
170 
171 } AML_RESOURCE_START_DEPENDENT_NOPRIO;
172 
173 
174 typedef struct aml_resource_end_dependent
175 {
176     AML_RESOURCE_SMALL_HEADER_COMMON
177 
178 } AML_RESOURCE_END_DEPENDENT;
179 
180 
181 typedef struct aml_resource_io
182 {
183     AML_RESOURCE_SMALL_HEADER_COMMON
184     UINT8                           Flags;
185     UINT16                          Minimum;
186     UINT16                          Maximum;
187     UINT8                           Alignment;
188     UINT8                           AddressLength;
189 
190 } AML_RESOURCE_IO;
191 
192 
193 typedef struct aml_resource_fixed_io
194 {
195     AML_RESOURCE_SMALL_HEADER_COMMON
196     UINT16                          Address;
197     UINT8                           AddressLength;
198 
199 } AML_RESOURCE_FIXED_IO;
200 
201 
202 typedef struct aml_resource_vendor_small
203 {
204     AML_RESOURCE_SMALL_HEADER_COMMON
205 
206 } AML_RESOURCE_VENDOR_SMALL;
207 
208 
209 typedef struct aml_resource_end_tag
210 {
211     AML_RESOURCE_SMALL_HEADER_COMMON
212     UINT8                           Checksum;
213 
214 } AML_RESOURCE_END_TAG;
215 
216 
217 /*
218  * LARGE descriptors
219  */
220 #define AML_RESOURCE_LARGE_HEADER_COMMON \
221     UINT8                           DescriptorType;\
222     UINT16                          ResourceLength;
223 
224 typedef struct aml_resource_large_header
225 {
226     AML_RESOURCE_LARGE_HEADER_COMMON
227 
228 } AML_RESOURCE_LARGE_HEADER;
229 
230 
231 /* General Flags for address space resource descriptors */
232 
233 #define ACPI_RESOURCE_FLAG_DEC      2
234 #define ACPI_RESOURCE_FLAG_MIF      4
235 #define ACPI_RESOURCE_FLAG_MAF      8
236 
237 typedef struct aml_resource_memory24
238 {
239     AML_RESOURCE_LARGE_HEADER_COMMON
240     UINT8                           Flags;
241     UINT16                          Minimum;
242     UINT16                          Maximum;
243     UINT16                          Alignment;
244     UINT16                          AddressLength;
245 
246 } AML_RESOURCE_MEMORY24;
247 
248 
249 typedef struct aml_resource_vendor_large
250 {
251     AML_RESOURCE_LARGE_HEADER_COMMON
252 
253 } AML_RESOURCE_VENDOR_LARGE;
254 
255 
256 typedef struct aml_resource_memory32
257 {
258     AML_RESOURCE_LARGE_HEADER_COMMON
259     UINT8                           Flags;
260     UINT32                          Minimum;
261     UINT32                          Maximum;
262     UINT32                          Alignment;
263     UINT32                          AddressLength;
264 
265 } AML_RESOURCE_MEMORY32;
266 
267 
268 typedef struct aml_resource_fixed_memory32
269 {
270     AML_RESOURCE_LARGE_HEADER_COMMON
271     UINT8                           Flags;
272     UINT32                          Address;
273     UINT32                          AddressLength;
274 
275 } AML_RESOURCE_FIXED_MEMORY32;
276 
277 
278 #define AML_RESOURCE_ADDRESS_COMMON \
279     UINT8                           ResourceType; \
280     UINT8                           Flags; \
281     UINT8                           SpecificFlags;
282 
283 
284 typedef struct aml_resource_address
285 {
286     AML_RESOURCE_LARGE_HEADER_COMMON
287     AML_RESOURCE_ADDRESS_COMMON
288 
289 } AML_RESOURCE_ADDRESS;
290 
291 
292 typedef struct aml_resource_extended_address64
293 {
294     AML_RESOURCE_LARGE_HEADER_COMMON
295     AML_RESOURCE_ADDRESS_COMMON
296     UINT8                           RevisionID;
297     UINT8                           Reserved;
298     UINT64                          Granularity;
299     UINT64                          Minimum;
300     UINT64                          Maximum;
301     UINT64                          TranslationOffset;
302     UINT64                          AddressLength;
303     UINT64                          TypeSpecific;
304 
305 } AML_RESOURCE_EXTENDED_ADDRESS64;
306 
307 #define AML_RESOURCE_EXTENDED_ADDRESS_REVISION          1       /* ACPI 3.0 */
308 
309 
310 typedef struct aml_resource_address64
311 {
312     AML_RESOURCE_LARGE_HEADER_COMMON
313     AML_RESOURCE_ADDRESS_COMMON
314     UINT64                          Granularity;
315     UINT64                          Minimum;
316     UINT64                          Maximum;
317     UINT64                          TranslationOffset;
318     UINT64                          AddressLength;
319 
320 } AML_RESOURCE_ADDRESS64;
321 
322 
323 typedef struct aml_resource_address32
324 {
325     AML_RESOURCE_LARGE_HEADER_COMMON
326     AML_RESOURCE_ADDRESS_COMMON
327     UINT32                          Granularity;
328     UINT32                          Minimum;
329     UINT32                          Maximum;
330     UINT32                          TranslationOffset;
331     UINT32                          AddressLength;
332 
333 } AML_RESOURCE_ADDRESS32;
334 
335 
336 typedef struct aml_resource_address16
337 {
338     AML_RESOURCE_LARGE_HEADER_COMMON
339     AML_RESOURCE_ADDRESS_COMMON
340     UINT16                          Granularity;
341     UINT16                          Minimum;
342     UINT16                          Maximum;
343     UINT16                          TranslationOffset;
344     UINT16                          AddressLength;
345 
346 } AML_RESOURCE_ADDRESS16;
347 
348 
349 typedef struct aml_resource_extended_irq
350 {
351     AML_RESOURCE_LARGE_HEADER_COMMON
352     UINT8                           Flags;
353     UINT8                           InterruptCount;
354     UINT32                          Interrupts[1];
355     /* ResSourceIndex, ResSource optional fields follow */
356 
357 } AML_RESOURCE_EXTENDED_IRQ;
358 
359 
360 typedef struct aml_resource_generic_register
361 {
362     AML_RESOURCE_LARGE_HEADER_COMMON
363     UINT8                           AddressSpaceId;
364     UINT8                           BitWidth;
365     UINT8                           BitOffset;
366     UINT8                           AccessSize; /* ACPI 3.0, was previously Reserved */
367     UINT64                          Address;
368 
369 } AML_RESOURCE_GENERIC_REGISTER;
370 
371 /* restore default alignment */
372 
373 #pragma pack()
374 
375 /* Union of all resource descriptors, so we can allocate the worst case */
376 
377 typedef union aml_resource
378 {
379     /* Descriptor headers */
380 
381     UINT8                                   DescriptorType;
382     AML_RESOURCE_SMALL_HEADER               SmallHeader;
383     AML_RESOURCE_LARGE_HEADER               LargeHeader;
384 
385     /* Small resource descriptors */
386 
387     AML_RESOURCE_IRQ                        Irq;
388     AML_RESOURCE_DMA                        Dma;
389     AML_RESOURCE_START_DEPENDENT            StartDpf;
390     AML_RESOURCE_END_DEPENDENT              EndDpf;
391     AML_RESOURCE_IO                         Io;
392     AML_RESOURCE_FIXED_IO                   FixedIo;
393     AML_RESOURCE_VENDOR_SMALL               VendorSmall;
394     AML_RESOURCE_END_TAG                    EndTag;
395 
396     /* Large resource descriptors */
397 
398     AML_RESOURCE_MEMORY24                   Memory24;
399     AML_RESOURCE_GENERIC_REGISTER           GenericReg;
400     AML_RESOURCE_VENDOR_LARGE               VendorLarge;
401     AML_RESOURCE_MEMORY32                   Memory32;
402     AML_RESOURCE_FIXED_MEMORY32             FixedMemory32;
403     AML_RESOURCE_ADDRESS16                  Address16;
404     AML_RESOURCE_ADDRESS32                  Address32;
405     AML_RESOURCE_ADDRESS64                  Address64;
406     AML_RESOURCE_EXTENDED_ADDRESS64         ExtAddress64;
407     AML_RESOURCE_EXTENDED_IRQ               ExtendedIrq;
408 
409     /* Utility overlays */
410 
411     AML_RESOURCE_ADDRESS                    Address;
412     UINT32                                  DwordItem;
413     UINT16                                  WordItem;
414     UINT8                                   ByteItem;
415 
416 } AML_RESOURCE;
417 
418 #endif
419 
420