actypes.h revision 216471
1142403Snectar/******************************************************************************
2233294Sstas *
3142403Snectar * Name: actypes.h - Common data types for the entire ACPI subsystem
4233294Sstas *
5142403Snectar *****************************************************************************/
6233294Sstas
7233294Sstas/******************************************************************************
8233294Sstas *
9142403Snectar * 1. Copyright Notice
10233294Sstas *
11233294Sstas * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp.
12233294Sstas * All rights reserved.
13142403Snectar *
14233294Sstas * 2. License
15233294Sstas *
16233294Sstas * 2.1. This is your license from Intel Corp. under its intellectual property
17233294Sstas * rights.  You may have additional license terms from the party that provided
18142403Snectar * you this software, covering your right to use that party's intellectual
19233294Sstas * property rights.
20233294Sstas *
21233294Sstas * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22142403Snectar * copy of the source code appearing in this file ("Covered Code") an
23233294Sstas * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24178825Sdfr * base code distributed originally by Intel ("Original Intel Code") to copy,
25233294Sstas * make derivatives, distribute, use and display any portion of the Covered
26178825Sdfr * Code in any form, with the right to sublicense such rights; and
27233294Sstas *
28178825Sdfr * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29233294Sstas * license (with the right to sublicense), under only those claims of Intel
30178825Sdfr * patents that are infringed by the Original Intel Code, to make, use, sell,
31233294Sstas * offer to sell, and import the Covered Code and derivative works thereof
32178825Sdfr * solely to the minimum extent necessary to exercise the above copyright
33233294Sstas * license, and in no event shall the patent license extend to any additions
34178825Sdfr * to or modifications of the Original Intel Code.  No other license or right
35233294Sstas * is granted directly or by implication, estoppel or otherwise;
36178825Sdfr *
37233294Sstas * The above copyright and patent license is granted only if the following
38233294Sstas * conditions are met:
39178825Sdfr *
40233294Sstas * 3. Conditions
41178825Sdfr *
42233294Sstas * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43178825Sdfr * Redistribution of source code of any substantial portion of the Covered
44233294Sstas * Code or modification with rights to further distribute source must include
45178825Sdfr * the above Copyright Notice, the above License, this list of Conditions,
46233294Sstas * and the following Disclaimer and Export Compliance provision.  In addition,
47142403Snectar * Licensee must cause all Covered Code to which Licensee contributes to
48233294Sstas * contain a file documenting the changes Licensee made to create that Covered
49233294Sstas * Code and the date of any change.  Licensee must include in that file the
50178825Sdfr * documentation of any changes made by any predecessor Licensee.  Licensee
51233294Sstas * must include a prominent statement that the modification is derived,
52233294Sstas * directly or indirectly, from Original Intel Code.
53178825Sdfr *
54233294Sstas * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55142403Snectar * Redistribution of source code of any substantial portion of the Covered
56233294Sstas * Code or modification without rights to further distribute source must
57178825Sdfr * include the following Disclaimer and Export Compliance provision in the
58233294Sstas * documentation and/or other materials provided with distribution.  In
59178825Sdfr * addition, Licensee may not authorize further sublicense of source of any
60233294Sstas * portion of the Covered Code, and must include terms to the effect that the
61142403Snectar * license from Licensee to its licensee is limited to the intellectual
62233294Sstas * property embodied in the software Licensee provides to its licensee, and
63142403Snectar * not to intellectual property embodied in modifications its licensee may
64233294Sstas * make.
65233294Sstas *
66142403Snectar * 3.3. Redistribution of Executable. Redistribution in executable form of any
67233294Sstas * substantial portion of the Covered Code or modification must reproduce the
68178825Sdfr * above Copyright Notice, and the following Disclaimer and Export Compliance
69233294Sstas * provision in the documentation and/or other materials provided with the
70178825Sdfr * distribution.
71233294Sstas *
72178825Sdfr * 3.4. Intel retains all right, title, and interest in and to the Original
73233294Sstas * Intel Code.
74127808Snectar *
75233294Sstas * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76127808Snectar * Intel shall be used in advertising or otherwise to promote the sale, use or
77233294Sstas * other dealings in products derived from or relating to the Covered Code
78127808Snectar * without prior written authorization from Intel.
79233294Sstas *
80178825Sdfr * 4. Disclaimer and Export Compliance
81233294Sstas *
82178825Sdfr * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83233294Sstas * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84178825Sdfr * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
85233294Sstas * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
86178825Sdfr * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
87233294Sstas * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88178825Sdfr * PARTICULAR PURPOSE.
89233294Sstas *
90178825Sdfr * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91233294Sstas * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92127808Snectar * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93233294Sstas * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94127808Snectar * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95233294Sstas * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
96233294Sstas * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97127808Snectar * LIMITED REMEDY.
98233294Sstas *
99127808Snectar * 4.3. Licensee shall not export, either directly or indirectly, any of this
100233294Sstas * software or system incorporating such software without first obtaining any
101233294Sstas * required license or other approval from the U. S. Department of Commerce or
102178825Sdfr * any other agency or department of the United States Government.  In the
103233294Sstas * event Licensee exports any such software from the United States or
104178825Sdfr * re-exports any such software from a foreign destination, Licensee shall
105233294Sstas * ensure that the distribution and export/re-export of the software is in
106178825Sdfr * compliance with all laws, regulations, orders, or other restrictions of the
107233294Sstas * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108178825Sdfr * any of its subsidiaries will export/re-export any technical data, process,
109233294Sstas * software, or service, directly or indirectly, to any country for which the
110178825Sdfr * United States government or any agency thereof requires an export license,
111233294Sstas * other governmental approval, or letter of assurance, without first obtaining
112127808Snectar * such license, approval or letter.
113233294Sstas *
114178825Sdfr *****************************************************************************/
115233294Sstas
116178825Sdfr#ifndef __ACTYPES_H__
117233294Sstas#define __ACTYPES_H__
118178825Sdfr
119233294Sstas/* acpisrc:StructDefs -- for acpisrc conversion */
120178825Sdfr
121233294Sstas/*
122178825Sdfr * ACPI_MACHINE_WIDTH must be specified in an OS- or compiler-dependent header
123233294Sstas * and must be either 32 or 64. 16-bit ACPICA is no longer supported, as of
124178825Sdfr * 12/2006.
125233294Sstas */
126178825Sdfr#ifndef ACPI_MACHINE_WIDTH
127233294Sstas#error ACPI_MACHINE_WIDTH not defined
128233294Sstas#endif
129178825Sdfr
130233294Sstas/*! [Begin] no source code translation */
131178825Sdfr
132233294Sstas/*
133178825Sdfr * Data type ranges
134233294Sstas * Note: These macros are designed to be compiler independent as well as
135233294Sstas * working around problems that some 32-bit compilers have with 64-bit
136127808Snectar * constants.
137233294Sstas */
138233294Sstas#define ACPI_UINT8_MAX                  (UINT8) (~((UINT8)  0)) /* 0xFF               */
139127808Snectar#define ACPI_UINT16_MAX                 (UINT16)(~((UINT16) 0)) /* 0xFFFF             */
140233294Sstas#define ACPI_UINT32_MAX                 (UINT32)(~((UINT32) 0)) /* 0xFFFFFFFF         */
141127808Snectar#define ACPI_UINT64_MAX                 (UINT64)(~((UINT64) 0)) /* 0xFFFFFFFFFFFFFFFF */
142233294Sstas#define ACPI_ASCII_MAX                  0x7F
143178825Sdfr
144233294Sstas
145178825Sdfr/*
146233294Sstas * Architecture-specific ACPICA Subsystem Data Types
147178825Sdfr *
148233294Sstas * The goal of these types is to provide source code portability across
149127808Snectar * 16-bit, 32-bit, and 64-bit targets.
150233294Sstas *
151233294Sstas * 1) The following types are of fixed size for all targets (16/32/64):
152127808Snectar *
153233294Sstas * BOOLEAN      Logical boolean
154127808Snectar *
155233294Sstas * UINT8        8-bit  (1 byte) unsigned value
156178825Sdfr * UINT16       16-bit (2 byte) unsigned value
157233294Sstas * UINT32       32-bit (4 byte) unsigned value
158127808Snectar * UINT64       64-bit (8 byte) unsigned value
159233294Sstas *
160127808Snectar * INT16        16-bit (2 byte) signed value
161233294Sstas * INT32        32-bit (4 byte) signed value
162178825Sdfr * INT64        64-bit (8 byte) signed value
163233294Sstas *
164233294Sstas * COMPILER_DEPENDENT_UINT64/INT64 - These types are defined in the
165178825Sdfr * compiler-dependent header(s) and were introduced because there is no common
166233294Sstas * 64-bit integer type across the various compilation models, as shown in
167233294Sstas * the table below.
168178825Sdfr *
169233294Sstas * Datatype  LP64 ILP64 LLP64 ILP32 LP32 16bit
170178825Sdfr * char      8    8     8     8     8    8
171233294Sstas * short     16   16    16    16    16   16
172178825Sdfr * _int32         32
173233294Sstas * int       32   64    32    32    16   16
174178825Sdfr * long      64   64    32    32    32   32
175233294Sstas * long long            64    64
176178825Sdfr * pointer   64   64    64    32    32   32
177233294Sstas *
178178825Sdfr * Note: ILP64 and LP32 are currently not supported.
179233294Sstas *
180233294Sstas *
181178825Sdfr * 2) These types represent the native word size of the target mode of the
182233294Sstas * processor, and may be 16-bit, 32-bit, or 64-bit as required. They are
183178825Sdfr * usually used for memory allocation, efficient loop counters, and array
184233294Sstas * indexes. The types are similar to the size_t type in the C library and are
185178825Sdfr * required because there is no C type that consistently represents the native
186233294Sstas * data width. ACPI_SIZE is needed because there is no guarantee that a
187178825Sdfr * kernel-level C library is present.
188233294Sstas *
189233294Sstas * ACPI_SIZE        16/32/64-bit unsigned value
190127808Snectar * ACPI_NATIVE_INT  16/32/64-bit signed value
191233294Sstas */
192127808Snectar
193233294Sstas/*******************************************************************************
194233294Sstas *
195127808Snectar * Common types for all compilers, all targets
196233294Sstas *
197127808Snectar ******************************************************************************/
198233294Sstas
199178825Sdfrtypedef unsigned char                   BOOLEAN;
200233294Sstastypedef unsigned char                   UINT8;
201233294Sstastypedef unsigned short                  UINT16;
202178825Sdfrtypedef COMPILER_DEPENDENT_UINT64       UINT64;
203233294Sstastypedef COMPILER_DEPENDENT_INT64        INT64;
204178825Sdfr
205233294Sstas/*! [End] no source code translation !*/
206127808Snectar
207233294Sstas/*
208127808Snectar * Value returned by AcpiOsGetThreadId. There is no standard "thread_id"
209233294Sstas * across operating systems or even the various UNIX systems. Since ACPICA
210127808Snectar * only needs the thread ID as a unique thread identifier, we use a UINT64
211233294Sstas * as the only common data type - it will accommodate any type of pointer or
212127808Snectar * any type of integer. It is up to the host-dependent OSL to cast the
213233294Sstas * native thread ID type to a UINT64 (in AcpiOsGetThreadId).
214178825Sdfr */
215233294Sstas#define ACPI_THREAD_ID                  UINT64
216178825Sdfr
217233294Sstas
218127808Snectar/*******************************************************************************
219233294Sstas *
220127808Snectar * Types specific to 64-bit targets
221233294Sstas *
222127808Snectar ******************************************************************************/
223233294Sstas
224127808Snectar#if ACPI_MACHINE_WIDTH == 64
225233294Sstas
226127808Snectar/*! [Begin] no source code translation (keep the typedefs as-is) */
227233294Sstas
228127808Snectartypedef unsigned int                    UINT32;
229233294Sstastypedef int                             INT32;
230178825Sdfr
231233294Sstas/*! [End] no source code translation !*/
232178825Sdfr
233233294Sstas
234178825Sdfrtypedef INT64                           ACPI_NATIVE_INT;
235233294Sstastypedef UINT64                          ACPI_SIZE;
236178825Sdfrtypedef UINT64                          ACPI_IO_ADDRESS;
237233294Sstastypedef UINT64                          ACPI_PHYSICAL_ADDRESS;
238178825Sdfr
239233294Sstas#define ACPI_MAX_PTR                    ACPI_UINT64_MAX
240233294Sstas#define ACPI_SIZE_MAX                   ACPI_UINT64_MAX
241178825Sdfr#define ACPI_USE_NATIVE_DIVIDE          /* Has native 64-bit integer support */
242233294Sstas
243178825Sdfr/*
244233294Sstas * In the case of the Itanium Processor Family (IPF), the hardware does not
245233294Sstas * support misaligned memory transfers. Set the MISALIGNMENT_NOT_SUPPORTED flag
246178825Sdfr * to indicate that special precautions must be taken to avoid alignment faults.
247233294Sstas * (IA64 or ia64 is currently used by existing compilers to indicate IPF.)
248178825Sdfr *
249233294Sstas * Note: EM64T and other X86-64 processors support misaligned transfers,
250178825Sdfr * so there is no need to define this flag.
251233294Sstas */
252233294Sstas#if defined (__IA64__) || defined (__ia64__)
253178825Sdfr#define ACPI_MISALIGNMENT_NOT_SUPPORTED
254233294Sstas#endif
255178825Sdfr
256233294Sstas
257178825Sdfr/*******************************************************************************
258233294Sstas *
259178825Sdfr * Types specific to 32-bit targets
260233294Sstas *
261233294Sstas ******************************************************************************/
262178825Sdfr
263233294Sstas#elif ACPI_MACHINE_WIDTH == 32
264178825Sdfr
265233294Sstas/*! [Begin] no source code translation (keep the typedefs as-is) */
266127808Snectar
267233294Sstastypedef unsigned int                    UINT32;
268178825Sdfrtypedef int                             INT32;
269233294Sstas
270233294Sstas/*! [End] no source code translation !*/
271178825Sdfr
272233294Sstas
273127808Snectartypedef INT32                           ACPI_NATIVE_INT;
274233294Sstastypedef UINT32                          ACPI_SIZE;
275127808Snectartypedef UINT32                          ACPI_IO_ADDRESS;
276233294Sstastypedef UINT32                          ACPI_PHYSICAL_ADDRESS;
277127808Snectar
278233294Sstas#define ACPI_MAX_PTR                    ACPI_UINT32_MAX
279127808Snectar#define ACPI_SIZE_MAX                   ACPI_UINT32_MAX
280233294Sstas
281127808Snectar#else
282233294Sstas
283127808Snectar/* ACPI_MACHINE_WIDTH must be either 64 or 32 */
284233294Sstas
285233294Sstas#error unknown ACPI_MACHINE_WIDTH
286233294Sstas#endif
287178825Sdfr
288233294Sstas
289178825Sdfr/*******************************************************************************
290233294Sstas *
291178825Sdfr * OS-dependent types
292233294Sstas *
293233294Sstas * If the defaults below are not appropriate for the host system, they can
294127808Snectar * be defined in the OS-specific header, and this will take precedence.
295233294Sstas *
296127808Snectar ******************************************************************************/
297233294Sstas
298127808Snectar/* Flags for AcpiOsAcquireLock/AcpiOsReleaseLock */
299233294Sstas
300127808Snectar#ifndef ACPI_CPU_FLAGS
301233294Sstas#define ACPI_CPU_FLAGS                  ACPI_SIZE
302233294Sstas#endif
303127808Snectar
304233294Sstas/* Object returned from AcpiOsCreateCache */
305233294Sstas
306233294Sstas#ifndef ACPI_CACHE_T
307178825Sdfr#ifdef ACPI_USE_LOCAL_CACHE
308233294Sstas#define ACPI_CACHE_T                    ACPI_MEMORY_LIST
309178825Sdfr#else
310233294Sstas#define ACPI_CACHE_T                    void *
311233294Sstas#endif
312178825Sdfr#endif
313233294Sstas
314127808Snectar/*
315233294Sstas * Synchronization objects - Mutexes, Semaphores, and SpinLocks
316178825Sdfr */
317233294Sstas#if (ACPI_MUTEX_TYPE == ACPI_BINARY_SEMAPHORE)
318233294Sstas/*
319233294Sstas * These macros are used if the host OS does not support a mutex object.
320127808Snectar * Map the OSL Mutex interfaces to binary semaphores.
321233294Sstas */
322127808Snectar#define ACPI_MUTEX                      ACPI_SEMAPHORE
323233294Sstas#define AcpiOsCreateMutex(OutHandle)    AcpiOsCreateSemaphore (1, 1, OutHandle)
324233294Sstas#define AcpiOsDeleteMutex(Handle)       (void) AcpiOsDeleteSemaphore (Handle)
325103423Snectar#define AcpiOsAcquireMutex(Handle,Time) AcpiOsWaitSemaphore (Handle, 1, Time)
326233294Sstas#define AcpiOsReleaseMutex(Handle)      (void) AcpiOsSignalSemaphore (Handle, 1)
327233294Sstas#endif
328103423Snectar
329233294Sstas/* Configurable types for synchronization objects */
330103423Snectar
331233294Sstas#ifndef ACPI_SPINLOCK
332103423Snectar#define ACPI_SPINLOCK                   void *
333233294Sstas#endif
334233294Sstas
335103423Snectar#ifndef ACPI_SEMAPHORE
336233294Sstas#define ACPI_SEMAPHORE                  void *
337233294Sstas#endif
338103423Snectar
339233294Sstas#ifndef ACPI_MUTEX
340120945Snectar#define ACPI_MUTEX                      void *
341233294Sstas#endif
342233294Sstas
343107207Snectar
344233294Sstas/*******************************************************************************
345107207Snectar *
346233294Sstas * Compiler-dependent types
347233294Sstas *
348120945Snectar * If the defaults below are not appropriate for the host compiler, they can
349233294Sstas * be defined in the compiler-specific header, and this will take precedence.
350107207Snectar *
351233294Sstas ******************************************************************************/
352103423Snectar
353233294Sstas/* Use C99 uintptr_t for pointer casting if available, "void *" otherwise */
354107207Snectar
355233294Sstas#ifndef ACPI_UINTPTR_T
356103423Snectar#define ACPI_UINTPTR_T                  void *
357233294Sstas#endif
358103423Snectar
359233294Sstas/*
360103423Snectar * ACPI_PRINTF_LIKE is used to tag functions as "printf-like" because
361233294Sstas * some compilers can catch printf format string problems
362103423Snectar */
363233294Sstas#ifndef ACPI_PRINTF_LIKE
364233294Sstas#define ACPI_PRINTF_LIKE(c)
365120945Snectar#endif
366233294Sstas
367103423Snectar/*
368233294Sstas * Some compilers complain about unused variables. Sometimes we don't want to
369103423Snectar * use all the variables (for example, _AcpiModuleName). This allows us
370233294Sstas * to to tell the compiler in a per-variable manner that a variable
371103423Snectar * is unused
372233294Sstas */
373178825Sdfr#ifndef ACPI_UNUSED_VAR
374233294Sstas#define ACPI_UNUSED_VAR
375178825Sdfr#endif
376233294Sstas
377178825Sdfr/*
378233294Sstas * All ACPICA functions that are available to the rest of the kernel are
379103423Snectar * tagged with this macro which can be defined as appropriate for the host.
380233294Sstas */
381120945Snectar#ifndef ACPI_EXPORT_SYMBOL
382233294Sstas#define ACPI_EXPORT_SYMBOL(Symbol)
383103423Snectar#endif
384233294Sstas
385233294Sstas
386233294Sstas/******************************************************************************
387103423Snectar *
388233294Sstas * ACPI Specification constants (Do not change unless the specification changes)
389178825Sdfr *
390233294Sstas *****************************************************************************/
391233294Sstas
392233294Sstas/* Number of distinct FADT-based GPE register blocks (GPE0 and GPE1) */
393103423Snectar
394233294Sstas#define ACPI_MAX_GPE_BLOCKS             2
395233294Sstas
396103423Snectar/* Default ACPI register widths */
397233294Sstas
398103423Snectar#define ACPI_GPE_REGISTER_WIDTH         8
399233294Sstas#define ACPI_PM1_REGISTER_WIDTH         16
400233294Sstas#define ACPI_PM2_REGISTER_WIDTH         8
401103423Snectar#define ACPI_PM_TIMER_WIDTH             32
402233294Sstas
403178825Sdfr/* Names within the namespace are 4 bytes long */
404233294Sstas
405178825Sdfr#define ACPI_NAME_SIZE                  4
406233294Sstas#define ACPI_PATH_SEGMENT_LENGTH        5           /* 4 chars for name + 1 char for separator */
407233294Sstas#define ACPI_PATH_SEPARATOR             '.'
408178825Sdfr
409233294Sstas/* Sizes for ACPI table headers */
410178825Sdfr
411233294Sstas#define ACPI_OEM_ID_SIZE                6
412178825Sdfr#define ACPI_OEM_TABLE_ID_SIZE          8
413233294Sstas
414178825Sdfr/* ACPI/PNP hardware IDs */
415233294Sstas
416233294Sstas#define PCI_ROOT_HID_STRING             "PNP0A03"
417178825Sdfr#define PCI_EXPRESS_ROOT_HID_STRING     "PNP0A08"
418233294Sstas
419178825Sdfr/* PM Timer ticks per second (HZ) */
420233294Sstas
421103423Snectar#define PM_TIMER_FREQUENCY              3579545
422233294Sstas
423178825Sdfr
424233294Sstas/*******************************************************************************
425178825Sdfr *
426233294Sstas * Independent types
427178825Sdfr *
428233294Sstas ******************************************************************************/
429178825Sdfr
430233294Sstas/* Logical defines and NULL */
431103423Snectar
432233294Sstas#ifdef FALSE
433233294Sstas#undef FALSE
434120945Snectar#endif
435233294Sstas#define FALSE                           (1 == 0)
436103423Snectar
437233294Sstas#ifdef TRUE
438178825Sdfr#undef TRUE
439233294Sstas#endif
440103423Snectar#define TRUE                            (1 == 1)
441233294Sstas
442233294Sstas#ifndef NULL
443103423Snectar#define NULL                            (void *) 0
444233294Sstas#endif
445103423Snectar
446233294Sstas
447233294Sstas/*
448103423Snectar * Miscellaneous types
449233294Sstas */
450103423Snectartypedef UINT32                          ACPI_STATUS;    /* All ACPI Exceptions */
451233294Sstastypedef UINT32                          ACPI_NAME;      /* 4-byte ACPI name */
452233294Sstastypedef char *                          ACPI_STRING;    /* Null terminated ASCII string */
453120945Snectartypedef void *                          ACPI_HANDLE;    /* Actually a ptr to a NS Node */
454233294Sstas
455103423Snectar
456233294Sstas/* Owner IDs are used to track namespace nodes for selective deletion */
457103423Snectar
458233294Sstastypedef UINT8                           ACPI_OWNER_ID;
459233294Sstas#define ACPI_OWNER_ID_MAX               0xFF
460103423Snectar
461233294Sstas
462233294Sstas#define ACPI_INTEGER_BIT_SIZE           64
463120945Snectar#define ACPI_MAX_DECIMAL_DIGITS         20  /* 2^64 = 18,446,744,073,709,551,616 */
464233294Sstas#define ACPI_MAX64_DECIMAL_DIGITS       20
465103423Snectar#define ACPI_MAX32_DECIMAL_DIGITS       10
466233294Sstas#define ACPI_MAX16_DECIMAL_DIGITS        5
467103423Snectar#define ACPI_MAX8_DECIMAL_DIGITS         3
468233294Sstas
469103423Snectar/*
470233294Sstas * Constants with special meanings
471103423Snectar */
472233294Sstas#define ACPI_ROOT_OBJECT                ACPI_ADD_PTR (ACPI_HANDLE, NULL, ACPI_MAX_PTR)
473103423Snectar#define ACPI_WAIT_FOREVER               0xFFFF  /* UINT16, as per ACPI spec */
474233294Sstas#define ACPI_DO_NOT_WAIT                0
475120945Snectar
476233294Sstas/*
477120945Snectar * Obsolete: Acpi integer width. In ACPI version 1 (1996), integers are 32 bits.
478233294Sstas * In ACPI version 2 (2000) and later, integers are 64 bits. Note that this
479233294Sstas * pertains to the ACPI integer type only, not to other integers used in the
480103423Snectar * implementation of the ACPICA subsystem.
481233294Sstas *
482103423Snectar * 01/2010: This type is obsolete and has been removed from the entire ACPICA
483233294Sstas * code base. It remains here for compatibility with device drivers that use
484103423Snectar * the type. However, it will be removed in the future.
485233294Sstas */
486typedef UINT64                          ACPI_INTEGER;
487#define ACPI_INTEGER_MAX                ACPI_UINT64_MAX
488
489
490/*******************************************************************************
491 *
492 * Commonly used macros
493 *
494 ******************************************************************************/
495
496/* Data manipulation */
497
498#define ACPI_LOBYTE(Integer)            ((UINT8)   (UINT16)(Integer))
499#define ACPI_HIBYTE(Integer)            ((UINT8) (((UINT16)(Integer)) >> 8))
500#define ACPI_LOWORD(Integer)            ((UINT16)  (UINT32)(Integer))
501#define ACPI_HIWORD(Integer)            ((UINT16)(((UINT32)(Integer)) >> 16))
502#define ACPI_LODWORD(Integer64)         ((UINT32)  (UINT64)(Integer64))
503#define ACPI_HIDWORD(Integer64)         ((UINT32)(((UINT64)(Integer64)) >> 32))
504
505#define ACPI_SET_BIT(target,bit)        ((target) |= (bit))
506#define ACPI_CLEAR_BIT(target,bit)      ((target) &= ~(bit))
507#define ACPI_MIN(a,b)                   (((a)<(b))?(a):(b))
508#define ACPI_MAX(a,b)                   (((a)>(b))?(a):(b))
509
510/* Size calculation */
511
512#define ACPI_ARRAY_LENGTH(x)            (sizeof(x) / sizeof((x)[0]))
513
514/* Pointer manipulation */
515
516#define ACPI_CAST_PTR(t, p)             ((t *) (ACPI_UINTPTR_T) (p))
517#define ACPI_CAST_INDIRECT_PTR(t, p)    ((t **) (ACPI_UINTPTR_T) (p))
518#define ACPI_ADD_PTR(t, a, b)           ACPI_CAST_PTR (t, (ACPI_CAST_PTR (UINT8, (a)) + (ACPI_SIZE)(b)))
519#define ACPI_PTR_DIFF(a, b)             (ACPI_SIZE) (ACPI_CAST_PTR (UINT8, (a)) - ACPI_CAST_PTR (UINT8, (b)))
520
521/* Pointer/Integer type conversions */
522
523#define ACPI_TO_POINTER(i)              ACPI_ADD_PTR (void, (void *) NULL,(ACPI_SIZE) i)
524#define ACPI_TO_INTEGER(p)              ACPI_PTR_DIFF (p, (void *) NULL)
525#define ACPI_OFFSET(d, f)               (ACPI_SIZE) ACPI_PTR_DIFF (&(((d *)0)->f), (void *) NULL)
526#define ACPI_PHYSADDR_TO_PTR(i)         ACPI_TO_POINTER(i)
527#define ACPI_PTR_TO_PHYSADDR(i)         ACPI_TO_INTEGER(i)
528
529#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED
530#define ACPI_COMPARE_NAME(a,b)          (*ACPI_CAST_PTR (UINT32, (a)) == *ACPI_CAST_PTR (UINT32, (b)))
531#else
532#define ACPI_COMPARE_NAME(a,b)          (!ACPI_STRNCMP (ACPI_CAST_PTR (char, (a)), ACPI_CAST_PTR (char, (b)), ACPI_NAME_SIZE))
533#endif
534
535
536/*******************************************************************************
537 *
538 * Miscellaneous constants
539 *
540 ******************************************************************************/
541
542/*
543 * Initialization sequence
544 */
545#define ACPI_FULL_INITIALIZATION        0x00
546#define ACPI_NO_ADDRESS_SPACE_INIT      0x01
547#define ACPI_NO_HARDWARE_INIT           0x02
548#define ACPI_NO_EVENT_INIT              0x04
549#define ACPI_NO_HANDLER_INIT            0x08
550#define ACPI_NO_ACPI_ENABLE             0x10
551#define ACPI_NO_DEVICE_INIT             0x20
552#define ACPI_NO_OBJECT_INIT             0x40
553
554/*
555 * Initialization state
556 */
557#define ACPI_SUBSYSTEM_INITIALIZE       0x01
558#define ACPI_INITIALIZED_OK             0x02
559
560/*
561 * Power state values
562 */
563#define ACPI_STATE_UNKNOWN              (UINT8) 0xFF
564
565#define ACPI_STATE_S0                   (UINT8) 0
566#define ACPI_STATE_S1                   (UINT8) 1
567#define ACPI_STATE_S2                   (UINT8) 2
568#define ACPI_STATE_S3                   (UINT8) 3
569#define ACPI_STATE_S4                   (UINT8) 4
570#define ACPI_STATE_S5                   (UINT8) 5
571#define ACPI_S_STATES_MAX               ACPI_STATE_S5
572#define ACPI_S_STATE_COUNT              6
573
574#define ACPI_STATE_D0                   (UINT8) 0
575#define ACPI_STATE_D1                   (UINT8) 1
576#define ACPI_STATE_D2                   (UINT8) 2
577#define ACPI_STATE_D3                   (UINT8) 3
578#define ACPI_D_STATES_MAX               ACPI_STATE_D3
579#define ACPI_D_STATE_COUNT              4
580
581#define ACPI_STATE_C0                   (UINT8) 0
582#define ACPI_STATE_C1                   (UINT8) 1
583#define ACPI_STATE_C2                   (UINT8) 2
584#define ACPI_STATE_C3                   (UINT8) 3
585#define ACPI_C_STATES_MAX               ACPI_STATE_C3
586#define ACPI_C_STATE_COUNT              4
587
588/*
589 * Sleep type invalid value
590 */
591#define ACPI_SLEEP_TYPE_MAX             0x7
592#define ACPI_SLEEP_TYPE_INVALID         0xFF
593
594/*
595 * Standard notify values
596 */
597#define ACPI_NOTIFY_BUS_CHECK           (UINT8) 0x00
598#define ACPI_NOTIFY_DEVICE_CHECK        (UINT8) 0x01
599#define ACPI_NOTIFY_DEVICE_WAKE         (UINT8) 0x02
600#define ACPI_NOTIFY_EJECT_REQUEST       (UINT8) 0x03
601#define ACPI_NOTIFY_DEVICE_CHECK_LIGHT  (UINT8) 0x04
602#define ACPI_NOTIFY_FREQUENCY_MISMATCH  (UINT8) 0x05
603#define ACPI_NOTIFY_BUS_MODE_MISMATCH   (UINT8) 0x06
604#define ACPI_NOTIFY_POWER_FAULT         (UINT8) 0x07
605#define ACPI_NOTIFY_CAPABILITIES_CHECK  (UINT8) 0x08
606#define ACPI_NOTIFY_DEVICE_PLD_CHECK    (UINT8) 0x09
607#define ACPI_NOTIFY_RESERVED            (UINT8) 0x0A
608#define ACPI_NOTIFY_LOCALITY_UPDATE     (UINT8) 0x0B
609
610#define ACPI_NOTIFY_MAX                 0x0B
611
612/*
613 * Types associated with ACPI names and objects. The first group of
614 * values (up to ACPI_TYPE_EXTERNAL_MAX) correspond to the definition
615 * of the ACPI ObjectType() operator (See the ACPI Spec). Therefore,
616 * only add to the first group if the spec changes.
617 *
618 * NOTE: Types must be kept in sync with the global AcpiNsProperties
619 * and AcpiNsTypeNames arrays.
620 */
621typedef UINT32                          ACPI_OBJECT_TYPE;
622
623#define ACPI_TYPE_ANY                   0x00
624#define ACPI_TYPE_INTEGER               0x01  /* Byte/Word/Dword/Zero/One/Ones */
625#define ACPI_TYPE_STRING                0x02
626#define ACPI_TYPE_BUFFER                0x03
627#define ACPI_TYPE_PACKAGE               0x04  /* ByteConst, multiple DataTerm/Constant/SuperName */
628#define ACPI_TYPE_FIELD_UNIT            0x05
629#define ACPI_TYPE_DEVICE                0x06  /* Name, multiple Node */
630#define ACPI_TYPE_EVENT                 0x07
631#define ACPI_TYPE_METHOD                0x08  /* Name, ByteConst, multiple Code */
632#define ACPI_TYPE_MUTEX                 0x09
633#define ACPI_TYPE_REGION                0x0A
634#define ACPI_TYPE_POWER                 0x0B  /* Name,ByteConst,WordConst,multi Node */
635#define ACPI_TYPE_PROCESSOR             0x0C  /* Name,ByteConst,DWordConst,ByteConst,multi NmO */
636#define ACPI_TYPE_THERMAL               0x0D  /* Name, multiple Node */
637#define ACPI_TYPE_BUFFER_FIELD          0x0E
638#define ACPI_TYPE_DDB_HANDLE            0x0F
639#define ACPI_TYPE_DEBUG_OBJECT          0x10
640
641#define ACPI_TYPE_EXTERNAL_MAX          0x10
642
643/*
644 * These are object types that do not map directly to the ACPI
645 * ObjectType() operator. They are used for various internal purposes only.
646 * If new predefined ACPI_TYPEs are added (via the ACPI specification), these
647 * internal types must move upwards. (There is code that depends on these
648 * values being contiguous with the external types above.)
649 */
650#define ACPI_TYPE_LOCAL_REGION_FIELD    0x11
651#define ACPI_TYPE_LOCAL_BANK_FIELD      0x12
652#define ACPI_TYPE_LOCAL_INDEX_FIELD     0x13
653#define ACPI_TYPE_LOCAL_REFERENCE       0x14  /* Arg#, Local#, Name, Debug, RefOf, Index */
654#define ACPI_TYPE_LOCAL_ALIAS           0x15
655#define ACPI_TYPE_LOCAL_METHOD_ALIAS    0x16
656#define ACPI_TYPE_LOCAL_NOTIFY          0x17
657#define ACPI_TYPE_LOCAL_ADDRESS_HANDLER 0x18
658#define ACPI_TYPE_LOCAL_RESOURCE        0x19
659#define ACPI_TYPE_LOCAL_RESOURCE_FIELD  0x1A
660#define ACPI_TYPE_LOCAL_SCOPE           0x1B  /* 1 Name, multiple ObjectList Nodes */
661
662#define ACPI_TYPE_NS_NODE_MAX           0x1B  /* Last typecode used within a NS Node */
663
664/*
665 * These are special object types that never appear in
666 * a Namespace node, only in an ACPI_OPERAND_OBJECT
667 */
668#define ACPI_TYPE_LOCAL_EXTRA           0x1C
669#define ACPI_TYPE_LOCAL_DATA            0x1D
670
671#define ACPI_TYPE_LOCAL_MAX             0x1D
672
673/* All types above here are invalid */
674
675#define ACPI_TYPE_INVALID               0x1E
676#define ACPI_TYPE_NOT_FOUND             0xFF
677
678#define ACPI_NUM_NS_TYPES               (ACPI_TYPE_INVALID + 1)
679
680
681/*
682 * All I/O
683 */
684#define ACPI_READ                       0
685#define ACPI_WRITE                      1
686#define ACPI_IO_MASK                    1
687
688/*
689 * Event Types: Fixed & General Purpose
690 */
691typedef UINT32                          ACPI_EVENT_TYPE;
692
693/*
694 * Fixed events
695 */
696#define ACPI_EVENT_PMTIMER              0
697#define ACPI_EVENT_GLOBAL               1
698#define ACPI_EVENT_POWER_BUTTON         2
699#define ACPI_EVENT_SLEEP_BUTTON         3
700#define ACPI_EVENT_RTC                  4
701#define ACPI_EVENT_MAX                  4
702#define ACPI_NUM_FIXED_EVENTS           ACPI_EVENT_MAX + 1
703
704/*
705 * Event Status - Per event
706 * -------------
707 * The encoding of ACPI_EVENT_STATUS is illustrated below.
708 * Note that a set bit (1) indicates the property is TRUE
709 * (e.g. if bit 0 is set then the event is enabled).
710 * +-------------+-+-+-+
711 * |   Bits 31:3 |2|1|0|
712 * +-------------+-+-+-+
713 *          |     | | |
714 *          |     | | +- Enabled?
715 *          |     | +--- Enabled for wake?
716 *          |     +----- Set?
717 *          +----------- <Reserved>
718 */
719typedef UINT32                          ACPI_EVENT_STATUS;
720
721#define ACPI_EVENT_FLAG_DISABLED        (ACPI_EVENT_STATUS) 0x00
722#define ACPI_EVENT_FLAG_ENABLED         (ACPI_EVENT_STATUS) 0x01
723#define ACPI_EVENT_FLAG_WAKE_ENABLED    (ACPI_EVENT_STATUS) 0x02
724#define ACPI_EVENT_FLAG_SET             (ACPI_EVENT_STATUS) 0x04
725
726/*
727 * General Purpose Events (GPE)
728 */
729#define ACPI_GPE_INVALID                0xFF
730#define ACPI_GPE_MAX                    0xFF
731#define ACPI_NUM_GPE                    256
732
733/* Actions for AcpiSetGpe, AcpiGpeWakeup, AcpiHwLowSetGpe */
734
735#define ACPI_GPE_ENABLE                 0
736#define ACPI_GPE_DISABLE                1
737#define ACPI_GPE_CONDITIONAL_ENABLE     2
738
739/*
740 * GPE info flags - Per GPE
741 * +-------+-+-+---+
742 * |  7:4  |3|2|1:0|
743 * +-------+-+-+---+
744 *     |    | |  |
745 *     |    | |  +-- Type of dispatch:to method, handler, notify, or none
746 *     |    | +----- Interrupt type: edge or level triggered
747 *     |    +------- Is a Wake GPE
748 *     +------------ <Reserved>
749 */
750#define ACPI_GPE_DISPATCH_NONE          (UINT8) 0x00
751#define ACPI_GPE_DISPATCH_METHOD        (UINT8) 0x01
752#define ACPI_GPE_DISPATCH_HANDLER       (UINT8) 0x02
753#define ACPI_GPE_DISPATCH_NOTIFY        (UINT8) 0x03
754#define ACPI_GPE_DISPATCH_MASK          (UINT8) 0x03
755
756#define ACPI_GPE_LEVEL_TRIGGERED        (UINT8) 0x04
757#define ACPI_GPE_EDGE_TRIGGERED         (UINT8) 0x00
758#define ACPI_GPE_XRUPT_TYPE_MASK        (UINT8) 0x04
759
760#define ACPI_GPE_CAN_WAKE               (UINT8) 0x08
761
762/*
763 * Flags for GPE and Lock interfaces
764 */
765#define ACPI_NOT_ISR                    0x1
766#define ACPI_ISR                        0x0
767
768
769/* Notify types */
770
771#define ACPI_SYSTEM_NOTIFY              0x1
772#define ACPI_DEVICE_NOTIFY              0x2
773#define ACPI_ALL_NOTIFY                 (ACPI_SYSTEM_NOTIFY | ACPI_DEVICE_NOTIFY)
774#define ACPI_MAX_NOTIFY_HANDLER_TYPE    0x3
775
776#define ACPI_MAX_SYS_NOTIFY             0x7f
777
778
779/* Address Space (Operation Region) Types */
780
781typedef UINT8                           ACPI_ADR_SPACE_TYPE;
782
783#define ACPI_ADR_SPACE_SYSTEM_MEMORY    (ACPI_ADR_SPACE_TYPE) 0
784#define ACPI_ADR_SPACE_SYSTEM_IO        (ACPI_ADR_SPACE_TYPE) 1
785#define ACPI_ADR_SPACE_PCI_CONFIG       (ACPI_ADR_SPACE_TYPE) 2
786#define ACPI_ADR_SPACE_EC               (ACPI_ADR_SPACE_TYPE) 3
787#define ACPI_ADR_SPACE_SMBUS            (ACPI_ADR_SPACE_TYPE) 4
788#define ACPI_ADR_SPACE_CMOS             (ACPI_ADR_SPACE_TYPE) 5
789#define ACPI_ADR_SPACE_PCI_BAR_TARGET   (ACPI_ADR_SPACE_TYPE) 6
790#define ACPI_ADR_SPACE_IPMI             (ACPI_ADR_SPACE_TYPE) 7
791#define ACPI_ADR_SPACE_DATA_TABLE       (ACPI_ADR_SPACE_TYPE) 8
792#define ACPI_ADR_SPACE_FIXED_HARDWARE   (ACPI_ADR_SPACE_TYPE) 127
793
794
795/*
796 * BitRegister IDs
797 *
798 * These values are intended to be used by the hardware interfaces
799 * and are mapped to individual bitfields defined within the ACPI
800 * registers. See the AcpiGbl_BitRegisterInfo global table in utglobal.c
801 * for this mapping.
802 */
803
804/* PM1 Status register */
805
806#define ACPI_BITREG_TIMER_STATUS                0x00
807#define ACPI_BITREG_BUS_MASTER_STATUS           0x01
808#define ACPI_BITREG_GLOBAL_LOCK_STATUS          0x02
809#define ACPI_BITREG_POWER_BUTTON_STATUS         0x03
810#define ACPI_BITREG_SLEEP_BUTTON_STATUS         0x04
811#define ACPI_BITREG_RT_CLOCK_STATUS             0x05
812#define ACPI_BITREG_WAKE_STATUS                 0x06
813#define ACPI_BITREG_PCIEXP_WAKE_STATUS          0x07
814
815/* PM1 Enable register */
816
817#define ACPI_BITREG_TIMER_ENABLE                0x08
818#define ACPI_BITREG_GLOBAL_LOCK_ENABLE          0x09
819#define ACPI_BITREG_POWER_BUTTON_ENABLE         0x0A
820#define ACPI_BITREG_SLEEP_BUTTON_ENABLE         0x0B
821#define ACPI_BITREG_RT_CLOCK_ENABLE             0x0C
822#define ACPI_BITREG_PCIEXP_WAKE_DISABLE         0x0D
823
824/* PM1 Control register */
825
826#define ACPI_BITREG_SCI_ENABLE                  0x0E
827#define ACPI_BITREG_BUS_MASTER_RLD              0x0F
828#define ACPI_BITREG_GLOBAL_LOCK_RELEASE         0x10
829#define ACPI_BITREG_SLEEP_TYPE                  0x11
830#define ACPI_BITREG_SLEEP_ENABLE                0x12
831
832/* PM2 Control register */
833
834#define ACPI_BITREG_ARB_DISABLE                 0x13
835
836#define ACPI_BITREG_MAX                         0x13
837#define ACPI_NUM_BITREG                         ACPI_BITREG_MAX + 1
838
839
840/* Status register values. A 1 clears a status bit. 0 = no effect */
841
842#define ACPI_CLEAR_STATUS                       1
843
844/* Enable and Control register values */
845
846#define ACPI_ENABLE_EVENT                       1
847#define ACPI_DISABLE_EVENT                      0
848
849
850/*
851 * External ACPI object definition
852 */
853
854/*
855 * Note: Type == ACPI_TYPE_ANY (0) is used to indicate a NULL package element
856 * or an unresolved named reference.
857 */
858typedef union acpi_object
859{
860    ACPI_OBJECT_TYPE                Type;   /* See definition of AcpiNsType for values */
861    struct
862    {
863        ACPI_OBJECT_TYPE                Type;       /* ACPI_TYPE_INTEGER */
864        UINT64                          Value;      /* The actual number */
865    } Integer;
866
867    struct
868    {
869        ACPI_OBJECT_TYPE                Type;       /* ACPI_TYPE_STRING */
870        UINT32                          Length;     /* # of bytes in string, excluding trailing null */
871        char                            *Pointer;   /* points to the string value */
872    } String;
873
874    struct
875    {
876        ACPI_OBJECT_TYPE                Type;       /* ACPI_TYPE_BUFFER */
877        UINT32                          Length;     /* # of bytes in buffer */
878        UINT8                           *Pointer;   /* points to the buffer */
879    } Buffer;
880
881    struct
882    {
883        ACPI_OBJECT_TYPE                Type;       /* ACPI_TYPE_PACKAGE */
884        UINT32                          Count;      /* # of elements in package */
885        union acpi_object               *Elements;  /* Pointer to an array of ACPI_OBJECTs */
886    } Package;
887
888    struct
889    {
890        ACPI_OBJECT_TYPE                Type;       /* ACPI_TYPE_LOCAL_REFERENCE */
891        ACPI_OBJECT_TYPE                ActualType; /* Type associated with the Handle */
892        ACPI_HANDLE                     Handle;     /* object reference */
893    } Reference;
894
895    struct
896    {
897        ACPI_OBJECT_TYPE                Type;       /* ACPI_TYPE_PROCESSOR */
898        UINT32                          ProcId;
899        ACPI_IO_ADDRESS                 PblkAddress;
900        UINT32                          PblkLength;
901    } Processor;
902
903    struct
904    {
905        ACPI_OBJECT_TYPE                Type;       /* ACPI_TYPE_POWER */
906        UINT32                          SystemLevel;
907        UINT32                          ResourceOrder;
908    } PowerResource;
909
910} ACPI_OBJECT;
911
912
913/*
914 * List of objects, used as a parameter list for control method evaluation
915 */
916typedef struct acpi_object_list
917{
918    UINT32                          Count;
919    ACPI_OBJECT                     *Pointer;
920
921} ACPI_OBJECT_LIST;
922
923
924/*
925 * Miscellaneous common Data Structures used by the interfaces
926 */
927#define ACPI_NO_BUFFER              0
928#define ACPI_ALLOCATE_BUFFER        (ACPI_SIZE) (-1)
929#define ACPI_ALLOCATE_LOCAL_BUFFER  (ACPI_SIZE) (-2)
930
931typedef struct acpi_buffer
932{
933    ACPI_SIZE                       Length;         /* Length in bytes of the buffer */
934    void                            *Pointer;       /* pointer to buffer */
935
936} ACPI_BUFFER;
937
938
939/*
940 * NameType for AcpiGetName
941 */
942#define ACPI_FULL_PATHNAME              0
943#define ACPI_SINGLE_NAME                1
944#define ACPI_NAME_TYPE_MAX              1
945
946
947/*
948 * Predefined Namespace items
949 */
950typedef struct acpi_predefined_names
951{
952    char                            *Name;
953    UINT8                           Type;
954    char                            *Val;
955
956} ACPI_PREDEFINED_NAMES;
957
958
959/*
960 * Structure and flags for AcpiGetSystemInfo
961 */
962#define ACPI_SYS_MODE_UNKNOWN           0x0000
963#define ACPI_SYS_MODE_ACPI              0x0001
964#define ACPI_SYS_MODE_LEGACY            0x0002
965#define ACPI_SYS_MODES_MASK             0x0003
966
967
968/*
969 * System info returned by AcpiGetSystemInfo()
970 */
971typedef struct acpi_system_info
972{
973    UINT32                          AcpiCaVersion;
974    UINT32                          Flags;
975    UINT32                          TimerResolution;
976    UINT32                          Reserved1;
977    UINT32                          Reserved2;
978    UINT32                          DebugLevel;
979    UINT32                          DebugLayer;
980
981} ACPI_SYSTEM_INFO;
982
983
984/*
985 * System statistics returned by AcpiGetStatistics()
986 */
987typedef struct acpi_statistics
988{
989    UINT32                          SciCount;
990    UINT32                          GpeCount;
991    UINT32                          FixedEventCount[ACPI_NUM_FIXED_EVENTS];
992    UINT32                          MethodCount;
993
994} ACPI_STATISTICS;
995
996
997/* Table Event Types */
998
999#define ACPI_TABLE_EVENT_LOAD           0x0
1000#define ACPI_TABLE_EVENT_UNLOAD         0x1
1001#define ACPI_NUM_TABLE_EVENTS           2
1002
1003
1004/*
1005 * Types specific to the OS service interfaces
1006 */
1007typedef UINT32
1008(ACPI_SYSTEM_XFACE *ACPI_OSD_HANDLER) (
1009    void                            *Context);
1010
1011typedef void
1012(ACPI_SYSTEM_XFACE *ACPI_OSD_EXEC_CALLBACK) (
1013    void                            *Context);
1014
1015/*
1016 * Various handlers and callback procedures
1017 */
1018typedef
1019void (*ACPI_GBL_EVENT_HANDLER) (
1020    UINT32                          EventType,
1021    ACPI_HANDLE                     Device,
1022    UINT32                          EventNumber,
1023    void                            *Context);
1024
1025#define ACPI_EVENT_TYPE_GPE         0
1026#define ACPI_EVENT_TYPE_FIXED       1
1027
1028typedef
1029UINT32 (*ACPI_EVENT_HANDLER) (
1030    void                            *Context);
1031
1032typedef
1033UINT32 (*ACPI_GPE_HANDLER) (
1034    ACPI_HANDLE                     GpeDevice,
1035    UINT32                          GpeNumber,
1036    void                            *Context);
1037
1038typedef
1039void (*ACPI_NOTIFY_HANDLER) (
1040    ACPI_HANDLE                     Device,
1041    UINT32                          Value,
1042    void                            *Context);
1043
1044typedef
1045void (*ACPI_OBJECT_HANDLER) (
1046    ACPI_HANDLE                     Object,
1047    void                            *Data);
1048
1049typedef
1050ACPI_STATUS (*ACPI_INIT_HANDLER) (
1051    ACPI_HANDLE                     Object,
1052    UINT32                          Function);
1053
1054#define ACPI_INIT_DEVICE_INI        1
1055
1056typedef
1057ACPI_STATUS (*ACPI_EXCEPTION_HANDLER) (
1058    ACPI_STATUS                     AmlStatus,
1059    ACPI_NAME                       Name,
1060    UINT16                          Opcode,
1061    UINT32                          AmlOffset,
1062    void                            *Context);
1063
1064/* Table Event handler (Load, LoadTable, etc.) and types */
1065
1066typedef
1067ACPI_STATUS (*ACPI_TABLE_HANDLER) (
1068    UINT32                          Event,
1069    void                            *Table,
1070    void                            *Context);
1071
1072#define ACPI_TABLE_LOAD             0x0
1073#define ACPI_TABLE_UNLOAD           0x1
1074#define ACPI_NUM_TABLE_EVENTS       2
1075
1076
1077/* Address Spaces (For Operation Regions) */
1078
1079typedef
1080ACPI_STATUS (*ACPI_ADR_SPACE_HANDLER) (
1081    UINT32                          Function,
1082    ACPI_PHYSICAL_ADDRESS           Address,
1083    UINT32                          BitWidth,
1084    UINT64                          *Value,
1085    void                            *HandlerContext,
1086    void                            *RegionContext);
1087
1088#define ACPI_DEFAULT_HANDLER            NULL
1089
1090typedef
1091ACPI_STATUS (*ACPI_ADR_SPACE_SETUP) (
1092    ACPI_HANDLE                     RegionHandle,
1093    UINT32                          Function,
1094    void                            *HandlerContext,
1095    void                            **RegionContext);
1096
1097#define ACPI_REGION_ACTIVATE    0
1098#define ACPI_REGION_DEACTIVATE  1
1099
1100typedef
1101ACPI_STATUS (*ACPI_WALK_CALLBACK) (
1102    ACPI_HANDLE                     Object,
1103    UINT32                          NestingLevel,
1104    void                            *Context,
1105    void                            **ReturnValue);
1106
1107typedef
1108UINT32 (*ACPI_INTERFACE_HANDLER) (
1109    ACPI_STRING                     InterfaceName,
1110    UINT32                          Supported);
1111
1112
1113/* Interrupt handler return values */
1114
1115#define ACPI_INTERRUPT_NOT_HANDLED      0x00
1116#define ACPI_INTERRUPT_HANDLED          0x01
1117
1118/* GPE handler return values */
1119
1120#define ACPI_REENABLE_GPE               0x80
1121
1122
1123/* Length of 32-bit EISAID values when converted back to a string */
1124
1125#define ACPI_EISAID_STRING_SIZE         8   /* Includes null terminator */
1126
1127/* Length of UUID (string) values */
1128
1129#define ACPI_UUID_LENGTH                16
1130
1131
1132/* Structures used for device/processor HID, UID, CID */
1133
1134typedef struct acpi_device_id
1135{
1136    UINT32                          Length;             /* Length of string + null */
1137    char                            *String;
1138
1139} ACPI_DEVICE_ID;
1140
1141typedef struct acpi_device_id_list
1142{
1143    UINT32                          Count;              /* Number of IDs in Ids array */
1144    UINT32                          ListSize;           /* Size of list, including ID strings */
1145    ACPI_DEVICE_ID                  Ids[1];             /* ID array */
1146
1147} ACPI_DEVICE_ID_LIST;
1148
1149/*
1150 * Structure returned from AcpiGetObjectInfo.
1151 * Optimized for both 32- and 64-bit builds
1152 */
1153typedef struct acpi_device_info
1154{
1155    UINT32                          InfoSize;           /* Size of info, including ID strings */
1156    UINT32                          Name;               /* ACPI object Name */
1157    ACPI_OBJECT_TYPE                Type;               /* ACPI object Type */
1158    UINT8                           ParamCount;         /* If a method, required parameter count */
1159    UINT8                           Valid;              /* Indicates which optional fields are valid */
1160    UINT8                           Flags;              /* Miscellaneous info */
1161    UINT8                           HighestDstates[4];  /* _SxD values: 0xFF indicates not valid */
1162    UINT8                           LowestDstates[5];   /* _SxW values: 0xFF indicates not valid */
1163    UINT32                          CurrentStatus;      /* _STA value */
1164    UINT64                          Address;            /* _ADR value */
1165    ACPI_DEVICE_ID                  HardwareId;         /* _HID value */
1166    ACPI_DEVICE_ID                  UniqueId;           /* _UID value */
1167    ACPI_DEVICE_ID_LIST             CompatibleIdList;   /* _CID list <must be last> */
1168
1169} ACPI_DEVICE_INFO;
1170
1171/* Values for Flags field above (AcpiGetObjectInfo) */
1172
1173#define ACPI_PCI_ROOT_BRIDGE            0x01
1174
1175/* Flags for Valid field above (AcpiGetObjectInfo) */
1176
1177#define ACPI_VALID_STA                  0x01
1178#define ACPI_VALID_ADR                  0x02
1179#define ACPI_VALID_HID                  0x04
1180#define ACPI_VALID_UID                  0x08
1181#define ACPI_VALID_CID                  0x10
1182#define ACPI_VALID_SXDS                 0x20
1183#define ACPI_VALID_SXWS                 0x40
1184
1185/* Flags for _STA method */
1186
1187#define ACPI_STA_DEVICE_PRESENT         0x01
1188#define ACPI_STA_DEVICE_ENABLED         0x02
1189#define ACPI_STA_DEVICE_UI              0x04
1190#define ACPI_STA_DEVICE_FUNCTIONING     0x08
1191#define ACPI_STA_DEVICE_OK              0x08 /* Synonym */
1192#define ACPI_STA_BATTERY_PRESENT        0x10
1193
1194
1195/* Context structs for address space handlers */
1196
1197typedef struct acpi_pci_id
1198{
1199    UINT16                          Segment;
1200    UINT16                          Bus;
1201    UINT16                          Device;
1202    UINT16                          Function;
1203
1204} ACPI_PCI_ID;
1205
1206typedef struct acpi_mem_space_context
1207{
1208    UINT32                          Length;
1209    ACPI_PHYSICAL_ADDRESS           Address;
1210    ACPI_PHYSICAL_ADDRESS           MappedPhysicalAddress;
1211    UINT8                           *MappedLogicalAddress;
1212    ACPI_SIZE                       MappedLength;
1213
1214} ACPI_MEM_SPACE_CONTEXT;
1215
1216
1217/*
1218 * ACPI_MEMORY_LIST is used only if the ACPICA local cache is enabled
1219 */
1220typedef struct acpi_memory_list
1221{
1222    char                            *ListName;
1223    void                            *ListHead;
1224    UINT16                          ObjectSize;
1225    UINT16                          MaxDepth;
1226    UINT16                          CurrentDepth;
1227    UINT16                          LinkOffset;
1228
1229#ifdef ACPI_DBG_TRACK_ALLOCATIONS
1230
1231    /* Statistics for debug memory tracking only */
1232
1233    UINT32                          TotalAllocated;
1234    UINT32                          TotalFreed;
1235    UINT32                          MaxOccupied;
1236    UINT32                          TotalSize;
1237    UINT32                          CurrentTotalSize;
1238    UINT32                          Requests;
1239    UINT32                          Hits;
1240#endif
1241
1242} ACPI_MEMORY_LIST;
1243
1244
1245#endif /* __ACTYPES_H__ */
1246