xref: /freebsd/sys/contrib/dev/acpica/include/amlresrc.h (revision 59c8e88e72633afbc47a4ace0d2170d00d51f7dc)
1 /******************************************************************************
2  *
3  * Module Name: amlresrc.h - AML resource descriptors
4  *
5  *****************************************************************************/
6 
7 /******************************************************************************
8  *
9  * 1. Copyright Notice
10  *
11  * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp.
12  * All rights reserved.
13  *
14  * 2. License
15  *
16  * 2.1. This is your license from Intel Corp. under its intellectual property
17  * rights. You may have additional license terms from the party that provided
18  * you this software, covering your right to use that party's intellectual
19  * property rights.
20  *
21  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22  * copy of the source code appearing in this file ("Covered Code") an
23  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24  * base code distributed originally by Intel ("Original Intel Code") to copy,
25  * make derivatives, distribute, use and display any portion of the Covered
26  * Code in any form, with the right to sublicense such rights; and
27  *
28  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29  * license (with the right to sublicense), under only those claims of Intel
30  * patents that are infringed by the Original Intel Code, to make, use, sell,
31  * offer to sell, and import the Covered Code and derivative works thereof
32  * solely to the minimum extent necessary to exercise the above copyright
33  * license, and in no event shall the patent license extend to any additions
34  * to or modifications of the Original Intel Code. No other license or right
35  * is granted directly or by implication, estoppel or otherwise;
36  *
37  * The above copyright and patent license is granted only if the following
38  * conditions are met:
39  *
40  * 3. Conditions
41  *
42  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43  * Redistribution of source code of any substantial portion of the Covered
44  * Code or modification with rights to further distribute source must include
45  * the above Copyright Notice, the above License, this list of Conditions,
46  * and the following Disclaimer and Export Compliance provision. In addition,
47  * Licensee must cause all Covered Code to which Licensee contributes to
48  * contain a file documenting the changes Licensee made to create that Covered
49  * Code and the date of any change. Licensee must include in that file the
50  * documentation of any changes made by any predecessor Licensee. Licensee
51  * must include a prominent statement that the modification is derived,
52  * directly or indirectly, from Original Intel Code.
53  *
54  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55  * Redistribution of source code of any substantial portion of the Covered
56  * Code or modification without rights to further distribute source must
57  * include the following Disclaimer and Export Compliance provision in the
58  * documentation and/or other materials provided with distribution. In
59  * addition, Licensee may not authorize further sublicense of source of any
60  * portion of the Covered Code, and must include terms to the effect that the
61  * license from Licensee to its licensee is limited to the intellectual
62  * property embodied in the software Licensee provides to its licensee, and
63  * not to intellectual property embodied in modifications its licensee may
64  * make.
65  *
66  * 3.3. Redistribution of Executable. Redistribution in executable form of any
67  * substantial portion of the Covered Code or modification must reproduce the
68  * above Copyright Notice, and the following Disclaimer and Export Compliance
69  * provision in the documentation and/or other materials provided with the
70  * distribution.
71  *
72  * 3.4. Intel retains all right, title, and interest in and to the Original
73  * Intel Code.
74  *
75  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76  * Intel shall be used in advertising or otherwise to promote the sale, use or
77  * other dealings in products derived from or relating to the Covered Code
78  * without prior written authorization from Intel.
79  *
80  * 4. Disclaimer and Export Compliance
81  *
82  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88  * PARTICULAR PURPOSE.
89  *
90  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97  * LIMITED REMEDY.
98  *
99  * 4.3. Licensee shall not export, either directly or indirectly, any of this
100  * software or system incorporating such software without first obtaining any
101  * required license or other approval from the U. S. Department of Commerce or
102  * any other agency or department of the United States Government. In the
103  * event Licensee exports any such software from the United States or
104  * re-exports any such software from a foreign destination, Licensee shall
105  * ensure that the distribution and export/re-export of the software is in
106  * compliance with all laws, regulations, orders, or other restrictions of the
107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108  * any of its subsidiaries will export/re-export any technical data, process,
109  * software, or service, directly or indirectly, to any country for which the
110  * United States government or any agency thereof requires an export license,
111  * other governmental approval, or letter of assurance, without first obtaining
112  * such license, approval or letter.
113  *
114  *****************************************************************************
115  *
116  * Alternatively, you may choose to be licensed under the terms of the
117  * following license:
118  *
119  * Redistribution and use in source and binary forms, with or without
120  * modification, are permitted provided that the following conditions
121  * are met:
122  * 1. Redistributions of source code must retain the above copyright
123  *    notice, this list of conditions, and the following disclaimer,
124  *    without modification.
125  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126  *    substantially similar to the "NO WARRANTY" disclaimer below
127  *    ("Disclaimer") and any redistribution must be conditioned upon
128  *    including a substantially similar Disclaimer requirement for further
129  *    binary redistribution.
130  * 3. Neither the names of the above-listed copyright holders nor the names
131  *    of any contributors may be used to endorse or promote products derived
132  *    from this software without specific prior written permission.
133  *
134  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145  *
146  * Alternatively, you may choose to be licensed under the terms of the
147  * GNU General Public License ("GPL") version 2 as published by the Free
148  * Software Foundation.
149  *
150  *****************************************************************************/
151 
152 /* acpisrc:StructDefs -- for acpisrc conversion */
153 
154 #ifndef __AMLRESRC_H
155 #define __AMLRESRC_H
156 
157 
158 /*
159  * Resource descriptor tags, as defined in the ACPI specification.
160  * Used to symbolically reference fields within a descriptor.
161  */
162 #define ACPI_RESTAG_ADDRESS                     "_ADR"
163 #define ACPI_RESTAG_ALIGNMENT                   "_ALN"
164 #define ACPI_RESTAG_ADDRESSSPACE                "_ASI"
165 #define ACPI_RESTAG_ACCESSSIZE                  "_ASZ"
166 #define ACPI_RESTAG_TYPESPECIFICATTRIBUTES      "_ATT"
167 #define ACPI_RESTAG_BASEADDRESS                 "_BAS"
168 #define ACPI_RESTAG_BUSMASTER                   "_BM_"  /* Master(1), Slave(0) */
169 #define ACPI_RESTAG_DEBOUNCETIME                "_DBT"
170 #define ACPI_RESTAG_DECODE                      "_DEC"
171 #define ACPI_RESTAG_DEVICEPOLARITY              "_DPL"
172 #define ACPI_RESTAG_DMA                         "_DMA"
173 #define ACPI_RESTAG_DMATYPE                     "_TYP"  /* Compatible(0), A(1), B(2), F(3) */
174 #define ACPI_RESTAG_DRIVESTRENGTH               "_DRS"
175 #define ACPI_RESTAG_ENDIANNESS                  "_END"
176 #define ACPI_RESTAG_FLOWCONTROL                 "_FLC"
177 #define ACPI_RESTAG_FUNCTION                    "_FUN"
178 #define ACPI_RESTAG_GRANULARITY                 "_GRA"
179 #define ACPI_RESTAG_INTERRUPT                   "_INT"
180 #define ACPI_RESTAG_INTERRUPTLEVEL              "_LL_"  /* ActiveLo(1), ActiveHi(0) */
181 #define ACPI_RESTAG_INTERRUPTSHARE              "_SHR"  /* Shareable(1), NoShare(0) */
182 #define ACPI_RESTAG_INTERRUPTTYPE               "_HE_"  /* Edge(1), Level(0) */
183 #define ACPI_RESTAG_IORESTRICTION               "_IOR"
184 #define ACPI_RESTAG_LENGTH                      "_LEN"
185 #define ACPI_RESTAG_LINE                        "_LIN"
186 #define ACPI_RESTAG_LOCALPORT                   "_PRT"
187 #define ACPI_RESTAG_MEMATTRIBUTES               "_MTP"  /* Memory(0), Reserved(1), ACPI(2), NVS(3) */
188 #define ACPI_RESTAG_MEMTYPE                     "_MEM"  /* NonCache(0), Cacheable(1) Cache+combine(2), Cache+prefetch(3) */
189 #define ACPI_RESTAG_MAXADDR                     "_MAX"
190 #define ACPI_RESTAG_MINADDR                     "_MIN"
191 #define ACPI_RESTAG_MAXTYPE                     "_MAF"
192 #define ACPI_RESTAG_MINTYPE                     "_MIF"
193 #define ACPI_RESTAG_MODE                        "_MOD"
194 #define ACPI_RESTAG_PARITY                      "_PAR"
195 #define ACPI_RESTAG_PHASE                       "_PHA"
196 #define ACPI_RESTAG_PHYTYPE                     "_PHY"
197 #define ACPI_RESTAG_PIN                         "_PIN"
198 #define ACPI_RESTAG_PINCONFIG                   "_PPI"
199 #define ACPI_RESTAG_PINCONFIG_TYPE              "_TYP"
200 #define ACPI_RESTAG_PINCONFIG_VALUE             "_VAL"
201 #define ACPI_RESTAG_POLARITY                    "_POL"
202 #define ACPI_RESTAG_REGISTERBITOFFSET           "_RBO"
203 #define ACPI_RESTAG_REGISTERBITWIDTH            "_RBW"
204 #define ACPI_RESTAG_RANGETYPE                   "_RNG"
205 #define ACPI_RESTAG_READWRITETYPE               "_RW_"  /* ReadOnly(0), Writeable (1) */
206 #define ACPI_RESTAG_LENGTH_RX                   "_RXL"
207 #define ACPI_RESTAG_LENGTH_TX                   "_TXL"
208 #define ACPI_RESTAG_SLAVEMODE                   "_SLV"
209 #define ACPI_RESTAG_SPEED                       "_SPE"
210 #define ACPI_RESTAG_STOPBITS                    "_STB"
211 #define ACPI_RESTAG_TRANSLATION                 "_TRA"
212 #define ACPI_RESTAG_TRANSTYPE                   "_TRS"  /* Sparse(1), Dense(0) */
213 #define ACPI_RESTAG_TYPE                        "_TTP"  /* Translation(1), Static (0) */
214 #define ACPI_RESTAG_XFERTYPE                    "_SIZ"  /* 8(0), 8And16(1), 16(2) */
215 #define ACPI_RESTAG_VENDORDATA                  "_VEN"
216 #define ACPI_RESTAG_FQN                         "_FQN"
217 #define ACPI_RESTAG_FQD                         "_FQD"
218 
219 
220 /* Default sizes for "small" resource descriptors */
221 
222 #define ASL_RDESC_IRQ_SIZE                      0x02
223 #define ASL_RDESC_DMA_SIZE                      0x02
224 #define ASL_RDESC_ST_DEPEND_SIZE                0x00
225 #define ASL_RDESC_END_DEPEND_SIZE               0x00
226 #define ASL_RDESC_IO_SIZE                       0x07
227 #define ASL_RDESC_FIXED_IO_SIZE                 0x03
228 #define ASL_RDESC_FIXED_DMA_SIZE                0x05
229 #define ASL_RDESC_END_TAG_SIZE                  0x01
230 
231 
232 typedef struct asl_resource_node
233 {
234     UINT32                          BufferLength;
235     void                            *Buffer;
236     struct asl_resource_node        *Next;
237 
238 } ASL_RESOURCE_NODE;
239 
240 typedef struct asl_resource_info
241 {
242     ACPI_PARSE_OBJECT               *DescriptorTypeOp;  /* Resource descriptor parse node */
243     ACPI_PARSE_OBJECT               *MappingOp;         /* Used for mapfile support */
244     UINT32                          CurrentByteOffset;  /* Offset in resource template */
245 
246 } ASL_RESOURCE_INFO;
247 
248 
249 /* Macros used to generate AML resource length fields */
250 
251 #define ACPI_AML_SIZE_LARGE(r)      (sizeof (r) - sizeof (AML_RESOURCE_LARGE_HEADER))
252 #define ACPI_AML_SIZE_SMALL(r)      (sizeof (r) - sizeof (AML_RESOURCE_SMALL_HEADER))
253 
254 /*
255  * Resource descriptors defined in the ACPI specification.
256  *
257  * Packing/alignment must be BYTE because these descriptors
258  * are used to overlay the raw AML byte stream.
259  */
260 #pragma pack(1)
261 
262 /*
263  * SMALL descriptors
264  */
265 #define AML_RESOURCE_SMALL_HEADER_COMMON \
266     UINT8                           DescriptorType;
267 
268 typedef struct aml_resource_small_header
269 {
270     AML_RESOURCE_SMALL_HEADER_COMMON
271 
272 } AML_RESOURCE_SMALL_HEADER;
273 
274 
275 typedef struct aml_resource_irq
276 {
277     AML_RESOURCE_SMALL_HEADER_COMMON
278     UINT16                          IrqMask;
279     UINT8                           Flags;
280 
281 } AML_RESOURCE_IRQ;
282 
283 
284 typedef struct aml_resource_irq_noflags
285 {
286     AML_RESOURCE_SMALL_HEADER_COMMON
287     UINT16                          IrqMask;
288 
289 } AML_RESOURCE_IRQ_NOFLAGS;
290 
291 
292 typedef struct aml_resource_dma
293 {
294     AML_RESOURCE_SMALL_HEADER_COMMON
295     UINT8                           DmaChannelMask;
296     UINT8                           Flags;
297 
298 } AML_RESOURCE_DMA;
299 
300 
301 typedef struct aml_resource_start_dependent
302 {
303     AML_RESOURCE_SMALL_HEADER_COMMON
304     UINT8                           Flags;
305 
306 } AML_RESOURCE_START_DEPENDENT;
307 
308 
309 typedef struct aml_resource_start_dependent_noprio
310 {
311     AML_RESOURCE_SMALL_HEADER_COMMON
312 
313 } AML_RESOURCE_START_DEPENDENT_NOPRIO;
314 
315 
316 typedef struct aml_resource_end_dependent
317 {
318     AML_RESOURCE_SMALL_HEADER_COMMON
319 
320 } AML_RESOURCE_END_DEPENDENT;
321 
322 
323 typedef struct aml_resource_io
324 {
325     AML_RESOURCE_SMALL_HEADER_COMMON
326     UINT8                           Flags;
327     UINT16                          Minimum;
328     UINT16                          Maximum;
329     UINT8                           Alignment;
330     UINT8                           AddressLength;
331 
332 } AML_RESOURCE_IO;
333 
334 
335 typedef struct aml_resource_fixed_io
336 {
337     AML_RESOURCE_SMALL_HEADER_COMMON
338     UINT16                          Address;
339     UINT8                           AddressLength;
340 
341 } AML_RESOURCE_FIXED_IO;
342 
343 
344 typedef struct aml_resource_vendor_small
345 {
346     AML_RESOURCE_SMALL_HEADER_COMMON
347 
348 } AML_RESOURCE_VENDOR_SMALL;
349 
350 
351 typedef struct aml_resource_end_tag
352 {
353     AML_RESOURCE_SMALL_HEADER_COMMON
354     UINT8                           Checksum;
355 
356 } AML_RESOURCE_END_TAG;
357 
358 
359 typedef struct aml_resource_fixed_dma
360 {
361     AML_RESOURCE_SMALL_HEADER_COMMON
362     UINT16                          RequestLines;
363     UINT16                          Channels;
364     UINT8                           Width;
365 
366 } AML_RESOURCE_FIXED_DMA;
367 
368 
369 /*
370  * LARGE descriptors
371  */
372 #define AML_RESOURCE_LARGE_HEADER_COMMON \
373     UINT8                           DescriptorType;\
374     UINT16                          ResourceLength;
375 
376 typedef struct aml_resource_large_header
377 {
378     AML_RESOURCE_LARGE_HEADER_COMMON
379 
380 } AML_RESOURCE_LARGE_HEADER;
381 
382 
383 /* General Flags for address space resource descriptors */
384 
385 #define ACPI_RESOURCE_FLAG_DEC      2
386 #define ACPI_RESOURCE_FLAG_MIF      4
387 #define ACPI_RESOURCE_FLAG_MAF      8
388 
389 typedef struct aml_resource_memory24
390 {
391     AML_RESOURCE_LARGE_HEADER_COMMON
392     UINT8                           Flags;
393     UINT16                          Minimum;
394     UINT16                          Maximum;
395     UINT16                          Alignment;
396     UINT16                          AddressLength;
397 
398 } AML_RESOURCE_MEMORY24;
399 
400 
401 typedef struct aml_resource_vendor_large
402 {
403     AML_RESOURCE_LARGE_HEADER_COMMON
404 
405 } AML_RESOURCE_VENDOR_LARGE;
406 
407 
408 typedef struct aml_resource_memory32
409 {
410     AML_RESOURCE_LARGE_HEADER_COMMON
411     UINT8                           Flags;
412     UINT32                          Minimum;
413     UINT32                          Maximum;
414     UINT32                          Alignment;
415     UINT32                          AddressLength;
416 
417 } AML_RESOURCE_MEMORY32;
418 
419 
420 typedef struct aml_resource_fixed_memory32
421 {
422     AML_RESOURCE_LARGE_HEADER_COMMON
423     UINT8                           Flags;
424     UINT32                          Address;
425     UINT32                          AddressLength;
426 
427 } AML_RESOURCE_FIXED_MEMORY32;
428 
429 
430 #define AML_RESOURCE_ADDRESS_COMMON \
431     UINT8                           ResourceType; \
432     UINT8                           Flags; \
433     UINT8                           SpecificFlags;
434 
435 
436 typedef struct aml_resource_address
437 {
438     AML_RESOURCE_LARGE_HEADER_COMMON
439     AML_RESOURCE_ADDRESS_COMMON
440 
441 } AML_RESOURCE_ADDRESS;
442 
443 
444 typedef struct aml_resource_extended_address64
445 {
446     AML_RESOURCE_LARGE_HEADER_COMMON
447     AML_RESOURCE_ADDRESS_COMMON
448     UINT8                           RevisionID;
449     UINT8                           Reserved;
450     UINT64                          Granularity;
451     UINT64                          Minimum;
452     UINT64                          Maximum;
453     UINT64                          TranslationOffset;
454     UINT64                          AddressLength;
455     UINT64                          TypeSpecific;
456 
457 } AML_RESOURCE_EXTENDED_ADDRESS64;
458 
459 #define AML_RESOURCE_EXTENDED_ADDRESS_REVISION          1       /* ACPI 3.0 */
460 
461 
462 typedef struct aml_resource_address64
463 {
464     AML_RESOURCE_LARGE_HEADER_COMMON
465     AML_RESOURCE_ADDRESS_COMMON
466     UINT64                          Granularity;
467     UINT64                          Minimum;
468     UINT64                          Maximum;
469     UINT64                          TranslationOffset;
470     UINT64                          AddressLength;
471 
472 } AML_RESOURCE_ADDRESS64;
473 
474 
475 typedef struct aml_resource_address32
476 {
477     AML_RESOURCE_LARGE_HEADER_COMMON
478     AML_RESOURCE_ADDRESS_COMMON
479     UINT32                          Granularity;
480     UINT32                          Minimum;
481     UINT32                          Maximum;
482     UINT32                          TranslationOffset;
483     UINT32                          AddressLength;
484 
485 } AML_RESOURCE_ADDRESS32;
486 
487 
488 typedef struct aml_resource_address16
489 {
490     AML_RESOURCE_LARGE_HEADER_COMMON
491     AML_RESOURCE_ADDRESS_COMMON
492     UINT16                          Granularity;
493     UINT16                          Minimum;
494     UINT16                          Maximum;
495     UINT16                          TranslationOffset;
496     UINT16                          AddressLength;
497 
498 } AML_RESOURCE_ADDRESS16;
499 
500 
501 typedef struct aml_resource_extended_irq
502 {
503     AML_RESOURCE_LARGE_HEADER_COMMON
504     UINT8                           Flags;
505     UINT8                           InterruptCount;
506     union {
507         UINT32                      Interrupt;
508         ACPI_FLEX_ARRAY(UINT32,     Interrupts);
509     };
510     /* ResSourceIndex, ResSource optional fields follow */
511 
512 } AML_RESOURCE_EXTENDED_IRQ;
513 
514 
515 typedef struct aml_resource_generic_register
516 {
517     AML_RESOURCE_LARGE_HEADER_COMMON
518     UINT8                           AddressSpaceId;
519     UINT8                           BitWidth;
520     UINT8                           BitOffset;
521     UINT8                           AccessSize; /* ACPI 3.0, was previously Reserved */
522     UINT64                          Address;
523 
524 } AML_RESOURCE_GENERIC_REGISTER;
525 
526 
527 /* Common descriptor for GpioInt and GpioIo (ACPI 5.0) */
528 
529 typedef struct aml_resource_gpio
530 {
531     AML_RESOURCE_LARGE_HEADER_COMMON
532     UINT8                           RevisionId;
533     UINT8                           ConnectionType;
534     UINT16                          Flags;
535     UINT16                          IntFlags;
536     UINT8                           PinConfig;
537     UINT16                          DriveStrength;
538     UINT16                          DebounceTimeout;
539     UINT16                          PinTableOffset;
540     UINT8                           ResSourceIndex;
541     UINT16                          ResSourceOffset;
542     UINT16                          VendorOffset;
543     UINT16                          VendorLength;
544     /*
545      * Optional fields follow immediately:
546      * 1) PIN list (Words)
547      * 2) Resource Source String
548      * 3) Vendor Data bytes
549      */
550 
551 } AML_RESOURCE_GPIO;
552 
553 #define AML_RESOURCE_GPIO_REVISION              1       /* ACPI 5.0 */
554 
555 /* Values for ConnectionType above */
556 
557 #define AML_RESOURCE_GPIO_TYPE_INT              0
558 #define AML_RESOURCE_GPIO_TYPE_IO               1
559 #define AML_RESOURCE_MAX_GPIOTYPE               1
560 
561 
562 /* Common preamble for all serial descriptors (ACPI 5.0) */
563 
564 #define AML_RESOURCE_SERIAL_COMMON \
565     UINT8                           RevisionId; \
566     UINT8                           ResSourceIndex; \
567     UINT8                           Type; \
568     UINT8                           Flags; \
569     UINT16                          TypeSpecificFlags; \
570     UINT8                           TypeRevisionId; \
571     UINT16                          TypeDataLength; \
572 
573 /* Values for the type field above */
574 
575 #define AML_RESOURCE_I2C_SERIALBUSTYPE          1
576 #define AML_RESOURCE_SPI_SERIALBUSTYPE          2
577 #define AML_RESOURCE_UART_SERIALBUSTYPE         3
578 #define AML_RESOURCE_CSI2_SERIALBUSTYPE         4
579 #define AML_RESOURCE_MAX_SERIALBUSTYPE          4
580 #define AML_RESOURCE_VENDOR_SERIALBUSTYPE       192 /* Vendor defined is 0xC0-0xFF (NOT SUPPORTED) */
581 
582 typedef struct aml_resource_common_serialbus
583 {
584     AML_RESOURCE_LARGE_HEADER_COMMON
585     AML_RESOURCE_SERIAL_COMMON
586 
587 } AML_RESOURCE_COMMON_SERIALBUS;
588 
589 
590 typedef struct aml_resource_csi2_serialbus
591 {
592     AML_RESOURCE_LARGE_HEADER_COMMON
593     AML_RESOURCE_SERIAL_COMMON
594 
595     /*
596      * Optional fields follow immediately:
597      * 1) Vendor Data bytes
598      * 2) Resource Source String
599      */
600 
601 } AML_RESOURCE_CSI2_SERIALBUS;
602 
603 #define AML_RESOURCE_CSI2_REVISION              1       /* ACPI 6.4 */
604 #define AML_RESOURCE_CSI2_TYPE_REVISION         1       /* ACPI 6.4 */
605 #define AML_RESOURCE_CSI2_MIN_DATA_LEN          0       /* ACPI 6.4 */
606 
607 typedef struct aml_resource_i2c_serialbus
608 {
609     AML_RESOURCE_LARGE_HEADER_COMMON
610     AML_RESOURCE_SERIAL_COMMON
611     UINT32                          ConnectionSpeed;
612     UINT16                          SlaveAddress;
613     /*
614      * Optional fields follow immediately:
615      * 1) Vendor Data bytes
616      * 2) Resource Source String
617      */
618 
619 } AML_RESOURCE_I2C_SERIALBUS;
620 
621 #define AML_RESOURCE_I2C_REVISION               1       /* ACPI 5.0 */
622 #define AML_RESOURCE_I2C_TYPE_REVISION          1       /* ACPI 5.0 */
623 #define AML_RESOURCE_I2C_MIN_DATA_LEN           6
624 
625 typedef struct aml_resource_spi_serialbus
626 {
627     AML_RESOURCE_LARGE_HEADER_COMMON
628     AML_RESOURCE_SERIAL_COMMON
629     UINT32                          ConnectionSpeed;
630     UINT8                           DataBitLength;
631     UINT8                           ClockPhase;
632     UINT8                           ClockPolarity;
633     UINT16                          DeviceSelection;
634     /*
635      * Optional fields follow immediately:
636      * 1) Vendor Data bytes
637      * 2) Resource Source String
638      */
639 
640 } AML_RESOURCE_SPI_SERIALBUS;
641 
642 #define AML_RESOURCE_SPI_REVISION               1       /* ACPI 5.0 */
643 #define AML_RESOURCE_SPI_TYPE_REVISION          1       /* ACPI 5.0 */
644 #define AML_RESOURCE_SPI_MIN_DATA_LEN           9
645 
646 typedef struct aml_resource_uart_serialbus
647 {
648     AML_RESOURCE_LARGE_HEADER_COMMON
649     AML_RESOURCE_SERIAL_COMMON
650     UINT32                          DefaultBaudRate;
651     UINT16                          RxFifoSize;
652     UINT16                          TxFifoSize;
653     UINT8                           Parity;
654     UINT8                           LinesEnabled;
655     /*
656      * Optional fields follow immediately:
657      * 1) Vendor Data bytes
658      * 2) Resource Source String
659      */
660 
661 } AML_RESOURCE_UART_SERIALBUS;
662 
663 #define AML_RESOURCE_UART_REVISION              1       /* ACPI 5.0 */
664 #define AML_RESOURCE_UART_TYPE_REVISION         1       /* ACPI 5.0 */
665 #define AML_RESOURCE_UART_MIN_DATA_LEN          10
666 
667 typedef struct aml_resource_pin_function
668 {
669     AML_RESOURCE_LARGE_HEADER_COMMON
670     UINT8                           RevisionId;
671     UINT16                          Flags;
672     UINT8                           PinConfig;
673     UINT16                          FunctionNumber;
674     UINT16                          PinTableOffset;
675     UINT8                           ResSourceIndex;
676     UINT16                          ResSourceOffset;
677     UINT16                          VendorOffset;
678     UINT16                          VendorLength;
679     /*
680      * Optional fields follow immediately:
681      * 1) PIN list (Words)
682      * 2) Resource Source String
683      * 3) Vendor Data bytes
684      */
685 
686 } AML_RESOURCE_PIN_FUNCTION;
687 
688 #define AML_RESOURCE_PIN_FUNCTION_REVISION      1       /* ACPI 6.2 */
689 
690 typedef struct aml_resource_pin_config
691 {
692     AML_RESOURCE_LARGE_HEADER_COMMON
693     UINT8                           RevisionId;
694     UINT16                          Flags;
695     UINT8                           PinConfigType;
696     UINT32                          PinConfigValue;
697     UINT16                          PinTableOffset;
698     UINT8                           ResSourceIndex;
699     UINT16                          ResSourceOffset;
700     UINT16                          VendorOffset;
701     UINT16                          VendorLength;
702     /*
703      * Optional fields follow immediately:
704      * 1) PIN list (Words)
705      * 2) Resource Source String
706      * 3) Vendor Data bytes
707      */
708 
709 } AML_RESOURCE_PIN_CONFIG;
710 
711 #define AML_RESOURCE_CLOCK_INPUT_REVISION      1       /* ACPI 6.5 */
712 
713 typedef struct aml_resource_clock_input
714 {
715     AML_RESOURCE_LARGE_HEADER_COMMON
716     UINT8                           RevisionId;
717     UINT16                          Flags;
718     UINT16                          FrequencyDivisor;
719     UINT32                          FrequencyNumerator;
720     /*
721      * Optional fields follow immediately:
722      * 1) Resource Source index
723      * 2) Resource Source String
724      */
725 } AML_RESOURCE_CLOCK_INPUT;
726 
727 
728 #define AML_RESOURCE_PIN_CONFIG_REVISION      1       /* ACPI 6.2 */
729 
730 typedef struct aml_resource_pin_group
731 {
732     AML_RESOURCE_LARGE_HEADER_COMMON
733     UINT8                           RevisionId;
734     UINT16                          Flags;
735     UINT16                          PinTableOffset;
736     UINT16                          LabelOffset;
737     UINT16                          VendorOffset;
738     UINT16                          VendorLength;
739     /*
740      * Optional fields follow immediately:
741      * 1) PIN list (Words)
742      * 2) Resource Label String
743      * 3) Vendor Data bytes
744      */
745 
746 } AML_RESOURCE_PIN_GROUP;
747 
748 #define AML_RESOURCE_PIN_GROUP_REVISION      1       /* ACPI 6.2 */
749 
750 typedef struct aml_resource_pin_group_function
751 {
752     AML_RESOURCE_LARGE_HEADER_COMMON
753     UINT8                           RevisionId;
754     UINT16                          Flags;
755     UINT16                          FunctionNumber;
756     UINT8                           ResSourceIndex;
757     UINT16                          ResSourceOffset;
758     UINT16                          ResSourceLabelOffset;
759     UINT16                          VendorOffset;
760     UINT16                          VendorLength;
761     /*
762      * Optional fields follow immediately:
763      * 1) Resource Source String
764      * 2) Resource Source Label String
765      * 3) Vendor Data bytes
766      */
767 
768 } AML_RESOURCE_PIN_GROUP_FUNCTION;
769 
770 #define AML_RESOURCE_PIN_GROUP_FUNCTION_REVISION    1       /* ACPI 6.2 */
771 
772 typedef struct aml_resource_pin_group_config
773 {
774     AML_RESOURCE_LARGE_HEADER_COMMON
775     UINT8                           RevisionId;
776     UINT16                          Flags;
777     UINT8                           PinConfigType;
778     UINT32                          PinConfigValue;
779     UINT8                           ResSourceIndex;
780     UINT16                          ResSourceOffset;
781     UINT16                          ResSourceLabelOffset;
782     UINT16                          VendorOffset;
783     UINT16                          VendorLength;
784     /*
785      * Optional fields follow immediately:
786      * 1) Resource Source String
787      * 2) Resource Source Label String
788      * 3) Vendor Data bytes
789      */
790 
791 } AML_RESOURCE_PIN_GROUP_CONFIG;
792 
793 #define AML_RESOURCE_PIN_GROUP_CONFIG_REVISION    1       /* ACPI 6.2 */
794 
795 /* restore default alignment */
796 
797 #pragma pack()
798 
799 /* Union of all resource descriptors, so we can allocate the worst case */
800 
801 typedef union aml_resource
802 {
803     /* Descriptor headers */
804 
805     UINT8                                   DescriptorType;
806     AML_RESOURCE_SMALL_HEADER               SmallHeader;
807     AML_RESOURCE_LARGE_HEADER               LargeHeader;
808 
809     /* Small resource descriptors */
810 
811     AML_RESOURCE_IRQ                        Irq;
812     AML_RESOURCE_DMA                        Dma;
813     AML_RESOURCE_START_DEPENDENT            StartDpf;
814     AML_RESOURCE_END_DEPENDENT              EndDpf;
815     AML_RESOURCE_IO                         Io;
816     AML_RESOURCE_FIXED_IO                   FixedIo;
817     AML_RESOURCE_FIXED_DMA                  FixedDma;
818     AML_RESOURCE_VENDOR_SMALL               VendorSmall;
819     AML_RESOURCE_END_TAG                    EndTag;
820 
821     /* Large resource descriptors */
822 
823     AML_RESOURCE_MEMORY24                   Memory24;
824     AML_RESOURCE_GENERIC_REGISTER           GenericReg;
825     AML_RESOURCE_VENDOR_LARGE               VendorLarge;
826     AML_RESOURCE_MEMORY32                   Memory32;
827     AML_RESOURCE_FIXED_MEMORY32             FixedMemory32;
828     AML_RESOURCE_ADDRESS16                  Address16;
829     AML_RESOURCE_ADDRESS32                  Address32;
830     AML_RESOURCE_ADDRESS64                  Address64;
831     AML_RESOURCE_EXTENDED_ADDRESS64         ExtAddress64;
832     AML_RESOURCE_EXTENDED_IRQ               ExtendedIrq;
833     AML_RESOURCE_GPIO                       Gpio;
834     AML_RESOURCE_I2C_SERIALBUS              I2cSerialBus;
835     AML_RESOURCE_SPI_SERIALBUS              SpiSerialBus;
836     AML_RESOURCE_UART_SERIALBUS             UartSerialBus;
837     AML_RESOURCE_CSI2_SERIALBUS             Csi2SerialBus;
838     AML_RESOURCE_COMMON_SERIALBUS           CommonSerialBus;
839     AML_RESOURCE_PIN_FUNCTION               PinFunction;
840     AML_RESOURCE_PIN_CONFIG                 PinConfig;
841     AML_RESOURCE_PIN_GROUP                  PinGroup;
842     AML_RESOURCE_PIN_GROUP_FUNCTION         PinGroupFunction;
843     AML_RESOURCE_PIN_GROUP_CONFIG           PinGroupConfig;
844     AML_RESOURCE_CLOCK_INPUT                ClockInput;
845 
846     /* Utility overlays */
847 
848     AML_RESOURCE_ADDRESS                    Address;
849     UINT32                                  DwordItem;
850     UINT16                                  WordItem;
851     UINT8                                   ByteItem;
852 
853 } AML_RESOURCE;
854 
855 
856 /* Interfaces used by both the disassembler and compiler */
857 
858 void
859 MpSaveGpioInfo (
860     ACPI_PARSE_OBJECT       *Op,
861     AML_RESOURCE            *Resource,
862     UINT32                  PinCount,
863     UINT16                  *PinList,
864     char                    *DeviceName);
865 
866 void
867 MpSaveSerialInfo (
868     ACPI_PARSE_OBJECT       *Op,
869     AML_RESOURCE            *Resource,
870     char                    *DeviceName);
871 
872 char *
873 MpGetHidFromParseTree (
874     ACPI_NAMESPACE_NODE     *HidNode);
875 
876 char *
877 MpGetHidViaNamestring (
878     char                    *DeviceName);
879 
880 char *
881 MpGetConnectionInfo (
882     ACPI_PARSE_OBJECT       *Op,
883     UINT32                  PinIndex,
884     ACPI_NAMESPACE_NODE     **TargetNode,
885     char                    **TargetName);
886 
887 char *
888 MpGetParentDeviceHid (
889     ACPI_PARSE_OBJECT       *Op,
890     ACPI_NAMESPACE_NODE     **TargetNode,
891     char                    **ParentDeviceName);
892 
893 char *
894 MpGetDdnValue (
895     char                    *DeviceName);
896 
897 char *
898 MpGetHidValue (
899     ACPI_NAMESPACE_NODE     *DeviceNode);
900 
901 #endif
902