1 2 /****************************************************************************** 3 * 4 * Module Name: amlresrc.h - AML resource descriptors 5 * 6 *****************************************************************************/ 7 8 /* 9 * Copyright (C) 2000 - 2012, Intel Corp. 10 * All rights reserved. 11 * 12 * Redistribution and use in source and binary forms, with or without 13 * modification, are permitted provided that the following conditions 14 * are met: 15 * 1. Redistributions of source code must retain the above copyright 16 * notice, this list of conditions, and the following disclaimer, 17 * without modification. 18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 19 * substantially similar to the "NO WARRANTY" disclaimer below 20 * ("Disclaimer") and any redistribution must be conditioned upon 21 * including a substantially similar Disclaimer requirement for further 22 * binary redistribution. 23 * 3. Neither the names of the above-listed copyright holders nor the names 24 * of any contributors may be used to endorse or promote products derived 25 * from this software without specific prior written permission. 26 * 27 * Alternatively, this software may be distributed under the terms of the 28 * GNU General Public License ("GPL") version 2 as published by the Free 29 * Software Foundation. 30 * 31 * NO WARRANTY 32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 42 * POSSIBILITY OF SUCH DAMAGES. 43 */ 44 45 /* acpisrc:StructDefs -- for acpisrc conversion */ 46 47 #ifndef __AMLRESRC_H 48 #define __AMLRESRC_H 49 50 51 /* 52 * Resource descriptor tags, as defined in the ACPI specification. 53 * Used to symbolically reference fields within a descriptor. 54 */ 55 #define ACPI_RESTAG_ADDRESS "_ADR" 56 #define ACPI_RESTAG_ALIGNMENT "_ALN" 57 #define ACPI_RESTAG_ADDRESSSPACE "_ASI" 58 #define ACPI_RESTAG_ACCESSSIZE "_ASZ" 59 #define ACPI_RESTAG_TYPESPECIFICATTRIBUTES "_ATT" 60 #define ACPI_RESTAG_BASEADDRESS "_BAS" 61 #define ACPI_RESTAG_BUSMASTER "_BM_" /* Master(1), Slave(0) */ 62 #define ACPI_RESTAG_DEBOUNCETIME "_DBT" 63 #define ACPI_RESTAG_DECODE "_DEC" 64 #define ACPI_RESTAG_DEVICEPOLARITY "_DPL" 65 #define ACPI_RESTAG_DMA "_DMA" 66 #define ACPI_RESTAG_DMATYPE "_TYP" /* Compatible(0), A(1), B(2), F(3) */ 67 #define ACPI_RESTAG_DRIVESTRENGTH "_DRS" 68 #define ACPI_RESTAG_ENDIANNESS "_END" 69 #define ACPI_RESTAG_FLOWCONTROL "_FLC" 70 #define ACPI_RESTAG_GRANULARITY "_GRA" 71 #define ACPI_RESTAG_INTERRUPT "_INT" 72 #define ACPI_RESTAG_INTERRUPTLEVEL "_LL_" /* ActiveLo(1), ActiveHi(0) */ 73 #define ACPI_RESTAG_INTERRUPTSHARE "_SHR" /* Shareable(1), NoShare(0) */ 74 #define ACPI_RESTAG_INTERRUPTTYPE "_HE_" /* Edge(1), Level(0) */ 75 #define ACPI_RESTAG_IORESTRICTION "_IOR" 76 #define ACPI_RESTAG_LENGTH "_LEN" 77 #define ACPI_RESTAG_LINE "_LIN" 78 #define ACPI_RESTAG_MEMATTRIBUTES "_MTP" /* Memory(0), Reserved(1), ACPI(2), NVS(3) */ 79 #define ACPI_RESTAG_MEMTYPE "_MEM" /* NonCache(0), Cacheable(1) Cache+combine(2), Cache+prefetch(3) */ 80 #define ACPI_RESTAG_MAXADDR "_MAX" 81 #define ACPI_RESTAG_MINADDR "_MIN" 82 #define ACPI_RESTAG_MAXTYPE "_MAF" 83 #define ACPI_RESTAG_MINTYPE "_MIF" 84 #define ACPI_RESTAG_MODE "_MOD" 85 #define ACPI_RESTAG_PARITY "_PAR" 86 #define ACPI_RESTAG_PHASE "_PHA" 87 #define ACPI_RESTAG_PIN "_PIN" 88 #define ACPI_RESTAG_PINCONFIG "_PPI" 89 #define ACPI_RESTAG_POLARITY "_POL" 90 #define ACPI_RESTAG_REGISTERBITOFFSET "_RBO" 91 #define ACPI_RESTAG_REGISTERBITWIDTH "_RBW" 92 #define ACPI_RESTAG_RANGETYPE "_RNG" 93 #define ACPI_RESTAG_READWRITETYPE "_RW_" /* ReadOnly(0), Writeable (1) */ 94 #define ACPI_RESTAG_LENGTH_RX "_RXL" 95 #define ACPI_RESTAG_LENGTH_TX "_TXL" 96 #define ACPI_RESTAG_SLAVEMODE "_SLV" 97 #define ACPI_RESTAG_SPEED "_SPE" 98 #define ACPI_RESTAG_STOPBITS "_STB" 99 #define ACPI_RESTAG_TRANSLATION "_TRA" 100 #define ACPI_RESTAG_TRANSTYPE "_TRS" /* Sparse(1), Dense(0) */ 101 #define ACPI_RESTAG_TYPE "_TTP" /* Translation(1), Static (0) */ 102 #define ACPI_RESTAG_XFERTYPE "_SIZ" /* 8(0), 8And16(1), 16(2) */ 103 #define ACPI_RESTAG_VENDORDATA "_VEN" 104 105 106 /* Default sizes for "small" resource descriptors */ 107 108 #define ASL_RDESC_IRQ_SIZE 0x02 109 #define ASL_RDESC_DMA_SIZE 0x02 110 #define ASL_RDESC_ST_DEPEND_SIZE 0x00 111 #define ASL_RDESC_END_DEPEND_SIZE 0x00 112 #define ASL_RDESC_IO_SIZE 0x07 113 #define ASL_RDESC_FIXED_IO_SIZE 0x03 114 #define ASL_RDESC_FIXED_DMA_SIZE 0x05 115 #define ASL_RDESC_END_TAG_SIZE 0x01 116 117 118 typedef struct asl_resource_node 119 { 120 UINT32 BufferLength; 121 void *Buffer; 122 struct asl_resource_node *Next; 123 124 } ASL_RESOURCE_NODE; 125 126 127 /* Macros used to generate AML resource length fields */ 128 129 #define ACPI_AML_SIZE_LARGE(r) (sizeof (r) - sizeof (AML_RESOURCE_LARGE_HEADER)) 130 #define ACPI_AML_SIZE_SMALL(r) (sizeof (r) - sizeof (AML_RESOURCE_SMALL_HEADER)) 131 132 /* 133 * Resource descriptors defined in the ACPI specification. 134 * 135 * Packing/alignment must be BYTE because these descriptors 136 * are used to overlay the raw AML byte stream. 137 */ 138 #pragma pack(1) 139 140 /* 141 * SMALL descriptors 142 */ 143 #define AML_RESOURCE_SMALL_HEADER_COMMON \ 144 UINT8 DescriptorType; 145 146 typedef struct aml_resource_small_header 147 { 148 AML_RESOURCE_SMALL_HEADER_COMMON 149 150 } AML_RESOURCE_SMALL_HEADER; 151 152 153 typedef struct aml_resource_irq 154 { 155 AML_RESOURCE_SMALL_HEADER_COMMON 156 UINT16 IrqMask; 157 UINT8 Flags; 158 159 } AML_RESOURCE_IRQ; 160 161 162 typedef struct aml_resource_irq_noflags 163 { 164 AML_RESOURCE_SMALL_HEADER_COMMON 165 UINT16 IrqMask; 166 167 } AML_RESOURCE_IRQ_NOFLAGS; 168 169 170 typedef struct aml_resource_dma 171 { 172 AML_RESOURCE_SMALL_HEADER_COMMON 173 UINT8 DmaChannelMask; 174 UINT8 Flags; 175 176 } AML_RESOURCE_DMA; 177 178 179 typedef struct aml_resource_start_dependent 180 { 181 AML_RESOURCE_SMALL_HEADER_COMMON 182 UINT8 Flags; 183 184 } AML_RESOURCE_START_DEPENDENT; 185 186 187 typedef struct aml_resource_start_dependent_noprio 188 { 189 AML_RESOURCE_SMALL_HEADER_COMMON 190 191 } AML_RESOURCE_START_DEPENDENT_NOPRIO; 192 193 194 typedef struct aml_resource_end_dependent 195 { 196 AML_RESOURCE_SMALL_HEADER_COMMON 197 198 } AML_RESOURCE_END_DEPENDENT; 199 200 201 typedef struct aml_resource_io 202 { 203 AML_RESOURCE_SMALL_HEADER_COMMON 204 UINT8 Flags; 205 UINT16 Minimum; 206 UINT16 Maximum; 207 UINT8 Alignment; 208 UINT8 AddressLength; 209 210 } AML_RESOURCE_IO; 211 212 213 typedef struct aml_resource_fixed_io 214 { 215 AML_RESOURCE_SMALL_HEADER_COMMON 216 UINT16 Address; 217 UINT8 AddressLength; 218 219 } AML_RESOURCE_FIXED_IO; 220 221 222 typedef struct aml_resource_vendor_small 223 { 224 AML_RESOURCE_SMALL_HEADER_COMMON 225 226 } AML_RESOURCE_VENDOR_SMALL; 227 228 229 typedef struct aml_resource_end_tag 230 { 231 AML_RESOURCE_SMALL_HEADER_COMMON 232 UINT8 Checksum; 233 234 } AML_RESOURCE_END_TAG; 235 236 237 typedef struct aml_resource_fixed_dma 238 { 239 AML_RESOURCE_SMALL_HEADER_COMMON 240 UINT16 RequestLines; 241 UINT16 Channels; 242 UINT8 Width; 243 244 } AML_RESOURCE_FIXED_DMA; 245 246 247 /* 248 * LARGE descriptors 249 */ 250 #define AML_RESOURCE_LARGE_HEADER_COMMON \ 251 UINT8 DescriptorType;\ 252 UINT16 ResourceLength; 253 254 typedef struct aml_resource_large_header 255 { 256 AML_RESOURCE_LARGE_HEADER_COMMON 257 258 } AML_RESOURCE_LARGE_HEADER; 259 260 261 /* General Flags for address space resource descriptors */ 262 263 #define ACPI_RESOURCE_FLAG_DEC 2 264 #define ACPI_RESOURCE_FLAG_MIF 4 265 #define ACPI_RESOURCE_FLAG_MAF 8 266 267 typedef struct aml_resource_memory24 268 { 269 AML_RESOURCE_LARGE_HEADER_COMMON 270 UINT8 Flags; 271 UINT16 Minimum; 272 UINT16 Maximum; 273 UINT16 Alignment; 274 UINT16 AddressLength; 275 276 } AML_RESOURCE_MEMORY24; 277 278 279 typedef struct aml_resource_vendor_large 280 { 281 AML_RESOURCE_LARGE_HEADER_COMMON 282 283 } AML_RESOURCE_VENDOR_LARGE; 284 285 286 typedef struct aml_resource_memory32 287 { 288 AML_RESOURCE_LARGE_HEADER_COMMON 289 UINT8 Flags; 290 UINT32 Minimum; 291 UINT32 Maximum; 292 UINT32 Alignment; 293 UINT32 AddressLength; 294 295 } AML_RESOURCE_MEMORY32; 296 297 298 typedef struct aml_resource_fixed_memory32 299 { 300 AML_RESOURCE_LARGE_HEADER_COMMON 301 UINT8 Flags; 302 UINT32 Address; 303 UINT32 AddressLength; 304 305 } AML_RESOURCE_FIXED_MEMORY32; 306 307 308 #define AML_RESOURCE_ADDRESS_COMMON \ 309 UINT8 ResourceType; \ 310 UINT8 Flags; \ 311 UINT8 SpecificFlags; 312 313 314 typedef struct aml_resource_address 315 { 316 AML_RESOURCE_LARGE_HEADER_COMMON 317 AML_RESOURCE_ADDRESS_COMMON 318 319 } AML_RESOURCE_ADDRESS; 320 321 322 typedef struct aml_resource_extended_address64 323 { 324 AML_RESOURCE_LARGE_HEADER_COMMON 325 AML_RESOURCE_ADDRESS_COMMON 326 UINT8 RevisionID; 327 UINT8 Reserved; 328 UINT64 Granularity; 329 UINT64 Minimum; 330 UINT64 Maximum; 331 UINT64 TranslationOffset; 332 UINT64 AddressLength; 333 UINT64 TypeSpecific; 334 335 } AML_RESOURCE_EXTENDED_ADDRESS64; 336 337 #define AML_RESOURCE_EXTENDED_ADDRESS_REVISION 1 /* ACPI 3.0 */ 338 339 340 typedef struct aml_resource_address64 341 { 342 AML_RESOURCE_LARGE_HEADER_COMMON 343 AML_RESOURCE_ADDRESS_COMMON 344 UINT64 Granularity; 345 UINT64 Minimum; 346 UINT64 Maximum; 347 UINT64 TranslationOffset; 348 UINT64 AddressLength; 349 350 } AML_RESOURCE_ADDRESS64; 351 352 353 typedef struct aml_resource_address32 354 { 355 AML_RESOURCE_LARGE_HEADER_COMMON 356 AML_RESOURCE_ADDRESS_COMMON 357 UINT32 Granularity; 358 UINT32 Minimum; 359 UINT32 Maximum; 360 UINT32 TranslationOffset; 361 UINT32 AddressLength; 362 363 } AML_RESOURCE_ADDRESS32; 364 365 366 typedef struct aml_resource_address16 367 { 368 AML_RESOURCE_LARGE_HEADER_COMMON 369 AML_RESOURCE_ADDRESS_COMMON 370 UINT16 Granularity; 371 UINT16 Minimum; 372 UINT16 Maximum; 373 UINT16 TranslationOffset; 374 UINT16 AddressLength; 375 376 } AML_RESOURCE_ADDRESS16; 377 378 379 typedef struct aml_resource_extended_irq 380 { 381 AML_RESOURCE_LARGE_HEADER_COMMON 382 UINT8 Flags; 383 UINT8 InterruptCount; 384 UINT32 Interrupts[1]; 385 /* ResSourceIndex, ResSource optional fields follow */ 386 387 } AML_RESOURCE_EXTENDED_IRQ; 388 389 390 typedef struct aml_resource_generic_register 391 { 392 AML_RESOURCE_LARGE_HEADER_COMMON 393 UINT8 AddressSpaceId; 394 UINT8 BitWidth; 395 UINT8 BitOffset; 396 UINT8 AccessSize; /* ACPI 3.0, was previously Reserved */ 397 UINT64 Address; 398 399 } AML_RESOURCE_GENERIC_REGISTER; 400 401 402 /* Common descriptor for GpioInt and GpioIo (ACPI 5.0) */ 403 404 typedef struct aml_resource_gpio 405 { 406 AML_RESOURCE_LARGE_HEADER_COMMON 407 UINT8 RevisionId; 408 UINT8 ConnectionType; 409 UINT16 Flags; 410 UINT16 IntFlags; 411 UINT8 PinConfig; 412 UINT16 DriveStrength; 413 UINT16 DebounceTimeout; 414 UINT16 PinTableOffset; 415 UINT8 ResSourceIndex; 416 UINT16 ResSourceOffset; 417 UINT16 VendorOffset; 418 UINT16 VendorLength; 419 /* 420 * Optional fields follow immediately: 421 * 1) PIN list (Words) 422 * 2) Resource Source String 423 * 3) Vendor Data bytes 424 */ 425 426 } AML_RESOURCE_GPIO; 427 428 #define AML_RESOURCE_GPIO_REVISION 1 /* ACPI 5.0 */ 429 430 /* Values for ConnectionType above */ 431 432 #define AML_RESOURCE_GPIO_TYPE_INT 0 433 #define AML_RESOURCE_GPIO_TYPE_IO 1 434 #define AML_RESOURCE_MAX_GPIOTYPE 1 435 436 437 /* Common preamble for all serial descriptors (ACPI 5.0) */ 438 439 #define AML_RESOURCE_SERIAL_COMMON \ 440 UINT8 RevisionId; \ 441 UINT8 ResSourceIndex; \ 442 UINT8 Type; \ 443 UINT8 Flags; \ 444 UINT16 TypeSpecificFlags; \ 445 UINT8 TypeRevisionId; \ 446 UINT16 TypeDataLength; \ 447 448 /* Values for the type field above */ 449 450 #define AML_RESOURCE_I2C_SERIALBUSTYPE 1 451 #define AML_RESOURCE_SPI_SERIALBUSTYPE 2 452 #define AML_RESOURCE_UART_SERIALBUSTYPE 3 453 #define AML_RESOURCE_MAX_SERIALBUSTYPE 3 454 #define AML_RESOURCE_VENDOR_SERIALBUSTYPE 192 /* Vendor defined is 0xC0-0xFF (NOT SUPPORTED) */ 455 456 typedef struct aml_resource_common_serialbus 457 { 458 AML_RESOURCE_LARGE_HEADER_COMMON 459 AML_RESOURCE_SERIAL_COMMON 460 461 } AML_RESOURCE_COMMON_SERIALBUS; 462 463 typedef struct aml_resource_i2c_serialbus 464 { 465 AML_RESOURCE_LARGE_HEADER_COMMON 466 AML_RESOURCE_SERIAL_COMMON 467 UINT32 ConnectionSpeed; 468 UINT16 SlaveAddress; 469 /* 470 * Optional fields follow immediately: 471 * 1) Vendor Data bytes 472 * 2) Resource Source String 473 */ 474 475 } AML_RESOURCE_I2C_SERIALBUS; 476 477 #define AML_RESOURCE_I2C_REVISION 1 /* ACPI 5.0 */ 478 #define AML_RESOURCE_I2C_TYPE_REVISION 1 /* ACPI 5.0 */ 479 #define AML_RESOURCE_I2C_MIN_DATA_LEN 6 480 481 typedef struct aml_resource_spi_serialbus 482 { 483 AML_RESOURCE_LARGE_HEADER_COMMON 484 AML_RESOURCE_SERIAL_COMMON 485 UINT32 ConnectionSpeed; 486 UINT8 DataBitLength; 487 UINT8 ClockPhase; 488 UINT8 ClockPolarity; 489 UINT16 DeviceSelection; 490 /* 491 * Optional fields follow immediately: 492 * 1) Vendor Data bytes 493 * 2) Resource Source String 494 */ 495 496 } AML_RESOURCE_SPI_SERIALBUS; 497 498 #define AML_RESOURCE_SPI_REVISION 1 /* ACPI 5.0 */ 499 #define AML_RESOURCE_SPI_TYPE_REVISION 1 /* ACPI 5.0 */ 500 #define AML_RESOURCE_SPI_MIN_DATA_LEN 9 501 502 503 typedef struct aml_resource_uart_serialbus 504 { 505 AML_RESOURCE_LARGE_HEADER_COMMON 506 AML_RESOURCE_SERIAL_COMMON 507 UINT32 DefaultBaudRate; 508 UINT16 RxFifoSize; 509 UINT16 TxFifoSize; 510 UINT8 Parity; 511 UINT8 LinesEnabled; 512 /* 513 * Optional fields follow immediately: 514 * 1) Vendor Data bytes 515 * 2) Resource Source String 516 */ 517 518 } AML_RESOURCE_UART_SERIALBUS; 519 520 #define AML_RESOURCE_UART_REVISION 1 /* ACPI 5.0 */ 521 #define AML_RESOURCE_UART_TYPE_REVISION 1 /* ACPI 5.0 */ 522 #define AML_RESOURCE_UART_MIN_DATA_LEN 10 523 524 525 /* restore default alignment */ 526 527 #pragma pack() 528 529 /* Union of all resource descriptors, so we can allocate the worst case */ 530 531 typedef union aml_resource 532 { 533 /* Descriptor headers */ 534 535 UINT8 DescriptorType; 536 AML_RESOURCE_SMALL_HEADER SmallHeader; 537 AML_RESOURCE_LARGE_HEADER LargeHeader; 538 539 /* Small resource descriptors */ 540 541 AML_RESOURCE_IRQ Irq; 542 AML_RESOURCE_DMA Dma; 543 AML_RESOURCE_START_DEPENDENT StartDpf; 544 AML_RESOURCE_END_DEPENDENT EndDpf; 545 AML_RESOURCE_IO Io; 546 AML_RESOURCE_FIXED_IO FixedIo; 547 AML_RESOURCE_FIXED_DMA FixedDma; 548 AML_RESOURCE_VENDOR_SMALL VendorSmall; 549 AML_RESOURCE_END_TAG EndTag; 550 551 /* Large resource descriptors */ 552 553 AML_RESOURCE_MEMORY24 Memory24; 554 AML_RESOURCE_GENERIC_REGISTER GenericReg; 555 AML_RESOURCE_VENDOR_LARGE VendorLarge; 556 AML_RESOURCE_MEMORY32 Memory32; 557 AML_RESOURCE_FIXED_MEMORY32 FixedMemory32; 558 AML_RESOURCE_ADDRESS16 Address16; 559 AML_RESOURCE_ADDRESS32 Address32; 560 AML_RESOURCE_ADDRESS64 Address64; 561 AML_RESOURCE_EXTENDED_ADDRESS64 ExtAddress64; 562 AML_RESOURCE_EXTENDED_IRQ ExtendedIrq; 563 AML_RESOURCE_GPIO Gpio; 564 AML_RESOURCE_I2C_SERIALBUS I2cSerialBus; 565 AML_RESOURCE_SPI_SERIALBUS SpiSerialBus; 566 AML_RESOURCE_UART_SERIALBUS UartSerialBus; 567 AML_RESOURCE_COMMON_SERIALBUS CommonSerialBus; 568 569 /* Utility overlays */ 570 571 AML_RESOURCE_ADDRESS Address; 572 UINT32 DwordItem; 573 UINT16 WordItem; 574 UINT8 ByteItem; 575 576 } AML_RESOURCE; 577 578 #endif 579 580