1 /******************************************************************************
2  *
3  * Name: acrestyp.h - Defines, types, and structures for 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 #ifndef __ACRESTYP_H__
153 #define __ACRESTYP_H__
154 
155 
156 /*
157  * Definitions for Resource Attributes
158  */
159 typedef UINT16                          ACPI_RS_LENGTH;    /* Resource Length field is fixed at 16 bits */
160 typedef UINT32                          ACPI_RSDESC_SIZE;  /* Max Resource Descriptor size is (Length+3) = (64K-1)+3 */
161 
162 /*
163  * Memory Attributes
164  */
165 #define ACPI_READ_ONLY_MEMORY           (UINT8) 0x00
166 #define ACPI_READ_WRITE_MEMORY          (UINT8) 0x01
167 
168 #define ACPI_NON_CACHEABLE_MEMORY       (UINT8) 0x00
169 #define ACPI_CACHABLE_MEMORY            (UINT8) 0x01
170 #define ACPI_WRITE_COMBINING_MEMORY     (UINT8) 0x02
171 #define ACPI_PREFETCHABLE_MEMORY        (UINT8) 0x03
172 
173 /*! [Begin] no source code translation */
174 /*
175  * IO Attributes
176  * The ISA IO ranges are:     n000-n0FFh,  n400-n4FFh, n800-n8FFh, nC00-nCFFh.
177  * The non-ISA IO ranges are: n100-n3FFh,  n500-n7FFh, n900-nBFFh, nCD0-nFFFh.
178  */
179 /*! [End] no source code translation !*/
180 
181 #define ACPI_NON_ISA_ONLY_RANGES        (UINT8) 0x01
182 #define ACPI_ISA_ONLY_RANGES            (UINT8) 0x02
183 #define ACPI_ENTIRE_RANGE               (ACPI_NON_ISA_ONLY_RANGES | ACPI_ISA_ONLY_RANGES)
184 
185 /* Type of translation - 1=Sparse, 0=Dense */
186 
187 #define ACPI_SPARSE_TRANSLATION         (UINT8) 0x01
188 
189 /*
190  * IO Port Descriptor Decode
191  */
192 #define ACPI_DECODE_10                  (UINT8) 0x00    /* 10-bit IO address decode */
193 #define ACPI_DECODE_16                  (UINT8) 0x01    /* 16-bit IO address decode */
194 
195 /*
196  * Interrupt attributes - used in multiple descriptors
197  */
198 
199 /* Triggering */
200 
201 #define ACPI_LEVEL_SENSITIVE            (UINT8) 0x00
202 #define ACPI_EDGE_SENSITIVE             (UINT8) 0x01
203 
204 /* Polarity */
205 
206 #define ACPI_ACTIVE_HIGH                (UINT8) 0x00
207 #define ACPI_ACTIVE_LOW                 (UINT8) 0x01
208 #define ACPI_ACTIVE_BOTH                (UINT8) 0x02
209 
210 /* Sharing */
211 
212 #define ACPI_EXCLUSIVE                  (UINT8) 0x00
213 #define ACPI_SHARED                     (UINT8) 0x01
214 
215 /* Wake */
216 
217 #define ACPI_NOT_WAKE_CAPABLE           (UINT8) 0x00
218 #define ACPI_WAKE_CAPABLE               (UINT8) 0x01
219 
220 /*
221  * DMA Attributes
222  */
223 #define ACPI_COMPATIBILITY              (UINT8) 0x00
224 #define ACPI_TYPE_A                     (UINT8) 0x01
225 #define ACPI_TYPE_B                     (UINT8) 0x02
226 #define ACPI_TYPE_F                     (UINT8) 0x03
227 
228 #define ACPI_NOT_BUS_MASTER             (UINT8) 0x00
229 #define ACPI_BUS_MASTER                 (UINT8) 0x01
230 
231 #define ACPI_TRANSFER_8                 (UINT8) 0x00
232 #define ACPI_TRANSFER_8_16              (UINT8) 0x01
233 #define ACPI_TRANSFER_16                (UINT8) 0x02
234 
235 /*
236  * Start Dependent Functions Priority definitions
237  */
238 #define ACPI_GOOD_CONFIGURATION         (UINT8) 0x00
239 #define ACPI_ACCEPTABLE_CONFIGURATION   (UINT8) 0x01
240 #define ACPI_SUB_OPTIMAL_CONFIGURATION  (UINT8) 0x02
241 
242 /*
243  * 16, 32 and 64-bit Address Descriptor resource types
244  */
245 #define ACPI_MEMORY_RANGE               (UINT8) 0x00
246 #define ACPI_IO_RANGE                   (UINT8) 0x01
247 #define ACPI_BUS_NUMBER_RANGE           (UINT8) 0x02
248 
249 #define ACPI_ADDRESS_NOT_FIXED          (UINT8) 0x00
250 #define ACPI_ADDRESS_FIXED              (UINT8) 0x01
251 
252 #define ACPI_POS_DECODE                 (UINT8) 0x00
253 #define ACPI_SUB_DECODE                 (UINT8) 0x01
254 
255 /* Producer/Consumer */
256 
257 #define ACPI_PRODUCER                   (UINT8) 0x00
258 #define ACPI_CONSUMER                   (UINT8) 0x01
259 
260 
261 /*
262  * If possible, pack the following structures to byte alignment
263  */
264 #ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED
265 #pragma pack(1)
266 #endif
267 
268 /* UUID data structures for use in vendor-defined resource descriptors */
269 
270 typedef struct acpi_uuid
271 {
272     UINT8                           Data[ACPI_UUID_LENGTH];
273 } ACPI_UUID;
274 
275 typedef struct acpi_vendor_uuid
276 {
277     UINT8                           Subtype;
278     UINT8                           Data[ACPI_UUID_LENGTH];
279 
280 } ACPI_VENDOR_UUID;
281 
282 /*
283  * Structures used to describe device resources
284  */
285 typedef struct acpi_resource_irq
286 {
287     UINT8                           DescriptorLength;
288     UINT8                           Triggering;
289     UINT8                           Polarity;
290     UINT8                           Shareable;
291     UINT8                           WakeCapable;
292     UINT8                           InterruptCount;
293     union {
294         UINT8                       Interrupt;
295         ACPI_FLEX_ARRAY(UINT8,      Interrupts);
296     };
297 
298 } ACPI_RESOURCE_IRQ;
299 
300 typedef struct acpi_resource_dma
301 {
302     UINT8                           Type;
303     UINT8                           BusMaster;
304     UINT8                           Transfer;
305     UINT8                           ChannelCount;
306     union {
307         UINT8                       Channel;
308         ACPI_FLEX_ARRAY(UINT8,      Channels);
309     };
310 
311 } ACPI_RESOURCE_DMA;
312 
313 typedef struct acpi_resource_start_dependent
314 {
315     UINT8                           DescriptorLength;
316     UINT8                           CompatibilityPriority;
317     UINT8                           PerformanceRobustness;
318 
319 } ACPI_RESOURCE_START_DEPENDENT;
320 
321 
322 /*
323  * The END_DEPENDENT_FUNCTIONS_RESOURCE struct is not
324  * needed because it has no fields
325  */
326 
327 
328 typedef struct acpi_resource_io
329 {
330     UINT8                           IoDecode;
331     UINT8                           Alignment;
332     UINT8                           AddressLength;
333     UINT16                          Minimum;
334     UINT16                          Maximum;
335 
336 } ACPI_RESOURCE_IO;
337 
338 typedef struct acpi_resource_fixed_io
339 {
340     UINT16                          Address;
341     UINT8                           AddressLength;
342 
343 } ACPI_RESOURCE_FIXED_IO;
344 
345 typedef struct acpi_resource_fixed_dma
346 {
347     UINT16                          RequestLines;
348     UINT16                          Channels;
349     UINT8                           Width;
350 
351 } ACPI_RESOURCE_FIXED_DMA;
352 
353 /* Values for Width field above */
354 
355 #define ACPI_DMA_WIDTH8                         0
356 #define ACPI_DMA_WIDTH16                        1
357 #define ACPI_DMA_WIDTH32                        2
358 #define ACPI_DMA_WIDTH64                        3
359 #define ACPI_DMA_WIDTH128                       4
360 #define ACPI_DMA_WIDTH256                       5
361 
362 
363 typedef struct acpi_resource_vendor
364 {
365     UINT16                          ByteLength;
366     UINT8                           ByteData[];
367 
368 } ACPI_RESOURCE_VENDOR;
369 
370 /* Vendor resource with UUID info (introduced in ACPI 3.0) */
371 
372 typedef struct acpi_resource_vendor_typed
373 {
374     UINT16                          ByteLength;
375     UINT8                           UuidSubtype;
376     UINT8                           Uuid[ACPI_UUID_LENGTH];
377     UINT8                           ByteData[];
378 
379 } ACPI_RESOURCE_VENDOR_TYPED;
380 
381 typedef struct acpi_resource_end_tag
382 {
383     UINT8                           Checksum;
384 
385 } ACPI_RESOURCE_END_TAG;
386 
387 typedef struct acpi_resource_memory24
388 {
389     UINT8                           WriteProtect;
390     UINT16                          Minimum;
391     UINT16                          Maximum;
392     UINT16                          Alignment;
393     UINT16                          AddressLength;
394 
395 } ACPI_RESOURCE_MEMORY24;
396 
397 typedef struct acpi_resource_memory32
398 {
399     UINT8                           WriteProtect;
400     UINT32                          Minimum;
401     UINT32                          Maximum;
402     UINT32                          Alignment;
403     UINT32                          AddressLength;
404 
405 } ACPI_RESOURCE_MEMORY32;
406 
407 typedef struct acpi_resource_fixed_memory32
408 {
409     UINT8                           WriteProtect;
410     UINT32                          Address;
411     UINT32                          AddressLength;
412 
413 } ACPI_RESOURCE_FIXED_MEMORY32;
414 
415 typedef struct acpi_memory_attribute
416 {
417     UINT8                           WriteProtect;
418     UINT8                           Caching;
419     UINT8                           RangeType;
420     UINT8                           Translation;
421 
422 } ACPI_MEMORY_ATTRIBUTE;
423 
424 typedef struct acpi_io_attribute
425 {
426     UINT8                           RangeType;
427     UINT8                           Translation;
428     UINT8                           TranslationType;
429     UINT8                           Reserved1;
430 
431 } ACPI_IO_ATTRIBUTE;
432 
433 typedef union acpi_resource_attribute
434 {
435     ACPI_MEMORY_ATTRIBUTE           Mem;
436     ACPI_IO_ATTRIBUTE               Io;
437 
438     /* Used for the *WordSpace macros */
439 
440     UINT8                           TypeSpecific;
441 
442 } ACPI_RESOURCE_ATTRIBUTE;
443 
444 typedef struct acpi_resource_label
445 {
446     UINT16                          StringLength;
447     char                            *StringPtr;
448 
449 } ACPI_RESOURCE_LABEL;
450 
451 typedef struct acpi_resource_source
452 {
453     UINT8                           Index;
454     UINT16                          StringLength;
455     char                            *StringPtr;
456 
457 } ACPI_RESOURCE_SOURCE;
458 
459 /* Fields common to all address descriptors, 16/32/64 bit */
460 
461 #define ACPI_RESOURCE_ADDRESS_COMMON \
462     UINT8                           ResourceType; \
463     UINT8                           ProducerConsumer; \
464     UINT8                           Decode; \
465     UINT8                           MinAddressFixed; \
466     UINT8                           MaxAddressFixed; \
467     ACPI_RESOURCE_ATTRIBUTE         Info;
468 
469 typedef struct acpi_address16_attribute
470 {
471     UINT16                          Granularity;
472     UINT16                          Minimum;
473     UINT16                          Maximum;
474     UINT16                          TranslationOffset;
475     UINT16                          AddressLength;
476 
477 } ACPI_ADDRESS16_ATTRIBUTE;
478 
479 typedef struct acpi_address32_attribute
480 {
481     UINT32                          Granularity;
482     UINT32                          Minimum;
483     UINT32                          Maximum;
484     UINT32                          TranslationOffset;
485     UINT32                          AddressLength;
486 
487 } ACPI_ADDRESS32_ATTRIBUTE;
488 
489 typedef struct acpi_address64_attribute
490 {
491     UINT64                          Granularity;
492     UINT64                          Minimum;
493     UINT64                          Maximum;
494     UINT64                          TranslationOffset;
495     UINT64                          AddressLength;
496 
497 } ACPI_ADDRESS64_ATTRIBUTE;
498 
499 typedef struct acpi_resource_address
500 {
501     ACPI_RESOURCE_ADDRESS_COMMON
502 
503 } ACPI_RESOURCE_ADDRESS;
504 
505 typedef struct acpi_resource_address16
506 {
507     ACPI_RESOURCE_ADDRESS_COMMON
508     ACPI_ADDRESS16_ATTRIBUTE        Address;
509     ACPI_RESOURCE_SOURCE            ResourceSource;
510 
511 } ACPI_RESOURCE_ADDRESS16;
512 
513 typedef struct acpi_resource_address32
514 {
515     ACPI_RESOURCE_ADDRESS_COMMON
516     ACPI_ADDRESS32_ATTRIBUTE        Address;
517     ACPI_RESOURCE_SOURCE            ResourceSource;
518 
519 } ACPI_RESOURCE_ADDRESS32;
520 
521 typedef struct acpi_resource_address64
522 {
523     ACPI_RESOURCE_ADDRESS_COMMON
524     ACPI_ADDRESS64_ATTRIBUTE        Address;
525     ACPI_RESOURCE_SOURCE            ResourceSource;
526 
527 } ACPI_RESOURCE_ADDRESS64;
528 
529 typedef struct acpi_resource_extended_address64
530 {
531     ACPI_RESOURCE_ADDRESS_COMMON
532     UINT8                           RevisionID;
533     ACPI_ADDRESS64_ATTRIBUTE        Address;
534     UINT64                          TypeSpecific;
535 
536 } ACPI_RESOURCE_EXTENDED_ADDRESS64;
537 
538 typedef struct acpi_resource_extended_irq
539 {
540     UINT8                           ProducerConsumer;
541     UINT8                           Triggering;
542     UINT8                           Polarity;
543     UINT8                           Shareable;
544     UINT8                           WakeCapable;
545     UINT8                           InterruptCount;
546     ACPI_RESOURCE_SOURCE            ResourceSource;
547     union {
548         UINT32                      Interrupt;
549         ACPI_FLEX_ARRAY(UINT32,     Interrupts);
550     };
551 
552 } ACPI_RESOURCE_EXTENDED_IRQ;
553 
554 typedef struct acpi_resource_generic_register
555 {
556     UINT8                           SpaceId;
557     UINT8                           BitWidth;
558     UINT8                           BitOffset;
559     UINT8                           AccessSize;
560     UINT64                          Address;
561 
562 } ACPI_RESOURCE_GENERIC_REGISTER;
563 
564 typedef struct acpi_resource_gpio
565 {
566     UINT8                           RevisionId;
567     UINT8                           ConnectionType;
568     UINT8                           ProducerConsumer;   /* For values, see Producer/Consumer above */
569     UINT8                           PinConfig;
570     UINT8                           Shareable;           /* For values, see Interrupt Attributes above */
571     UINT8                           WakeCapable;        /* For values, see Interrupt Attributes above */
572     UINT8                           IoRestriction;
573     UINT8                           Triggering;         /* For values, see Interrupt Attributes above */
574     UINT8                           Polarity;           /* For values, see Interrupt Attributes above */
575     UINT16                          DriveStrength;
576     UINT16                          DebounceTimeout;
577     UINT16                          PinTableLength;
578     UINT16                          VendorLength;
579     ACPI_RESOURCE_SOURCE            ResourceSource;
580     UINT16                          *PinTable;
581     UINT8                           *VendorData;
582 
583 } ACPI_RESOURCE_GPIO;
584 
585 /* Values for GPIO ConnectionType field above */
586 
587 #define ACPI_RESOURCE_GPIO_TYPE_INT             0
588 #define ACPI_RESOURCE_GPIO_TYPE_IO              1
589 
590 /* Values for PinConfig field above */
591 
592 #define ACPI_PIN_CONFIG_DEFAULT                 0
593 #define ACPI_PIN_CONFIG_PULLUP                  1
594 #define ACPI_PIN_CONFIG_PULLDOWN                2
595 #define ACPI_PIN_CONFIG_NOPULL                  3
596 
597 /* Values for IoRestriction field above */
598 
599 #define ACPI_IO_RESTRICT_NONE                   0
600 #define ACPI_IO_RESTRICT_INPUT                  1
601 #define ACPI_IO_RESTRICT_OUTPUT                 2
602 #define ACPI_IO_RESTRICT_NONE_PRESERVE          3
603 
604 
605 /* Common structure for I2C, SPI, UART, CSI2 serial descriptors */
606 
607 #define ACPI_RESOURCE_SERIAL_COMMON \
608     UINT8                           RevisionId; \
609     UINT8                           Type; \
610     UINT8                           ProducerConsumer;    /* For values, see Producer/Consumer above */\
611     UINT8                           SlaveMode; \
612     UINT8                           ConnectionSharing; \
613     UINT8                           TypeRevisionId; \
614     UINT16                          TypeDataLength; \
615     UINT16                          VendorLength; \
616     ACPI_RESOURCE_SOURCE            ResourceSource; \
617     UINT8                           *VendorData;
618 
619 typedef struct acpi_resource_common_serialbus
620 {
621     ACPI_RESOURCE_SERIAL_COMMON
622 
623 } ACPI_RESOURCE_COMMON_SERIALBUS;
624 
625 /* Values for the Type field above */
626 
627 #define ACPI_RESOURCE_SERIAL_TYPE_I2C           1
628 #define ACPI_RESOURCE_SERIAL_TYPE_SPI           2
629 #define ACPI_RESOURCE_SERIAL_TYPE_UART          3
630 #define ACPI_RESOURCE_SERIAL_TYPE_CSI2          4
631 
632 /* Values for SlaveMode field above */
633 
634 #define ACPI_CONTROLLER_INITIATED               0
635 #define ACPI_DEVICE_INITIATED                   1
636 
637 
638 typedef struct acpi_resource_i2c_serialbus
639 {
640     ACPI_RESOURCE_SERIAL_COMMON
641     UINT8                           AccessMode;
642     UINT16                          SlaveAddress;
643     UINT32                          ConnectionSpeed;
644 
645 } ACPI_RESOURCE_I2C_SERIALBUS;
646 
647 /* Values for AccessMode field above */
648 
649 #define ACPI_I2C_7BIT_MODE                      0
650 #define ACPI_I2C_10BIT_MODE                     1
651 
652 
653 typedef struct acpi_resource_spi_serialbus
654 {
655     ACPI_RESOURCE_SERIAL_COMMON
656     UINT8                           WireMode;
657     UINT8                           DevicePolarity;
658     UINT8                           DataBitLength;
659     UINT8                           ClockPhase;
660     UINT8                           ClockPolarity;
661     UINT16                          DeviceSelection;
662     UINT32                          ConnectionSpeed;
663 
664 } ACPI_RESOURCE_SPI_SERIALBUS;
665 
666 /* Values for WireMode field above */
667 
668 #define ACPI_SPI_4WIRE_MODE                     0
669 #define ACPI_SPI_3WIRE_MODE                     1
670 
671 /* Values for DevicePolarity field above */
672 
673 #define ACPI_SPI_ACTIVE_LOW                     0
674 #define ACPI_SPI_ACTIVE_HIGH                    1
675 
676 /* Values for ClockPhase field above */
677 
678 #define ACPI_SPI_FIRST_PHASE                    0
679 #define ACPI_SPI_SECOND_PHASE                   1
680 
681 /* Values for ClockPolarity field above */
682 
683 #define ACPI_SPI_START_LOW                      0
684 #define ACPI_SPI_START_HIGH                     1
685 
686 
687 typedef struct acpi_resource_uart_serialbus
688 {
689     ACPI_RESOURCE_SERIAL_COMMON
690     UINT8                           Endian;
691     UINT8                           DataBits;
692     UINT8                           StopBits;
693     UINT8                           FlowControl;
694     UINT8                           Parity;
695     UINT8                           LinesEnabled;
696     UINT16                          RxFifoSize;
697     UINT16                          TxFifoSize;
698     UINT32                          DefaultBaudRate;
699 
700 } ACPI_RESOURCE_UART_SERIALBUS;
701 
702 /* Values for Endian field above */
703 
704 #define ACPI_UART_LITTLE_ENDIAN                 0
705 #define ACPI_UART_BIG_ENDIAN                    1
706 
707 /* Values for DataBits field above */
708 
709 #define ACPI_UART_5_DATA_BITS                   0
710 #define ACPI_UART_6_DATA_BITS                   1
711 #define ACPI_UART_7_DATA_BITS                   2
712 #define ACPI_UART_8_DATA_BITS                   3
713 #define ACPI_UART_9_DATA_BITS                   4
714 
715 /* Values for StopBits field above */
716 
717 #define ACPI_UART_NO_STOP_BITS                  0
718 #define ACPI_UART_1_STOP_BIT                    1
719 #define ACPI_UART_1P5_STOP_BITS                 2
720 #define ACPI_UART_2_STOP_BITS                   3
721 
722 /* Values for FlowControl field above */
723 
724 #define ACPI_UART_FLOW_CONTROL_NONE             0
725 #define ACPI_UART_FLOW_CONTROL_HW               1
726 #define ACPI_UART_FLOW_CONTROL_XON_XOFF         2
727 
728 /* Values for Parity field above */
729 
730 #define ACPI_UART_PARITY_NONE                   0
731 #define ACPI_UART_PARITY_EVEN                   1
732 #define ACPI_UART_PARITY_ODD                    2
733 #define ACPI_UART_PARITY_MARK                   3
734 #define ACPI_UART_PARITY_SPACE                  4
735 
736 /* Values for LinesEnabled bitfield above */
737 
738 #define ACPI_UART_CARRIER_DETECT                (1<<2)
739 #define ACPI_UART_RING_INDICATOR                (1<<3)
740 #define ACPI_UART_DATA_SET_READY                (1<<4)
741 #define ACPI_UART_DATA_TERMINAL_READY           (1<<5)
742 #define ACPI_UART_CLEAR_TO_SEND                 (1<<6)
743 #define ACPI_UART_REQUEST_TO_SEND               (1<<7)
744 
745 typedef struct acpi_resource_csi2_serialbus
746 {
747     ACPI_RESOURCE_SERIAL_COMMON
748     UINT8                           LocalPortInstance;
749     UINT8                           PhyType;
750 
751 } ACPI_RESOURCE_CSI2_SERIALBUS;
752 
753 typedef struct acpi_resource_pin_function
754 {
755     UINT8                           RevisionId;
756     UINT8                           PinConfig;
757     UINT8                           Shareable;           /* For values, see Interrupt Attributes above */
758     UINT16                          FunctionNumber;
759     UINT16                          PinTableLength;
760     UINT16                          VendorLength;
761     ACPI_RESOURCE_SOURCE            ResourceSource;
762     UINT16                          *PinTable;
763     UINT8                           *VendorData;
764 
765 } ACPI_RESOURCE_PIN_FUNCTION;
766 
767 typedef struct acpi_resource_pin_config
768 {
769     UINT8                           RevisionId;
770     UINT8                           ProducerConsumer;   /* For values, see Producer/Consumer above */
771     UINT8                           Shareable;           /* For values, see Interrupt Attributes above */
772     UINT8                           PinConfigType;
773     UINT32                          PinConfigValue;
774     UINT16                          PinTableLength;
775     UINT16                          VendorLength;
776     ACPI_RESOURCE_SOURCE            ResourceSource;
777     UINT16                          *PinTable;
778     UINT8                           *VendorData;
779 
780 } ACPI_RESOURCE_PIN_CONFIG;
781 
782 typedef struct acpi_resource_clock_input
783 {
784     UINT8                           RevisionId;
785     UINT8                           Mode;
786     UINT8                           Scale;
787     UINT16                          FrequencyDivisor;
788     UINT32                          FrequencyNumerator;
789     ACPI_RESOURCE_SOURCE            ResourceSource;
790 } ACPI_RESOURCE_CLOCK_INPUT;
791 
792 /* Values for PinConfigType field above */
793 
794 #define ACPI_PIN_CONFIG_DEFAULT                 0
795 #define ACPI_PIN_CONFIG_BIAS_PULL_UP            1
796 #define ACPI_PIN_CONFIG_BIAS_PULL_DOWN          2
797 #define ACPI_PIN_CONFIG_BIAS_DEFAULT            3
798 #define ACPI_PIN_CONFIG_BIAS_DISABLE            4
799 #define ACPI_PIN_CONFIG_BIAS_HIGH_IMPEDANCE     5
800 #define ACPI_PIN_CONFIG_BIAS_BUS_HOLD           6
801 #define ACPI_PIN_CONFIG_DRIVE_OPEN_DRAIN        7
802 #define ACPI_PIN_CONFIG_DRIVE_OPEN_SOURCE       8
803 #define ACPI_PIN_CONFIG_DRIVE_PUSH_PULL         9
804 #define ACPI_PIN_CONFIG_DRIVE_STRENGTH          10
805 #define ACPI_PIN_CONFIG_SLEW_RATE               11
806 #define ACPI_PIN_CONFIG_INPUT_DEBOUNCE          12
807 #define ACPI_PIN_CONFIG_INPUT_SCHMITT_TRIGGER   13
808 
809 typedef struct acpi_resource_pin_group
810 {
811     UINT8                           RevisionId;
812     UINT8                           ProducerConsumer;   /* For values, see Producer/Consumer above */
813     UINT16                          PinTableLength;
814     UINT16                          VendorLength;
815     UINT16                          *PinTable;
816     ACPI_RESOURCE_LABEL             ResourceLabel;
817     UINT8                           *VendorData;
818 
819 } ACPI_RESOURCE_PIN_GROUP;
820 
821 typedef struct acpi_resource_pin_group_function
822 {
823     UINT8                           RevisionId;
824     UINT8                           ProducerConsumer;   /* For values, see Producer/Consumer above */
825     UINT8                           Shareable;           /* For values, see Interrupt Attributes above */
826     UINT16                          FunctionNumber;
827     UINT16                          VendorLength;
828     ACPI_RESOURCE_SOURCE            ResourceSource;
829     ACPI_RESOURCE_LABEL             ResourceSourceLabel;
830     UINT8                           *VendorData;
831 
832 } ACPI_RESOURCE_PIN_GROUP_FUNCTION;
833 
834 typedef struct acpi_resource_pin_group_config
835 {
836     UINT8                           RevisionId;
837     UINT8                           ProducerConsumer;   /* For values, see Producer/Consumer above */
838     UINT8                           Shareable;           /* For values, see Interrupt Attributes above */
839     UINT8                           PinConfigType;      /* For values, see PinConfigType above */
840     UINT32                          PinConfigValue;
841     UINT16                          VendorLength;
842     ACPI_RESOURCE_SOURCE            ResourceSource;
843     ACPI_RESOURCE_LABEL             ResourceSourceLabel;
844     UINT8                           *VendorData;
845 
846 } ACPI_RESOURCE_PIN_GROUP_CONFIG;
847 
848 /* ACPI_RESOURCE_TYPEs */
849 
850 #define ACPI_RESOURCE_TYPE_IRQ                  0
851 #define ACPI_RESOURCE_TYPE_DMA                  1
852 #define ACPI_RESOURCE_TYPE_START_DEPENDENT      2
853 #define ACPI_RESOURCE_TYPE_END_DEPENDENT        3
854 #define ACPI_RESOURCE_TYPE_IO                   4
855 #define ACPI_RESOURCE_TYPE_FIXED_IO             5
856 #define ACPI_RESOURCE_TYPE_VENDOR               6
857 #define ACPI_RESOURCE_TYPE_END_TAG              7
858 #define ACPI_RESOURCE_TYPE_MEMORY24             8
859 #define ACPI_RESOURCE_TYPE_MEMORY32             9
860 #define ACPI_RESOURCE_TYPE_FIXED_MEMORY32       10
861 #define ACPI_RESOURCE_TYPE_ADDRESS16            11
862 #define ACPI_RESOURCE_TYPE_ADDRESS32            12
863 #define ACPI_RESOURCE_TYPE_ADDRESS64            13
864 #define ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64   14  /* ACPI 3.0 */
865 #define ACPI_RESOURCE_TYPE_EXTENDED_IRQ         15
866 #define ACPI_RESOURCE_TYPE_GENERIC_REGISTER     16
867 #define ACPI_RESOURCE_TYPE_GPIO                 17  /* ACPI 5.0 */
868 #define ACPI_RESOURCE_TYPE_FIXED_DMA            18  /* ACPI 5.0 */
869 #define ACPI_RESOURCE_TYPE_SERIAL_BUS           19  /* ACPI 5.0 */
870 #define ACPI_RESOURCE_TYPE_PIN_FUNCTION         20  /* ACPI 6.2 */
871 #define ACPI_RESOURCE_TYPE_PIN_CONFIG           21  /* ACPI 6.2 */
872 #define ACPI_RESOURCE_TYPE_PIN_GROUP            22  /* ACPI 6.2 */
873 #define ACPI_RESOURCE_TYPE_PIN_GROUP_FUNCTION   23  /* ACPI 6.2 */
874 #define ACPI_RESOURCE_TYPE_PIN_GROUP_CONFIG     24  /* ACPI 6.2 */
875 #define ACPI_RESOURCE_TYPE_CLOCK_INPUT          25  /* ACPI 6.5 */
876 #define ACPI_RESOURCE_TYPE_MAX                  25
877 
878 /* Master union for resource descriptors */
879 
880 typedef union acpi_resource_data
881 {
882     ACPI_RESOURCE_IRQ                       Irq;
883     ACPI_RESOURCE_DMA                       Dma;
884     ACPI_RESOURCE_START_DEPENDENT           StartDpf;
885     ACPI_RESOURCE_IO                        Io;
886     ACPI_RESOURCE_FIXED_IO                  FixedIo;
887     ACPI_RESOURCE_FIXED_DMA                 FixedDma;
888     ACPI_RESOURCE_VENDOR                    Vendor;
889     ACPI_RESOURCE_VENDOR_TYPED              VendorTyped;
890     ACPI_RESOURCE_END_TAG                   EndTag;
891     ACPI_RESOURCE_MEMORY24                  Memory24;
892     ACPI_RESOURCE_MEMORY32                  Memory32;
893     ACPI_RESOURCE_FIXED_MEMORY32            FixedMemory32;
894     ACPI_RESOURCE_ADDRESS16                 Address16;
895     ACPI_RESOURCE_ADDRESS32                 Address32;
896     ACPI_RESOURCE_ADDRESS64                 Address64;
897     ACPI_RESOURCE_EXTENDED_ADDRESS64        ExtAddress64;
898     ACPI_RESOURCE_EXTENDED_IRQ              ExtendedIrq;
899     ACPI_RESOURCE_GENERIC_REGISTER          GenericReg;
900     ACPI_RESOURCE_GPIO                      Gpio;
901     ACPI_RESOURCE_I2C_SERIALBUS             I2cSerialBus;
902     ACPI_RESOURCE_SPI_SERIALBUS             SpiSerialBus;
903     ACPI_RESOURCE_UART_SERIALBUS            UartSerialBus;
904     ACPI_RESOURCE_CSI2_SERIALBUS            Csi2SerialBus;
905     ACPI_RESOURCE_COMMON_SERIALBUS          CommonSerialBus;
906     ACPI_RESOURCE_PIN_FUNCTION              PinFunction;
907     ACPI_RESOURCE_PIN_CONFIG                PinConfig;
908     ACPI_RESOURCE_PIN_GROUP                 PinGroup;
909     ACPI_RESOURCE_PIN_GROUP_FUNCTION        PinGroupFunction;
910     ACPI_RESOURCE_PIN_GROUP_CONFIG          PinGroupConfig;
911     ACPI_RESOURCE_CLOCK_INPUT               ClockInput;
912 
913     /* Common fields */
914 
915     ACPI_RESOURCE_ADDRESS                   Address;        /* Common 16/32/64 address fields */
916 
917 } ACPI_RESOURCE_DATA;
918 
919 
920 /* Common resource header */
921 
922 typedef struct acpi_resource
923 {
924     UINT32                          Type;
925     UINT32                          Length;
926     ACPI_RESOURCE_DATA              Data;
927 
928 } ACPI_RESOURCE;
929 
930 /* restore default alignment */
931 
932 #pragma pack()
933 
934 
935 #define ACPI_RS_SIZE_NO_DATA                8       /* Id + Length fields */
936 #define ACPI_RS_SIZE_MIN                    (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (12)
937 #define ACPI_RS_SIZE(Type)                  (UINT32) (ACPI_RS_SIZE_NO_DATA + sizeof (Type))
938 
939 /* Macro for walking resource templates with multiple descriptors */
940 
941 #define ACPI_NEXT_RESOURCE(Res) \
942     ACPI_ADD_PTR (ACPI_RESOURCE, (Res), (Res)->Length)
943 
944 
945 typedef struct acpi_pci_routing_table
946 {
947     UINT32                          Length;
948     UINT32                          Pin;
949     UINT64                          Address;        /* here for 64-bit alignment */
950     UINT32                          SourceIndex;
951     union {
952                                     char Pad[4];    /* pad to 64 bits so sizeof() works in all cases */
953                                     ACPI_FLEX_ARRAY(char, Source);
954     };
955 } ACPI_PCI_ROUTING_TABLE;
956 
957 #endif /* __ACRESTYP_H__ */
958