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