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