Home | History | Annotate | Line # | Download | only in include
      1 /******************************************************************************
      2  *
      3  * Name: actypes.h - Common data types for the entire ACPI subsystem
      4  *
      5  *****************************************************************************/
      6 
      7 /*
      8  * Copyright (C) 2000 - 2025, 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 MERCHANTABILITY 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 __ACTYPES_H__
     45 #define __ACTYPES_H__
     46 
     47 /* acpisrc:StructDefs -- for acpisrc conversion */
     48 
     49 /*
     50  * ACPI_MACHINE_WIDTH must be specified in an OS- or compiler-dependent
     51  * header and must be either 32 or 64. 16-bit ACPICA is no longer
     52  * supported, as of 12/2006.
     53  */
     54 #ifndef ACPI_MACHINE_WIDTH
     55 #error ACPI_MACHINE_WIDTH not defined
     56 #endif
     57 
     58 /*
     59  * Data type ranges
     60  * Note: These macros are designed to be compiler independent as well as
     61  * working around problems that some 32-bit compilers have with 64-bit
     62  * constants.
     63  */
     64 #define ACPI_UINT8_MAX                  (UINT8) (~((UINT8)  0)) /* 0xFF               */
     65 #define ACPI_UINT16_MAX                 (UINT16)(~((UINT16) 0)) /* 0xFFFF             */
     66 #define ACPI_UINT32_MAX                 (UINT32)(~((UINT32) 0)) /* 0xFFFFFFFF         */
     67 #define ACPI_UINT64_MAX                 (UINT64)(~((UINT64) 0)) /* 0xFFFFFFFFFFFFFFFF */
     68 #define ACPI_ASCII_MAX                  0x7F
     69 
     70 
     71 /*
     72  * Architecture-specific ACPICA Subsystem Data Types
     73  *
     74  * The goal of these types is to provide source code portability across
     75  * 16-bit, 32-bit, and 64-bit targets.
     76  *
     77  * 1) The following types are of fixed size for all targets (16/32/64):
     78  *
     79  * BOOLEAN      Logical boolean
     80  *
     81  * UINT8        8-bit  (1 byte) unsigned value
     82  * UINT16       16-bit (2 byte) unsigned value
     83  * UINT32       32-bit (4 byte) unsigned value
     84  * UINT64       64-bit (8 byte) unsigned value
     85  *
     86  * INT16        16-bit (2 byte) signed value
     87  * INT32        32-bit (4 byte) signed value
     88  * INT64        64-bit (8 byte) signed value
     89  *
     90  * COMPILER_DEPENDENT_UINT64/INT64 - These types are defined in the
     91  * compiler-dependent header(s) and were introduced because there is no
     92  * common 64-bit integer type across the various compilation models, as
     93  * shown in the table below.
     94  *
     95  * Datatype  LP64 ILP64 LLP64 ILP32 LP32 16bit
     96  * char      8    8     8     8     8    8
     97  * short     16   16    16    16    16   16
     98  * _int32         32
     99  * int       32   64    32    32    16   16
    100  * long      64   64    32    32    32   32
    101  * long long            64    64
    102  * pointer   64   64    64    32    32   32
    103  *
    104  * Note: ILP64 and LP32 are currently not supported.
    105  *
    106  *
    107  * 2) These types represent the native word size of the target mode of the
    108  * processor, and may be 16-bit, 32-bit, or 64-bit as required. They are
    109  * usually used for memory allocation, efficient loop counters, and array
    110  * indexes. The types are similar to the size_t type in the C library and
    111  * are required because there is no C type that consistently represents the
    112  * native data width. ACPI_SIZE is needed because there is no guarantee
    113  * that a kernel-level C library is present.
    114  *
    115  * ACPI_SIZE        16/32/64-bit unsigned value
    116  * ACPI_NATIVE_INT  16/32/64-bit signed value
    117  */
    118 
    119 /*******************************************************************************
    120  *
    121  * Common types for all compilers, all targets
    122  *
    123  ******************************************************************************/
    124 
    125 #ifndef ACPI_USE_SYSTEM_INTTYPES
    126 
    127 typedef unsigned char                   BOOLEAN;
    128 typedef unsigned char                   UINT8;
    129 typedef unsigned short                  UINT16;
    130 typedef short                           INT16;
    131 typedef COMPILER_DEPENDENT_UINT64       UINT64;
    132 typedef COMPILER_DEPENDENT_INT64        INT64;
    133 
    134 #endif /* ACPI_USE_SYSTEM_INTTYPES */
    135 
    136 /*
    137  * Value returned by AcpiOsGetThreadId. There is no standard "thread_id"
    138  * across operating systems or even the various UNIX systems. Since ACPICA
    139  * only needs the thread ID as a unique thread identifier, we use a UINT64
    140  * as the only common data type - it will accommodate any type of pointer or
    141  * any type of integer. It is up to the host-dependent OSL to cast the
    142  * native thread ID type to a UINT64 (in AcpiOsGetThreadId).
    143  */
    144 #define ACPI_THREAD_ID                  UINT64
    145 
    146 
    147 /*******************************************************************************
    148  *
    149  * Types specific to 64-bit targets
    150  *
    151  ******************************************************************************/
    152 
    153 #if ACPI_MACHINE_WIDTH == 64
    154 
    155 #ifndef ACPI_USE_SYSTEM_INTTYPES
    156 
    157 typedef unsigned int                    UINT32;
    158 typedef int                             INT32;
    159 
    160 #endif /* ACPI_USE_SYSTEM_INTTYPES */
    161 
    162 
    163 typedef INT64                           ACPI_NATIVE_INT;
    164 typedef UINT64                          ACPI_SIZE;
    165 typedef UINT64                          ACPI_IO_ADDRESS;
    166 typedef UINT64                          ACPI_PHYSICAL_ADDRESS;
    167 
    168 #define ACPI_MAX_PTR                    ACPI_UINT64_MAX
    169 #define ACPI_SIZE_MAX                   ACPI_UINT64_MAX
    170 #define ACPI_USE_NATIVE_DIVIDE          /* Has native 64-bit integer support */
    171 #define ACPI_USE_NATIVE_MATH64          /* Has native 64-bit integer support */
    172 
    173 /*
    174  * In the case of the Itanium Processor Family (IPF), the hardware does not
    175  * support misaligned memory transfers. Set the MISALIGNMENT_NOT_SUPPORTED
    176  * flag to indicate that special precautions must be taken to avoid alignment
    177  * faults. (IA64 or ia64 is currently used by existing compilers to indicate
    178  * IPF.)
    179  *
    180  * Note: EM64T and other X86-64 processors support misaligned transfers,
    181  * so there is no need to define this flag.
    182  */
    183 #if defined (__IA64__) || defined (__ia64__)
    184 #define ACPI_MISALIGNMENT_NOT_SUPPORTED
    185 #endif
    186 
    187 
    188 /*******************************************************************************
    189  *
    190  * Types specific to 32-bit targets
    191  *
    192  ******************************************************************************/
    193 
    194 #elif ACPI_MACHINE_WIDTH == 32
    195 
    196 #ifndef ACPI_USE_SYSTEM_INTTYPES
    197 
    198 typedef unsigned int                    UINT32;
    199 typedef int                             INT32;
    200 
    201 #endif /* ACPI_USE_SYSTEM_INTTYPES */
    202 
    203 
    204 typedef INT32                           ACPI_NATIVE_INT;
    205 typedef UINT32                          ACPI_SIZE;
    206 
    207 #ifdef ACPI_32BIT_PHYSICAL_ADDRESS
    208 
    209 /*
    210  * OSPMs can define this to shrink the size of the structures for 32-bit
    211  * none PAE environment. ASL compiler may always define this to generate
    212  * 32-bit OSPM compliant tables.
    213  */
    214 typedef UINT32                          ACPI_IO_ADDRESS;
    215 typedef UINT32                          ACPI_PHYSICAL_ADDRESS;
    216 
    217 #else /* ACPI_32BIT_PHYSICAL_ADDRESS */
    218 
    219 /*
    220  * It is reported that, after some calculations, the physical addresses can
    221  * wrap over the 32-bit boundary on 32-bit PAE environment.
    222  * https://bugzilla.kernel.org/show_bug.cgi?id=87971
    223  */
    224 typedef UINT64                          ACPI_IO_ADDRESS;
    225 typedef UINT64                          ACPI_PHYSICAL_ADDRESS;
    226 
    227 #endif /* ACPI_32BIT_PHYSICAL_ADDRESS */
    228 
    229 #define ACPI_MAX_PTR                    ACPI_UINT32_MAX
    230 #define ACPI_SIZE_MAX                   ACPI_UINT32_MAX
    231 
    232 #else
    233 
    234 /* ACPI_MACHINE_WIDTH must be either 64 or 32 */
    235 
    236 #error unknown ACPI_MACHINE_WIDTH
    237 #endif
    238 
    239 
    240 /*******************************************************************************
    241  *
    242  * OS-dependent types
    243  *
    244  * If the defaults below are not appropriate for the host system, they can
    245  * be defined in the OS-specific header, and this will take precedence.
    246  *
    247  ******************************************************************************/
    248 
    249 /* Flags for AcpiOsAcquireLock/AcpiOsReleaseLock */
    250 
    251 #ifndef ACPI_CPU_FLAGS
    252 #define ACPI_CPU_FLAGS                  ACPI_SIZE
    253 #endif
    254 
    255 /* Object returned from AcpiOsCreateCache */
    256 
    257 #ifndef ACPI_CACHE_T
    258 #ifdef ACPI_USE_LOCAL_CACHE
    259 #define ACPI_CACHE_T                    ACPI_MEMORY_LIST
    260 #else
    261 #define ACPI_CACHE_T                    void *
    262 #endif
    263 #endif
    264 
    265 /*
    266  * Synchronization objects - Mutexes, Semaphores, and SpinLocks
    267  */
    268 #if (ACPI_MUTEX_TYPE == ACPI_BINARY_SEMAPHORE)
    269 /*
    270  * These macros are used if the host OS does not support a mutex object.
    271  * Map the OSL Mutex interfaces to binary semaphores.
    272  */
    273 #define ACPI_MUTEX                      ACPI_SEMAPHORE
    274 #define AcpiOsCreateMutex(OutHandle)    AcpiOsCreateSemaphore (1, 1, OutHandle)
    275 #define AcpiOsDeleteMutex(Handle)       (void) AcpiOsDeleteSemaphore (Handle)
    276 #define AcpiOsAcquireMutex(Handle,Time) AcpiOsWaitSemaphore (Handle, 1, Time)
    277 #define AcpiOsReleaseMutex(Handle)      (void) AcpiOsSignalSemaphore (Handle, 1)
    278 #endif
    279 
    280 /* Configurable types for synchronization objects */
    281 
    282 #ifndef ACPI_SPINLOCK
    283 #define ACPI_SPINLOCK                   void *
    284 #endif
    285 
    286 #ifndef ACPI_SEMAPHORE
    287 #define ACPI_SEMAPHORE                  void *
    288 #endif
    289 
    290 #ifndef ACPI_MUTEX
    291 #define ACPI_MUTEX                      void *
    292 #endif
    293 
    294 
    295 /*******************************************************************************
    296  *
    297  * Compiler-dependent types
    298  *
    299  * If the defaults below are not appropriate for the host compiler, they can
    300  * be defined in the compiler-specific header, and this will take precedence.
    301  *
    302  ******************************************************************************/
    303 
    304 /* Use C99 uintptr_t for pointer casting if available, "void *" otherwise */
    305 
    306 #ifndef ACPI_UINTPTR_T
    307 #define ACPI_UINTPTR_T                  void *
    308 #endif
    309 
    310 /*
    311  * ACPI_PRINTF_LIKE is used to tag functions as "printf-like" because
    312  * some compilers can catch printf format string problems
    313  */
    314 #ifndef ACPI_PRINTF_LIKE
    315 #define ACPI_PRINTF_LIKE(c)
    316 #endif
    317 
    318 /*
    319  * Some compilers complain about unused variables. Sometimes we don't want
    320  * to use all the variables (for example, _AcpiModuleName). This allows us
    321  * to tell the compiler in a per-variable manner that a variable
    322  * is unused
    323  */
    324 #ifndef ACPI_UNUSED_VAR
    325 #define ACPI_UNUSED_VAR
    326 #endif
    327 
    328 /*
    329  * All ACPICA external functions that are available to the rest of the
    330  * kernel are tagged with these macros which can be defined as appropriate
    331  * for the host.
    332  *
    333  * Notes:
    334  * ACPI_EXPORT_SYMBOL_INIT is used for initialization and termination
    335  * interfaces that may need special processing.
    336  * ACPI_EXPORT_SYMBOL is used for all other public external functions.
    337  */
    338 #ifndef ACPI_EXPORT_SYMBOL_INIT
    339 #define ACPI_EXPORT_SYMBOL_INIT(Symbol)
    340 #endif
    341 
    342 #ifndef ACPI_EXPORT_SYMBOL
    343 #define ACPI_EXPORT_SYMBOL(Symbol)
    344 #endif
    345 
    346 /*
    347  * Compiler/Clibrary-dependent debug initialization. Used for ACPICA
    348  * utilities only.
    349  */
    350 #ifndef ACPI_DEBUG_INITIALIZE
    351 #define ACPI_DEBUG_INITIALIZE()
    352 #endif
    353 
    354 
    355 /*******************************************************************************
    356  *
    357  * Configuration
    358  *
    359  ******************************************************************************/
    360 
    361 #ifdef ACPI_NO_MEM_ALLOCATIONS
    362 
    363 #define ACPI_ALLOCATE(a)                NULL
    364 #define ACPI_ALLOCATE_ZEROED(a)         NULL
    365 #define ACPI_FREE(a)
    366 #define ACPI_MEM_TRACKING(a)
    367 
    368 #else /* ACPI_NO_MEM_ALLOCATIONS */
    369 
    370 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
    371 /*
    372  * Memory allocation tracking (used by AcpiExec to detect memory leaks)
    373  */
    374 #define ACPI_MEM_PARAMETERS             _COMPONENT, _AcpiModuleName, __LINE__
    375 #define ACPI_ALLOCATE(a)                AcpiUtAllocateAndTrack ((ACPI_SIZE) (a), ACPI_MEM_PARAMETERS)
    376 #define ACPI_ALLOCATE_ZEROED(a)         AcpiUtAllocateZeroedAndTrack ((ACPI_SIZE) (a), ACPI_MEM_PARAMETERS)
    377 #define ACPI_FREE(a)                    AcpiUtFreeAndTrack (a, ACPI_MEM_PARAMETERS)
    378 #define ACPI_MEM_TRACKING(a)            a
    379 
    380 #else
    381 /*
    382  * Normal memory allocation directly via the OS services layer
    383  */
    384 #define ACPI_ALLOCATE(a)                AcpiOsAllocate ((ACPI_SIZE) (a))
    385 #define ACPI_ALLOCATE_ZEROED(a)         AcpiOsAllocateZeroed ((ACPI_SIZE) (a))
    386 #define ACPI_FREE(a)                    AcpiOsFree (a)
    387 #define ACPI_MEM_TRACKING(a)
    388 
    389 #endif /* ACPI_DBG_TRACK_ALLOCATIONS */
    390 
    391 #endif /* ACPI_NO_MEM_ALLOCATIONS */
    392 
    393 
    394 /******************************************************************************
    395  *
    396  * ACPI Specification constants (Do not change unless the specification
    397  * changes)
    398  *
    399  *****************************************************************************/
    400 
    401 /* Number of distinct FADT-based GPE register blocks (GPE0 and GPE1) */
    402 
    403 #define ACPI_MAX_GPE_BLOCKS             2
    404 
    405 /* Default ACPI register widths */
    406 
    407 #define ACPI_GPE_REGISTER_WIDTH         8
    408 #define ACPI_PM1_REGISTER_WIDTH         16
    409 #define ACPI_PM2_REGISTER_WIDTH         8
    410 #define ACPI_PM_TIMER_WIDTH             32
    411 #define ACPI_RESET_REGISTER_WIDTH       8
    412 
    413 /* Names within the namespace are 4 bytes long */
    414 
    415 #define ACPI_NAMESEG_SIZE               4           /* Fixed by ACPI spec */
    416 #define ACPI_PATH_SEGMENT_LENGTH        5           /* 4 chars for name + 1 char for separator */
    417 #define ACPI_PATH_SEPARATOR             '.'
    418 
    419 /* Sizes for ACPI table headers */
    420 
    421 #define ACPI_OEM_ID_SIZE                6
    422 #define ACPI_OEM_TABLE_ID_SIZE          8
    423 
    424 /* ACPI/PNP hardware IDs */
    425 
    426 #define PCI_ROOT_HID_STRING             "PNP0A03"
    427 #define PCI_EXPRESS_ROOT_HID_STRING     "PNP0A08"
    428 
    429 /* PM Timer ticks per second (HZ) */
    430 
    431 #define ACPI_PM_TIMER_FREQUENCY         3579545
    432 
    433 
    434 /*******************************************************************************
    435  *
    436  * Independent types
    437  *
    438  ******************************************************************************/
    439 
    440 /* Logical defines and NULL */
    441 
    442 #ifdef FALSE
    443 #undef FALSE
    444 #endif
    445 #define FALSE                           (1 == 0)
    446 
    447 #ifdef TRUE
    448 #undef TRUE
    449 #endif
    450 #define TRUE                            (1 == 1)
    451 
    452 #ifndef NULL
    453 #define NULL                            (void *) 0
    454 #endif
    455 
    456 
    457 /*
    458  * Miscellaneous types
    459  */
    460 typedef UINT32                          ACPI_STATUS;    /* All ACPI Exceptions */
    461 typedef UINT32                          ACPI_NAME;      /* 4-byte ACPI name */
    462 typedef char *                          ACPI_STRING;    /* Null terminated ASCII string */
    463 typedef const char *                    ACPI_CONST_STRING;    /* Null terminated ASCII string */
    464 typedef void *                          ACPI_HANDLE;    /* Actually a ptr to a NS Node */
    465 
    466 
    467 /* Time constants for timer calculations */
    468 
    469 #define ACPI_MSEC_PER_SEC               1000L
    470 
    471 #define ACPI_USEC_PER_MSEC              1000L
    472 #define ACPI_USEC_PER_SEC               1000000L
    473 
    474 #define ACPI_100NSEC_PER_USEC           10L
    475 #define ACPI_100NSEC_PER_MSEC           10000L
    476 #define ACPI_100NSEC_PER_SEC            10000000L
    477 
    478 #define ACPI_NSEC_PER_USEC              1000L
    479 #define ACPI_NSEC_PER_MSEC              1000000L
    480 #define ACPI_NSEC_PER_SEC               1000000000L
    481 
    482 #define ACPI_TIME_AFTER(a, b)           ((INT64)((b) - (a)) < 0)
    483 
    484 
    485 /* Owner IDs are used to track namespace nodes for selective deletion */
    486 
    487 typedef UINT16                          ACPI_OWNER_ID;
    488 #define ACPI_OWNER_ID_MAX               0xFFF   /* 4095 possible owner IDs */
    489 
    490 
    491 #define ACPI_INTEGER_BIT_SIZE           64
    492 #define ACPI_MAX_DECIMAL_DIGITS         20  /* 2^64 = 18,446,744,073,709,551,616 */
    493 #define ACPI_MAX64_DECIMAL_DIGITS       20
    494 #define ACPI_MAX32_DECIMAL_DIGITS       10
    495 #define ACPI_MAX16_DECIMAL_DIGITS        5
    496 #define ACPI_MAX8_DECIMAL_DIGITS         3
    497 
    498 /*
    499  * Constants with special meanings
    500  */
    501 #define ACPI_ROOT_OBJECT                ((ACPI_HANDLE) ACPI_TO_POINTER (ACPI_MAX_PTR))
    502 #define ACPI_WAIT_FOREVER               0xFFFF  /* UINT16, as per ACPI spec */
    503 #define ACPI_DO_NOT_WAIT                0
    504 
    505 /*
    506  * Obsolete: Acpi integer width. In ACPI version 1 (1996), integers are
    507  * 32 bits. In ACPI version 2 (2000) and later, integers are max 64 bits.
    508  * Note that this pertains to the ACPI integer type only, not to other
    509  * integers used in the implementation of the ACPICA subsystem.
    510  *
    511  * 01/2010: This type is obsolete and has been removed from the entire ACPICA
    512  * code base. It remains here for compatibility with device drivers that use
    513  * the type. However, it will be removed in the future.
    514  */
    515 typedef UINT64                          ACPI_INTEGER;
    516 #define ACPI_INTEGER_MAX                ACPI_UINT64_MAX
    517 
    518 
    519 /*******************************************************************************
    520  *
    521  * Commonly used macros
    522  *
    523  ******************************************************************************/
    524 
    525 /* Data manipulation */
    526 
    527 #define ACPI_LOBYTE(Integer)            ((UINT8)   (UINT16)(Integer))
    528 #define ACPI_HIBYTE(Integer)            ((UINT8) (((UINT16)(Integer)) >> 8))
    529 #define ACPI_LOWORD(Integer)            ((UINT16)  (UINT32)(Integer))
    530 #define ACPI_HIWORD(Integer)            ((UINT16)(((UINT32)(Integer)) >> 16))
    531 #define ACPI_LODWORD(Integer64)         ((UINT32)  (UINT64)(Integer64))
    532 #define ACPI_HIDWORD(Integer64)         ((UINT32)(((UINT64)(Integer64)) >> 32))
    533 
    534 #define ACPI_SET_BIT(target,bit)        ((target) |= (bit))
    535 #define ACPI_CLEAR_BIT(target,bit)      ((target) &= ~(bit))
    536 #define ACPI_MIN(a,b)                   (((a)<(b))?(a):(b))
    537 #define ACPI_MAX(a,b)                   (((a)>(b))?(a):(b))
    538 
    539 /* Size calculation */
    540 
    541 #define ACPI_ARRAY_LENGTH(x)            (sizeof(x) / sizeof((x)[0]))
    542 
    543 /* Use a union to align  string s to type t */
    544 #define ACPI_ALIGNED_STR_UNION(t, s)	\
    545     (&((const union { char _s[sizeof(t)]; t _t; }){ s }._t))
    546 
    547 /* Pointer manipulation */
    548 
    549 #define ACPI_CAST_PTR(t, p)             ((t *) (ACPI_UINTPTR_T) (p))
    550 #define ACPI_CAST_INDIRECT_PTR(t, p)    ((t **) (ACPI_UINTPTR_T) (p))
    551 #define ACPI_ADD_PTR(t, a, b)           ACPI_CAST_PTR (t, (ACPI_CAST_PTR (UINT8, (a)) + (ACPI_SIZE)(b)))
    552 #define ACPI_SUB_PTR(t, a, b)           ACPI_CAST_PTR (t, (ACPI_CAST_PTR (UINT8, (a)) - (ACPI_SIZE)(b)))
    553 #define ACPI_PTR_DIFF(a, b)             ((ACPI_SIZE) (ACPI_CAST_PTR (UINT8, (a)) - ACPI_CAST_PTR (UINT8, (b))))
    554 
    555 /* Pointer/Integer type conversions */
    556 
    557 #define ACPI_TO_POINTER(i)              ACPI_CAST_PTR (void, (ACPI_SIZE) (i))
    558 #ifndef ACPI_TO_INTEGER
    559 #define ACPI_TO_INTEGER(p)              ACPI_PTR_DIFF (p, (void *) 0)
    560 #endif
    561 #ifndef ACPI_OFFSET
    562 #define ACPI_OFFSET(d, f)               ACPI_PTR_DIFF (&(((d *) 0)->f), (void *) 0)
    563 #endif
    564 #define ACPI_PTR_TO_PHYSADDR(i)         ACPI_TO_INTEGER(i)
    565 
    566 /* Optimizations for 4-character (32-bit) ACPI_NAME manipulation */
    567 
    568 #ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED
    569 #define ACPI_COMPARE_NAMESEG(a,b)       (*ACPI_CAST_PTR (UINT32, (a)) == *ACPI_CAST_PTR (UINT32, (b)))
    570 #define ACPI_COPY_NAMESEG(dest,src)     (*ACPI_CAST_PTR (UINT32, (dest)) = *ACPI_CAST_PTR (UINT32, (src)))
    571 #else
    572 #define ACPI_COMPARE_NAMESEG(a,b)       (!strncmp (ACPI_CAST_PTR (char, (a)), ACPI_CAST_PTR (char, (b)), ACPI_NAMESEG_SIZE))
    573 #define ACPI_COPY_NAMESEG(dest,src)     (memcpy (ACPI_CAST_PTR (char, (dest)), ACPI_CAST_PTR (char, (src)), ACPI_NAMESEG_SIZE))
    574 #endif
    575 
    576 /* Support for the special RSDP signature (8 characters) */
    577 
    578 #define ACPI_VALIDATE_RSDP_SIG(a)       (!strncmp (ACPI_CAST_PTR (char, (a)), ACPI_SIG_RSDP, (sizeof(a) < 8) ? ACPI_NAMESEG_SIZE : 8))
    579 #define ACPI_MAKE_RSDP_SIG(dest)        (memcpy (ACPI_CAST_PTR (char, (dest)), ACPI_SIG_RSDP, 8))
    580 
    581 /* Support for OEMx signature (x can be any character) */
    582 #define ACPI_IS_OEM_SIG(a)        (!strncmp (ACPI_CAST_PTR (char, (a)), ACPI_OEM_NAME, 3) &&\
    583                                       strnlen (a, ACPI_NAMESEG_SIZE) == ACPI_NAMESEG_SIZE)
    584 
    585 /*
    586  * Algorithm to obtain access bit or byte width.
    587  * Can be used with AccessSize field of ACPI_GENERIC_ADDRESS and
    588  * ACPI_RESOURCE_GENERIC_REGISTER.
    589  */
    590 #define ACPI_ACCESS_BIT_SHIFT           2
    591 #define ACPI_ACCESS_BYTE_SHIFT          -1
    592 #define ACPI_ACCESS_BIT_MAX             (31 - ACPI_ACCESS_BIT_SHIFT)
    593 #define ACPI_ACCESS_BYTE_MAX            (31 - ACPI_ACCESS_BYTE_SHIFT)
    594 #define ACPI_ACCESS_BIT_DEFAULT         (8 - ACPI_ACCESS_BIT_SHIFT)
    595 #define ACPI_ACCESS_BYTE_DEFAULT        (8 - ACPI_ACCESS_BYTE_SHIFT)
    596 #define ACPI_ACCESS_BIT_WIDTH(size)     (1 << ((size) + ACPI_ACCESS_BIT_SHIFT))
    597 #define ACPI_ACCESS_BYTE_WIDTH(size)    (1 << ((size) + ACPI_ACCESS_BYTE_SHIFT))
    598 
    599 /*******************************************************************************
    600  *
    601  * Miscellaneous constants
    602  *
    603  ******************************************************************************/
    604 
    605 /*
    606  * Initialization sequence options
    607  */
    608 #define ACPI_FULL_INITIALIZATION        0x0000
    609 #define ACPI_NO_FACS_INIT               0x0001
    610 #define ACPI_NO_ACPI_ENABLE             0x0002
    611 #define ACPI_NO_HARDWARE_INIT           0x0004
    612 #define ACPI_NO_EVENT_INIT              0x0008
    613 #define ACPI_NO_HANDLER_INIT            0x0010
    614 #define ACPI_NO_OBJECT_INIT             0x0020
    615 #define ACPI_NO_DEVICE_INIT             0x0040
    616 #define ACPI_NO_ADDRESS_SPACE_INIT      0x0080
    617 
    618 /*
    619  * Initialization state
    620  */
    621 #define ACPI_SUBSYSTEM_INITIALIZE       0x01
    622 #define ACPI_INITIALIZED_OK             0x02
    623 
    624 /*
    625  * Power state values
    626  */
    627 #define ACPI_STATE_UNKNOWN              (UINT8) 0xFF
    628 
    629 #define ACPI_STATE_S0                   (UINT8) 0
    630 #define ACPI_STATE_S1                   (UINT8) 1
    631 #define ACPI_STATE_S2                   (UINT8) 2
    632 #define ACPI_STATE_S3                   (UINT8) 3
    633 #define ACPI_STATE_S4                   (UINT8) 4
    634 #define ACPI_STATE_S5                   (UINT8) 5
    635 #define ACPI_S_STATES_MAX               ACPI_STATE_S5
    636 #define ACPI_S_STATE_COUNT              6
    637 
    638 #define ACPI_STATE_D0                   (UINT8) 0
    639 #define ACPI_STATE_D1                   (UINT8) 1
    640 #define ACPI_STATE_D2                   (UINT8) 2
    641 #define ACPI_STATE_D3_HOT               (UINT8) 3
    642 #define ACPI_STATE_D3_COLD              (UINT8) 4
    643 #define ACPI_STATE_D3                   ACPI_STATE_D3_COLD
    644 #define ACPI_D_STATES_MAX               ACPI_STATE_D3_COLD
    645 #define ACPI_D_STATE_COUNT              5
    646 
    647 #define ACPI_STATE_C0                   (UINT8) 0
    648 #define ACPI_STATE_C1                   (UINT8) 1
    649 #define ACPI_STATE_C2                   (UINT8) 2
    650 #define ACPI_STATE_C3                   (UINT8) 3
    651 #define ACPI_C_STATES_MAX               ACPI_STATE_C3
    652 #define ACPI_C_STATE_COUNT              4
    653 
    654 /*
    655  * Sleep type invalid value
    656  */
    657 #define ACPI_SLEEP_TYPE_MAX             0x7
    658 #define ACPI_SLEEP_TYPE_INVALID         0xFF
    659 
    660 /*
    661  * Standard notify values
    662  */
    663 #define ACPI_NOTIFY_BUS_CHECK           (UINT8) 0x00
    664 #define ACPI_NOTIFY_DEVICE_CHECK        (UINT8) 0x01
    665 #define ACPI_NOTIFY_DEVICE_WAKE         (UINT8) 0x02
    666 #define ACPI_NOTIFY_EJECT_REQUEST       (UINT8) 0x03
    667 #define ACPI_NOTIFY_DEVICE_CHECK_LIGHT  (UINT8) 0x04
    668 #define ACPI_NOTIFY_FREQUENCY_MISMATCH  (UINT8) 0x05
    669 #define ACPI_NOTIFY_BUS_MODE_MISMATCH   (UINT8) 0x06
    670 #define ACPI_NOTIFY_POWER_FAULT         (UINT8) 0x07
    671 #define ACPI_NOTIFY_CAPABILITIES_CHECK  (UINT8) 0x08
    672 #define ACPI_NOTIFY_DEVICE_PLD_CHECK    (UINT8) 0x09
    673 #define ACPI_NOTIFY_RESERVED            (UINT8) 0x0A
    674 #define ACPI_NOTIFY_LOCALITY_UPDATE     (UINT8) 0x0B
    675 #define ACPI_NOTIFY_SHUTDOWN_REQUEST    (UINT8) 0x0C
    676 #define ACPI_NOTIFY_AFFINITY_UPDATE     (UINT8) 0x0D
    677 #define ACPI_NOTIFY_MEMORY_UPDATE       (UINT8) 0x0E
    678 #define ACPI_NOTIFY_DISCONNECT_RECOVER  (UINT8) 0x0F
    679 
    680 #define ACPI_GENERIC_NOTIFY_MAX         0x0F
    681 #define ACPI_SPECIFIC_NOTIFY_MAX        0x84
    682 
    683 /*
    684  * Types associated with ACPI names and objects. The first group of
    685  * values (up to ACPI_TYPE_EXTERNAL_MAX) correspond to the definition
    686  * of the ACPI ObjectType() operator (See the ACPI Spec). Therefore,
    687  * only add to the first group if the spec changes.
    688  *
    689  * NOTE: Types must be kept in sync with the global AcpiNsProperties
    690  * and AcpiNsTypeNames arrays.
    691  */
    692 typedef UINT32                          ACPI_OBJECT_TYPE;
    693 
    694 #define ACPI_TYPE_ANY                   0x00
    695 #define ACPI_TYPE_INTEGER               0x01  /* Byte/Word/Dword/Zero/One/Ones */
    696 #define ACPI_TYPE_STRING                0x02
    697 #define ACPI_TYPE_BUFFER                0x03
    698 #define ACPI_TYPE_PACKAGE               0x04  /* ByteConst, multiple DataTerm/Constant/SuperName */
    699 #define ACPI_TYPE_FIELD_UNIT            0x05
    700 #define ACPI_TYPE_DEVICE                0x06  /* Name, multiple Node */
    701 #define ACPI_TYPE_EVENT                 0x07
    702 #define ACPI_TYPE_METHOD                0x08  /* Name, ByteConst, multiple Code */
    703 #define ACPI_TYPE_MUTEX                 0x09
    704 #define ACPI_TYPE_REGION                0x0A
    705 #define ACPI_TYPE_POWER                 0x0B  /* Name,ByteConst,WordConst,multi Node */
    706 #define ACPI_TYPE_PROCESSOR             0x0C  /* Name,ByteConst,DWordConst,ByteConst,multi NmO */
    707 #define ACPI_TYPE_THERMAL               0x0D  /* Name, multiple Node */
    708 #define ACPI_TYPE_BUFFER_FIELD          0x0E
    709 #define ACPI_TYPE_DDB_HANDLE            0x0F
    710 #define ACPI_TYPE_DEBUG_OBJECT          0x10
    711 
    712 #define ACPI_TYPE_EXTERNAL_MAX          0x10
    713 #define ACPI_NUM_TYPES                  (ACPI_TYPE_EXTERNAL_MAX + 1)
    714 
    715 /*
    716  * These are object types that do not map directly to the ACPI
    717  * ObjectType() operator. They are used for various internal purposes
    718  * only. If new predefined ACPI_TYPEs are added (via the ACPI
    719  * specification), these internal types must move upwards. (There
    720  * is code that depends on these values being contiguous with the
    721  * external types above.)
    722  */
    723 #define ACPI_TYPE_LOCAL_REGION_FIELD    0x11
    724 #define ACPI_TYPE_LOCAL_BANK_FIELD      0x12
    725 #define ACPI_TYPE_LOCAL_INDEX_FIELD     0x13
    726 #define ACPI_TYPE_LOCAL_REFERENCE       0x14  /* Arg#, Local#, Name, Debug, RefOf, Index */
    727 #define ACPI_TYPE_LOCAL_ALIAS           0x15
    728 #define ACPI_TYPE_LOCAL_METHOD_ALIAS    0x16
    729 #define ACPI_TYPE_LOCAL_NOTIFY          0x17
    730 #define ACPI_TYPE_LOCAL_ADDRESS_HANDLER 0x18
    731 #define ACPI_TYPE_LOCAL_RESOURCE        0x19
    732 #define ACPI_TYPE_LOCAL_RESOURCE_FIELD  0x1A
    733 #define ACPI_TYPE_LOCAL_SCOPE           0x1B  /* 1 Name, multiple ObjectList Nodes */
    734 
    735 #define ACPI_TYPE_NS_NODE_MAX           0x1B  /* Last typecode used within a NS Node */
    736 #define ACPI_TOTAL_TYPES                (ACPI_TYPE_NS_NODE_MAX + 1)
    737 
    738 /*
    739  * These are special object types that never appear in
    740  * a Namespace node, only in an object of ACPI_OPERAND_OBJECT
    741  */
    742 #define ACPI_TYPE_LOCAL_EXTRA           0x1C
    743 #define ACPI_TYPE_LOCAL_DATA            0x1D
    744 
    745 #define ACPI_TYPE_LOCAL_MAX             0x1D
    746 
    747 /* All types above here are invalid */
    748 
    749 #define ACPI_TYPE_INVALID               0x1E
    750 #define ACPI_TYPE_NOT_FOUND             0xFF
    751 
    752 #define ACPI_NUM_NS_TYPES               (ACPI_TYPE_INVALID + 1)
    753 
    754 
    755 /*
    756  * All I/O
    757  */
    758 #define ACPI_READ                       0
    759 #define ACPI_WRITE                      1
    760 #define ACPI_IO_MASK                    1
    761 
    762 /*
    763  * Event Types: Fixed & General Purpose
    764  */
    765 typedef UINT32                          ACPI_EVENT_TYPE;
    766 
    767 /*
    768  * Fixed events
    769  */
    770 #define ACPI_EVENT_PMTIMER              0
    771 #define ACPI_EVENT_GLOBAL               1
    772 #define ACPI_EVENT_POWER_BUTTON         2
    773 #define ACPI_EVENT_SLEEP_BUTTON         3
    774 #define ACPI_EVENT_RTC                  4
    775 #define ACPI_EVENT_MAX                  4
    776 #define ACPI_NUM_FIXED_EVENTS           ACPI_EVENT_MAX + 1
    777 
    778 /*
    779  * Event Status - Per event
    780  * -------------
    781  * The encoding of ACPI_EVENT_STATUS is illustrated below.
    782  * Note that a set bit (1) indicates the property is TRUE
    783  * (e.g. if bit 0 is set then the event is enabled).
    784  * +-------------+-+-+-+-+-+-+
    785  * |   Bits 31:6 |5|4|3|2|1|0|
    786  * +-------------+-+-+-+-+-+-+
    787  *          |     | | | | | |
    788  *          |     | | | | | +- Enabled?
    789  *          |     | | | | +--- Enabled for wake?
    790  *          |     | | | +----- Status bit set?
    791  *          |     | | +------- Enable bit set?
    792  *          |     | +--------- Has a handler?
    793  *          |     +----------- Masked?
    794  *          +----------------- <Reserved>
    795  */
    796 typedef UINT32                          ACPI_EVENT_STATUS;
    797 
    798 #define ACPI_EVENT_FLAG_DISABLED        (ACPI_EVENT_STATUS) 0x00
    799 #define ACPI_EVENT_FLAG_ENABLED         (ACPI_EVENT_STATUS) 0x01
    800 #define ACPI_EVENT_FLAG_WAKE_ENABLED    (ACPI_EVENT_STATUS) 0x02
    801 #define ACPI_EVENT_FLAG_STATUS_SET      (ACPI_EVENT_STATUS) 0x04
    802 #define ACPI_EVENT_FLAG_ENABLE_SET      (ACPI_EVENT_STATUS) 0x08
    803 #define ACPI_EVENT_FLAG_HAS_HANDLER     (ACPI_EVENT_STATUS) 0x10
    804 #define ACPI_EVENT_FLAG_MASKED          (ACPI_EVENT_STATUS) 0x20
    805 #define ACPI_EVENT_FLAG_SET             ACPI_EVENT_FLAG_STATUS_SET
    806 
    807 /* Actions for AcpiSetGpe, AcpiGpeWakeup, AcpiHwLowSetGpe */
    808 
    809 #define ACPI_GPE_ENABLE                 0
    810 #define ACPI_GPE_DISABLE                1
    811 #define ACPI_GPE_CONDITIONAL_ENABLE     2
    812 
    813 /*
    814  * GPE info flags - Per GPE
    815  * +---+-+-+-+---+
    816  * |7:6|5|4|3|2:0|
    817  * +---+-+-+-+---+
    818  *   |  | | |  |
    819  *   |  | | |  +-- Type of dispatch:to method, handler, notify, or none
    820  *   |  | | +----- Interrupt type: edge or level triggered
    821  *   |  | +------- Is a Wake GPE
    822  *   |  +--------- Has been enabled automatically at init time
    823  *   +------------ <Reserved>
    824  */
    825 #define ACPI_GPE_DISPATCH_NONE          (UINT8) 0x00
    826 #define ACPI_GPE_DISPATCH_METHOD        (UINT8) 0x01
    827 #define ACPI_GPE_DISPATCH_HANDLER       (UINT8) 0x02
    828 #define ACPI_GPE_DISPATCH_NOTIFY        (UINT8) 0x03
    829 #define ACPI_GPE_DISPATCH_RAW_HANDLER   (UINT8) 0x04
    830 #define ACPI_GPE_DISPATCH_MASK          (UINT8) 0x07
    831 #define ACPI_GPE_DISPATCH_TYPE(flags)   ((UINT8) ((flags) & ACPI_GPE_DISPATCH_MASK))
    832 
    833 #define ACPI_GPE_LEVEL_TRIGGERED        (UINT8) 0x08
    834 #define ACPI_GPE_EDGE_TRIGGERED         (UINT8) 0x00
    835 #define ACPI_GPE_XRUPT_TYPE_MASK        (UINT8) 0x08
    836 
    837 #define ACPI_GPE_CAN_WAKE               (UINT8) 0x10
    838 #define ACPI_GPE_AUTO_ENABLED           (UINT8) 0x20
    839 #define ACPI_GPE_INITIALIZED            (UINT8) 0x40
    840 
    841 /*
    842  * Flags for GPE and Lock interfaces
    843  */
    844 #define ACPI_NOT_ISR                    0x1
    845 #define ACPI_ISR                        0x0
    846 
    847 
    848 /* Notify types */
    849 
    850 #define ACPI_SYSTEM_NOTIFY              0x1
    851 #define ACPI_DEVICE_NOTIFY              0x2
    852 #define ACPI_ALL_NOTIFY                 (ACPI_SYSTEM_NOTIFY | ACPI_DEVICE_NOTIFY)
    853 #define ACPI_MAX_NOTIFY_HANDLER_TYPE    0x3
    854 #define ACPI_NUM_NOTIFY_TYPES           2
    855 
    856 #define ACPI_MAX_SYS_NOTIFY             0x7F
    857 #define ACPI_MAX_DEVICE_SPECIFIC_NOTIFY 0xBF
    858 
    859 #define ACPI_SYSTEM_HANDLER_LIST        0 /* Used as index, must be SYSTEM_NOTIFY -1 */
    860 #define ACPI_DEVICE_HANDLER_LIST        1 /* Used as index, must be DEVICE_NOTIFY -1 */
    861 
    862 
    863 /* Address Space (Operation Region) Types */
    864 
    865 typedef UINT8                           ACPI_ADR_SPACE_TYPE;
    866 
    867 #define ACPI_ADR_SPACE_SYSTEM_MEMORY    (ACPI_ADR_SPACE_TYPE) 0
    868 #define ACPI_ADR_SPACE_SYSTEM_IO        (ACPI_ADR_SPACE_TYPE) 1
    869 #define ACPI_ADR_SPACE_PCI_CONFIG       (ACPI_ADR_SPACE_TYPE) 2
    870 #define ACPI_ADR_SPACE_EC               (ACPI_ADR_SPACE_TYPE) 3
    871 #define ACPI_ADR_SPACE_SMBUS            (ACPI_ADR_SPACE_TYPE) 4
    872 #define ACPI_ADR_SPACE_CMOS             (ACPI_ADR_SPACE_TYPE) 5
    873 #define ACPI_ADR_SPACE_PCI_BAR_TARGET   (ACPI_ADR_SPACE_TYPE) 6
    874 #define ACPI_ADR_SPACE_IPMI             (ACPI_ADR_SPACE_TYPE) 7
    875 #define ACPI_ADR_SPACE_GPIO             (ACPI_ADR_SPACE_TYPE) 8
    876 #define ACPI_ADR_SPACE_GSBUS            (ACPI_ADR_SPACE_TYPE) 9
    877 #define ACPI_ADR_SPACE_PLATFORM_COMM    (ACPI_ADR_SPACE_TYPE) 10
    878 #define ACPI_ADR_SPACE_PLATFORM_RT      (ACPI_ADR_SPACE_TYPE) 11
    879 
    880 #define ACPI_NUM_PREDEFINED_REGIONS     12
    881 
    882 /*
    883  * Special Address Spaces
    884  *
    885  * Note: A Data Table region is a special type of operation region
    886  * that has its own AML opcode. However, internally, the AML
    887  * interpreter simply creates an operation region with an address
    888  * space type of ACPI_ADR_SPACE_DATA_TABLE.
    889  */
    890 #define ACPI_ADR_SPACE_DATA_TABLE       (ACPI_ADR_SPACE_TYPE) 0x7E /* Internal to ACPICA only */
    891 #define ACPI_ADR_SPACE_FIXED_HARDWARE   (ACPI_ADR_SPACE_TYPE) 0x7F
    892 
    893 /* Values for _REG connection code */
    894 
    895 #define ACPI_REG_DISCONNECT             0
    896 #define ACPI_REG_CONNECT                1
    897 
    898 /*
    899  * BitRegister IDs
    900  *
    901  * These values are intended to be used by the hardware interfaces
    902  * and are mapped to individual bitfields defined within the ACPI
    903  * registers. See the AcpiGbl_BitRegisterInfo global table in utglobal.c
    904  * for this mapping.
    905  */
    906 
    907 /* PM1 Status register */
    908 
    909 #define ACPI_BITREG_TIMER_STATUS                0x00
    910 #define ACPI_BITREG_BUS_MASTER_STATUS           0x01
    911 #define ACPI_BITREG_GLOBAL_LOCK_STATUS          0x02
    912 #define ACPI_BITREG_POWER_BUTTON_STATUS         0x03
    913 #define ACPI_BITREG_SLEEP_BUTTON_STATUS         0x04
    914 #define ACPI_BITREG_RT_CLOCK_STATUS             0x05
    915 #define ACPI_BITREG_WAKE_STATUS                 0x06
    916 #define ACPI_BITREG_PCIEXP_WAKE_STATUS          0x07
    917 
    918 /* PM1 Enable register */
    919 
    920 #define ACPI_BITREG_TIMER_ENABLE                0x08
    921 #define ACPI_BITREG_GLOBAL_LOCK_ENABLE          0x09
    922 #define ACPI_BITREG_POWER_BUTTON_ENABLE         0x0A
    923 #define ACPI_BITREG_SLEEP_BUTTON_ENABLE         0x0B
    924 #define ACPI_BITREG_RT_CLOCK_ENABLE             0x0C
    925 #define ACPI_BITREG_PCIEXP_WAKE_DISABLE         0x0D
    926 
    927 /* PM1 Control register */
    928 
    929 #define ACPI_BITREG_SCI_ENABLE                  0x0E
    930 #define ACPI_BITREG_BUS_MASTER_RLD              0x0F
    931 #define ACPI_BITREG_GLOBAL_LOCK_RELEASE         0x10
    932 #define ACPI_BITREG_SLEEP_TYPE                  0x11
    933 #define ACPI_BITREG_SLEEP_ENABLE                0x12
    934 
    935 /* PM2 Control register */
    936 
    937 #define ACPI_BITREG_ARB_DISABLE                 0x13
    938 
    939 #define ACPI_BITREG_MAX                         0x13
    940 #define ACPI_NUM_BITREG                         ACPI_BITREG_MAX + 1
    941 
    942 
    943 /* Status register values. A 1 clears a status bit. 0 = no effect */
    944 
    945 #define ACPI_CLEAR_STATUS                       1
    946 
    947 /* Enable and Control register values */
    948 
    949 #define ACPI_ENABLE_EVENT                       1
    950 #define ACPI_DISABLE_EVENT                      0
    951 
    952 
    953 /* Sleep function dispatch */
    954 
    955 typedef ACPI_STATUS (*ACPI_SLEEP_FUNCTION) (
    956     UINT8                   SleepState);
    957 
    958 typedef struct acpi_sleep_functions
    959 {
    960     ACPI_SLEEP_FUNCTION     LegacyFunction;
    961     ACPI_SLEEP_FUNCTION     ExtendedFunction;
    962 
    963 } ACPI_SLEEP_FUNCTIONS;
    964 
    965 
    966 /*
    967  * External ACPI object definition
    968  */
    969 
    970 /*
    971  * Note: Type == ACPI_TYPE_ANY (0) is used to indicate a NULL package
    972  * element or an unresolved named reference.
    973  */
    974 typedef union acpi_object
    975 {
    976     ACPI_OBJECT_TYPE                Type;   /* See definition of AcpiNsType for values */
    977     struct
    978     {
    979         ACPI_OBJECT_TYPE                Type;       /* ACPI_TYPE_INTEGER */
    980         UINT64                          Value;      /* The actual number */
    981     } Integer;
    982 
    983     struct
    984     {
    985         ACPI_OBJECT_TYPE                Type;       /* ACPI_TYPE_STRING */
    986         UINT32                          Length;     /* # of bytes in string, excluding trailing null */
    987         char                            *Pointer;   /* points to the string value */
    988     } String;
    989 
    990     struct
    991     {
    992         ACPI_OBJECT_TYPE                Type;       /* ACPI_TYPE_BUFFER */
    993         UINT32                          Length;     /* # of bytes in buffer */
    994         UINT8                           *Pointer;   /* points to the buffer */
    995     } Buffer;
    996 
    997     struct
    998     {
    999         ACPI_OBJECT_TYPE                Type;       /* ACPI_TYPE_PACKAGE */
   1000         UINT32                          Count;      /* # of elements in package */
   1001         union acpi_object               *Elements;  /* Pointer to an array of ACPI_OBJECTs */
   1002     } Package;
   1003 
   1004     struct
   1005     {
   1006         ACPI_OBJECT_TYPE                Type;       /* ACPI_TYPE_LOCAL_REFERENCE */
   1007         ACPI_OBJECT_TYPE                ActualType; /* Type associated with the Handle */
   1008         ACPI_HANDLE                     Handle;     /* object reference */
   1009     } Reference;
   1010 
   1011     struct
   1012     {
   1013         ACPI_OBJECT_TYPE                Type;       /* ACPI_TYPE_PROCESSOR */
   1014         UINT32                          ProcId;
   1015         ACPI_IO_ADDRESS                 PblkAddress;
   1016         UINT32                          PblkLength;
   1017     } Processor;
   1018 
   1019     struct
   1020     {
   1021         ACPI_OBJECT_TYPE                Type;       /* ACPI_TYPE_POWER */
   1022         UINT32                          SystemLevel;
   1023         UINT32                          ResourceOrder;
   1024     } PowerResource;
   1025 
   1026 } ACPI_OBJECT;
   1027 
   1028 
   1029 /*
   1030  * List of objects, used as a parameter list for control method evaluation
   1031  */
   1032 typedef struct acpi_object_list
   1033 {
   1034     UINT32                          Count;
   1035     ACPI_OBJECT                     *Pointer;
   1036 
   1037 } ACPI_OBJECT_LIST;
   1038 
   1039 
   1040 /*
   1041  * Miscellaneous common Data Structures used by the interfaces
   1042  */
   1043 #define ACPI_NO_BUFFER              0
   1044 
   1045 #ifdef ACPI_NO_MEM_ALLOCATIONS
   1046 
   1047 #define ACPI_ALLOCATE_BUFFER        (ACPI_SIZE) (0)
   1048 #define ACPI_ALLOCATE_LOCAL_BUFFER  (ACPI_SIZE) (0)
   1049 
   1050 #else /* ACPI_NO_MEM_ALLOCATIONS */
   1051 
   1052 #define ACPI_ALLOCATE_BUFFER        (ACPI_SIZE) (-1)    /* Let ACPICA allocate buffer */
   1053 #define ACPI_ALLOCATE_LOCAL_BUFFER  (ACPI_SIZE) (-2)    /* For internal use only (enables tracking) */
   1054 
   1055 #endif /* ACPI_NO_MEM_ALLOCATIONS */
   1056 
   1057 typedef struct acpi_buffer
   1058 {
   1059     ACPI_SIZE                       Length;         /* Length in bytes of the buffer */
   1060     void                            *Pointer;       /* pointer to buffer */
   1061 
   1062 } ACPI_BUFFER;
   1063 
   1064 
   1065 /*
   1066  * NameType for AcpiGetName
   1067  */
   1068 #define ACPI_FULL_PATHNAME              0
   1069 #define ACPI_SINGLE_NAME                1
   1070 #define ACPI_FULL_PATHNAME_NO_TRAILING  2
   1071 #define ACPI_NAME_TYPE_MAX              2
   1072 
   1073 
   1074 /*
   1075  * Predefined Namespace items
   1076  */
   1077 typedef struct acpi_predefined_names
   1078 {
   1079     const char                      *Name;
   1080     UINT8                           Type;
   1081     const char                      *Val;
   1082 
   1083 } ACPI_PREDEFINED_NAMES;
   1084 
   1085 
   1086 /*
   1087  * Structure and flags for AcpiGetSystemInfo
   1088  */
   1089 #define ACPI_SYS_MODE_UNKNOWN           0x0000
   1090 #define ACPI_SYS_MODE_ACPI              0x0001
   1091 #define ACPI_SYS_MODE_LEGACY            0x0002
   1092 #define ACPI_SYS_MODES_MASK             0x0003
   1093 
   1094 
   1095 /*
   1096  * System info returned by AcpiGetSystemInfo()
   1097  */
   1098 typedef struct acpi_system_info
   1099 {
   1100     UINT32                          AcpiCaVersion;
   1101     UINT32                          Flags;
   1102     UINT32                          TimerResolution;
   1103     UINT32                          Reserved1;
   1104     UINT32                          Reserved2;
   1105     UINT32                          DebugLevel;
   1106     UINT32                          DebugLayer;
   1107 
   1108 } ACPI_SYSTEM_INFO;
   1109 
   1110 
   1111 /*
   1112  * System statistics returned by AcpiGetStatistics()
   1113  */
   1114 typedef struct acpi_statistics
   1115 {
   1116     UINT32                          SciCount;
   1117     UINT32                          GpeCount;
   1118     UINT32                          FixedEventCount[ACPI_NUM_FIXED_EVENTS];
   1119     UINT32                          MethodCount;
   1120 
   1121 } ACPI_STATISTICS;
   1122 
   1123 
   1124 /*
   1125  * Types specific to the OS service interfaces
   1126  */
   1127 typedef UINT32
   1128 (ACPI_SYSTEM_XFACE *ACPI_OSD_HANDLER) (
   1129     void                            *Context);
   1130 
   1131 typedef void
   1132 (ACPI_SYSTEM_XFACE *ACPI_OSD_EXEC_CALLBACK) (
   1133     void                            *Context);
   1134 
   1135 /*
   1136  * Various handlers and callback procedures
   1137  */
   1138 typedef
   1139 UINT32 (*ACPI_SCI_HANDLER) (
   1140     void                            *Context);
   1141 
   1142 typedef
   1143 void (*ACPI_GBL_EVENT_HANDLER) (
   1144     UINT32                          EventType,
   1145     ACPI_HANDLE                     Device,
   1146     UINT32                          EventNumber,
   1147     void                            *Context);
   1148 
   1149 #define ACPI_EVENT_TYPE_GPE         0
   1150 #define ACPI_EVENT_TYPE_FIXED       1
   1151 
   1152 typedef
   1153 UINT32 (*ACPI_EVENT_HANDLER) (
   1154     void                            *Context);
   1155 
   1156 typedef
   1157 UINT32 (*ACPI_GPE_HANDLER) (
   1158     ACPI_HANDLE                     GpeDevice,
   1159     UINT32                          GpeNumber,
   1160     void                            *Context);
   1161 
   1162 typedef
   1163 void (*ACPI_NOTIFY_HANDLER) (
   1164     ACPI_HANDLE                     Device,
   1165     UINT32                          Value,
   1166     void                            *Context);
   1167 
   1168 typedef
   1169 void (*ACPI_OBJECT_HANDLER) (
   1170     ACPI_HANDLE                     Object,
   1171     void                            *Data);
   1172 
   1173 typedef
   1174 ACPI_STATUS (*ACPI_INIT_HANDLER) (
   1175     ACPI_HANDLE                     Object,
   1176     UINT32                          Function);
   1177 
   1178 #define ACPI_INIT_DEVICE_INI        1
   1179 
   1180 typedef
   1181 ACPI_STATUS (*ACPI_EXCEPTION_HANDLER) (
   1182     ACPI_STATUS                     AmlStatus,
   1183     ACPI_NAME                       Name,
   1184     UINT16                          Opcode,
   1185     UINT32                          AmlOffset,
   1186     void                            *Context);
   1187 
   1188 /* Table Event handler (Load, LoadTable, etc.) and types */
   1189 
   1190 typedef
   1191 ACPI_STATUS (*ACPI_TABLE_HANDLER) (
   1192     UINT32                          Event,
   1193     void                            *Table,
   1194     void                            *Context);
   1195 
   1196 
   1197 /* Table Event Types */
   1198 
   1199 #define ACPI_TABLE_EVENT_LOAD           0x0
   1200 #define ACPI_TABLE_EVENT_UNLOAD         0x1
   1201 #define ACPI_TABLE_EVENT_INSTALL        0x2
   1202 #define ACPI_TABLE_EVENT_UNINSTALL      0x3
   1203 #define ACPI_NUM_TABLE_EVENTS           4
   1204 
   1205 
   1206 /* Address Spaces (For Operation Regions) */
   1207 
   1208 typedef
   1209 ACPI_STATUS (*ACPI_ADR_SPACE_HANDLER) (
   1210     UINT32                          Function,
   1211     ACPI_PHYSICAL_ADDRESS           Address,
   1212     UINT32                          BitWidth,
   1213     UINT64                          *Value,
   1214     void                            *HandlerContext,
   1215     void                            *RegionContext);
   1216 
   1217 #define ACPI_DEFAULT_HANDLER            NULL
   1218 
   1219 /* Special Context data for GenericSerialBus/GeneralPurposeIo (ACPI 5.0) */
   1220 
   1221 typedef struct acpi_connection_info
   1222 {
   1223     UINT8                           *Connection;
   1224     UINT16                          Length;
   1225     UINT8                           AccessLength;
   1226 
   1227 } ACPI_CONNECTION_INFO;
   1228 
   1229 /* Special Context data for PCC Opregion (ACPI 6.3) */
   1230 
   1231 typedef struct acpi_pcc_info {
   1232     UINT8                           SubspaceId;
   1233     UINT16                          Length;
   1234     UINT8                           *InternalBuffer;
   1235 } ACPI_PCC_INFO;
   1236 
   1237 /* Special Context data for FFH Opregion (ACPI 6.5) */
   1238 
   1239 typedef struct acpi_ffh_info {
   1240     UINT64                          Offset;
   1241     UINT64                          Length;
   1242 } ACPI_FFH_INFO;
   1243 
   1244 typedef
   1245 ACPI_STATUS (*ACPI_ADR_SPACE_SETUP) (
   1246     ACPI_HANDLE                     RegionHandle,
   1247     UINT32                          Function,
   1248     void                            *HandlerContext,
   1249     void                            **RegionContext);
   1250 
   1251 #define ACPI_REGION_ACTIVATE    0
   1252 #define ACPI_REGION_DEACTIVATE  1
   1253 
   1254 typedef
   1255 ACPI_STATUS (*ACPI_WALK_CALLBACK) (
   1256     ACPI_HANDLE                     Object,
   1257     UINT32                          NestingLevel,
   1258     void                            *Context,
   1259     void                            **ReturnValue);
   1260 
   1261 typedef
   1262 UINT32 (*ACPI_INTERFACE_HANDLER) (
   1263     ACPI_STRING                     InterfaceName,
   1264     UINT32                          Supported);
   1265 
   1266 
   1267 /* Interrupt handler return values */
   1268 
   1269 #define ACPI_INTERRUPT_NOT_HANDLED      0x00
   1270 #define ACPI_INTERRUPT_HANDLED          0x01
   1271 
   1272 /* GPE handler return values */
   1273 
   1274 #define ACPI_REENABLE_GPE               0x80
   1275 
   1276 
   1277 /* Length of 32-bit EISAID values when converted back to a string */
   1278 
   1279 #define ACPI_EISAID_STRING_SIZE         8   /* Includes null terminator */
   1280 
   1281 /* Length of UUID (string) values */
   1282 
   1283 #define ACPI_UUID_LENGTH                16
   1284 
   1285 /* Length of 3-byte PCI class code values when converted back to a string */
   1286 
   1287 #define ACPI_PCICLS_STRING_SIZE         7   /* Includes null terminator */
   1288 
   1289 
   1290 /* Structures used for device/processor HID, UID, CID */
   1291 
   1292 typedef struct acpi_pnp_device_id
   1293 {
   1294     UINT32                          Length;             /* Length of string + null */
   1295     char                            *String;
   1296 
   1297 } ACPI_PNP_DEVICE_ID;
   1298 
   1299 typedef struct acpi_pnp_device_id_list
   1300 {
   1301     UINT32                          Count;              /* Number of IDs in Ids array */
   1302     UINT32                          ListSize;           /* Size of list, including ID strings */
   1303     ACPI_PNP_DEVICE_ID              Ids[];              /* ID array */
   1304 
   1305 } ACPI_PNP_DEVICE_ID_LIST;
   1306 
   1307 /*
   1308  * Structure returned from AcpiGetObjectInfo.
   1309  * Optimized for both 32-bit and 64-bit builds.
   1310  */
   1311 typedef struct acpi_device_info
   1312 {
   1313     UINT32                          InfoSize;           /* Size of info, including ID strings */
   1314     UINT32                          Name;               /* ACPI object Name */
   1315     ACPI_OBJECT_TYPE                Type;               /* ACPI object Type */
   1316     UINT8                           ParamCount;         /* If a method, required parameter count */
   1317     UINT16                          Valid;              /* Indicates which optional fields are valid */
   1318     UINT8                           Flags;              /* Miscellaneous info */
   1319     UINT8                           HighestDstates[4];  /* _SxD values: 0xFF indicates not valid */
   1320     UINT8                           LowestDstates[5];   /* _SxW values: 0xFF indicates not valid */
   1321     UINT64                          Address;            /* _ADR value */
   1322     ACPI_PNP_DEVICE_ID              HardwareId;         /* _HID value */
   1323     ACPI_PNP_DEVICE_ID              UniqueId;           /* _UID value */
   1324     ACPI_PNP_DEVICE_ID              ClassCode;          /* _CLS value */
   1325     ACPI_PNP_DEVICE_ID_LIST         CompatibleIdList;   /* _CID list <must be last> */
   1326 
   1327 } ACPI_DEVICE_INFO;
   1328 
   1329 /* Values for Flags field above (AcpiGetObjectInfo) */
   1330 
   1331 #define ACPI_PCI_ROOT_BRIDGE            0x01
   1332 
   1333 /* Flags for Valid field above (AcpiGetObjectInfo) */
   1334 
   1335 #define ACPI_VALID_ADR                  0x0002
   1336 #define ACPI_VALID_HID                  0x0004
   1337 #define ACPI_VALID_UID                  0x0008
   1338 #define ACPI_VALID_CID                  0x0020
   1339 #define ACPI_VALID_CLS                  0x0040
   1340 #define ACPI_VALID_SXDS                 0x0100
   1341 #define ACPI_VALID_SXWS                 0x0200
   1342 
   1343 /* Flags for _STA method */
   1344 
   1345 #define ACPI_STA_DEVICE_PRESENT         0x01
   1346 #define ACPI_STA_DEVICE_ENABLED         0x02
   1347 #define ACPI_STA_DEVICE_UI              0x04
   1348 #define ACPI_STA_DEVICE_FUNCTIONING     0x08
   1349 #define ACPI_STA_DEVICE_OK              0x08 /* Synonym */
   1350 #define ACPI_STA_BATTERY_PRESENT        0x10
   1351 
   1352 
   1353 /* Context structs for address space handlers */
   1354 
   1355 typedef struct acpi_pci_id
   1356 {
   1357     UINT16                          Segment;
   1358     UINT16                          Bus;
   1359     UINT16                          Device;
   1360     UINT16                          Function;
   1361 
   1362 } ACPI_PCI_ID;
   1363 
   1364 typedef struct acpi_mem_mapping
   1365 {
   1366     ACPI_PHYSICAL_ADDRESS           PhysicalAddress;
   1367     UINT8                           *LogicalAddress;
   1368     ACPI_SIZE                       Length;
   1369     struct acpi_mem_mapping         *NextMm;
   1370 
   1371 } ACPI_MEM_MAPPING;
   1372 
   1373 typedef struct acpi_mem_space_context
   1374 {
   1375     UINT32                          Length;
   1376     ACPI_PHYSICAL_ADDRESS           Address;
   1377     ACPI_MEM_MAPPING                *CurMm;
   1378     ACPI_MEM_MAPPING                *FirstMm;
   1379 
   1380 } ACPI_MEM_SPACE_CONTEXT;
   1381 
   1382 typedef struct acpi_data_table_mapping
   1383 {
   1384     void                            *Pointer;
   1385 
   1386 } ACPI_DATA_TABLE_MAPPING;
   1387 
   1388 /*
   1389  * ACPI_MEMORY_LIST is used only if the ACPICA local cache is enabled
   1390  */
   1391 typedef struct acpi_memory_list
   1392 {
   1393     const char                      *ListName;
   1394     void                            *ListHead;
   1395     UINT16                          ObjectSize;
   1396     UINT16                          MaxDepth;
   1397     UINT16                          CurrentDepth;
   1398 
   1399 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
   1400 
   1401     /* Statistics for debug memory tracking only */
   1402 
   1403     UINT32                          TotalAllocated;
   1404     UINT32                          TotalFreed;
   1405     UINT32                          MaxOccupied;
   1406     UINT32                          TotalSize;
   1407     UINT32                          CurrentTotalSize;
   1408     UINT32                          Requests;
   1409     UINT32                          Hits;
   1410 #endif
   1411 
   1412 } ACPI_MEMORY_LIST;
   1413 
   1414 
   1415 /* Definitions of trace event types */
   1416 
   1417 typedef enum
   1418 {
   1419     ACPI_TRACE_AML_METHOD,
   1420     ACPI_TRACE_AML_OPCODE,
   1421     ACPI_TRACE_AML_REGION
   1422 
   1423 } ACPI_TRACE_EVENT_TYPE;
   1424 
   1425 
   1426 /* Definitions of _OSI support */
   1427 
   1428 #define ACPI_VENDOR_STRINGS                 0x01
   1429 #define ACPI_FEATURE_STRINGS                0x02
   1430 #define ACPI_ENABLE_INTERFACES              0x00
   1431 #define ACPI_DISABLE_INTERFACES             0x04
   1432 
   1433 #define ACPI_DISABLE_ALL_VENDOR_STRINGS     (ACPI_DISABLE_INTERFACES | ACPI_VENDOR_STRINGS)
   1434 #define ACPI_DISABLE_ALL_FEATURE_STRINGS    (ACPI_DISABLE_INTERFACES | ACPI_FEATURE_STRINGS)
   1435 #define ACPI_DISABLE_ALL_STRINGS            (ACPI_DISABLE_INTERFACES | ACPI_VENDOR_STRINGS | ACPI_FEATURE_STRINGS)
   1436 #define ACPI_ENABLE_ALL_VENDOR_STRINGS      (ACPI_ENABLE_INTERFACES | ACPI_VENDOR_STRINGS)
   1437 #define ACPI_ENABLE_ALL_FEATURE_STRINGS     (ACPI_ENABLE_INTERFACES | ACPI_FEATURE_STRINGS)
   1438 #define ACPI_ENABLE_ALL_STRINGS             (ACPI_ENABLE_INTERFACES | ACPI_VENDOR_STRINGS | ACPI_FEATURE_STRINGS)
   1439 
   1440 #define ACPI_OSI_WIN_2000               0x01
   1441 #define ACPI_OSI_WIN_XP                 0x02
   1442 #define ACPI_OSI_WIN_XP_SP1             0x03
   1443 #define ACPI_OSI_WINSRV_2003            0x04
   1444 #define ACPI_OSI_WIN_XP_SP2             0x05
   1445 #define ACPI_OSI_WINSRV_2003_SP1        0x06
   1446 #define ACPI_OSI_WIN_VISTA              0x07
   1447 #define ACPI_OSI_WINSRV_2008            0x08
   1448 #define ACPI_OSI_WIN_VISTA_SP1          0x09
   1449 #define ACPI_OSI_WIN_VISTA_SP2          0x0A
   1450 #define ACPI_OSI_WIN_7                  0x0B
   1451 #define ACPI_OSI_WIN_8                  0x0C
   1452 #define ACPI_OSI_WIN_8_1                0x0D
   1453 #define ACPI_OSI_WIN_10                 0x0E
   1454 #define ACPI_OSI_WIN_10_RS1             0x0F
   1455 #define ACPI_OSI_WIN_10_RS2             0x10
   1456 #define ACPI_OSI_WIN_10_RS3             0x11
   1457 #define ACPI_OSI_WIN_10_RS4             0x12
   1458 #define ACPI_OSI_WIN_10_RS5             0x13
   1459 #define ACPI_OSI_WIN_10_19H1            0x14
   1460 #define ACPI_OSI_WIN_10_20H1            0x15
   1461 #define ACPI_OSI_WIN_11                 0x16
   1462 #define ACPI_OSI_WIN_11_22H2            0x17
   1463 
   1464 
   1465 /* Definitions of getopt */
   1466 
   1467 #define ACPI_OPT_END                    -1
   1468 
   1469 /* Definitions for explicit fallthrough */
   1470 
   1471 #ifndef ACPI_FALLTHROUGH
   1472 #define ACPI_FALLTHROUGH do {} while(0)
   1473 #endif
   1474 
   1475 #ifndef ACPI_FLEX_ARRAY
   1476 #define ACPI_FLEX_ARRAY(TYPE, NAME)     TYPE NAME[0]
   1477 #endif
   1478 
   1479 #ifndef ACPI_NONSTRING
   1480 #define ACPI_NONSTRING	/* No terminating NUL character */
   1481 #endif
   1482 
   1483 #endif /* __ACTYPES_H__ */
   1484