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