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 - 2021, 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 
217 
218 /* Default sizes for "small" resource descriptors */
219 
220 #define ASL_RDESC_IRQ_SIZE                      0x02
221 #define ASL_RDESC_DMA_SIZE                      0x02
222 #define ASL_RDESC_ST_DEPEND_SIZE                0x00
223 #define ASL_RDESC_END_DEPEND_SIZE               0x00
224 #define ASL_RDESC_IO_SIZE                       0x07
225 #define ASL_RDESC_FIXED_IO_SIZE                 0x03
226 #define ASL_RDESC_FIXED_DMA_SIZE                0x05
227 #define ASL_RDESC_END_TAG_SIZE                  0x01
228 
229 
230 typedef struct asl_resource_node
231 {
232     UINT32                          BufferLength;
233     void                            *Buffer;
234     struct asl_resource_node        *Next;
235 
236 } ASL_RESOURCE_NODE;
237 
238 typedef struct asl_resource_info
239 {
240     ACPI_PARSE_OBJECT               *DescriptorTypeOp;  /* Resource descriptor parse node */
241     ACPI_PARSE_OBJECT               *MappingOp;         /* Used for mapfile support */
242     UINT32                          CurrentByteOffset;  /* Offset in resource template */
243 
244 } ASL_RESOURCE_INFO;
245 
246 
247 /* Macros used to generate AML resource length fields */
248 
249 #define ACPI_AML_SIZE_LARGE(r)      (sizeof (r) - sizeof (AML_RESOURCE_LARGE_HEADER))
250 #define ACPI_AML_SIZE_SMALL(r)      (sizeof (r) - sizeof (AML_RESOURCE_SMALL_HEADER))
251 
252 /*
253  * Resource descriptors defined in the ACPI specification.
254  *
255  * Packing/alignment must be BYTE because these descriptors
256  * are used to overlay the raw AML byte stream.
257  */
258 #pragma pack(1)
259 
260 /*
261  * SMALL descriptors
262  */
263 #define AML_RESOURCE_SMALL_HEADER_COMMON \
264     UINT8                           DescriptorType;
265 
266 typedef struct aml_resource_small_header
267 {
268     AML_RESOURCE_SMALL_HEADER_COMMON
269 
270 } AML_RESOURCE_SMALL_HEADER;
271 
272 
273 typedef struct aml_resource_irq
274 {
275     AML_RESOURCE_SMALL_HEADER_COMMON
276     UINT16                          IrqMask;
277     UINT8                           Flags;
278 
279 } AML_RESOURCE_IRQ;
280 
281 
282 typedef struct aml_resource_irq_noflags
283 {
284     AML_RESOURCE_SMALL_HEADER_COMMON
285     UINT16                          IrqMask;
286 
287 } AML_RESOURCE_IRQ_NOFLAGS;
288 
289 
290 typedef struct aml_resource_dma
291 {
292     AML_RESOURCE_SMALL_HEADER_COMMON
293     UINT8                           DmaChannelMask;
294     UINT8                           Flags;
295 
296 } AML_RESOURCE_DMA;
297 
298 
299 typedef struct aml_resource_start_dependent
300 {
301     AML_RESOURCE_SMALL_HEADER_COMMON
302     UINT8                           Flags;
303 
304 } AML_RESOURCE_START_DEPENDENT;
305 
306 
307 typedef struct aml_resource_start_dependent_noprio
308 {
309     AML_RESOURCE_SMALL_HEADER_COMMON
310 
311 } AML_RESOURCE_START_DEPENDENT_NOPRIO;
312 
313 
314 typedef struct aml_resource_end_dependent
315 {
316     AML_RESOURCE_SMALL_HEADER_COMMON
317 
318 } AML_RESOURCE_END_DEPENDENT;
319 
320 
321 typedef struct aml_resource_io
322 {
323     AML_RESOURCE_SMALL_HEADER_COMMON
324     UINT8                           Flags;
325     UINT16                          Minimum;
326     UINT16                          Maximum;
327     UINT8                           Alignment;
328     UINT8                           AddressLength;
329 
330 } AML_RESOURCE_IO;
331 
332 
333 typedef struct aml_resource_fixed_io
334 {
335     AML_RESOURCE_SMALL_HEADER_COMMON
336     UINT16                          Address;
337     UINT8                           AddressLength;
338 
339 } AML_RESOURCE_FIXED_IO;
340 
341 
342 typedef struct aml_resource_vendor_small
343 {
344     AML_RESOURCE_SMALL_HEADER_COMMON
345 
346 } AML_RESOURCE_VENDOR_SMALL;
347 
348 
349 typedef struct aml_resource_end_tag
350 {
351     AML_RESOURCE_SMALL_HEADER_COMMON
352     UINT8                           Checksum;
353 
354 } AML_RESOURCE_END_TAG;
355 
356 
357 typedef struct aml_resource_fixed_dma
358 {
359     AML_RESOURCE_SMALL_HEADER_COMMON
360     UINT16                          RequestLines;
361     UINT16                          Channels;
362     UINT8                           Width;
363 
364 } AML_RESOURCE_FIXED_DMA;
365 
366 
367 /*
368  * LARGE descriptors
369  */
370 #define AML_RESOURCE_LARGE_HEADER_COMMON \
371     UINT8                           DescriptorType;\
372     UINT16                          ResourceLength;
373 
374 typedef struct aml_resource_large_header
375 {
376     AML_RESOURCE_LARGE_HEADER_COMMON
377 
378 } AML_RESOURCE_LARGE_HEADER;
379 
380 
381 /* General Flags for address space resource descriptors */
382 
383 #define ACPI_RESOURCE_FLAG_DEC      2
384 #define ACPI_RESOURCE_FLAG_MIF      4
385 #define ACPI_RESOURCE_FLAG_MAF      8
386 
387 typedef struct aml_resource_memory24
388 {
389     AML_RESOURCE_LARGE_HEADER_COMMON
390     UINT8                           Flags;
391     UINT16                          Minimum;
392     UINT16                          Maximum;
393     UINT16                          Alignment;
394     UINT16                          AddressLength;
395 
396 } AML_RESOURCE_MEMORY24;
397 
398 
399 typedef struct aml_resource_vendor_large
400 {
401     AML_RESOURCE_LARGE_HEADER_COMMON
402 
403 } AML_RESOURCE_VENDOR_LARGE;
404 
405 
406 typedef struct aml_resource_memory32
407 {
408     AML_RESOURCE_LARGE_HEADER_COMMON
409     UINT8                           Flags;
410     UINT32                          Minimum;
411     UINT32                          Maximum;
412     UINT32                          Alignment;
413     UINT32                          AddressLength;
414 
415 } AML_RESOURCE_MEMORY32;
416 
417 
418 typedef struct aml_resource_fixed_memory32
419 {
420     AML_RESOURCE_LARGE_HEADER_COMMON
421     UINT8                           Flags;
422     UINT32                          Address;
423     UINT32                          AddressLength;
424 
425 } AML_RESOURCE_FIXED_MEMORY32;
426 
427 
428 #define AML_RESOURCE_ADDRESS_COMMON \
429     UINT8                           ResourceType; \
430     UINT8                           Flags; \
431     UINT8                           SpecificFlags;
432 
433 
434 typedef struct aml_resource_address
435 {
436     AML_RESOURCE_LARGE_HEADER_COMMON
437     AML_RESOURCE_ADDRESS_COMMON
438 
439 } AML_RESOURCE_ADDRESS;
440 
441 
442 typedef struct aml_resource_extended_address64
443 {
444     AML_RESOURCE_LARGE_HEADER_COMMON
445     AML_RESOURCE_ADDRESS_COMMON
446     UINT8                           RevisionID;
447     UINT8                           Reserved;
448     UINT64                          Granularity;
449     UINT64                          Minimum;
450     UINT64                          Maximum;
451     UINT64                          TranslationOffset;
452     UINT64                          AddressLength;
453     UINT64                          TypeSpecific;
454 
455 } AML_RESOURCE_EXTENDED_ADDRESS64;
456 
457 #define AML_RESOURCE_EXTENDED_ADDRESS_REVISION          1       /* ACPI 3.0 */
458 
459 
460 typedef struct aml_resource_address64
461 {
462     AML_RESOURCE_LARGE_HEADER_COMMON
463     AML_RESOURCE_ADDRESS_COMMON
464     UINT64                          Granularity;
465     UINT64                          Minimum;
466     UINT64                          Maximum;
467     UINT64                          TranslationOffset;
468     UINT64                          AddressLength;
469 
470 } AML_RESOURCE_ADDRESS64;
471 
472 
473 typedef struct aml_resource_address32
474 {
475     AML_RESOURCE_LARGE_HEADER_COMMON
476     AML_RESOURCE_ADDRESS_COMMON
477     UINT32                          Granularity;
478     UINT32                          Minimum;
479     UINT32                          Maximum;
480     UINT32                          TranslationOffset;
481     UINT32                          AddressLength;
482 
483 } AML_RESOURCE_ADDRESS32;
484 
485 
486 typedef struct aml_resource_address16
487 {
488     AML_RESOURCE_LARGE_HEADER_COMMON
489     AML_RESOURCE_ADDRESS_COMMON
490     UINT16                          Granularity;
491     UINT16                          Minimum;
492     UINT16                          Maximum;
493     UINT16                          TranslationOffset;
494     UINT16                          AddressLength;
495 
496 } AML_RESOURCE_ADDRESS16;
497 
498 
499 typedef struct aml_resource_extended_irq
500 {
501     AML_RESOURCE_LARGE_HEADER_COMMON
502     UINT8                           Flags;
503     UINT8                           InterruptCount;
504     UINT32                          Interrupts[1];
505     /* ResSourceIndex, ResSource optional fields follow */
506 
507 } AML_RESOURCE_EXTENDED_IRQ;
508 
509 
510 typedef struct aml_resource_generic_register
511 {
512     AML_RESOURCE_LARGE_HEADER_COMMON
513     UINT8                           AddressSpaceId;
514     UINT8                           BitWidth;
515     UINT8                           BitOffset;
516     UINT8                           AccessSize; /* ACPI 3.0, was previously Reserved */
517     UINT64                          Address;
518 
519 } AML_RESOURCE_GENERIC_REGISTER;
520 
521 
522 /* Common descriptor for GpioInt and GpioIo (ACPI 5.0) */
523 
524 typedef struct aml_resource_gpio
525 {
526     AML_RESOURCE_LARGE_HEADER_COMMON
527     UINT8                           RevisionId;
528     UINT8                           ConnectionType;
529     UINT16                          Flags;
530     UINT16                          IntFlags;
531     UINT8                           PinConfig;
532     UINT16                          DriveStrength;
533     UINT16                          DebounceTimeout;
534     UINT16                          PinTableOffset;
535     UINT8                           ResSourceIndex;
536     UINT16                          ResSourceOffset;
537     UINT16                          VendorOffset;
538     UINT16                          VendorLength;
539     /*
540      * Optional fields follow immediately:
541      * 1) PIN list (Words)
542      * 2) Resource Source String
543      * 3) Vendor Data bytes
544      */
545 
546 } AML_RESOURCE_GPIO;
547 
548 #define AML_RESOURCE_GPIO_REVISION              1       /* ACPI 5.0 */
549 
550 /* Values for ConnectionType above */
551 
552 #define AML_RESOURCE_GPIO_TYPE_INT              0
553 #define AML_RESOURCE_GPIO_TYPE_IO               1
554 #define AML_RESOURCE_MAX_GPIOTYPE               1
555 
556 
557 /* Common preamble for all serial descriptors (ACPI 5.0) */
558 
559 #define AML_RESOURCE_SERIAL_COMMON \
560     UINT8                           RevisionId; \
561     UINT8                           ResSourceIndex; \
562     UINT8                           Type; \
563     UINT8                           Flags; \
564     UINT16                          TypeSpecificFlags; \
565     UINT8                           TypeRevisionId; \
566     UINT16                          TypeDataLength; \
567 
568 /* Values for the type field above */
569 
570 #define AML_RESOURCE_I2C_SERIALBUSTYPE          1
571 #define AML_RESOURCE_SPI_SERIALBUSTYPE          2
572 #define AML_RESOURCE_UART_SERIALBUSTYPE         3
573 #define AML_RESOURCE_CSI2_SERIALBUSTYPE         4
574 #define AML_RESOURCE_MAX_SERIALBUSTYPE          4
575 #define AML_RESOURCE_VENDOR_SERIALBUSTYPE       192 /* Vendor defined is 0xC0-0xFF (NOT SUPPORTED) */
576 
577 typedef struct aml_resource_common_serialbus
578 {
579     AML_RESOURCE_LARGE_HEADER_COMMON
580     AML_RESOURCE_SERIAL_COMMON
581 
582 } AML_RESOURCE_COMMON_SERIALBUS;
583 
584 
585 typedef struct aml_resource_csi2_serialbus
586 {
587     AML_RESOURCE_LARGE_HEADER_COMMON
588     AML_RESOURCE_SERIAL_COMMON
589 
590     /*
591      * Optional fields follow immediately:
592      * 1) Vendor Data bytes
593      * 2) Resource Source String
594      */
595 
596 } AML_RESOURCE_CSI2_SERIALBUS;
597 
598 #define AML_RESOURCE_CSI2_REVISION              1       /* ACPI 6.4 */
599 #define AML_RESOURCE_CSI2_TYPE_REVISION         1       /* ACPI 6.4 */
600 #define AML_RESOURCE_CSI2_MIN_DATA_LEN          0       /* ACPI 6.4 */
601 
602 typedef struct aml_resource_i2c_serialbus
603 {
604     AML_RESOURCE_LARGE_HEADER_COMMON
605     AML_RESOURCE_SERIAL_COMMON
606     UINT32                          ConnectionSpeed;
607     UINT16                          SlaveAddress;
608     /*
609      * Optional fields follow immediately:
610      * 1) Vendor Data bytes
611      * 2) Resource Source String
612      */
613 
614 } AML_RESOURCE_I2C_SERIALBUS;
615 
616 #define AML_RESOURCE_I2C_REVISION               1       /* ACPI 5.0 */
617 #define AML_RESOURCE_I2C_TYPE_REVISION          1       /* ACPI 5.0 */
618 #define AML_RESOURCE_I2C_MIN_DATA_LEN           6
619 
620 typedef struct aml_resource_spi_serialbus
621 {
622     AML_RESOURCE_LARGE_HEADER_COMMON
623     AML_RESOURCE_SERIAL_COMMON
624     UINT32                          ConnectionSpeed;
625     UINT8                           DataBitLength;
626     UINT8                           ClockPhase;
627     UINT8                           ClockPolarity;
628     UINT16                          DeviceSelection;
629     /*
630      * Optional fields follow immediately:
631      * 1) Vendor Data bytes
632      * 2) Resource Source String
633      */
634 
635 } AML_RESOURCE_SPI_SERIALBUS;
636 
637 #define AML_RESOURCE_SPI_REVISION               1       /* ACPI 5.0 */
638 #define AML_RESOURCE_SPI_TYPE_REVISION          1       /* ACPI 5.0 */
639 #define AML_RESOURCE_SPI_MIN_DATA_LEN           9
640 
641 typedef struct aml_resource_uart_serialbus
642 {
643     AML_RESOURCE_LARGE_HEADER_COMMON
644     AML_RESOURCE_SERIAL_COMMON
645     UINT32                          DefaultBaudRate;
646     UINT16                          RxFifoSize;
647     UINT16                          TxFifoSize;
648     UINT8                           Parity;
649     UINT8                           LinesEnabled;
650     /*
651      * Optional fields follow immediately:
652      * 1) Vendor Data bytes
653      * 2) Resource Source String
654      */
655 
656 } AML_RESOURCE_UART_SERIALBUS;
657 
658 #define AML_RESOURCE_UART_REVISION              1       /* ACPI 5.0 */
659 #define AML_RESOURCE_UART_TYPE_REVISION         1       /* ACPI 5.0 */
660 #define AML_RESOURCE_UART_MIN_DATA_LEN          10
661 
662 typedef struct aml_resource_pin_function
663 {
664     AML_RESOURCE_LARGE_HEADER_COMMON
665     UINT8                           RevisionId;
666     UINT16                          Flags;
667     UINT8                           PinConfig;
668     UINT16                          FunctionNumber;
669     UINT16                          PinTableOffset;
670     UINT8                           ResSourceIndex;
671     UINT16                          ResSourceOffset;
672     UINT16                          VendorOffset;
673     UINT16                          VendorLength;
674     /*
675      * Optional fields follow immediately:
676      * 1) PIN list (Words)
677      * 2) Resource Source String
678      * 3) Vendor Data bytes
679      */
680 
681 } AML_RESOURCE_PIN_FUNCTION;
682 
683 #define AML_RESOURCE_PIN_FUNCTION_REVISION      1       /* ACPI 6.2 */
684 
685 typedef struct aml_resource_pin_config
686 {
687     AML_RESOURCE_LARGE_HEADER_COMMON
688     UINT8                           RevisionId;
689     UINT16                          Flags;
690     UINT8                           PinConfigType;
691     UINT32                          PinConfigValue;
692     UINT16                          PinTableOffset;
693     UINT8                           ResSourceIndex;
694     UINT16                          ResSourceOffset;
695     UINT16                          VendorOffset;
696     UINT16                          VendorLength;
697     /*
698      * Optional fields follow immediately:
699      * 1) PIN list (Words)
700      * 2) Resource Source String
701      * 3) Vendor Data bytes
702      */
703 
704 } AML_RESOURCE_PIN_CONFIG;
705 
706 #define AML_RESOURCE_PIN_CONFIG_REVISION      1       /* ACPI 6.2 */
707 
708 typedef struct aml_resource_pin_group
709 {
710     AML_RESOURCE_LARGE_HEADER_COMMON
711     UINT8                           RevisionId;
712     UINT16                          Flags;
713     UINT16                          PinTableOffset;
714     UINT16                          LabelOffset;
715     UINT16                          VendorOffset;
716     UINT16                          VendorLength;
717     /*
718      * Optional fields follow immediately:
719      * 1) PIN list (Words)
720      * 2) Resource Label String
721      * 3) Vendor Data bytes
722      */
723 
724 } AML_RESOURCE_PIN_GROUP;
725 
726 #define AML_RESOURCE_PIN_GROUP_REVISION      1       /* ACPI 6.2 */
727 
728 typedef struct aml_resource_pin_group_function
729 {
730     AML_RESOURCE_LARGE_HEADER_COMMON
731     UINT8                           RevisionId;
732     UINT16                          Flags;
733     UINT16                          FunctionNumber;
734     UINT8                           ResSourceIndex;
735     UINT16                          ResSourceOffset;
736     UINT16                          ResSourceLabelOffset;
737     UINT16                          VendorOffset;
738     UINT16                          VendorLength;
739     /*
740      * Optional fields follow immediately:
741      * 1) Resource Source String
742      * 2) Resource Source Label String
743      * 3) Vendor Data bytes
744      */
745 
746 } AML_RESOURCE_PIN_GROUP_FUNCTION;
747 
748 #define AML_RESOURCE_PIN_GROUP_FUNCTION_REVISION    1       /* ACPI 6.2 */
749 
750 typedef struct aml_resource_pin_group_config
751 {
752     AML_RESOURCE_LARGE_HEADER_COMMON
753     UINT8                           RevisionId;
754     UINT16                          Flags;
755     UINT8                           PinConfigType;
756     UINT32                          PinConfigValue;
757     UINT8                           ResSourceIndex;
758     UINT16                          ResSourceOffset;
759     UINT16                          ResSourceLabelOffset;
760     UINT16                          VendorOffset;
761     UINT16                          VendorLength;
762     /*
763      * Optional fields follow immediately:
764      * 1) Resource Source String
765      * 2) Resource Source Label String
766      * 3) Vendor Data bytes
767      */
768 
769 } AML_RESOURCE_PIN_GROUP_CONFIG;
770 
771 #define AML_RESOURCE_PIN_GROUP_CONFIG_REVISION    1       /* ACPI 6.2 */
772 
773 /* restore default alignment */
774 
775 #pragma pack()
776 
777 /* Union of all resource descriptors, so we can allocate the worst case */
778 
779 typedef union aml_resource
780 {
781     /* Descriptor headers */
782 
783     UINT8                                   DescriptorType;
784     AML_RESOURCE_SMALL_HEADER               SmallHeader;
785     AML_RESOURCE_LARGE_HEADER               LargeHeader;
786 
787     /* Small resource descriptors */
788 
789     AML_RESOURCE_IRQ                        Irq;
790     AML_RESOURCE_DMA                        Dma;
791     AML_RESOURCE_START_DEPENDENT            StartDpf;
792     AML_RESOURCE_END_DEPENDENT              EndDpf;
793     AML_RESOURCE_IO                         Io;
794     AML_RESOURCE_FIXED_IO                   FixedIo;
795     AML_RESOURCE_FIXED_DMA                  FixedDma;
796     AML_RESOURCE_VENDOR_SMALL               VendorSmall;
797     AML_RESOURCE_END_TAG                    EndTag;
798 
799     /* Large resource descriptors */
800 
801     AML_RESOURCE_MEMORY24                   Memory24;
802     AML_RESOURCE_GENERIC_REGISTER           GenericReg;
803     AML_RESOURCE_VENDOR_LARGE               VendorLarge;
804     AML_RESOURCE_MEMORY32                   Memory32;
805     AML_RESOURCE_FIXED_MEMORY32             FixedMemory32;
806     AML_RESOURCE_ADDRESS16                  Address16;
807     AML_RESOURCE_ADDRESS32                  Address32;
808     AML_RESOURCE_ADDRESS64                  Address64;
809     AML_RESOURCE_EXTENDED_ADDRESS64         ExtAddress64;
810     AML_RESOURCE_EXTENDED_IRQ               ExtendedIrq;
811     AML_RESOURCE_GPIO                       Gpio;
812     AML_RESOURCE_I2C_SERIALBUS              I2cSerialBus;
813     AML_RESOURCE_SPI_SERIALBUS              SpiSerialBus;
814     AML_RESOURCE_UART_SERIALBUS             UartSerialBus;
815     AML_RESOURCE_CSI2_SERIALBUS             Csi2SerialBus;
816     AML_RESOURCE_COMMON_SERIALBUS           CommonSerialBus;
817     AML_RESOURCE_PIN_FUNCTION               PinFunction;
818     AML_RESOURCE_PIN_CONFIG                 PinConfig;
819     AML_RESOURCE_PIN_GROUP                  PinGroup;
820     AML_RESOURCE_PIN_GROUP_FUNCTION         PinGroupFunction;
821     AML_RESOURCE_PIN_GROUP_CONFIG           PinGroupConfig;
822 
823     /* Utility overlays */
824 
825     AML_RESOURCE_ADDRESS                    Address;
826     UINT32                                  DwordItem;
827     UINT16                                  WordItem;
828     UINT8                                   ByteItem;
829 
830 } AML_RESOURCE;
831 
832 
833 /* Interfaces used by both the disassembler and compiler */
834 
835 void
836 MpSaveGpioInfo (
837     ACPI_PARSE_OBJECT       *Op,
838     AML_RESOURCE            *Resource,
839     UINT32                  PinCount,
840     UINT16                  *PinList,
841     char                    *DeviceName);
842 
843 void
844 MpSaveSerialInfo (
845     ACPI_PARSE_OBJECT       *Op,
846     AML_RESOURCE            *Resource,
847     char                    *DeviceName);
848 
849 char *
850 MpGetHidFromParseTree (
851     ACPI_NAMESPACE_NODE     *HidNode);
852 
853 char *
854 MpGetHidViaNamestring (
855     char                    *DeviceName);
856 
857 char *
858 MpGetConnectionInfo (
859     ACPI_PARSE_OBJECT       *Op,
860     UINT32                  PinIndex,
861     ACPI_NAMESPACE_NODE     **TargetNode,
862     char                    **TargetName);
863 
864 char *
865 MpGetParentDeviceHid (
866     ACPI_PARSE_OBJECT       *Op,
867     ACPI_NAMESPACE_NODE     **TargetNode,
868     char                    **ParentDeviceName);
869 
870 char *
871 MpGetDdnValue (
872     char                    *DeviceName);
873 
874 char *
875 MpGetHidValue (
876     ACPI_NAMESPACE_NODE     *DeviceNode);
877 
878 #endif
879