Debian Codegraph @

source/include/actypes.h

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