ACPICA: Cleanup source to reduce differences between Linux and ACPICA.
[linux-2.6-block.git] / include / acpi / actypes.h
1 /******************************************************************************
2  *
3  * Name: actypes.h - Common data types for the entire ACPI subsystem
4  *
5  *****************************************************************************/
6
7 /*
8  * Copyright (C) 2000 - 2012, 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:struct_defs -- 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 /*! [Begin] no source code translation */
59
60 /*
61  * Data type ranges
62  * Note: These macros are designed to be compiler independent as well as
63  * working around problems that some 32-bit compilers have with 64-bit
64  * constants.
65  */
66 #define ACPI_UINT8_MAX                  (UINT8) (~((UINT8)  0)) /* 0xFF               */
67 #define ACPI_UINT16_MAX                 (UINT16)(~((UINT16) 0)) /* 0xFFFF             */
68 #define ACPI_UINT32_MAX                 (UINT32)(~((UINT32) 0)) /* 0xFFFFFFFF         */
69 #define ACPI_UINT64_MAX                 (UINT64)(~((UINT64) 0)) /* 0xFFFFFFFFFFFFFFFF */
70 #define ACPI_ASCII_MAX                  0x7F
71
72 /*
73  * Architecture-specific ACPICA Subsystem Data Types
74  *
75  * The goal of these types is to provide source code portability across
76  * 16-bit, 32-bit, and 64-bit targets.
77  *
78  * 1) The following types are of fixed size for all targets (16/32/64):
79  *
80  * BOOLEAN      Logical boolean
81  *
82  * UINT8        8-bit  (1 byte) unsigned value
83  * UINT16       16-bit (2 byte) unsigned value
84  * UINT32       32-bit (4 byte) unsigned value
85  * UINT64       64-bit (8 byte) unsigned value
86  *
87  * INT16        16-bit (2 byte) signed value
88  * INT32        32-bit (4 byte) signed value
89  * INT64        64-bit (8 byte) signed value
90  *
91  * COMPILER_DEPENDENT_UINT64/INT64 - These types are defined in the
92  * compiler-dependent header(s) and were introduced because there is no common
93  * 64-bit integer type across the various compilation models, as shown in
94  * the table below.
95  *
96  * Datatype  LP64 ILP64 LLP64 ILP32 LP32 16bit
97  * char      8    8     8     8     8    8
98  * short     16   16    16    16    16   16
99  * _int32         32
100  * int       32   64    32    32    16   16
101  * long      64   64    32    32    32   32
102  * long long            64    64
103  * pointer   64   64    64    32    32   32
104  *
105  * Note: ILP64 and LP32 are currently not supported.
106  *
107  *
108  * 2) These types represent the native word size of the target mode of the
109  * processor, and may be 16-bit, 32-bit, or 64-bit as required. They are
110  * usually used for memory allocation, efficient loop counters, and array
111  * indexes. The types are similar to the size_t type in the C library and are
112  * required because there is no C type that consistently represents the native
113  * data width. ACPI_SIZE is needed because there is no guarantee that a
114  * kernel-level C library is present.
115  *
116  * ACPI_SIZE        16/32/64-bit unsigned value
117  * ACPI_NATIVE_INT  16/32/64-bit signed value
118  */
119
120 /*******************************************************************************
121  *
122  * Common types for all compilers, all targets
123  *
124  ******************************************************************************/
125
126 typedef unsigned char BOOLEAN;
127 typedef unsigned char UINT8;
128 typedef unsigned short UINT16;
129 typedef COMPILER_DEPENDENT_UINT64 UINT64;
130 typedef COMPILER_DEPENDENT_INT64 INT64;
131
132 /*! [End] no source code translation !*/
133
134 /*
135  * Value returned by acpi_os_get_thread_id. There is no standard "thread_id"
136  * across operating systems or even the various UNIX systems. Since ACPICA
137  * only needs the thread ID as a unique thread identifier, we use a u64
138  * as the only common data type - it will accommodate any type of pointer or
139  * any type of integer. It is up to the host-dependent OSL to cast the
140  * native thread ID type to a u64 (in acpi_os_get_thread_id).
141  */
142 #define acpi_thread_id                  u64
143
144 /*******************************************************************************
145  *
146  * Types specific to 64-bit targets
147  *
148  ******************************************************************************/
149
150 #if ACPI_MACHINE_WIDTH == 64
151
152 /*! [Begin] no source code translation (keep the typedefs as-is) */
153
154 typedef unsigned int UINT32;
155 typedef int INT32;
156
157 /*! [End] no source code translation !*/
158
159 typedef s64 acpi_native_int;
160
161 typedef u64 acpi_size;
162 typedef u64 acpi_io_address;
163 typedef u64 acpi_physical_address;
164
165 #define ACPI_MAX_PTR                    ACPI_UINT64_MAX
166 #define ACPI_SIZE_MAX                   ACPI_UINT64_MAX
167
168 #define ACPI_USE_NATIVE_DIVIDE  /* Has native 64-bit integer support */
169
170 /*
171  * In the case of the Itanium Processor Family (IPF), the hardware does not
172  * support misaligned memory transfers. Set the MISALIGNMENT_NOT_SUPPORTED flag
173  * to indicate that special precautions must be taken to avoid alignment faults.
174  * (IA64 or ia64 is currently used by existing compilers to indicate IPF.)
175  *
176  * Note: EM64T and other X86-64 processors support misaligned transfers,
177  * so there is no need to define this flag.
178  */
179 #if defined (__IA64__) || defined (__ia64__)
180 #define ACPI_MISALIGNMENT_NOT_SUPPORTED
181 #endif
182
183 /*******************************************************************************
184  *
185  * Types specific to 32-bit targets
186  *
187  ******************************************************************************/
188
189 #elif ACPI_MACHINE_WIDTH == 32
190
191 /*! [Begin] no source code translation (keep the typedefs as-is) */
192
193 typedef unsigned int UINT32;
194 typedef int INT32;
195
196 /*! [End] no source code translation !*/
197
198 typedef s32 acpi_native_int;
199
200 typedef u32 acpi_size;
201 typedef u32 acpi_io_address;
202 typedef u32 acpi_physical_address;
203
204 #define ACPI_MAX_PTR                    ACPI_UINT32_MAX
205 #define ACPI_SIZE_MAX                   ACPI_UINT32_MAX
206
207 #else
208
209 /* ACPI_MACHINE_WIDTH must be either 64 or 32 */
210
211 #error unknown ACPI_MACHINE_WIDTH
212 #endif
213
214 /*******************************************************************************
215  *
216  * OS-dependent types
217  *
218  * If the defaults below are not appropriate for the host system, they can
219  * be defined in the OS-specific header, and this will take precedence.
220  *
221  ******************************************************************************/
222
223 /* Flags for acpi_os_acquire_lock/acpi_os_release_lock */
224
225 #ifndef acpi_cpu_flags
226 #define acpi_cpu_flags                  acpi_size
227 #endif
228
229 /* Object returned from acpi_os_create_cache */
230
231 #ifndef acpi_cache_t
232 #ifdef ACPI_USE_LOCAL_CACHE
233 #define acpi_cache_t                    struct acpi_memory_list
234 #else
235 #define acpi_cache_t                    void *
236 #endif
237 #endif
238
239 /*
240  * Synchronization objects - Mutexes, Semaphores, and spin_locks
241  */
242 #if (ACPI_MUTEX_TYPE == ACPI_BINARY_SEMAPHORE)
243 /*
244  * These macros are used if the host OS does not support a mutex object.
245  * Map the OSL Mutex interfaces to binary semaphores.
246  */
247 #define acpi_mutex                      acpi_semaphore
248 #define acpi_os_create_mutex(out_handle) acpi_os_create_semaphore (1, 1, out_handle)
249 #define acpi_os_delete_mutex(handle)    (void) acpi_os_delete_semaphore (handle)
250 #define acpi_os_acquire_mutex(handle,time) acpi_os_wait_semaphore (handle, 1, time)
251 #define acpi_os_release_mutex(handle)   (void) acpi_os_signal_semaphore (handle, 1)
252 #endif
253
254 /* Configurable types for synchronization objects */
255
256 #ifndef acpi_spinlock
257 #define acpi_spinlock                   void *
258 #endif
259
260 #ifndef acpi_semaphore
261 #define acpi_semaphore                  void *
262 #endif
263
264 #ifndef acpi_mutex
265 #define acpi_mutex                      void *
266 #endif
267
268 /*******************************************************************************
269  *
270  * Compiler-dependent types
271  *
272  * If the defaults below are not appropriate for the host compiler, they can
273  * be defined in the compiler-specific header, and this will take precedence.
274  *
275  ******************************************************************************/
276
277 /* Use C99 uintptr_t for pointer casting if available, "void *" otherwise */
278
279 #ifndef acpi_uintptr_t
280 #define acpi_uintptr_t                  void *
281 #endif
282
283 /*
284  * ACPI_PRINTF_LIKE is used to tag functions as "printf-like" because
285  * some compilers can catch printf format string problems
286  */
287 #ifndef ACPI_PRINTF_LIKE
288 #define ACPI_PRINTF_LIKE(c)
289 #endif
290
291 /*
292  * Some compilers complain about unused variables. Sometimes we don't want to
293  * use all the variables (for example, _acpi_module_name). This allows us
294  * to tell the compiler in a per-variable manner that a variable
295  * is unused
296  */
297 #ifndef ACPI_UNUSED_VAR
298 #define ACPI_UNUSED_VAR
299 #endif
300
301 /*
302  * All ACPICA functions that are available to the rest of the kernel are
303  * tagged with this macro which can be defined as appropriate for the host.
304  */
305 #ifndef ACPI_EXPORT_SYMBOL
306 #define ACPI_EXPORT_SYMBOL(symbol)
307 #endif
308
309 /******************************************************************************
310  *
311  * ACPI Specification constants (Do not change unless the specification changes)
312  *
313  *****************************************************************************/
314
315 /* Number of distinct FADT-based GPE register blocks (GPE0 and GPE1) */
316
317 #define ACPI_MAX_GPE_BLOCKS             2
318
319 /* Default ACPI register widths */
320
321 #define ACPI_GPE_REGISTER_WIDTH         8
322 #define ACPI_PM1_REGISTER_WIDTH         16
323 #define ACPI_PM2_REGISTER_WIDTH         8
324 #define ACPI_PM_TIMER_WIDTH             32
325
326 /* Names within the namespace are 4 bytes long */
327
328 #define ACPI_NAME_SIZE                  4
329 #define ACPI_PATH_SEGMENT_LENGTH        5       /* 4 chars for name + 1 char for separator */
330 #define ACPI_PATH_SEPARATOR             '.'
331
332 /* Sizes for ACPI table headers */
333
334 #define ACPI_OEM_ID_SIZE                6
335 #define ACPI_OEM_TABLE_ID_SIZE          8
336
337 /* ACPI/PNP hardware IDs */
338
339 #define PCI_ROOT_HID_STRING             "PNP0A03"
340 #define PCI_EXPRESS_ROOT_HID_STRING     "PNP0A08"
341
342 /* PM Timer ticks per second (HZ) */
343
344 #define PM_TIMER_FREQUENCY              3579545
345
346 /*******************************************************************************
347  *
348  * Independent types
349  *
350  ******************************************************************************/
351
352 /* Logical defines and NULL */
353
354 #ifdef FALSE
355 #undef FALSE
356 #endif
357 #define FALSE                           (1 == 0)
358
359 #ifdef TRUE
360 #undef TRUE
361 #endif
362 #define TRUE                            (1 == 1)
363
364 #ifndef NULL
365 #define NULL                            (void *) 0
366 #endif
367
368 /*
369  * Miscellaneous types
370  */
371 typedef u32 acpi_status;        /* All ACPI Exceptions */
372 typedef u32 acpi_name;          /* 4-byte ACPI name */
373 typedef char *acpi_string;      /* Null terminated ASCII string */
374 typedef void *acpi_handle;      /* Actually a ptr to a NS Node */
375
376 /* Owner IDs are used to track namespace nodes for selective deletion */
377
378 typedef u8 acpi_owner_id;
379 #define ACPI_OWNER_ID_MAX               0xFF
380
381 #define ACPI_INTEGER_BIT_SIZE           64
382 #define ACPI_MAX_DECIMAL_DIGITS         20      /* 2^64 = 18,446,744,073,709,551,616 */
383
384 #if ACPI_MACHINE_WIDTH == 64
385 #define ACPI_USE_NATIVE_DIVIDE  /* Use compiler native 64-bit divide */
386 #endif
387
388 #define ACPI_MAX64_DECIMAL_DIGITS       20
389 #define ACPI_MAX32_DECIMAL_DIGITS       10
390 #define ACPI_MAX16_DECIMAL_DIGITS        5
391 #define ACPI_MAX8_DECIMAL_DIGITS         3
392
393 /* PM Timer ticks per second (HZ) */
394
395 #define PM_TIMER_FREQUENCY  3579545
396
397 /*
398  * Constants with special meanings
399  */
400 #define ACPI_ROOT_OBJECT                ACPI_ADD_PTR (acpi_handle, NULL, ACPI_MAX_PTR)
401 #define ACPI_WAIT_FOREVER               0xFFFF  /* u16, as per ACPI spec */
402 #define ACPI_DO_NOT_WAIT                0
403
404 /*
405  * Obsolete: Acpi integer width. In ACPI version 1 (1996), integers are 32 bits.
406  * In ACPI version 2 (2000) and later, integers are 64 bits. Note that this
407  * pertains to the ACPI integer type only, not to other integers used in the
408  * implementation of the ACPICA subsystem.
409  *
410  * 01/2010: This type is obsolete and has been removed from the entire ACPICA
411  * code base. It remains here for compatibility with device drivers that use
412  * the type. However, it will be removed in the future.
413  */
414 typedef u64 acpi_integer;
415 #define ACPI_INTEGER_MAX                ACPI_UINT64_MAX
416
417 /*******************************************************************************
418  *
419  * Commonly used macros
420  *
421  ******************************************************************************/
422
423 /* Data manipulation */
424
425 #define ACPI_LOBYTE(integer)            ((u8)   (u16)(integer))
426 #define ACPI_HIBYTE(integer)            ((u8) (((u16)(integer)) >> 8))
427 #define ACPI_LOWORD(integer)            ((u16)  (u32)(integer))
428 #define ACPI_HIWORD(integer)            ((u16)(((u32)(integer)) >> 16))
429 #define ACPI_LODWORD(integer64)         ((u32)  (u64)(integer64))
430 #define ACPI_HIDWORD(integer64)         ((u32)(((u64)(integer64)) >> 32))
431
432 #define ACPI_SET_BIT(target,bit)        ((target) |= (bit))
433 #define ACPI_CLEAR_BIT(target,bit)      ((target) &= ~(bit))
434 #define ACPI_MIN(a,b)                   (((a)<(b))?(a):(b))
435 #define ACPI_MAX(a,b)                   (((a)>(b))?(a):(b))
436
437 /* Size calculation */
438
439 #define ACPI_ARRAY_LENGTH(x)            (sizeof(x) / sizeof((x)[0]))
440
441 /* Pointer manipulation */
442
443 #define ACPI_CAST_PTR(t, p)             ((t *) (acpi_uintptr_t) (p))
444 #define ACPI_CAST_INDIRECT_PTR(t, p)    ((t **) (acpi_uintptr_t) (p))
445 #define ACPI_ADD_PTR(t, a, b)           ACPI_CAST_PTR (t, (ACPI_CAST_PTR (u8, (a)) + (acpi_size)(b)))
446 #define ACPI_PTR_DIFF(a, b)             (acpi_size) (ACPI_CAST_PTR (u8, (a)) - ACPI_CAST_PTR (u8, (b)))
447
448 /* Pointer/Integer type conversions */
449
450 #define ACPI_TO_POINTER(i)              ACPI_ADD_PTR (void, (void *) NULL,(acpi_size) i)
451 #define ACPI_TO_INTEGER(p)              ACPI_PTR_DIFF (p, (void *) NULL)
452 #define ACPI_OFFSET(d, f)               (acpi_size) ACPI_PTR_DIFF (&(((d *)0)->f), (void *) NULL)
453 #define ACPI_PHYSADDR_TO_PTR(i)         ACPI_TO_POINTER(i)
454 #define ACPI_PTR_TO_PHYSADDR(i)         ACPI_TO_INTEGER(i)
455
456 /* Optimizations for 4-character (32-bit) acpi_name manipulation */
457
458 #ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED
459 #define ACPI_COMPARE_NAME(a,b)          (*ACPI_CAST_PTR (u32, (a)) == *ACPI_CAST_PTR (u32, (b)))
460 #define ACPI_MOVE_NAME(dest,src)        (*ACPI_CAST_PTR (u32, (dest)) = *ACPI_CAST_PTR (u32, (src)))
461 #else
462 #define ACPI_COMPARE_NAME(a,b)          (!ACPI_STRNCMP (ACPI_CAST_PTR (char, (a)), ACPI_CAST_PTR (char, (b)), ACPI_NAME_SIZE))
463 #define ACPI_MOVE_NAME(dest,src)        (ACPI_STRNCPY (ACPI_CAST_PTR (char, (dest)), ACPI_CAST_PTR (char, (src)), ACPI_NAME_SIZE))
464 #endif
465
466 /*******************************************************************************
467  *
468  * Miscellaneous constants
469  *
470  ******************************************************************************/
471
472 /*
473  * Initialization sequence
474  */
475 #define ACPI_FULL_INITIALIZATION        0x00
476 #define ACPI_NO_ADDRESS_SPACE_INIT      0x01
477 #define ACPI_NO_HARDWARE_INIT           0x02
478 #define ACPI_NO_EVENT_INIT              0x04
479 #define ACPI_NO_HANDLER_INIT            0x08
480 #define ACPI_NO_ACPI_ENABLE             0x10
481 #define ACPI_NO_DEVICE_INIT             0x20
482 #define ACPI_NO_OBJECT_INIT             0x40
483
484 /*
485  * Initialization state
486  */
487 #define ACPI_SUBSYSTEM_INITIALIZE       0x01
488 #define ACPI_INITIALIZED_OK             0x02
489
490 /*
491  * Power state values
492  */
493 #define ACPI_STATE_UNKNOWN              (u8) 0xFF
494
495 #define ACPI_STATE_S0                   (u8) 0
496 #define ACPI_STATE_S1                   (u8) 1
497 #define ACPI_STATE_S2                   (u8) 2
498 #define ACPI_STATE_S3                   (u8) 3
499 #define ACPI_STATE_S4                   (u8) 4
500 #define ACPI_STATE_S5                   (u8) 5
501 #define ACPI_S_STATES_MAX               ACPI_STATE_S5
502 #define ACPI_S_STATE_COUNT              6
503
504 #define ACPI_STATE_D0                   (u8) 0
505 #define ACPI_STATE_D1                   (u8) 1
506 #define ACPI_STATE_D2                   (u8) 2
507 #define ACPI_STATE_D3_HOT               (u8) 3
508 #define ACPI_STATE_D3                   (u8) 4
509 #define ACPI_STATE_D3_COLD              ACPI_STATE_D3
510 #define ACPI_D_STATES_MAX               ACPI_STATE_D3
511 #define ACPI_D_STATE_COUNT              5
512
513 #define ACPI_STATE_C0                   (u8) 0
514 #define ACPI_STATE_C1                   (u8) 1
515 #define ACPI_STATE_C2                   (u8) 2
516 #define ACPI_STATE_C3                   (u8) 3
517 #define ACPI_C_STATES_MAX               ACPI_STATE_C3
518 #define ACPI_C_STATE_COUNT              4
519
520 /*
521  * Sleep type invalid value
522  */
523 #define ACPI_SLEEP_TYPE_MAX             0x7
524 #define ACPI_SLEEP_TYPE_INVALID         0xFF
525
526 /*
527  * Standard notify values
528  */
529 #define ACPI_NOTIFY_BUS_CHECK           (u8) 0x00
530 #define ACPI_NOTIFY_DEVICE_CHECK        (u8) 0x01
531 #define ACPI_NOTIFY_DEVICE_WAKE         (u8) 0x02
532 #define ACPI_NOTIFY_EJECT_REQUEST       (u8) 0x03
533 #define ACPI_NOTIFY_DEVICE_CHECK_LIGHT  (u8) 0x04
534 #define ACPI_NOTIFY_FREQUENCY_MISMATCH  (u8) 0x05
535 #define ACPI_NOTIFY_BUS_MODE_MISMATCH   (u8) 0x06
536 #define ACPI_NOTIFY_POWER_FAULT         (u8) 0x07
537 #define ACPI_NOTIFY_CAPABILITIES_CHECK  (u8) 0x08
538 #define ACPI_NOTIFY_DEVICE_PLD_CHECK    (u8) 0x09
539 #define ACPI_NOTIFY_RESERVED            (u8) 0x0A
540 #define ACPI_NOTIFY_LOCALITY_UPDATE     (u8) 0x0B
541 #define ACPI_NOTIFY_SHUTDOWN_REQUEST    (u8) 0x0C
542
543 #define ACPI_NOTIFY_MAX                 0x0C
544
545 /*
546  * Types associated with ACPI names and objects. The first group of
547  * values (up to ACPI_TYPE_EXTERNAL_MAX) correspond to the definition
548  * of the ACPI object_type() operator (See the ACPI Spec). Therefore,
549  * only add to the first group if the spec changes.
550  *
551  * NOTE: Types must be kept in sync with the global acpi_ns_properties
552  * and acpi_ns_type_names arrays.
553  */
554 typedef u32 acpi_object_type;
555
556 #define ACPI_TYPE_ANY                   0x00
557 #define ACPI_TYPE_INTEGER               0x01    /* Byte/Word/Dword/Zero/One/Ones */
558 #define ACPI_TYPE_STRING                0x02
559 #define ACPI_TYPE_BUFFER                0x03
560 #define ACPI_TYPE_PACKAGE               0x04    /* byte_const, multiple data_term/Constant/super_name */
561 #define ACPI_TYPE_FIELD_UNIT            0x05
562 #define ACPI_TYPE_DEVICE                0x06    /* Name, multiple Node */
563 #define ACPI_TYPE_EVENT                 0x07
564 #define ACPI_TYPE_METHOD                0x08    /* Name, byte_const, multiple Code */
565 #define ACPI_TYPE_MUTEX                 0x09
566 #define ACPI_TYPE_REGION                0x0A
567 #define ACPI_TYPE_POWER                 0x0B    /* Name,byte_const,word_const,multi Node */
568 #define ACPI_TYPE_PROCESSOR             0x0C    /* Name,byte_const,Dword_const,byte_const,multi nm_o */
569 #define ACPI_TYPE_THERMAL               0x0D    /* Name, multiple Node */
570 #define ACPI_TYPE_BUFFER_FIELD          0x0E
571 #define ACPI_TYPE_DDB_HANDLE            0x0F
572 #define ACPI_TYPE_DEBUG_OBJECT          0x10
573
574 #define ACPI_TYPE_EXTERNAL_MAX          0x10
575
576 /*
577  * These are object types that do not map directly to the ACPI
578  * object_type() operator. They are used for various internal purposes only.
579  * If new predefined ACPI_TYPEs are added (via the ACPI specification), these
580  * internal types must move upwards. (There is code that depends on these
581  * values being contiguous with the external types above.)
582  */
583 #define ACPI_TYPE_LOCAL_REGION_FIELD    0x11
584 #define ACPI_TYPE_LOCAL_BANK_FIELD      0x12
585 #define ACPI_TYPE_LOCAL_INDEX_FIELD     0x13
586 #define ACPI_TYPE_LOCAL_REFERENCE       0x14    /* Arg#, Local#, Name, Debug, ref_of, Index */
587 #define ACPI_TYPE_LOCAL_ALIAS           0x15
588 #define ACPI_TYPE_LOCAL_METHOD_ALIAS    0x16
589 #define ACPI_TYPE_LOCAL_NOTIFY          0x17
590 #define ACPI_TYPE_LOCAL_ADDRESS_HANDLER 0x18
591 #define ACPI_TYPE_LOCAL_RESOURCE        0x19
592 #define ACPI_TYPE_LOCAL_RESOURCE_FIELD  0x1A
593 #define ACPI_TYPE_LOCAL_SCOPE           0x1B    /* 1 Name, multiple object_list Nodes */
594
595 #define ACPI_TYPE_NS_NODE_MAX           0x1B    /* Last typecode used within a NS Node */
596
597 /*
598  * These are special object types that never appear in
599  * a Namespace node, only in an object of union acpi_operand_object
600  */
601 #define ACPI_TYPE_LOCAL_EXTRA           0x1C
602 #define ACPI_TYPE_LOCAL_DATA            0x1D
603
604 #define ACPI_TYPE_LOCAL_MAX             0x1D
605
606 /* All types above here are invalid */
607
608 #define ACPI_TYPE_INVALID               0x1E
609 #define ACPI_TYPE_NOT_FOUND             0xFF
610
611 #define ACPI_NUM_NS_TYPES               (ACPI_TYPE_INVALID + 1)
612
613 /*
614  * All I/O
615  */
616 #define ACPI_READ                       0
617 #define ACPI_WRITE                      1
618 #define ACPI_IO_MASK                    1
619
620 /*
621  * Event Types: Fixed & General Purpose
622  */
623 typedef u32 acpi_event_type;
624
625 /*
626  * Fixed events
627  */
628 #define ACPI_EVENT_PMTIMER              0
629 #define ACPI_EVENT_GLOBAL               1
630 #define ACPI_EVENT_POWER_BUTTON         2
631 #define ACPI_EVENT_SLEEP_BUTTON         3
632 #define ACPI_EVENT_RTC                  4
633 #define ACPI_EVENT_MAX                  4
634 #define ACPI_NUM_FIXED_EVENTS           ACPI_EVENT_MAX + 1
635
636 /*
637  * Event status - Per event
638  * -------------
639  * The encoding of acpi_event_status is illustrated below.
640  * Note that a set bit (1) indicates the property is TRUE
641  * (e.g. if bit 0 is set then the event is enabled).
642  * +-------------+-+-+-+
643  * |   Bits 31:3 |2|1|0|
644  * +-------------+-+-+-+
645  *          |     | | |
646  *          |     | | +- Enabled?
647  *          |     | +--- Enabled for wake?
648  *          |     +----- Set?
649  *          +----------- <Reserved>
650  */
651 typedef u32 acpi_event_status;
652
653 #define ACPI_EVENT_FLAG_DISABLED        (acpi_event_status) 0x00
654 #define ACPI_EVENT_FLAG_ENABLED         (acpi_event_status) 0x01
655 #define ACPI_EVENT_FLAG_WAKE_ENABLED    (acpi_event_status) 0x02
656 #define ACPI_EVENT_FLAG_SET             (acpi_event_status) 0x04
657 #define ACPI_EVENT_FLAG_HANDLE          (acpi_event_status) 0x08
658
659 /*
660  * General Purpose Events (GPE)
661  */
662 #define ACPI_GPE_INVALID                0xFF
663 #define ACPI_GPE_MAX                    0xFF
664 #define ACPI_NUM_GPE                    256
665
666 /* Actions for acpi_set_gpe, acpi_gpe_wakeup, acpi_hw_low_set_gpe */
667
668 #define ACPI_GPE_ENABLE                 0
669 #define ACPI_GPE_DISABLE                1
670 #define ACPI_GPE_CONDITIONAL_ENABLE     2
671
672 /*
673  * GPE info flags - Per GPE
674  * +-------+-+-+---+
675  * |  7:4  |3|2|1:0|
676  * +-------+-+-+---+
677  *     |    | |  |
678  *     |    | |  +-- Type of dispatch:to method, handler, notify, or none
679  *     |    | +----- Interrupt type: edge or level triggered
680  *     |    +------- Is a Wake GPE
681  *     +------------ <Reserved>
682  */
683 #define ACPI_GPE_DISPATCH_NONE          (u8) 0x00
684 #define ACPI_GPE_DISPATCH_METHOD        (u8) 0x01
685 #define ACPI_GPE_DISPATCH_HANDLER       (u8) 0x02
686 #define ACPI_GPE_DISPATCH_NOTIFY        (u8) 0x03
687 #define ACPI_GPE_DISPATCH_MASK          (u8) 0x03
688
689 #define ACPI_GPE_LEVEL_TRIGGERED        (u8) 0x04
690 #define ACPI_GPE_EDGE_TRIGGERED         (u8) 0x00
691 #define ACPI_GPE_XRUPT_TYPE_MASK        (u8) 0x04
692
693 #define ACPI_GPE_CAN_WAKE               (u8) 0x08
694
695 /*
696  * Flags for GPE and Lock interfaces
697  */
698 #define ACPI_NOT_ISR                    0x1
699 #define ACPI_ISR                        0x0
700
701 /* Notify types */
702
703 #define ACPI_SYSTEM_NOTIFY              0x1
704 #define ACPI_DEVICE_NOTIFY              0x2
705 #define ACPI_ALL_NOTIFY                 (ACPI_SYSTEM_NOTIFY | ACPI_DEVICE_NOTIFY)
706 #define ACPI_MAX_NOTIFY_HANDLER_TYPE    0x3
707 #define ACPI_NUM_NOTIFY_TYPES           2
708
709 #define ACPI_MAX_SYS_NOTIFY             0x7F
710 #define ACPI_MAX_DEVICE_SPECIFIC_NOTIFY 0xBF
711
712 #define ACPI_SYSTEM_HANDLER_LIST        0       /* Used as index, must be SYSTEM_NOTIFY -1 */
713 #define ACPI_DEVICE_HANDLER_LIST        1       /* Used as index, must be DEVICE_NOTIFY -1 */
714
715 /* Address Space (Operation Region) Types */
716
717 typedef u8 acpi_adr_space_type;
718
719 #define ACPI_ADR_SPACE_SYSTEM_MEMORY    (acpi_adr_space_type) 0
720 #define ACPI_ADR_SPACE_SYSTEM_IO        (acpi_adr_space_type) 1
721 #define ACPI_ADR_SPACE_PCI_CONFIG       (acpi_adr_space_type) 2
722 #define ACPI_ADR_SPACE_EC               (acpi_adr_space_type) 3
723 #define ACPI_ADR_SPACE_SMBUS            (acpi_adr_space_type) 4
724 #define ACPI_ADR_SPACE_CMOS             (acpi_adr_space_type) 5
725 #define ACPI_ADR_SPACE_PCI_BAR_TARGET   (acpi_adr_space_type) 6
726 #define ACPI_ADR_SPACE_IPMI             (acpi_adr_space_type) 7
727 #define ACPI_ADR_SPACE_GPIO             (acpi_adr_space_type) 8
728 #define ACPI_ADR_SPACE_GSBUS            (acpi_adr_space_type) 9
729 #define ACPI_ADR_SPACE_PLATFORM_COMM    (acpi_adr_space_type) 10
730
731 #define ACPI_NUM_PREDEFINED_REGIONS     11
732
733 /*
734  * Special Address Spaces
735  *
736  * Note: A Data Table region is a special type of operation region
737  * that has its own AML opcode. However, internally, the AML
738  * interpreter simply creates an operation region with an an address
739  * space type of ACPI_ADR_SPACE_DATA_TABLE.
740  */
741 #define ACPI_ADR_SPACE_DATA_TABLE       (acpi_adr_space_type) 0x7E      /* Internal to ACPICA only */
742 #define ACPI_ADR_SPACE_FIXED_HARDWARE   (acpi_adr_space_type) 0x7F
743
744 /* Values for _REG connection code */
745
746 #define ACPI_REG_DISCONNECT             0
747 #define ACPI_REG_CONNECT                1
748
749 /*
750  * bit_register IDs
751  *
752  * These values are intended to be used by the hardware interfaces
753  * and are mapped to individual bitfields defined within the ACPI
754  * registers. See the acpi_gbl_bit_register_info global table in utglobal.c
755  * for this mapping.
756  */
757
758 /* PM1 Status register */
759
760 #define ACPI_BITREG_TIMER_STATUS                0x00
761 #define ACPI_BITREG_BUS_MASTER_STATUS           0x01
762 #define ACPI_BITREG_GLOBAL_LOCK_STATUS          0x02
763 #define ACPI_BITREG_POWER_BUTTON_STATUS         0x03
764 #define ACPI_BITREG_SLEEP_BUTTON_STATUS         0x04
765 #define ACPI_BITREG_RT_CLOCK_STATUS             0x05
766 #define ACPI_BITREG_WAKE_STATUS                 0x06
767 #define ACPI_BITREG_PCIEXP_WAKE_STATUS          0x07
768
769 /* PM1 Enable register */
770
771 #define ACPI_BITREG_TIMER_ENABLE                0x08
772 #define ACPI_BITREG_GLOBAL_LOCK_ENABLE          0x09
773 #define ACPI_BITREG_POWER_BUTTON_ENABLE         0x0A
774 #define ACPI_BITREG_SLEEP_BUTTON_ENABLE         0x0B
775 #define ACPI_BITREG_RT_CLOCK_ENABLE             0x0C
776 #define ACPI_BITREG_PCIEXP_WAKE_DISABLE         0x0D
777
778 /* PM1 Control register */
779
780 #define ACPI_BITREG_SCI_ENABLE                  0x0E
781 #define ACPI_BITREG_BUS_MASTER_RLD              0x0F
782 #define ACPI_BITREG_GLOBAL_LOCK_RELEASE         0x10
783 #define ACPI_BITREG_SLEEP_TYPE                  0x11
784 #define ACPI_BITREG_SLEEP_ENABLE                0x12
785
786 /* PM2 Control register */
787
788 #define ACPI_BITREG_ARB_DISABLE                 0x13
789
790 #define ACPI_BITREG_MAX                         0x13
791 #define ACPI_NUM_BITREG                         ACPI_BITREG_MAX + 1
792
793 /* Status register values. A 1 clears a status bit. 0 = no effect */
794
795 #define ACPI_CLEAR_STATUS                       1
796
797 /* Enable and Control register values */
798
799 #define ACPI_ENABLE_EVENT                       1
800 #define ACPI_DISABLE_EVENT                      0
801
802 /* Sleep function dispatch */
803
804 typedef acpi_status(*acpi_sleep_function) (u8 sleep_state);
805
806 struct acpi_sleep_functions {
807         acpi_sleep_function legacy_function;
808         acpi_sleep_function extended_function;
809 };
810
811 /*
812  * External ACPI object definition
813  */
814
815 /*
816  * Note: Type == ACPI_TYPE_ANY (0) is used to indicate a NULL package element
817  * or an unresolved named reference.
818  */
819 union acpi_object {
820         acpi_object_type type;  /* See definition of acpi_ns_type for values */
821         struct {
822                 acpi_object_type type;  /* ACPI_TYPE_INTEGER */
823                 u64 value;      /* The actual number */
824         } integer;
825
826         struct {
827                 acpi_object_type type;  /* ACPI_TYPE_STRING */
828                 u32 length;     /* # of bytes in string, excluding trailing null */
829                 char *pointer;  /* points to the string value */
830         } string;
831
832         struct {
833                 acpi_object_type type;  /* ACPI_TYPE_BUFFER */
834                 u32 length;     /* # of bytes in buffer */
835                 u8 *pointer;    /* points to the buffer */
836         } buffer;
837
838         struct {
839                 acpi_object_type type;  /* ACPI_TYPE_PACKAGE */
840                 u32 count;      /* # of elements in package */
841                 union acpi_object *elements;    /* Pointer to an array of ACPI_OBJECTs */
842         } package;
843
844         struct {
845                 acpi_object_type type;  /* ACPI_TYPE_LOCAL_REFERENCE */
846                 acpi_object_type actual_type;   /* Type associated with the Handle */
847                 acpi_handle handle;     /* object reference */
848         } reference;
849
850         struct {
851                 acpi_object_type type;  /* ACPI_TYPE_PROCESSOR */
852                 u32 proc_id;
853                 acpi_io_address pblk_address;
854                 u32 pblk_length;
855         } processor;
856
857         struct {
858                 acpi_object_type type;  /* ACPI_TYPE_POWER */
859                 u32 system_level;
860                 u32 resource_order;
861         } power_resource;
862 };
863
864 /*
865  * List of objects, used as a parameter list for control method evaluation
866  */
867 struct acpi_object_list {
868         u32 count;
869         union acpi_object *pointer;
870 };
871
872 /*
873  * Miscellaneous common Data Structures used by the interfaces
874  */
875 #define ACPI_NO_BUFFER              0
876 #define ACPI_ALLOCATE_BUFFER        (acpi_size) (-1)
877 #define ACPI_ALLOCATE_LOCAL_BUFFER  (acpi_size) (-2)
878
879 struct acpi_buffer {
880         acpi_size length;       /* Length in bytes of the buffer */
881         void *pointer;          /* pointer to buffer */
882 };
883
884 /*
885  * name_type for acpi_get_name
886  */
887 #define ACPI_FULL_PATHNAME              0
888 #define ACPI_SINGLE_NAME                1
889 #define ACPI_NAME_TYPE_MAX              1
890
891 /*
892  * Predefined Namespace items
893  */
894 struct acpi_predefined_names {
895         char *name;
896         u8 type;
897         char *val;
898 };
899
900 /*
901  * Structure and flags for acpi_get_system_info
902  */
903 #define ACPI_SYS_MODE_UNKNOWN           0x0000
904 #define ACPI_SYS_MODE_ACPI              0x0001
905 #define ACPI_SYS_MODE_LEGACY            0x0002
906 #define ACPI_SYS_MODES_MASK             0x0003
907
908 /*
909  * System info returned by acpi_get_system_info()
910  */
911 struct acpi_system_info {
912         u32 acpi_ca_version;
913         u32 flags;
914         u32 timer_resolution;
915         u32 reserved1;
916         u32 reserved2;
917         u32 debug_level;
918         u32 debug_layer;
919 };
920
921 /* Table Event Types */
922
923 #define ACPI_TABLE_EVENT_LOAD           0x0
924 #define ACPI_TABLE_EVENT_UNLOAD         0x1
925 #define ACPI_NUM_TABLE_EVENTS           2
926
927 /*
928  * Types specific to the OS service interfaces
929  */
930 typedef u32
931  (ACPI_SYSTEM_XFACE * acpi_osd_handler) (void *context);
932
933 typedef void
934  (ACPI_SYSTEM_XFACE * acpi_osd_exec_callback) (void *context);
935
936 /*
937  * Various handlers and callback procedures
938  */
939 typedef
940 void (*acpi_gbl_event_handler) (u32 event_type,
941                                acpi_handle device,
942                                u32 event_number, void *context);
943
944 #define ACPI_EVENT_TYPE_GPE         0
945 #define ACPI_EVENT_TYPE_FIXED       1
946
947 typedef
948 u32(*acpi_event_handler) (void *context);
949
950 typedef
951 u32 (*acpi_gpe_handler) (acpi_handle gpe_device, u32 gpe_number, void *context);
952
953 typedef
954 void (*acpi_notify_handler) (acpi_handle device, u32 value, void *context);
955
956 typedef
957 void (*acpi_object_handler) (acpi_handle object, void *data);
958
959 typedef acpi_status(*acpi_init_handler) (acpi_handle object, u32 function);
960
961 #define ACPI_INIT_DEVICE_INI        1
962
963 typedef
964 acpi_status(*acpi_exception_handler) (acpi_status aml_status,
965                                       acpi_name name,
966                                       u16 opcode,
967                                       u32 aml_offset, void *context);
968
969 /* Table Event handler (Load, load_table, etc.) and types */
970
971 typedef
972 acpi_status(*acpi_tbl_handler) (u32 event, void *table, void *context);
973
974 #define ACPI_TABLE_LOAD             0x0
975 #define ACPI_TABLE_UNLOAD           0x1
976 #define ACPI_NUM_TABLE_EVENTS       2
977
978 /* Address Spaces (For Operation Regions) */
979
980 typedef
981 acpi_status(*acpi_adr_space_handler) (u32 function,
982                                       acpi_physical_address address,
983                                       u32 bit_width,
984                                       u64 *value,
985                                       void *handler_context,
986                                       void *region_context);
987
988 #define ACPI_DEFAULT_HANDLER            NULL
989
990 /* Special Context data for generic_serial_bus/general_purpose_io (ACPI 5.0) */
991
992 struct acpi_connection_info {
993         u8 *connection;
994         u16 length;
995         u8 access_length;
996 };
997
998 typedef
999 acpi_status(*acpi_adr_space_setup) (acpi_handle region_handle,
1000                                     u32 function,
1001                                     void *handler_context,
1002                                     void **region_context);
1003
1004 #define ACPI_REGION_ACTIVATE    0
1005 #define ACPI_REGION_DEACTIVATE  1
1006
1007 typedef
1008 acpi_status(*acpi_walk_callback) (acpi_handle object,
1009                                   u32 nesting_level,
1010                                   void *context, void **return_value);
1011
1012 typedef
1013 u32 (*acpi_interface_handler) (acpi_string interface_name, u32 supported);
1014
1015 /* Interrupt handler return values */
1016
1017 #define ACPI_INTERRUPT_NOT_HANDLED      0x00
1018 #define ACPI_INTERRUPT_HANDLED          0x01
1019
1020 /* GPE handler return values */
1021
1022 #define ACPI_REENABLE_GPE               0x80
1023
1024 /* Length of 32-bit EISAID values when converted back to a string */
1025
1026 #define ACPI_EISAID_STRING_SIZE         8       /* Includes null terminator */
1027
1028 /* Length of UUID (string) values */
1029
1030 #define ACPI_UUID_LENGTH                16
1031
1032 /* Structures used for device/processor HID, UID, CID, and SUB */
1033
1034 struct acpi_pnp_device_id {
1035         u32 length;             /* Length of string + null */
1036         char *string;
1037 };
1038
1039 struct acpi_pnp_device_id_list {
1040         u32 count;              /* Number of IDs in Ids array */
1041         u32 list_size;          /* Size of list, including ID strings */
1042         struct acpi_pnp_device_id ids[1];       /* ID array */
1043 };
1044
1045 /*
1046  * Structure returned from acpi_get_object_info.
1047  * Optimized for both 32- and 64-bit builds
1048  */
1049 struct acpi_device_info {
1050         u32 info_size;          /* Size of info, including ID strings */
1051         u32 name;               /* ACPI object Name */
1052         acpi_object_type type;  /* ACPI object Type */
1053         u8 param_count;         /* If a method, required parameter count */
1054         u8 valid;               /* Indicates which optional fields are valid */
1055         u8 flags;               /* Miscellaneous info */
1056         u8 highest_dstates[4];  /* _sx_d values: 0xFF indicates not valid */
1057         u8 lowest_dstates[5];   /* _sx_w values: 0xFF indicates not valid */
1058         u32 current_status;     /* _STA value */
1059         u64 address;    /* _ADR value */
1060         struct acpi_pnp_device_id hardware_id;  /* _HID value */
1061         struct acpi_pnp_device_id unique_id;    /* _UID value */
1062         struct acpi_pnp_device_id subsystem_id; /* _SUB value */
1063         struct acpi_pnp_device_id_list compatible_id_list;      /* _CID list <must be last> */
1064 };
1065
1066 /* Values for Flags field above (acpi_get_object_info) */
1067
1068 #define ACPI_PCI_ROOT_BRIDGE            0x01
1069
1070 /* Flags for Valid field above (acpi_get_object_info) */
1071
1072 #define ACPI_VALID_STA                  0x01
1073 #define ACPI_VALID_ADR                  0x02
1074 #define ACPI_VALID_HID                  0x04
1075 #define ACPI_VALID_UID                  0x08
1076 #define ACPI_VALID_SUB                  0x10
1077 #define ACPI_VALID_CID                  0x20
1078 #define ACPI_VALID_SXDS                 0x40
1079 #define ACPI_VALID_SXWS                 0x80
1080
1081 /* Flags for _STA return value (current_status above) */
1082
1083 #define ACPI_STA_DEVICE_PRESENT         0x01
1084 #define ACPI_STA_DEVICE_ENABLED         0x02
1085 #define ACPI_STA_DEVICE_UI              0x04
1086 #define ACPI_STA_DEVICE_FUNCTIONING     0x08
1087 #define ACPI_STA_DEVICE_OK              0x08    /* Synonym */
1088 #define ACPI_STA_BATTERY_PRESENT        0x10
1089
1090 /* Context structs for address space handlers */
1091
1092 struct acpi_pci_id {
1093         u16 segment;
1094         u16 bus;
1095         u16 device;
1096         u16 function;
1097 };
1098
1099 struct acpi_mem_space_context {
1100         u32 length;
1101         acpi_physical_address address;
1102         acpi_physical_address mapped_physical_address;
1103         u8 *mapped_logical_address;
1104         acpi_size mapped_length;
1105 };
1106
1107 /*
1108  * struct acpi_memory_list is used only if the ACPICA local cache is enabled
1109  */
1110 struct acpi_memory_list {
1111         char *list_name;
1112         void *list_head;
1113         u16 object_size;
1114         u16 max_depth;
1115         u16 current_depth;
1116         u16 link_offset;
1117
1118 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
1119
1120         /* Statistics for debug memory tracking only */
1121
1122         u32 total_allocated;
1123         u32 total_freed;
1124         u32 max_occupied;
1125         u32 total_size;
1126         u32 current_total_size;
1127         u32 requests;
1128         u32 hits;
1129 #endif
1130 };
1131
1132 #endif                          /* __ACTYPES_H__ */