1 /******************************************************************************
   2  *
   3  * Name: acrestyp.h - Defines, types, and structures for resource descriptors
   4  *
   5  *****************************************************************************/
   6 
   7 /*
   8  * Copyright (C) 2000 - 2011, Intel Corp.
   9  * All rights reserved.
  10  *
  11  * Redistribution and use in source and binary forms, with or without
  12  * modification, are permitted provided that the following conditions
  13  * are met:
  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.
  25  *
  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.
  29  *
  30  * NO WARRANTY
  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.
  42  */
  43 
  44 #ifndef __ACRESTYP_H__
  45 #define __ACRESTYP_H__
  46 
  47 
  48 /*
  49  * Definitions for Resource Attributes
  50  */
  51 typedef UINT16                          ACPI_RS_LENGTH;    /* Resource Length field is fixed at 16 bits */
  52 typedef UINT32                          ACPI_RSDESC_SIZE;  /* Max Resource Descriptor size is (Length+3) = (64K-1)+3 */
  53 
  54 /*
  55  * Memory Attributes
  56  */
  57 #define ACPI_READ_ONLY_MEMORY           (UINT8) 0x00
  58 #define ACPI_READ_WRITE_MEMORY          (UINT8) 0x01
  59 
  60 #define ACPI_NON_CACHEABLE_MEMORY       (UINT8) 0x00
  61 #define ACPI_CACHABLE_MEMORY            (UINT8) 0x01
  62 #define ACPI_WRITE_COMBINING_MEMORY     (UINT8) 0x02
  63 #define ACPI_PREFETCHABLE_MEMORY        (UINT8) 0x03
  64 
  65 /*
  66  * IO Attributes
  67  * The ISA IO ranges are:     n000-n0FFh,  n400-n4FFh, n800-n8FFh, nC00-nCFFh.
  68  * The non-ISA IO ranges are: n100-n3FFh,  n500-n7FFh, n900-nBFFh, nCD0-nFFFh.
  69  */
  70 #define ACPI_NON_ISA_ONLY_RANGES        (UINT8) 0x01
  71 #define ACPI_ISA_ONLY_RANGES            (UINT8) 0x02
  72 #define ACPI_ENTIRE_RANGE               (ACPI_NON_ISA_ONLY_RANGES | ACPI_ISA_ONLY_RANGES)
  73 
  74 /* Type of translation - 1=Sparse, 0=Dense */
  75 
  76 #define ACPI_SPARSE_TRANSLATION         (UINT8) 0x01
  77 
  78 /*
  79  * IO Port Descriptor Decode
  80  */
  81 #define ACPI_DECODE_10                  (UINT8) 0x00    /* 10-bit IO address decode */
  82 #define ACPI_DECODE_16                  (UINT8) 0x01    /* 16-bit IO address decode */
  83 
  84 /*
  85  * IRQ Attributes
  86  */
  87 #define ACPI_LEVEL_SENSITIVE            (UINT8) 0x00
  88 #define ACPI_EDGE_SENSITIVE             (UINT8) 0x01
  89 
  90 #define ACPI_ACTIVE_HIGH                (UINT8) 0x00
  91 #define ACPI_ACTIVE_LOW                 (UINT8) 0x01
  92 
  93 #define ACPI_EXCLUSIVE                  (UINT8) 0x00
  94 #define ACPI_SHARED                     (UINT8) 0x01
  95 
  96 /*
  97  * DMA Attributes
  98  */
  99 #define ACPI_COMPATIBILITY              (UINT8) 0x00
 100 #define ACPI_TYPE_A                     (UINT8) 0x01
 101 #define ACPI_TYPE_B                     (UINT8) 0x02
 102 #define ACPI_TYPE_F                     (UINT8) 0x03
 103 
 104 #define ACPI_NOT_BUS_MASTER             (UINT8) 0x00
 105 #define ACPI_BUS_MASTER                 (UINT8) 0x01
 106 
 107 #define ACPI_TRANSFER_8                 (UINT8) 0x00
 108 #define ACPI_TRANSFER_8_16              (UINT8) 0x01
 109 #define ACPI_TRANSFER_16                (UINT8) 0x02
 110 
 111 /*
 112  * Start Dependent Functions Priority definitions
 113  */
 114 #define ACPI_GOOD_CONFIGURATION         (UINT8) 0x00
 115 #define ACPI_ACCEPTABLE_CONFIGURATION   (UINT8) 0x01
 116 #define ACPI_SUB_OPTIMAL_CONFIGURATION  (UINT8) 0x02
 117 
 118 /*
 119  * 16, 32 and 64-bit Address Descriptor resource types
 120  */
 121 #define ACPI_MEMORY_RANGE               (UINT8) 0x00
 122 #define ACPI_IO_RANGE                   (UINT8) 0x01
 123 #define ACPI_BUS_NUMBER_RANGE           (UINT8) 0x02
 124 
 125 #define ACPI_ADDRESS_NOT_FIXED          (UINT8) 0x00
 126 #define ACPI_ADDRESS_FIXED              (UINT8) 0x01
 127 
 128 #define ACPI_POS_DECODE                 (UINT8) 0x00
 129 #define ACPI_SUB_DECODE                 (UINT8) 0x01
 130 
 131 #define ACPI_PRODUCER                   (UINT8) 0x00
 132 #define ACPI_CONSUMER                   (UINT8) 0x01
 133 
 134 
 135 /*
 136  * If possible, pack the following structures to byte alignment
 137  */
 138 #ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED
 139 #pragma pack(1)
 140 #endif
 141 
 142 /* UUID data structures for use in vendor-defined resource descriptors */
 143 
 144 typedef struct acpi_uuid
 145 {
 146     UINT8                           Data[ACPI_UUID_LENGTH];
 147 } ACPI_UUID;
 148 
 149 typedef struct acpi_vendor_uuid
 150 {
 151     UINT8                           Subtype;
 152     UINT8                           Data[ACPI_UUID_LENGTH];
 153 
 154 } ACPI_VENDOR_UUID;
 155 
 156 /*
 157  * Structures used to describe device resources
 158  */
 159 typedef struct acpi_resource_irq
 160 {
 161     UINT8                           DescriptorLength;
 162     UINT8                           Triggering;
 163     UINT8                           Polarity;
 164     UINT8                           Sharable;
 165     UINT8                           InterruptCount;
 166     UINT8                           Interrupts[1];
 167 
 168 } ACPI_RESOURCE_IRQ;
 169 
 170 typedef struct ACPI_RESOURCE_DMA
 171 {
 172     UINT8                           Type;
 173     UINT8                           BusMaster;
 174     UINT8                           Transfer;
 175     UINT8                           ChannelCount;
 176     UINT8                           Channels[1];
 177 
 178 } ACPI_RESOURCE_DMA;
 179 
 180 typedef struct acpi_resource_start_dependent
 181 {
 182     UINT8                           DescriptorLength;
 183     UINT8                           CompatibilityPriority;
 184     UINT8                           PerformanceRobustness;
 185 
 186 } ACPI_RESOURCE_START_DEPENDENT;
 187 
 188 
 189 /*
 190  * The END_DEPENDENT_FUNCTIONS_RESOURCE struct is not
 191  * needed because it has no fields
 192  */
 193 
 194 
 195 typedef struct acpi_resource_io
 196 {
 197     UINT8                           IoDecode;
 198     UINT8                           Alignment;
 199     UINT8                           AddressLength;
 200     UINT16                          Minimum;
 201     UINT16                          Maximum;
 202 
 203 } ACPI_RESOURCE_IO;
 204 
 205 typedef struct acpi_resource_fixed_io
 206 {
 207     UINT16                          Address;
 208     UINT8                           AddressLength;
 209 
 210 } ACPI_RESOURCE_FIXED_IO;
 211 
 212 typedef struct acpi_resource_vendor
 213 {
 214     UINT16                          ByteLength;
 215     UINT8                           ByteData[1];
 216 
 217 } ACPI_RESOURCE_VENDOR;
 218 
 219 /* Vendor resource with UUID info (introduced in ACPI 3.0) */
 220 
 221 typedef struct acpi_resource_vendor_typed
 222 {
 223     UINT16                          ByteLength;
 224     UINT8                           UuidSubtype;
 225     UINT8                           Uuid[ACPI_UUID_LENGTH];
 226     UINT8                           ByteData[1];
 227 
 228 } ACPI_RESOURCE_VENDOR_TYPED;
 229 
 230 typedef struct acpi_resource_end_tag
 231 {
 232     UINT8                           Checksum;
 233 
 234 } ACPI_RESOURCE_END_TAG;
 235 
 236 typedef struct acpi_resource_memory24
 237 {
 238     UINT8                           WriteProtect;
 239     UINT16                          Minimum;
 240     UINT16                          Maximum;
 241     UINT16                          Alignment;
 242     UINT16                          AddressLength;
 243 
 244 } ACPI_RESOURCE_MEMORY24;
 245 
 246 typedef struct acpi_resource_memory32
 247 {
 248     UINT8                           WriteProtect;
 249     UINT32                          Minimum;
 250     UINT32                          Maximum;
 251     UINT32                          Alignment;
 252     UINT32                          AddressLength;
 253 
 254 } ACPI_RESOURCE_MEMORY32;
 255 
 256 typedef struct acpi_resource_fixed_memory32
 257 {
 258     UINT8                           WriteProtect;
 259     UINT32                          Address;
 260     UINT32                          AddressLength;
 261 
 262 } ACPI_RESOURCE_FIXED_MEMORY32;
 263 
 264 typedef struct acpi_memory_attribute
 265 {
 266     UINT8                           WriteProtect;
 267     UINT8                           Caching;
 268     UINT8                           RangeType;
 269     UINT8                           Translation;
 270 
 271 } ACPI_MEMORY_ATTRIBUTE;
 272 
 273 typedef struct acpi_io_attribute
 274 {
 275     UINT8                           RangeType;
 276     UINT8                           Translation;
 277     UINT8                           TranslationType;
 278     UINT8                           Reserved1;
 279 
 280 } ACPI_IO_ATTRIBUTE;
 281 
 282 typedef union acpi_resource_attribute
 283 {
 284     ACPI_MEMORY_ATTRIBUTE           Mem;
 285     ACPI_IO_ATTRIBUTE               Io;
 286 
 287     /* Used for the *WordSpace macros */
 288 
 289     UINT8                           TypeSpecific;
 290 
 291 } ACPI_RESOURCE_ATTRIBUTE;
 292 
 293 typedef struct acpi_resource_source
 294 {
 295     UINT8                           Index;
 296     UINT16                          StringLength;
 297     char                            *StringPtr;
 298 
 299 } ACPI_RESOURCE_SOURCE;
 300 
 301 /* Fields common to all address descriptors, 16/32/64 bit */
 302 
 303 #define ACPI_RESOURCE_ADDRESS_COMMON \
 304     UINT8                           ResourceType; \
 305     UINT8                           ProducerConsumer; \
 306     UINT8                           Decode; \
 307     UINT8                           MinAddressFixed; \
 308     UINT8                           MaxAddressFixed; \
 309     ACPI_RESOURCE_ATTRIBUTE         Info;
 310 
 311 typedef struct acpi_resource_address
 312 {
 313     ACPI_RESOURCE_ADDRESS_COMMON
 314 
 315 } ACPI_RESOURCE_ADDRESS;
 316 
 317 typedef struct acpi_resource_address16
 318 {
 319     ACPI_RESOURCE_ADDRESS_COMMON
 320     UINT16                          Granularity;
 321     UINT16                          Minimum;
 322     UINT16                          Maximum;
 323     UINT16                          TranslationOffset;
 324     UINT16                          AddressLength;
 325     ACPI_RESOURCE_SOURCE            ResourceSource;
 326 
 327 } ACPI_RESOURCE_ADDRESS16;
 328 
 329 typedef struct acpi_resource_address32
 330 {
 331     ACPI_RESOURCE_ADDRESS_COMMON
 332     UINT32                          Granularity;
 333     UINT32                          Minimum;
 334     UINT32                          Maximum;
 335     UINT32                          TranslationOffset;
 336     UINT32                          AddressLength;
 337     ACPI_RESOURCE_SOURCE            ResourceSource;
 338 
 339 } ACPI_RESOURCE_ADDRESS32;
 340 
 341 typedef struct acpi_resource_address64
 342 {
 343     ACPI_RESOURCE_ADDRESS_COMMON
 344     UINT64                          Granularity;
 345     UINT64                          Minimum;
 346     UINT64                          Maximum;
 347     UINT64                          TranslationOffset;
 348     UINT64                          AddressLength;
 349     ACPI_RESOURCE_SOURCE            ResourceSource;
 350 
 351 } ACPI_RESOURCE_ADDRESS64;
 352 
 353 typedef struct acpi_resource_extended_address64
 354 {
 355     ACPI_RESOURCE_ADDRESS_COMMON
 356     UINT8                           RevisionID;
 357     UINT64                          Granularity;
 358     UINT64                          Minimum;
 359     UINT64                          Maximum;
 360     UINT64                          TranslationOffset;
 361     UINT64                          AddressLength;
 362     UINT64                          TypeSpecific;
 363 
 364 } ACPI_RESOURCE_EXTENDED_ADDRESS64;
 365 
 366 typedef struct acpi_resource_extended_irq
 367 {
 368     UINT8                           ProducerConsumer;
 369     UINT8                           Triggering;
 370     UINT8                           Polarity;
 371     UINT8                           Sharable;
 372     UINT8                           InterruptCount;
 373     ACPI_RESOURCE_SOURCE            ResourceSource;
 374     UINT32                          Interrupts[1];
 375 
 376 } ACPI_RESOURCE_EXTENDED_IRQ;
 377 
 378 typedef struct acpi_resource_generic_register
 379 {
 380     UINT8                           SpaceId;
 381     UINT8                           BitWidth;
 382     UINT8                           BitOffset;
 383     UINT8                           AccessSize;
 384     UINT64                          Address;
 385 
 386 } ACPI_RESOURCE_GENERIC_REGISTER;
 387 
 388 
 389 /* ACPI_RESOURCE_TYPEs */
 390 
 391 #define ACPI_RESOURCE_TYPE_IRQ                  0
 392 #define ACPI_RESOURCE_TYPE_DMA                  1
 393 #define ACPI_RESOURCE_TYPE_START_DEPENDENT      2
 394 #define ACPI_RESOURCE_TYPE_END_DEPENDENT        3
 395 #define ACPI_RESOURCE_TYPE_IO                   4
 396 #define ACPI_RESOURCE_TYPE_FIXED_IO             5
 397 #define ACPI_RESOURCE_TYPE_VENDOR               6
 398 #define ACPI_RESOURCE_TYPE_END_TAG              7
 399 #define ACPI_RESOURCE_TYPE_MEMORY24             8
 400 #define ACPI_RESOURCE_TYPE_MEMORY32             9
 401 #define ACPI_RESOURCE_TYPE_FIXED_MEMORY32       10
 402 #define ACPI_RESOURCE_TYPE_ADDRESS16            11
 403 #define ACPI_RESOURCE_TYPE_ADDRESS32            12
 404 #define ACPI_RESOURCE_TYPE_ADDRESS64            13
 405 #define ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64   14  /* ACPI 3.0 */
 406 #define ACPI_RESOURCE_TYPE_EXTENDED_IRQ         15
 407 #define ACPI_RESOURCE_TYPE_GENERIC_REGISTER     16
 408 #define ACPI_RESOURCE_TYPE_MAX                  16
 409 
 410 /* Master union for resource descriptors */
 411 
 412 typedef union acpi_resource_data
 413 {
 414     ACPI_RESOURCE_IRQ                       Irq;
 415     ACPI_RESOURCE_DMA                       Dma;
 416     ACPI_RESOURCE_START_DEPENDENT           StartDpf;
 417     ACPI_RESOURCE_IO                        Io;
 418     ACPI_RESOURCE_FIXED_IO                  FixedIo;
 419     ACPI_RESOURCE_VENDOR                    Vendor;
 420     ACPI_RESOURCE_VENDOR_TYPED              VendorTyped;
 421     ACPI_RESOURCE_END_TAG                   EndTag;
 422     ACPI_RESOURCE_MEMORY24                  Memory24;
 423     ACPI_RESOURCE_MEMORY32                  Memory32;
 424     ACPI_RESOURCE_FIXED_MEMORY32            FixedMemory32;
 425     ACPI_RESOURCE_ADDRESS16                 Address16;
 426     ACPI_RESOURCE_ADDRESS32                 Address32;
 427     ACPI_RESOURCE_ADDRESS64                 Address64;
 428     ACPI_RESOURCE_EXTENDED_ADDRESS64        ExtAddress64;
 429     ACPI_RESOURCE_EXTENDED_IRQ              ExtendedIrq;
 430     ACPI_RESOURCE_GENERIC_REGISTER          GenericReg;
 431 
 432     /* Common fields */
 433 
 434     ACPI_RESOURCE_ADDRESS                   Address;        /* Common 16/32/64 address fields */
 435 
 436 } ACPI_RESOURCE_DATA;
 437 
 438 
 439 /* Common resource header */
 440 
 441 typedef struct acpi_resource
 442 {
 443     UINT32                          Type;
 444     UINT32                          Length;
 445     ACPI_RESOURCE_DATA              Data;
 446 
 447 } ACPI_RESOURCE;
 448 
 449 /* restore default alignment */
 450 
 451 #pragma pack()
 452 
 453 
 454 #define ACPI_RS_SIZE_NO_DATA                8       /* Id + Length fields */
 455 #define ACPI_RS_SIZE_MIN                    (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (12)
 456 #define ACPI_RS_SIZE(Type)                  (UINT32) (ACPI_RS_SIZE_NO_DATA + sizeof (Type))
 457 
 458 #define ACPI_NEXT_RESOURCE(Res)             (ACPI_RESOURCE *)((UINT8 *) Res + Res->Length)
 459 
 460 
 461 typedef struct acpi_pci_routing_table
 462 {
 463     UINT32                          Length;
 464     UINT32                          Pin;
 465     UINT64                          Address;        /* here for 64-bit alignment */
 466     UINT32                          SourceIndex;
 467     char                            Source[4];      /* pad to 64 bits so sizeof() works in all cases */
 468 
 469 } ACPI_PCI_ROUTING_TABLE;
 470 
 471 #endif /* __ACRESTYP_H__ */
 472