1 /******************************************************************************
3 * Module Name: amlresrc.h - AML resource descriptors
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2016, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
44 /* acpisrc:StructDefs -- for acpisrc conversion */
51 * Resource descriptor tags, as defined in the ACPI specification.
52 * Used to symbolically reference fields within a descriptor.
54 #define ACPI_RESTAG_ADDRESS "_ADR"
55 #define ACPI_RESTAG_ALIGNMENT "_ALN"
56 #define ACPI_RESTAG_ADDRESSSPACE "_ASI"
57 #define ACPI_RESTAG_ACCESSSIZE "_ASZ"
58 #define ACPI_RESTAG_TYPESPECIFICATTRIBUTES "_ATT"
59 #define ACPI_RESTAG_BASEADDRESS "_BAS"
60 #define ACPI_RESTAG_BUSMASTER "_BM_" /* Master(1), Slave(0) */
61 #define ACPI_RESTAG_DEBOUNCETIME "_DBT"
62 #define ACPI_RESTAG_DECODE "_DEC"
63 #define ACPI_RESTAG_DEVICEPOLARITY "_DPL"
64 #define ACPI_RESTAG_DMA "_DMA"
65 #define ACPI_RESTAG_DMATYPE "_TYP" /* Compatible(0), A(1), B(2), F(3) */
66 #define ACPI_RESTAG_DRIVESTRENGTH "_DRS"
67 #define ACPI_RESTAG_ENDIANNESS "_END"
68 #define ACPI_RESTAG_FLOWCONTROL "_FLC"
69 #define ACPI_RESTAG_GRANULARITY "_GRA"
70 #define ACPI_RESTAG_INTERRUPT "_INT"
71 #define ACPI_RESTAG_INTERRUPTLEVEL "_LL_" /* ActiveLo(1), ActiveHi(0) */
72 #define ACPI_RESTAG_INTERRUPTSHARE "_SHR" /* Shareable(1), NoShare(0) */
73 #define ACPI_RESTAG_INTERRUPTTYPE "_HE_" /* Edge(1), Level(0) */
74 #define ACPI_RESTAG_IORESTRICTION "_IOR"
75 #define ACPI_RESTAG_LENGTH "_LEN"
76 #define ACPI_RESTAG_LINE "_LIN"
77 #define ACPI_RESTAG_MEMATTRIBUTES "_MTP" /* Memory(0), Reserved(1), ACPI(2), NVS(3) */
78 #define ACPI_RESTAG_MEMTYPE "_MEM" /* NonCache(0), Cacheable(1) Cache+combine(2), Cache+prefetch(3) */
79 #define ACPI_RESTAG_MAXADDR "_MAX"
80 #define ACPI_RESTAG_MINADDR "_MIN"
81 #define ACPI_RESTAG_MAXTYPE "_MAF"
82 #define ACPI_RESTAG_MINTYPE "_MIF"
83 #define ACPI_RESTAG_MODE "_MOD"
84 #define ACPI_RESTAG_PARITY "_PAR"
85 #define ACPI_RESTAG_PHASE "_PHA"
86 #define ACPI_RESTAG_PIN "_PIN"
87 #define ACPI_RESTAG_PINCONFIG "_PPI"
88 #define ACPI_RESTAG_POLARITY "_POL"
89 #define ACPI_RESTAG_REGISTERBITOFFSET "_RBO"
90 #define ACPI_RESTAG_REGISTERBITWIDTH "_RBW"
91 #define ACPI_RESTAG_RANGETYPE "_RNG"
92 #define ACPI_RESTAG_READWRITETYPE "_RW_" /* ReadOnly(0), Writeable (1) */
93 #define ACPI_RESTAG_LENGTH_RX "_RXL"
94 #define ACPI_RESTAG_LENGTH_TX "_TXL"
95 #define ACPI_RESTAG_SLAVEMODE "_SLV"
96 #define ACPI_RESTAG_SPEED "_SPE"
97 #define ACPI_RESTAG_STOPBITS "_STB"
98 #define ACPI_RESTAG_TRANSLATION "_TRA"
99 #define ACPI_RESTAG_TRANSTYPE "_TRS" /* Sparse(1), Dense(0) */
100 #define ACPI_RESTAG_TYPE "_TTP" /* Translation(1), Static (0) */
101 #define ACPI_RESTAG_XFERTYPE "_SIZ" /* 8(0), 8And16(1), 16(2) */
102 #define ACPI_RESTAG_VENDORDATA "_VEN"
105 /* Default sizes for "small" resource descriptors */
107 #define ASL_RDESC_IRQ_SIZE 0x02
108 #define ASL_RDESC_DMA_SIZE 0x02
109 #define ASL_RDESC_ST_DEPEND_SIZE 0x00
110 #define ASL_RDESC_END_DEPEND_SIZE 0x00
111 #define ASL_RDESC_IO_SIZE 0x07
112 #define ASL_RDESC_FIXED_IO_SIZE 0x03
113 #define ASL_RDESC_FIXED_DMA_SIZE 0x05
114 #define ASL_RDESC_END_TAG_SIZE 0x01
117 typedef struct asl_resource_node
121 struct asl_resource_node
*Next
;
125 typedef struct asl_resource_info
127 ACPI_PARSE_OBJECT
*DescriptorTypeOp
; /* Resource descriptor parse node */
128 ACPI_PARSE_OBJECT
*MappingOp
; /* Used for mapfile support */
129 UINT32 CurrentByteOffset
; /* Offset in resource template */
134 /* Macros used to generate AML resource length fields */
136 #define ACPI_AML_SIZE_LARGE(r) (sizeof (r) - sizeof (AML_RESOURCE_LARGE_HEADER))
137 #define ACPI_AML_SIZE_SMALL(r) (sizeof (r) - sizeof (AML_RESOURCE_SMALL_HEADER))
140 * Resource descriptors defined in the ACPI specification.
142 * Packing/alignment must be BYTE because these descriptors
143 * are used to overlay the raw AML byte stream.
150 #define AML_RESOURCE_SMALL_HEADER_COMMON \
151 UINT8 DescriptorType;
153 typedef struct aml_resource_small_header
155 AML_RESOURCE_SMALL_HEADER_COMMON
157 } AML_RESOURCE_SMALL_HEADER
;
160 typedef struct aml_resource_irq
162 AML_RESOURCE_SMALL_HEADER_COMMON
169 typedef struct aml_resource_irq_noflags
171 AML_RESOURCE_SMALL_HEADER_COMMON
174 } AML_RESOURCE_IRQ_NOFLAGS
;
177 typedef struct aml_resource_dma
179 AML_RESOURCE_SMALL_HEADER_COMMON
180 UINT8 DmaChannelMask
;
186 typedef struct aml_resource_start_dependent
188 AML_RESOURCE_SMALL_HEADER_COMMON
191 } AML_RESOURCE_START_DEPENDENT
;
194 typedef struct aml_resource_start_dependent_noprio
196 AML_RESOURCE_SMALL_HEADER_COMMON
198 } AML_RESOURCE_START_DEPENDENT_NOPRIO
;
201 typedef struct aml_resource_end_dependent
203 AML_RESOURCE_SMALL_HEADER_COMMON
205 } AML_RESOURCE_END_DEPENDENT
;
208 typedef struct aml_resource_io
210 AML_RESOURCE_SMALL_HEADER_COMMON
220 typedef struct aml_resource_fixed_io
222 AML_RESOURCE_SMALL_HEADER_COMMON
226 } AML_RESOURCE_FIXED_IO
;
229 typedef struct aml_resource_vendor_small
231 AML_RESOURCE_SMALL_HEADER_COMMON
233 } AML_RESOURCE_VENDOR_SMALL
;
236 typedef struct aml_resource_end_tag
238 AML_RESOURCE_SMALL_HEADER_COMMON
241 } AML_RESOURCE_END_TAG
;
244 typedef struct aml_resource_fixed_dma
246 AML_RESOURCE_SMALL_HEADER_COMMON
251 } AML_RESOURCE_FIXED_DMA
;
257 #define AML_RESOURCE_LARGE_HEADER_COMMON \
258 UINT8 DescriptorType;\
259 UINT16 ResourceLength;
261 typedef struct aml_resource_large_header
263 AML_RESOURCE_LARGE_HEADER_COMMON
265 } AML_RESOURCE_LARGE_HEADER
;
268 /* General Flags for address space resource descriptors */
270 #define ACPI_RESOURCE_FLAG_DEC 2
271 #define ACPI_RESOURCE_FLAG_MIF 4
272 #define ACPI_RESOURCE_FLAG_MAF 8
274 typedef struct aml_resource_memory24
276 AML_RESOURCE_LARGE_HEADER_COMMON
281 UINT16 AddressLength
;
283 } AML_RESOURCE_MEMORY24
;
286 typedef struct aml_resource_vendor_large
288 AML_RESOURCE_LARGE_HEADER_COMMON
290 } AML_RESOURCE_VENDOR_LARGE
;
293 typedef struct aml_resource_memory32
295 AML_RESOURCE_LARGE_HEADER_COMMON
300 UINT32 AddressLength
;
302 } AML_RESOURCE_MEMORY32
;
305 typedef struct aml_resource_fixed_memory32
307 AML_RESOURCE_LARGE_HEADER_COMMON
310 UINT32 AddressLength
;
312 } AML_RESOURCE_FIXED_MEMORY32
;
315 #define AML_RESOURCE_ADDRESS_COMMON \
316 UINT8 ResourceType; \
321 typedef struct aml_resource_address
323 AML_RESOURCE_LARGE_HEADER_COMMON
324 AML_RESOURCE_ADDRESS_COMMON
326 } AML_RESOURCE_ADDRESS
;
329 typedef struct aml_resource_extended_address64
331 AML_RESOURCE_LARGE_HEADER_COMMON
332 AML_RESOURCE_ADDRESS_COMMON
338 UINT64 TranslationOffset
;
339 UINT64 AddressLength
;
342 } AML_RESOURCE_EXTENDED_ADDRESS64
;
344 #define AML_RESOURCE_EXTENDED_ADDRESS_REVISION 1 /* ACPI 3.0 */
347 typedef struct aml_resource_address64
349 AML_RESOURCE_LARGE_HEADER_COMMON
350 AML_RESOURCE_ADDRESS_COMMON
354 UINT64 TranslationOffset
;
355 UINT64 AddressLength
;
357 } AML_RESOURCE_ADDRESS64
;
360 typedef struct aml_resource_address32
362 AML_RESOURCE_LARGE_HEADER_COMMON
363 AML_RESOURCE_ADDRESS_COMMON
367 UINT32 TranslationOffset
;
368 UINT32 AddressLength
;
370 } AML_RESOURCE_ADDRESS32
;
373 typedef struct aml_resource_address16
375 AML_RESOURCE_LARGE_HEADER_COMMON
376 AML_RESOURCE_ADDRESS_COMMON
380 UINT16 TranslationOffset
;
381 UINT16 AddressLength
;
383 } AML_RESOURCE_ADDRESS16
;
386 typedef struct aml_resource_extended_irq
388 AML_RESOURCE_LARGE_HEADER_COMMON
390 UINT8 InterruptCount
;
391 UINT32 Interrupts
[1];
392 /* ResSourceIndex, ResSource optional fields follow */
394 } AML_RESOURCE_EXTENDED_IRQ
;
397 typedef struct aml_resource_generic_register
399 AML_RESOURCE_LARGE_HEADER_COMMON
400 UINT8 AddressSpaceId
;
403 UINT8 AccessSize
; /* ACPI 3.0, was previously Reserved */
406 } AML_RESOURCE_GENERIC_REGISTER
;
409 /* Common descriptor for GpioInt and GpioIo (ACPI 5.0) */
411 typedef struct aml_resource_gpio
413 AML_RESOURCE_LARGE_HEADER_COMMON
415 UINT8 ConnectionType
;
419 UINT16 DriveStrength
;
420 UINT16 DebounceTimeout
;
421 UINT16 PinTableOffset
;
422 UINT8 ResSourceIndex
;
423 UINT16 ResSourceOffset
;
427 * Optional fields follow immediately:
428 * 1) PIN list (Words)
429 * 2) Resource Source String
430 * 3) Vendor Data bytes
435 #define AML_RESOURCE_GPIO_REVISION 1 /* ACPI 5.0 */
437 /* Values for ConnectionType above */
439 #define AML_RESOURCE_GPIO_TYPE_INT 0
440 #define AML_RESOURCE_GPIO_TYPE_IO 1
441 #define AML_RESOURCE_MAX_GPIOTYPE 1
444 /* Common preamble for all serial descriptors (ACPI 5.0) */
446 #define AML_RESOURCE_SERIAL_COMMON \
448 UINT8 ResSourceIndex; \
451 UINT16 TypeSpecificFlags; \
452 UINT8 TypeRevisionId; \
453 UINT16 TypeDataLength; \
455 /* Values for the type field above */
457 #define AML_RESOURCE_I2C_SERIALBUSTYPE 1
458 #define AML_RESOURCE_SPI_SERIALBUSTYPE 2
459 #define AML_RESOURCE_UART_SERIALBUSTYPE 3
460 #define AML_RESOURCE_MAX_SERIALBUSTYPE 3
461 #define AML_RESOURCE_VENDOR_SERIALBUSTYPE 192 /* Vendor defined is 0xC0-0xFF (NOT SUPPORTED) */
463 typedef struct aml_resource_common_serialbus
465 AML_RESOURCE_LARGE_HEADER_COMMON
466 AML_RESOURCE_SERIAL_COMMON
468 } AML_RESOURCE_COMMON_SERIALBUS
;
470 typedef struct aml_resource_i2c_serialbus
472 AML_RESOURCE_LARGE_HEADER_COMMON
473 AML_RESOURCE_SERIAL_COMMON
474 UINT32 ConnectionSpeed
;
477 * Optional fields follow immediately:
478 * 1) Vendor Data bytes
479 * 2) Resource Source String
482 } AML_RESOURCE_I2C_SERIALBUS
;
484 #define AML_RESOURCE_I2C_REVISION 1 /* ACPI 5.0 */
485 #define AML_RESOURCE_I2C_TYPE_REVISION 1 /* ACPI 5.0 */
486 #define AML_RESOURCE_I2C_MIN_DATA_LEN 6
488 typedef struct aml_resource_spi_serialbus
490 AML_RESOURCE_LARGE_HEADER_COMMON
491 AML_RESOURCE_SERIAL_COMMON
492 UINT32 ConnectionSpeed
;
496 UINT16 DeviceSelection
;
498 * Optional fields follow immediately:
499 * 1) Vendor Data bytes
500 * 2) Resource Source String
503 } AML_RESOURCE_SPI_SERIALBUS
;
505 #define AML_RESOURCE_SPI_REVISION 1 /* ACPI 5.0 */
506 #define AML_RESOURCE_SPI_TYPE_REVISION 1 /* ACPI 5.0 */
507 #define AML_RESOURCE_SPI_MIN_DATA_LEN 9
510 typedef struct aml_resource_uart_serialbus
512 AML_RESOURCE_LARGE_HEADER_COMMON
513 AML_RESOURCE_SERIAL_COMMON
514 UINT32 DefaultBaudRate
;
520 * Optional fields follow immediately:
521 * 1) Vendor Data bytes
522 * 2) Resource Source String
525 } AML_RESOURCE_UART_SERIALBUS
;
527 #define AML_RESOURCE_UART_REVISION 1 /* ACPI 5.0 */
528 #define AML_RESOURCE_UART_TYPE_REVISION 1 /* ACPI 5.0 */
529 #define AML_RESOURCE_UART_MIN_DATA_LEN 10
532 /* restore default alignment */
536 /* Union of all resource descriptors, so we can allocate the worst case */
538 typedef union aml_resource
540 /* Descriptor headers */
542 UINT8 DescriptorType
;
543 AML_RESOURCE_SMALL_HEADER SmallHeader
;
544 AML_RESOURCE_LARGE_HEADER LargeHeader
;
546 /* Small resource descriptors */
548 AML_RESOURCE_IRQ Irq
;
549 AML_RESOURCE_DMA Dma
;
550 AML_RESOURCE_START_DEPENDENT StartDpf
;
551 AML_RESOURCE_END_DEPENDENT EndDpf
;
553 AML_RESOURCE_FIXED_IO FixedIo
;
554 AML_RESOURCE_FIXED_DMA FixedDma
;
555 AML_RESOURCE_VENDOR_SMALL VendorSmall
;
556 AML_RESOURCE_END_TAG EndTag
;
558 /* Large resource descriptors */
560 AML_RESOURCE_MEMORY24 Memory24
;
561 AML_RESOURCE_GENERIC_REGISTER GenericReg
;
562 AML_RESOURCE_VENDOR_LARGE VendorLarge
;
563 AML_RESOURCE_MEMORY32 Memory32
;
564 AML_RESOURCE_FIXED_MEMORY32 FixedMemory32
;
565 AML_RESOURCE_ADDRESS16 Address16
;
566 AML_RESOURCE_ADDRESS32 Address32
;
567 AML_RESOURCE_ADDRESS64 Address64
;
568 AML_RESOURCE_EXTENDED_ADDRESS64 ExtAddress64
;
569 AML_RESOURCE_EXTENDED_IRQ ExtendedIrq
;
570 AML_RESOURCE_GPIO Gpio
;
571 AML_RESOURCE_I2C_SERIALBUS I2cSerialBus
;
572 AML_RESOURCE_SPI_SERIALBUS SpiSerialBus
;
573 AML_RESOURCE_UART_SERIALBUS UartSerialBus
;
574 AML_RESOURCE_COMMON_SERIALBUS CommonSerialBus
;
576 /* Utility overlays */
578 AML_RESOURCE_ADDRESS Address
;
586 /* Interfaces used by both the disassembler and compiler */
590 ACPI_PARSE_OBJECT
*Op
,
591 AML_RESOURCE
*Resource
,
598 ACPI_PARSE_OBJECT
*Op
,
599 AML_RESOURCE
*Resource
,
603 MpGetHidFromParseTree (
604 ACPI_NAMESPACE_NODE
*HidNode
);
607 MpGetHidViaNamestring (
611 MpGetConnectionInfo (
612 ACPI_PARSE_OBJECT
*Op
,
614 ACPI_NAMESPACE_NODE
**TargetNode
,
618 MpGetParentDeviceHid (
619 ACPI_PARSE_OBJECT
*Op
,
620 ACPI_NAMESPACE_NODE
**TargetNode
,
621 char **ParentDeviceName
);
629 ACPI_NAMESPACE_NODE
*DeviceNode
);