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