Import acpica-unix-20061109 from Intel.
[dragonfly.git] / sys / contrib / dev / acpica-unix-20061109 / include / actypes.h
1 /******************************************************************************
2  *
3  * Name: actypes.h - Common data types for the entire ACPI subsystem
4  *       $Revision: 1.312 $
5  *
6  *****************************************************************************/
7
8 /******************************************************************************
9  *
10  * 1. Copyright Notice
11  *
12  * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp.
13  * All rights reserved.
14  *
15  * 2. License
16  *
17  * 2.1. This is your license from Intel Corp. under its intellectual property
18  * rights.  You may have additional license terms from the party that provided
19  * you this software, covering your right to use that party's intellectual
20  * property rights.
21  *
22  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23  * copy of the source code appearing in this file ("Covered Code") an
24  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25  * base code distributed originally by Intel ("Original Intel Code") to copy,
26  * make derivatives, distribute, use and display any portion of the Covered
27  * Code in any form, with the right to sublicense such rights; and
28  *
29  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30  * license (with the right to sublicense), under only those claims of Intel
31  * patents that are infringed by the Original Intel Code, to make, use, sell,
32  * offer to sell, and import the Covered Code and derivative works thereof
33  * solely to the minimum extent necessary to exercise the above copyright
34  * license, and in no event shall the patent license extend to any additions
35  * to or modifications of the Original Intel Code.  No other license or right
36  * is granted directly or by implication, estoppel or otherwise;
37  *
38  * The above copyright and patent license is granted only if the following
39  * conditions are met:
40  *
41  * 3. Conditions
42  *
43  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44  * Redistribution of source code of any substantial portion of the Covered
45  * Code or modification with rights to further distribute source must include
46  * the above Copyright Notice, the above License, this list of Conditions,
47  * and the following Disclaimer and Export Compliance provision.  In addition,
48  * Licensee must cause all Covered Code to which Licensee contributes to
49  * contain a file documenting the changes Licensee made to create that Covered
50  * Code and the date of any change.  Licensee must include in that file the
51  * documentation of any changes made by any predecessor Licensee.  Licensee
52  * must include a prominent statement that the modification is derived,
53  * directly or indirectly, from Original Intel Code.
54  *
55  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56  * Redistribution of source code of any substantial portion of the Covered
57  * Code or modification without rights to further distribute source must
58  * include the following Disclaimer and Export Compliance provision in the
59  * documentation and/or other materials provided with distribution.  In
60  * addition, Licensee may not authorize further sublicense of source of any
61  * portion of the Covered Code, and must include terms to the effect that the
62  * license from Licensee to its licensee is limited to the intellectual
63  * property embodied in the software Licensee provides to its licensee, and
64  * not to intellectual property embodied in modifications its licensee may
65  * make.
66  *
67  * 3.3. Redistribution of Executable. Redistribution in executable form of any
68  * substantial portion of the Covered Code or modification must reproduce the
69  * above Copyright Notice, and the following Disclaimer and Export Compliance
70  * provision in the documentation and/or other materials provided with the
71  * distribution.
72  *
73  * 3.4. Intel retains all right, title, and interest in and to the Original
74  * Intel Code.
75  *
76  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77  * Intel shall be used in advertising or otherwise to promote the sale, use or
78  * other dealings in products derived from or relating to the Covered Code
79  * without prior written authorization from Intel.
80  *
81  * 4. Disclaimer and Export Compliance
82  *
83  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
86  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
87  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
88  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89  * PARTICULAR PURPOSE.
90  *
91  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
97  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98  * LIMITED REMEDY.
99  *
100  * 4.3. Licensee shall not export, either directly or indirectly, any of this
101  * software or system incorporating such software without first obtaining any
102  * required license or other approval from the U. S. Department of Commerce or
103  * any other agency or department of the United States Government.  In the
104  * event Licensee exports any such software from the United States or
105  * re-exports any such software from a foreign destination, Licensee shall
106  * ensure that the distribution and export/re-export of the software is in
107  * compliance with all laws, regulations, orders, or other restrictions of the
108  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109  * any of its subsidiaries will export/re-export any technical data, process,
110  * software, or service, directly or indirectly, to any country for which the
111  * United States government or any agency thereof requires an export license,
112  * other governmental approval, or letter of assurance, without first obtaining
113  * such license, approval or letter.
114  *
115  *****************************************************************************/
116
117 #ifndef __ACTYPES_H__
118 #define __ACTYPES_H__
119
120 /* acpisrc:StructDefs -- for acpisrc conversion */
121
122 /*
123  * ACPI_MACHINE_WIDTH must be specified in an OS- or compiler-dependent header
124  * and must be either 16, 32, or 64
125  */
126 #ifndef ACPI_MACHINE_WIDTH
127 #error ACPI_MACHINE_WIDTH not defined
128 #endif
129
130 /*! [Begin] no source code translation */
131
132 /*
133  * Data type ranges
134  * Note: These macros are designed to be compiler independent as well as
135  * working around problems that some 32-bit compilers have with 64-bit
136  * constants.
137  */
138 #define ACPI_UINT8_MAX                  (UINT8) (~((UINT8)  0)) /* 0xFF               */
139 #define ACPI_UINT16_MAX                 (UINT16)(~((UINT16) 0)) /* 0xFFFF             */
140 #define ACPI_UINT32_MAX                 (UINT32)(~((UINT32) 0)) /* 0xFFFFFFFF         */
141 #define ACPI_UINT64_MAX                 (UINT64)(~((UINT64) 0)) /* 0xFFFFFFFFFFFFFFFF */
142 #define ACPI_ASCII_MAX                  0x7F
143
144
145 /*
146  * Architecture-specific ACPICA Subsystem Data Types
147  *
148  * The goal of these types is to provide source code portability across
149  * 16-bit, 32-bit, and 64-bit targets.
150  *
151  * 1) The following types are of fixed size for all targets (16/32/64):
152  *
153  * BOOLEAN      Logical boolean
154  *
155  * UINT8        8-bit  (1 byte) unsigned value
156  * UINT16       16-bit (2 byte) unsigned value
157  * UINT32       32-bit (4 byte) unsigned value
158  * UINT64       64-bit (8 byte) unsigned value
159  *
160  * INT16        16-bit (2 byte) signed value
161  * INT32        32-bit (4 byte) signed value
162  * INT64        64-bit (8 byte) signed value
163  *
164  * COMPILER_DEPENDENT_UINT64/INT64 - These types are defined in the
165  * compiler-dependent header(s) and were introduced because there is no common
166  * 64-bit integer type across the various compilation models, as shown in
167  * the table below.
168  *
169  * Datatype  LP64 ILP64 LLP64 ILP32 LP32 16bit
170  * char      8    8     8     8     8    8
171  * short     16   16    16    16    16   16
172  * _int32         32
173  * int       32   64    32    32    16   16
174  * long      64   64    32    32    32   32
175  * long long            64    64
176  * pointer   64   64    64    32    32   32
177  *
178  * Note: ILP64 and LP32 are currently not supported.
179  *
180  *
181  * 2) These types represent the native word size of the target mode of the
182  * processor, and may be 16-bit, 32-bit, or 64-bit as required. They are
183  * usually used for memory allocation, efficient loop counters, and array
184  * indexes. The types are similar to the size_t type in the C library and are
185  * required because there is no C type that consistently represents the native
186  * data width.
187  *
188  * ACPI_SIZE        16/32/64-bit unsigned value
189  * ACPI_NATIVE_UINT 16/32/64-bit unsigned value
190  * ACPI_NATIVE_INT  16/32/64-bit signed value
191  *
192  */
193
194 /*******************************************************************************
195  *
196  * Common types for all compilers, all targets
197  *
198  ******************************************************************************/
199
200 typedef unsigned char                   BOOLEAN;
201 typedef unsigned char                   UINT8;
202 typedef unsigned short                  UINT16;
203 typedef COMPILER_DEPENDENT_UINT64       UINT64;
204 typedef COMPILER_DEPENDENT_INT64        INT64;
205
206 /*! [End] no source code translation !*/
207
208
209 /*******************************************************************************
210  *
211  * Types specific to 64-bit targets
212  *
213  ******************************************************************************/
214
215 #if ACPI_MACHINE_WIDTH == 64
216
217 /*! [Begin] no source code translation (keep the typedefs as-is) */
218
219 typedef unsigned int                    UINT32;
220 typedef int                             INT32;
221
222 /*! [End] no source code translation !*/
223
224
225 typedef UINT64                          ACPI_NATIVE_UINT;
226 typedef INT64                           ACPI_NATIVE_INT;
227
228 typedef UINT64                          ACPI_TABLE_PTR;
229 typedef UINT64                          ACPI_IO_ADDRESS;
230 typedef UINT64                          ACPI_PHYSICAL_ADDRESS;
231
232 #define ACPI_MAX_PTR                    ACPI_UINT64_MAX
233 #define ACPI_SIZE_MAX                   ACPI_UINT64_MAX
234
235 #define ACPI_NATIVE_BOUNDARY            8
236 #define ACPI_USE_NATIVE_DIVIDE          /* Has native 64-bit integer support */
237
238 /*
239  * In the case of the Itanium Processor Family (IPF), the hardware does not
240  * support misaligned memory transfers. Set the MISALIGNMENT_NOT_SUPPORTED flag
241  * to indicate that special precautions must be taken to avoid alignment faults.
242  * (IA64 or ia64 is currently used by existing compilers to indicate IPF.)
243  *
244  * Note: EM64T and other X86-64 processors support misaligned transfers,
245  * so there is no need to define this flag.
246  */
247 #if defined (__IA64__) || defined (__ia64__)
248 #define ACPI_MISALIGNMENT_NOT_SUPPORTED
249 #endif
250
251
252 /*******************************************************************************
253  *
254  * Types specific to 32-bit targets
255  *
256  ******************************************************************************/
257
258 #elif ACPI_MACHINE_WIDTH == 32
259
260 /*! [Begin] no source code translation (keep the typedefs as-is) */
261
262 typedef unsigned int                    UINT32;
263 typedef int                             INT32;
264
265 /*! [End] no source code translation !*/
266
267
268 typedef UINT32                          ACPI_NATIVE_UINT;
269 typedef INT32                           ACPI_NATIVE_INT;
270
271 typedef UINT64                          ACPI_TABLE_PTR;
272 typedef UINT32                          ACPI_IO_ADDRESS;
273 typedef UINT32                          ACPI_PHYSICAL_ADDRESS;
274
275 #define ACPI_MAX_PTR                    ACPI_UINT32_MAX
276 #define ACPI_SIZE_MAX                   ACPI_UINT32_MAX
277
278 #define ACPI_NATIVE_BOUNDARY            4
279
280
281 /*******************************************************************************
282  *
283  * Types specific to 16-bit targets
284  *
285  ******************************************************************************/
286
287 #elif ACPI_MACHINE_WIDTH == 16
288
289 /*! [Begin] no source code translation (keep the typedefs as-is) */
290
291 typedef unsigned long                   UINT32;
292 typedef short                           INT16;
293 typedef long                            INT32;
294
295 /*! [End] no source code translation !*/
296
297
298 typedef UINT16                          ACPI_NATIVE_UINT;
299 typedef INT16                           ACPI_NATIVE_INT;
300
301 typedef UINT32                          ACPI_TABLE_PTR;
302 typedef UINT32                          ACPI_IO_ADDRESS;
303 typedef char                            *ACPI_PHYSICAL_ADDRESS;
304
305 #define ACPI_MAX_PTR                    ACPI_UINT16_MAX
306 #define ACPI_SIZE_MAX                   ACPI_UINT16_MAX
307
308 #define ACPI_NATIVE_BOUNDARY            2
309 #define ACPI_USE_NATIVE_DIVIDE          /* No 64-bit integers, ok to use native divide */
310
311 /* 64-bit integers cannot be supported */
312
313 #define ACPI_NO_INTEGER64_SUPPORT
314
315
316 #else
317
318 /* ACPI_MACHINE_WIDTH must be either 64, 32, or 16 */
319
320 #error unknown ACPI_MACHINE_WIDTH
321 #endif
322
323
324 /* Variable-width type, used instead of clib size_t */
325
326 typedef ACPI_NATIVE_UINT                ACPI_SIZE;
327
328
329 /*******************************************************************************
330  *
331  * OS-dependent and compiler-dependent types
332  *
333  * If the defaults below are not appropriate for the host system, they can
334  * be defined in the compiler-specific or OS-specific header, and this will
335  * take precedence.
336  *
337  ******************************************************************************/
338
339
340 /* Value returned by AcpiOsGetThreadId */
341
342 #ifndef ACPI_THREAD_ID
343 #define ACPI_THREAD_ID                  ACPI_NATIVE_UINT
344 #endif
345
346 /* Object returned from AcpiOsCreateLock */
347
348 #ifndef ACPI_SPINLOCK
349 #define ACPI_SPINLOCK                   void *
350 #endif
351
352 /* Flags for AcpiOsAcquireLock/AcpiOsReleaseLock */
353
354 #ifndef ACPI_CPU_FLAGS
355 #define ACPI_CPU_FLAGS                  ACPI_NATIVE_UINT
356 #endif
357
358 /* Object returned from AcpiOsCreateCache */
359
360 #ifndef ACPI_CACHE_T
361 #define ACPI_CACHE_T                    ACPI_MEMORY_LIST
362 #endif
363
364 /* Use C99 uintptr_t for pointer casting if available, "void *" otherwise */
365
366 #ifndef ACPI_UINTPTR_T
367 #define ACPI_UINTPTR_T                  void *
368 #endif
369
370 /*
371  * ACPI_PRINTF_LIKE is used to tag functions as "printf-like" because
372  * some compilers can catch printf format string problems
373  */
374 #ifndef ACPI_PRINTF_LIKE
375 #define ACPI_PRINTF_LIKE(c)
376 #endif
377
378 /*
379  * Some compilers complain about unused variables. Sometimes we don't want to
380  * use all the variables (for example, _AcpiModuleName). This allows us
381  * to to tell the compiler in a per-variable manner that a variable
382  * is unused
383  */
384 #ifndef ACPI_UNUSED_VAR
385 #define ACPI_UNUSED_VAR
386 #endif
387
388 /*
389  * All ACPICA functions that are available to the rest of the kernel are
390  * tagged with this macro which can be defined as appropriate for the host.
391  */
392 #ifndef ACPI_EXPORT_SYMBOL
393 #define ACPI_EXPORT_SYMBOL(Symbol)
394 #endif
395
396
397 /*******************************************************************************
398  *
399  * Independent types
400  *
401  ******************************************************************************/
402
403 /* Logical defines and NULL */
404
405 #ifdef FALSE
406 #undef FALSE
407 #endif
408 #define FALSE                           (1 == 0)
409
410 #ifdef TRUE
411 #undef TRUE
412 #endif
413 #define TRUE                            (1 == 1)
414
415 #ifndef NULL
416 #define NULL                            (void *) 0
417 #endif
418
419
420 /*
421  * Mescellaneous types
422  */
423 typedef UINT32                          ACPI_STATUS;    /* All ACPI Exceptions */
424 typedef UINT32                          ACPI_NAME;      /* 4-byte ACPI name */
425 typedef char *                          ACPI_STRING;    /* Null terminated ASCII string */
426 typedef void *                          ACPI_HANDLE;    /* Actually a ptr to a NS Node */
427
428 typedef struct uint64_struct
429 {
430     UINT32                          Lo;
431     UINT32                          Hi;
432
433 } UINT64_STRUCT;
434
435 typedef union uint64_overlay
436 {
437     UINT64                          Full;
438     UINT64_STRUCT                   Part;
439
440 } UINT64_OVERLAY;
441
442 typedef struct uint32_struct
443 {
444     UINT32                          Lo;
445     UINT32                          Hi;
446
447 } UINT32_STRUCT;
448
449
450 /* Synchronization objects */
451
452 #define ACPI_MUTEX                      void *
453 #define ACPI_SEMAPHORE                  void *
454
455
456 /*
457  * Acpi integer width. In ACPI version 1, integers are
458  * 32 bits.  In ACPI version 2, integers are 64 bits.
459  * Note that this pertains to the ACPI integer type only, not
460  * other integers used in the implementation of the ACPI CA
461  * subsystem.
462  */
463 #ifdef ACPI_NO_INTEGER64_SUPPORT
464
465 /* 32-bit integers only, no 64-bit support */
466
467 typedef UINT32                          ACPI_INTEGER;
468 #define ACPI_INTEGER_MAX                ACPI_UINT32_MAX
469 #define ACPI_INTEGER_BIT_SIZE           32
470 #define ACPI_MAX_DECIMAL_DIGITS         10  /* 2^32 = 4,294,967,296 */
471
472 #define ACPI_USE_NATIVE_DIVIDE          /* Use compiler native 32-bit divide */
473
474
475 #else
476
477 /* 64-bit integers */
478
479 typedef UINT64                          ACPI_INTEGER;
480 #define ACPI_INTEGER_MAX                ACPI_UINT64_MAX
481 #define ACPI_INTEGER_BIT_SIZE           64
482 #define ACPI_MAX_DECIMAL_DIGITS         20  /* 2^64 = 18,446,744,073,709,551,616 */
483
484
485 #if ACPI_MACHINE_WIDTH == 64
486 #define ACPI_USE_NATIVE_DIVIDE          /* Use compiler native 64-bit divide */
487 #endif
488 #endif
489
490 #define ACPI_MAX64_DECIMAL_DIGITS       20
491 #define ACPI_MAX32_DECIMAL_DIGITS       10
492 #define ACPI_MAX16_DECIMAL_DIGITS        5
493 #define ACPI_MAX8_DECIMAL_DIGITS         3
494
495 /*
496  * Constants with special meanings
497  */
498 #define ACPI_ROOT_OBJECT                ACPI_ADD_PTR (ACPI_HANDLE, NULL, ACPI_MAX_PTR)
499
500
501 /*
502  * Initialization sequence
503  */
504 #define ACPI_FULL_INITIALIZATION        0x00
505 #define ACPI_NO_ADDRESS_SPACE_INIT      0x01
506 #define ACPI_NO_HARDWARE_INIT           0x02
507 #define ACPI_NO_EVENT_INIT              0x04
508 #define ACPI_NO_HANDLER_INIT            0x08
509 #define ACPI_NO_ACPI_ENABLE             0x10
510 #define ACPI_NO_DEVICE_INIT             0x20
511 #define ACPI_NO_OBJECT_INIT             0x40
512
513 /*
514  * Initialization state
515  */
516 #define ACPI_SUBSYSTEM_INITIALIZE       0x01
517 #define ACPI_INITIALIZED_OK             0x02
518
519 /*
520  * Power state values
521  */
522 #define ACPI_STATE_UNKNOWN              (UINT8) 0xFF
523
524 #define ACPI_STATE_S0                   (UINT8) 0
525 #define ACPI_STATE_S1                   (UINT8) 1
526 #define ACPI_STATE_S2                   (UINT8) 2
527 #define ACPI_STATE_S3                   (UINT8) 3
528 #define ACPI_STATE_S4                   (UINT8) 4
529 #define ACPI_STATE_S5                   (UINT8) 5
530 #define ACPI_S_STATES_MAX               ACPI_STATE_S5
531 #define ACPI_S_STATE_COUNT              6
532
533 #define ACPI_STATE_D0                   (UINT8) 0
534 #define ACPI_STATE_D1                   (UINT8) 1
535 #define ACPI_STATE_D2                   (UINT8) 2
536 #define ACPI_STATE_D3                   (UINT8) 3
537 #define ACPI_D_STATES_MAX               ACPI_STATE_D3
538 #define ACPI_D_STATE_COUNT              4
539
540 #define ACPI_STATE_C0                   (UINT8) 0
541 #define ACPI_STATE_C1                   (UINT8) 1
542 #define ACPI_STATE_C2                   (UINT8) 2
543 #define ACPI_STATE_C3                   (UINT8) 3
544 #define ACPI_C_STATES_MAX               ACPI_STATE_C3
545 #define ACPI_C_STATE_COUNT              4
546
547 /*
548  * Sleep type invalid value
549  */
550 #define ACPI_SLEEP_TYPE_MAX             0x7
551 #define ACPI_SLEEP_TYPE_INVALID         0xFF
552
553 /*
554  * Standard notify values
555  */
556 #define ACPI_NOTIFY_BUS_CHECK           (UINT8) 0
557 #define ACPI_NOTIFY_DEVICE_CHECK        (UINT8) 1
558 #define ACPI_NOTIFY_DEVICE_WAKE         (UINT8) 2
559 #define ACPI_NOTIFY_EJECT_REQUEST       (UINT8) 3
560 #define ACPI_NOTIFY_DEVICE_CHECK_LIGHT  (UINT8) 4
561 #define ACPI_NOTIFY_FREQUENCY_MISMATCH  (UINT8) 5
562 #define ACPI_NOTIFY_BUS_MODE_MISMATCH   (UINT8) 6
563 #define ACPI_NOTIFY_POWER_FAULT         (UINT8) 7
564
565 /*
566  * Types associated with ACPI names and objects.  The first group of
567  * values (up to ACPI_TYPE_EXTERNAL_MAX) correspond to the definition
568  * of the ACPI ObjectType() operator (See the ACPI Spec).  Therefore,
569  * only add to the first group if the spec changes.
570  *
571  * NOTE: Types must be kept in sync with the global AcpiNsProperties
572  * and AcpiNsTypeNames arrays.
573  */
574 typedef UINT32                          ACPI_OBJECT_TYPE;
575
576 #define ACPI_TYPE_ANY                   0x00
577 #define ACPI_TYPE_INTEGER               0x01  /* Byte/Word/Dword/Zero/One/Ones */
578 #define ACPI_TYPE_STRING                0x02
579 #define ACPI_TYPE_BUFFER                0x03
580 #define ACPI_TYPE_PACKAGE               0x04  /* ByteConst, multiple DataTerm/Constant/SuperName */
581 #define ACPI_TYPE_FIELD_UNIT            0x05
582 #define ACPI_TYPE_DEVICE                0x06  /* Name, multiple Node */
583 #define ACPI_TYPE_EVENT                 0x07
584 #define ACPI_TYPE_METHOD                0x08  /* Name, ByteConst, multiple Code */
585 #define ACPI_TYPE_MUTEX                 0x09
586 #define ACPI_TYPE_REGION                0x0A
587 #define ACPI_TYPE_POWER                 0x0B  /* Name,ByteConst,WordConst,multi Node */
588 #define ACPI_TYPE_PROCESSOR             0x0C  /* Name,ByteConst,DWordConst,ByteConst,multi NmO */
589 #define ACPI_TYPE_THERMAL               0x0D  /* Name, multiple Node */
590 #define ACPI_TYPE_BUFFER_FIELD          0x0E
591 #define ACPI_TYPE_DDB_HANDLE            0x0F
592 #define ACPI_TYPE_DEBUG_OBJECT          0x10
593
594 #define ACPI_TYPE_EXTERNAL_MAX          0x10
595
596 /*
597  * These are object types that do not map directly to the ACPI
598  * ObjectType() operator. They are used for various internal purposes only.
599  * If new predefined ACPI_TYPEs are added (via the ACPI specification), these
600  * internal types must move upwards. (There is code that depends on these
601  * values being contiguous with the external types above.)
602  */
603 #define ACPI_TYPE_LOCAL_REGION_FIELD    0x11
604 #define ACPI_TYPE_LOCAL_BANK_FIELD      0x12
605 #define ACPI_TYPE_LOCAL_INDEX_FIELD     0x13
606 #define ACPI_TYPE_LOCAL_REFERENCE       0x14  /* Arg#, Local#, Name, Debug, RefOf, Index */
607 #define ACPI_TYPE_LOCAL_ALIAS           0x15
608 #define ACPI_TYPE_LOCAL_METHOD_ALIAS    0x16
609 #define ACPI_TYPE_LOCAL_NOTIFY          0x17
610 #define ACPI_TYPE_LOCAL_ADDRESS_HANDLER 0x18
611 #define ACPI_TYPE_LOCAL_RESOURCE        0x19
612 #define ACPI_TYPE_LOCAL_RESOURCE_FIELD  0x1A
613 #define ACPI_TYPE_LOCAL_SCOPE           0x1B  /* 1 Name, multiple ObjectList Nodes */
614
615 #define ACPI_TYPE_NS_NODE_MAX           0x1B  /* Last typecode used within a NS Node */
616
617 /*
618  * These are special object types that never appear in
619  * a Namespace node, only in an ACPI_OPERAND_OBJECT
620  */
621 #define ACPI_TYPE_LOCAL_EXTRA           0x1C
622 #define ACPI_TYPE_LOCAL_DATA            0x1D
623
624 #define ACPI_TYPE_LOCAL_MAX             0x1D
625
626 /* All types above here are invalid */
627
628 #define ACPI_TYPE_INVALID               0x1E
629 #define ACPI_TYPE_NOT_FOUND             0xFF
630
631 /*
632  * All I/O
633  */
634 #define ACPI_READ                       0
635 #define ACPI_WRITE                      1
636 #define ACPI_IO_MASK                    1
637
638 /*
639  * Event Types: Fixed & General Purpose
640  */
641 typedef UINT32                          ACPI_EVENT_TYPE;
642
643 /*
644  * Fixed events
645  */
646 #define ACPI_EVENT_PMTIMER              0
647 #define ACPI_EVENT_GLOBAL               1
648 #define ACPI_EVENT_POWER_BUTTON         2
649 #define ACPI_EVENT_SLEEP_BUTTON         3
650 #define ACPI_EVENT_RTC                  4
651 #define ACPI_EVENT_MAX                  4
652 #define ACPI_NUM_FIXED_EVENTS           ACPI_EVENT_MAX + 1
653
654 /*
655  * Event Status - Per event
656  * -------------
657  * The encoding of ACPI_EVENT_STATUS is illustrated below.
658  * Note that a set bit (1) indicates the property is TRUE
659  * (e.g. if bit 0 is set then the event is enabled).
660  * +-------------+-+-+-+
661  * |   Bits 31:3 |2|1|0|
662  * +-------------+-+-+-+
663  *          |     | | |
664  *          |     | | +- Enabled?
665  *          |     | +--- Enabled for wake?
666  *          |     +----- Set?
667  *          +----------- <Reserved>
668  */
669 typedef UINT32                          ACPI_EVENT_STATUS;
670
671 #define ACPI_EVENT_FLAG_DISABLED        (ACPI_EVENT_STATUS) 0x00
672 #define ACPI_EVENT_FLAG_ENABLED         (ACPI_EVENT_STATUS) 0x01
673 #define ACPI_EVENT_FLAG_WAKE_ENABLED    (ACPI_EVENT_STATUS) 0x02
674 #define ACPI_EVENT_FLAG_SET             (ACPI_EVENT_STATUS) 0x04
675
676 /*
677  * General Purpose Events (GPE)
678  */
679 #define ACPI_GPE_INVALID                0xFF
680 #define ACPI_GPE_MAX                    0xFF
681 #define ACPI_NUM_GPE                    256
682
683 #define ACPI_GPE_ENABLE                 0
684 #define ACPI_GPE_DISABLE                1
685
686
687 /*
688  * GPE info flags - Per GPE
689  * +-+-+-+---+---+-+
690  * |7|6|5|4:3|2:1|0|
691  * +-+-+-+---+---+-+
692  *  | | |  |   |  |
693  *  | | |  |   |  +--- Interrupt type: Edge or Level Triggered
694  *  | | |  |   +--- Type: Wake-only, Runtime-only, or wake/runtime
695  *  | | |  +--- Type of dispatch -- to method, handler, or none
696  *  | | +--- Enabled for runtime?
697  *  | +--- Enabled for wake?
698  *  +--- Unused
699  */
700 #define ACPI_GPE_XRUPT_TYPE_MASK        (UINT8) 0x01
701 #define ACPI_GPE_LEVEL_TRIGGERED        (UINT8) 0x01
702 #define ACPI_GPE_EDGE_TRIGGERED         (UINT8) 0x00
703
704 #define ACPI_GPE_TYPE_MASK              (UINT8) 0x06
705 #define ACPI_GPE_TYPE_WAKE_RUN          (UINT8) 0x06
706 #define ACPI_GPE_TYPE_WAKE              (UINT8) 0x02
707 #define ACPI_GPE_TYPE_RUNTIME           (UINT8) 0x04    /* Default */
708
709 #define ACPI_GPE_DISPATCH_MASK          (UINT8) 0x18
710 #define ACPI_GPE_DISPATCH_HANDLER       (UINT8) 0x08
711 #define ACPI_GPE_DISPATCH_METHOD        (UINT8) 0x10
712 #define ACPI_GPE_DISPATCH_NOT_USED      (UINT8) 0x00    /* Default */
713
714 #define ACPI_GPE_RUN_ENABLE_MASK        (UINT8) 0x20
715 #define ACPI_GPE_RUN_ENABLED            (UINT8) 0x20
716 #define ACPI_GPE_RUN_DISABLED           (UINT8) 0x00    /* Default */
717
718 #define ACPI_GPE_WAKE_ENABLE_MASK       (UINT8) 0x40
719 #define ACPI_GPE_WAKE_ENABLED           (UINT8) 0x40
720 #define ACPI_GPE_WAKE_DISABLED          (UINT8) 0x00    /* Default */
721
722 #define ACPI_GPE_ENABLE_MASK            (UINT8) 0x60    /* Both run/wake */
723
724 /*
725  * Flags for GPE and Lock interfaces
726  */
727 #define ACPI_EVENT_WAKE_ENABLE          0x2             /* AcpiGpeEnable */
728 #define ACPI_EVENT_WAKE_DISABLE         0x2             /* AcpiGpeDisable */
729
730 #define ACPI_NOT_ISR                    0x1
731 #define ACPI_ISR                        0x0
732
733
734 /* Notify types */
735
736 #define ACPI_SYSTEM_NOTIFY              0x1
737 #define ACPI_DEVICE_NOTIFY              0x2
738 #define ACPI_ALL_NOTIFY                 0x3
739 #define ACPI_MAX_NOTIFY_HANDLER_TYPE    0x3
740
741 #define ACPI_MAX_SYS_NOTIFY             0x7f
742
743
744 /* Address Space (Operation Region) Types */
745
746 typedef UINT8                           ACPI_ADR_SPACE_TYPE;
747
748 #define ACPI_ADR_SPACE_SYSTEM_MEMORY    (ACPI_ADR_SPACE_TYPE) 0
749 #define ACPI_ADR_SPACE_SYSTEM_IO        (ACPI_ADR_SPACE_TYPE) 1
750 #define ACPI_ADR_SPACE_PCI_CONFIG       (ACPI_ADR_SPACE_TYPE) 2
751 #define ACPI_ADR_SPACE_EC               (ACPI_ADR_SPACE_TYPE) 3
752 #define ACPI_ADR_SPACE_SMBUS            (ACPI_ADR_SPACE_TYPE) 4
753 #define ACPI_ADR_SPACE_CMOS             (ACPI_ADR_SPACE_TYPE) 5
754 #define ACPI_ADR_SPACE_PCI_BAR_TARGET   (ACPI_ADR_SPACE_TYPE) 6
755 #define ACPI_ADR_SPACE_DATA_TABLE       (ACPI_ADR_SPACE_TYPE) 7
756 #define ACPI_ADR_SPACE_FIXED_HARDWARE   (ACPI_ADR_SPACE_TYPE) 127
757
758
759 /*
760  * BitRegister IDs
761  * These are bitfields defined within the full ACPI registers
762  */
763 #define ACPI_BITREG_TIMER_STATUS                0x00
764 #define ACPI_BITREG_BUS_MASTER_STATUS           0x01
765 #define ACPI_BITREG_GLOBAL_LOCK_STATUS          0x02
766 #define ACPI_BITREG_POWER_BUTTON_STATUS         0x03
767 #define ACPI_BITREG_SLEEP_BUTTON_STATUS         0x04
768 #define ACPI_BITREG_RT_CLOCK_STATUS             0x05
769 #define ACPI_BITREG_WAKE_STATUS                 0x06
770 #define ACPI_BITREG_PCIEXP_WAKE_STATUS          0x07
771
772 #define ACPI_BITREG_TIMER_ENABLE                0x08
773 #define ACPI_BITREG_GLOBAL_LOCK_ENABLE          0x09
774 #define ACPI_BITREG_POWER_BUTTON_ENABLE         0x0A
775 #define ACPI_BITREG_SLEEP_BUTTON_ENABLE         0x0B
776 #define ACPI_BITREG_RT_CLOCK_ENABLE             0x0C
777 #define ACPI_BITREG_WAKE_ENABLE                 0x0D
778 #define ACPI_BITREG_PCIEXP_WAKE_DISABLE         0x0E
779
780 #define ACPI_BITREG_SCI_ENABLE                  0x0F
781 #define ACPI_BITREG_BUS_MASTER_RLD              0x10
782 #define ACPI_BITREG_GLOBAL_LOCK_RELEASE         0x11
783 #define ACPI_BITREG_SLEEP_TYPE_A                0x12
784 #define ACPI_BITREG_SLEEP_TYPE_B                0x13
785 #define ACPI_BITREG_SLEEP_ENABLE                0x14
786
787 #define ACPI_BITREG_ARB_DISABLE                 0x15
788
789 #define ACPI_BITREG_MAX                         0x15
790 #define ACPI_NUM_BITREG                         ACPI_BITREG_MAX + 1
791
792
793 /*
794  * External ACPI object definition
795  */
796 typedef union acpi_object
797 {
798     ACPI_OBJECT_TYPE                Type;   /* See definition of AcpiNsType for values */
799     struct
800     {
801         ACPI_OBJECT_TYPE                Type;
802         ACPI_INTEGER                    Value;      /* The actual number */
803     } Integer;
804
805     struct
806     {
807         ACPI_OBJECT_TYPE                Type;
808         UINT32                          Length;     /* # of bytes in string, excluding trailing null */
809         char                            *Pointer;   /* points to the string value */
810     } String;
811
812     struct
813     {
814         ACPI_OBJECT_TYPE                Type;
815         UINT32                          Length;     /* # of bytes in buffer */
816         UINT8                           *Pointer;   /* points to the buffer */
817     } Buffer;
818
819     struct
820     {
821         ACPI_OBJECT_TYPE                Type;
822         UINT32                          Fill1;
823         ACPI_HANDLE                     Handle;     /* object reference */
824     } Reference;
825
826     struct
827     {
828         ACPI_OBJECT_TYPE                Type;
829         UINT32                          Count;      /* # of elements in package */
830         union acpi_object               *Elements;  /* Pointer to an array of ACPI_OBJECTs */
831     } Package;
832
833     struct
834     {
835         ACPI_OBJECT_TYPE                Type;
836         UINT32                          ProcId;
837         ACPI_IO_ADDRESS                 PblkAddress;
838         UINT32                          PblkLength;
839     } Processor;
840
841     struct
842     {
843         ACPI_OBJECT_TYPE                Type;
844         UINT32                          SystemLevel;
845         UINT32                          ResourceOrder;
846     } PowerResource;
847
848 } ACPI_OBJECT;
849
850
851 /*
852  * List of objects, used as a parameter list for control method evaluation
853  */
854 typedef struct acpi_object_list
855 {
856     UINT32                          Count;
857     ACPI_OBJECT                     *Pointer;
858
859 } ACPI_OBJECT_LIST;
860
861
862 /*
863  * Miscellaneous common Data Structures used by the interfaces
864  */
865 #define ACPI_NO_BUFFER              0
866 #define ACPI_ALLOCATE_BUFFER        (ACPI_SIZE) (-1)
867 #define ACPI_ALLOCATE_LOCAL_BUFFER  (ACPI_SIZE) (-2)
868
869 typedef struct acpi_buffer
870 {
871     ACPI_SIZE                       Length;         /* Length in bytes of the buffer */
872     void                            *Pointer;       /* pointer to buffer */
873
874 } ACPI_BUFFER;
875
876
877 /*
878  * NameType for AcpiGetName
879  */
880 #define ACPI_FULL_PATHNAME              0
881 #define ACPI_SINGLE_NAME                1
882 #define ACPI_NAME_TYPE_MAX              1
883
884
885 /*
886  * Structure and flags for AcpiGetSystemInfo
887  */
888 #define ACPI_SYS_MODE_UNKNOWN           0x0000
889 #define ACPI_SYS_MODE_ACPI              0x0001
890 #define ACPI_SYS_MODE_LEGACY            0x0002
891 #define ACPI_SYS_MODES_MASK             0x0003
892
893
894 /*
895  * System info returned by AcpiGetSystemInfo()
896  */
897 typedef struct acpi_system_info
898 {
899     UINT32                          AcpiCaVersion;
900     UINT32                          Flags;
901     UINT32                          TimerResolution;
902     UINT32                          Reserved1;
903     UINT32                          Reserved2;
904     UINT32                          DebugLevel;
905     UINT32                          DebugLayer;
906
907 } ACPI_SYSTEM_INFO;
908
909
910 /*
911  * Types specific to the OS service interfaces
912  */
913 typedef UINT32
914 (ACPI_SYSTEM_XFACE *ACPI_OSD_HANDLER) (
915     void                            *Context);
916
917 typedef void
918 (ACPI_SYSTEM_XFACE *ACPI_OSD_EXEC_CALLBACK) (
919     void                            *Context);
920
921 /*
922  * Various handlers and callback procedures
923  */
924 typedef
925 UINT32 (*ACPI_EVENT_HANDLER) (
926     void                            *Context);
927
928 typedef
929 void (*ACPI_NOTIFY_HANDLER) (
930     ACPI_HANDLE                     Device,
931     UINT32                          Value,
932     void                            *Context);
933
934 typedef
935 void (*ACPI_OBJECT_HANDLER) (
936     ACPI_HANDLE                     Object,
937     UINT32                          Function,
938     void                            *Data);
939
940 typedef
941 ACPI_STATUS (*ACPI_INIT_HANDLER) (
942     ACPI_HANDLE                     Object,
943     UINT32                          Function);
944
945 #define ACPI_INIT_DEVICE_INI        1
946
947 typedef
948 ACPI_STATUS (*ACPI_EXCEPTION_HANDLER) (
949     ACPI_STATUS                     AmlStatus,
950     ACPI_NAME                       Name,
951     UINT16                          Opcode,
952     UINT32                          AmlOffset,
953     void                            *Context);
954
955
956 /* Address Spaces (For Operation Regions) */
957
958 typedef
959 ACPI_STATUS (*ACPI_ADR_SPACE_HANDLER) (
960     UINT32                          Function,
961     ACPI_PHYSICAL_ADDRESS           Address,
962     UINT32                          BitWidth,
963     ACPI_INTEGER                    *Value,
964     void                            *HandlerContext,
965     void                            *RegionContext);
966
967 #define ACPI_DEFAULT_HANDLER            NULL
968
969
970 typedef
971 ACPI_STATUS (*ACPI_ADR_SPACE_SETUP) (
972     ACPI_HANDLE                     RegionHandle,
973     UINT32                          Function,
974     void                            *HandlerContext,
975     void                            **RegionContext);
976
977 #define ACPI_REGION_ACTIVATE    0
978 #define ACPI_REGION_DEACTIVATE  1
979
980 typedef
981 ACPI_STATUS (*ACPI_WALK_CALLBACK) (
982     ACPI_HANDLE                     ObjHandle,
983     UINT32                          NestingLevel,
984     void                            *Context,
985     void                            **ReturnValue);
986
987
988 /* Interrupt handler return values */
989
990 #define ACPI_INTERRUPT_NOT_HANDLED      0x00
991 #define ACPI_INTERRUPT_HANDLED          0x01
992
993
994 /* Common string version of device HIDs and UIDs */
995
996 typedef struct acpi_device_id
997 {
998     char                            Value[ACPI_DEVICE_ID_LENGTH];
999
1000 } ACPI_DEVICE_ID;
1001
1002 /* Common string version of device CIDs */
1003
1004 typedef struct acpi_compatible_id
1005 {
1006     char                            Value[ACPI_MAX_CID_LENGTH];
1007
1008 } ACPI_COMPATIBLE_ID;
1009
1010 typedef struct acpi_compatible_id_list
1011 {
1012     UINT32                          Count;
1013     UINT32                          Size;
1014     ACPI_COMPATIBLE_ID              Id[1];
1015
1016 } ACPI_COMPATIBLE_ID_LIST;
1017
1018
1019 /* Structure and flags for AcpiGetObjectInfo */
1020
1021 #define ACPI_VALID_STA                  0x0001
1022 #define ACPI_VALID_ADR                  0x0002
1023 #define ACPI_VALID_HID                  0x0004
1024 #define ACPI_VALID_UID                  0x0008
1025 #define ACPI_VALID_CID                  0x0010
1026 #define ACPI_VALID_SXDS                 0x0020
1027
1028 /* Flags for _STA method */
1029
1030 #define ACPI_STA_DEVICE_PRESENT         0x01
1031 #define ACPI_STA_DEVICE_ENABLED         0x02
1032 #define ACPI_STA_DEVICE_UI              0x04
1033 #define ACPI_STA_DEVICE_FUNCTIONING     0x08
1034 #define ACPI_STA_DEVICE_OK              0x08 /* Synonym */
1035 #define ACPI_STA_BATTERY_PRESENT        0x10
1036
1037
1038 #define ACPI_COMMON_OBJ_INFO \
1039     ACPI_OBJECT_TYPE                Type;           /* ACPI object type */ \
1040     ACPI_NAME                       Name            /* ACPI object Name */
1041
1042
1043 typedef struct acpi_obj_info_header
1044 {
1045     ACPI_COMMON_OBJ_INFO;
1046
1047 } ACPI_OBJ_INFO_HEADER;
1048
1049
1050 /* Structure returned from Get Object Info */
1051
1052 typedef struct acpi_device_info
1053 {
1054     ACPI_COMMON_OBJ_INFO;
1055
1056     UINT32                          Valid;              /* Indicates which fields below are valid */
1057     UINT32                          CurrentStatus;      /* _STA value */
1058     ACPI_INTEGER                    Address;            /* _ADR value if any */
1059     ACPI_DEVICE_ID                  HardwareId;         /* _HID value if any */
1060     ACPI_DEVICE_ID                  UniqueId;           /* _UID value if any */
1061     UINT8                           HighestDstates[4];  /* _SxD values: 0xFF indicates not valid */
1062     ACPI_COMPATIBLE_ID_LIST         CompatibilityId;    /* List of _CIDs if any */
1063
1064 } ACPI_DEVICE_INFO;
1065
1066
1067 /* Context structs for address space handlers */
1068
1069 typedef struct acpi_pci_id
1070 {
1071     UINT16                          Segment;
1072     UINT16                          Bus;
1073     UINT16                          Device;
1074     UINT16                          Function;
1075
1076 } ACPI_PCI_ID;
1077
1078
1079 typedef struct acpi_mem_space_context
1080 {
1081     UINT32                          Length;
1082     ACPI_PHYSICAL_ADDRESS           Address;
1083     ACPI_PHYSICAL_ADDRESS           MappedPhysicalAddress;
1084     UINT8                           *MappedLogicalAddress;
1085     ACPI_SIZE                       MappedLength;
1086
1087 } ACPI_MEM_SPACE_CONTEXT;
1088
1089
1090 /*
1091  * Definitions for Resource Attributes
1092  */
1093 typedef UINT16                          ACPI_RS_LENGTH;    /* Resource Length field is fixed at 16 bits */
1094 typedef UINT32                          ACPI_RSDESC_SIZE;  /* Max Resource Descriptor size is (Length+3) = (64K-1)+3 */
1095
1096 /*
1097  *  Memory Attributes
1098  */
1099 #define ACPI_READ_ONLY_MEMORY           (UINT8) 0x00
1100 #define ACPI_READ_WRITE_MEMORY          (UINT8) 0x01
1101
1102 #define ACPI_NON_CACHEABLE_MEMORY       (UINT8) 0x00
1103 #define ACPI_CACHABLE_MEMORY            (UINT8) 0x01
1104 #define ACPI_WRITE_COMBINING_MEMORY     (UINT8) 0x02
1105 #define ACPI_PREFETCHABLE_MEMORY        (UINT8) 0x03
1106
1107 /*
1108  *  IO Attributes
1109  *  The ISA IO ranges are:     n000-n0FFh,  n400-n4FFh, n800-n8FFh, nC00-nCFFh.
1110  *  The non-ISA IO ranges are: n100-n3FFh,  n500-n7FFh, n900-nBFFh, nCD0-nFFFh.
1111  */
1112 #define ACPI_NON_ISA_ONLY_RANGES        (UINT8) 0x01
1113 #define ACPI_ISA_ONLY_RANGES            (UINT8) 0x02
1114 #define ACPI_ENTIRE_RANGE               (ACPI_NON_ISA_ONLY_RANGES | ACPI_ISA_ONLY_RANGES)
1115
1116 /* Type of translation - 1=Sparse, 0=Dense */
1117
1118 #define ACPI_SPARSE_TRANSLATION         (UINT8) 0x01
1119
1120 /*
1121  *  IO Port Descriptor Decode
1122  */
1123 #define ACPI_DECODE_10                  (UINT8) 0x00    /* 10-bit IO address decode */
1124 #define ACPI_DECODE_16                  (UINT8) 0x01    /* 16-bit IO address decode */
1125
1126 /*
1127  *  IRQ Attributes
1128  */
1129 #define ACPI_LEVEL_SENSITIVE            (UINT8) 0x00
1130 #define ACPI_EDGE_SENSITIVE             (UINT8) 0x01
1131
1132 #define ACPI_ACTIVE_HIGH                (UINT8) 0x00
1133 #define ACPI_ACTIVE_LOW                 (UINT8) 0x01
1134
1135 #define ACPI_EXCLUSIVE                  (UINT8) 0x00
1136 #define ACPI_SHARED                     (UINT8) 0x01
1137
1138 /*
1139  *  DMA Attributes
1140  */
1141 #define ACPI_COMPATIBILITY              (UINT8) 0x00
1142 #define ACPI_TYPE_A                     (UINT8) 0x01
1143 #define ACPI_TYPE_B                     (UINT8) 0x02
1144 #define ACPI_TYPE_F                     (UINT8) 0x03
1145
1146 #define ACPI_NOT_BUS_MASTER             (UINT8) 0x00
1147 #define ACPI_BUS_MASTER                 (UINT8) 0x01
1148
1149 #define ACPI_TRANSFER_8                 (UINT8) 0x00
1150 #define ACPI_TRANSFER_8_16              (UINT8) 0x01
1151 #define ACPI_TRANSFER_16                (UINT8) 0x02
1152
1153 /*
1154  * Start Dependent Functions Priority definitions
1155  */
1156 #define ACPI_GOOD_CONFIGURATION         (UINT8) 0x00
1157 #define ACPI_ACCEPTABLE_CONFIGURATION   (UINT8) 0x01
1158 #define ACPI_SUB_OPTIMAL_CONFIGURATION  (UINT8) 0x02
1159
1160 /*
1161  *  16, 32 and 64-bit Address Descriptor resource types
1162  */
1163 #define ACPI_MEMORY_RANGE               (UINT8) 0x00
1164 #define ACPI_IO_RANGE                   (UINT8) 0x01
1165 #define ACPI_BUS_NUMBER_RANGE           (UINT8) 0x02
1166
1167 #define ACPI_ADDRESS_NOT_FIXED          (UINT8) 0x00
1168 #define ACPI_ADDRESS_FIXED              (UINT8) 0x01
1169
1170 #define ACPI_POS_DECODE                 (UINT8) 0x00
1171 #define ACPI_SUB_DECODE                 (UINT8) 0x01
1172
1173 #define ACPI_PRODUCER                   (UINT8) 0x00
1174 #define ACPI_CONSUMER                   (UINT8) 0x01
1175
1176
1177 /*
1178  * If possible, pack the following structures to byte alignment
1179  */
1180 #ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED
1181 #pragma pack(1)
1182 #endif
1183
1184 /* UUID data structures for use in vendor-defined resource descriptors */
1185
1186 typedef struct acpi_uuid
1187 {
1188     UINT8                           Data[ACPI_UUID_LENGTH];
1189 } ACPI_UUID;
1190
1191 typedef struct acpi_vendor_uuid
1192 {
1193     UINT8                           Subtype;
1194     UINT8                           Data[ACPI_UUID_LENGTH];
1195
1196 } ACPI_VENDOR_UUID;
1197
1198 /*
1199  *  Structures used to describe device resources
1200  */
1201 typedef struct acpi_resource_irq
1202 {
1203     UINT8                           Triggering;
1204     UINT8                           Polarity;
1205     UINT8                           Sharable;
1206     UINT8                           InterruptCount;
1207     UINT8                           Interrupts[1];
1208
1209 } ACPI_RESOURCE_IRQ;
1210
1211
1212 typedef struct ACPI_RESOURCE_DMA
1213 {
1214     UINT8                           Type;
1215     UINT8                           BusMaster;
1216     UINT8                           Transfer;
1217     UINT8                           ChannelCount;
1218     UINT8                           Channels[1];
1219
1220 } ACPI_RESOURCE_DMA;
1221
1222
1223 typedef struct acpi_resource_start_dependent
1224 {
1225     UINT8                           CompatibilityPriority;
1226     UINT8                           PerformanceRobustness;
1227
1228 } ACPI_RESOURCE_START_DEPENDENT;
1229
1230
1231 /*
1232  * END_DEPENDENT_FUNCTIONS_RESOURCE struct is not
1233  * needed because it has no fields
1234  */
1235
1236
1237 typedef struct acpi_resource_io
1238 {
1239     UINT8                           IoDecode;
1240     UINT8                           Alignment;
1241     UINT8                           AddressLength;
1242     UINT16                          Minimum;
1243     UINT16                          Maximum;
1244
1245 } ACPI_RESOURCE_IO;
1246
1247 typedef struct acpi_resource_fixed_io
1248 {
1249     UINT16                          Address;
1250     UINT8                           AddressLength;
1251
1252 } ACPI_RESOURCE_FIXED_IO;
1253
1254 typedef struct acpi_resource_vendor
1255 {
1256     UINT16                          ByteLength;
1257     UINT8                           ByteData[1];
1258
1259 } ACPI_RESOURCE_VENDOR;
1260
1261 /* Vendor resource with UUID info (introduced in ACPI 3.0) */
1262
1263 typedef struct acpi_resource_vendor_typed
1264 {
1265     UINT16                          ByteLength;
1266     UINT8                           UuidSubtype;
1267     UINT8                           Uuid[ACPI_UUID_LENGTH];
1268     UINT8                           ByteData[1];
1269
1270 } ACPI_RESOURCE_VENDOR_TYPED;
1271
1272 typedef struct acpi_resource_end_tag
1273 {
1274     UINT8                           Checksum;
1275
1276 } ACPI_RESOURCE_END_TAG;
1277
1278 typedef struct acpi_resource_memory24
1279 {
1280     UINT8                           WriteProtect;
1281     UINT16                          Minimum;
1282     UINT16                          Maximum;
1283     UINT16                          Alignment;
1284     UINT16                          AddressLength;
1285
1286 } ACPI_RESOURCE_MEMORY24;
1287
1288 typedef struct acpi_resource_memory32
1289 {
1290     UINT8                           WriteProtect;
1291     UINT32                          Minimum;
1292     UINT32                          Maximum;
1293     UINT32                          Alignment;
1294     UINT32                          AddressLength;
1295
1296 } ACPI_RESOURCE_MEMORY32;
1297
1298 typedef struct acpi_resource_fixed_memory32
1299 {
1300     UINT8                           WriteProtect;
1301     UINT32                          Address;
1302     UINT32                          AddressLength;
1303
1304 } ACPI_RESOURCE_FIXED_MEMORY32;
1305
1306 typedef struct acpi_memory_attribute
1307 {
1308     UINT8                           WriteProtect;
1309     UINT8                           Caching;
1310     UINT8                           RangeType;
1311     UINT8                           Translation;
1312
1313 } ACPI_MEMORY_ATTRIBUTE;
1314
1315 typedef struct acpi_io_attribute
1316 {
1317     UINT8                           RangeType;
1318     UINT8                           Translation;
1319     UINT8                           TranslationType;
1320     UINT8                           Reserved1;
1321
1322 } ACPI_IO_ATTRIBUTE;
1323
1324 typedef union acpi_resource_attribute
1325 {
1326     ACPI_MEMORY_ATTRIBUTE           Mem;
1327     ACPI_IO_ATTRIBUTE               Io;
1328
1329     /* Used for the *WordSpace macros */
1330
1331     UINT8                           TypeSpecific;
1332
1333 } ACPI_RESOURCE_ATTRIBUTE;
1334
1335 typedef struct acpi_resource_source
1336 {
1337     UINT8                           Index;
1338     UINT16                          StringLength;
1339     char                            *StringPtr;
1340
1341 } ACPI_RESOURCE_SOURCE;
1342
1343 /* Fields common to all address descriptors, 16/32/64 bit */
1344
1345 #define ACPI_RESOURCE_ADDRESS_COMMON \
1346     UINT8                           ResourceType; \
1347     UINT8                           ProducerConsumer; \
1348     UINT8                           Decode; \
1349     UINT8                           MinAddressFixed; \
1350     UINT8                           MaxAddressFixed; \
1351     ACPI_RESOURCE_ATTRIBUTE         Info;
1352
1353 typedef struct acpi_resource_address
1354 {
1355     ACPI_RESOURCE_ADDRESS_COMMON
1356
1357 } ACPI_RESOURCE_ADDRESS;
1358
1359 typedef struct acpi_resource_address16
1360 {
1361     ACPI_RESOURCE_ADDRESS_COMMON
1362     UINT16                          Granularity;
1363     UINT16                          Minimum;
1364     UINT16                          Maximum;
1365     UINT16                          TranslationOffset;
1366     UINT16                          AddressLength;
1367     ACPI_RESOURCE_SOURCE            ResourceSource;
1368
1369 } ACPI_RESOURCE_ADDRESS16;
1370
1371 typedef struct acpi_resource_address32
1372 {
1373     ACPI_RESOURCE_ADDRESS_COMMON
1374     UINT32                          Granularity;
1375     UINT32                          Minimum;
1376     UINT32                          Maximum;
1377     UINT32                          TranslationOffset;
1378     UINT32                          AddressLength;
1379     ACPI_RESOURCE_SOURCE            ResourceSource;
1380
1381 } ACPI_RESOURCE_ADDRESS32;
1382
1383 typedef struct acpi_resource_address64
1384 {
1385     ACPI_RESOURCE_ADDRESS_COMMON
1386     UINT64                          Granularity;
1387     UINT64                          Minimum;
1388     UINT64                          Maximum;
1389     UINT64                          TranslationOffset;
1390     UINT64                          AddressLength;
1391     ACPI_RESOURCE_SOURCE            ResourceSource;
1392
1393 } ACPI_RESOURCE_ADDRESS64;
1394
1395 typedef struct acpi_resource_extended_address64
1396 {
1397     ACPI_RESOURCE_ADDRESS_COMMON
1398     UINT8                           RevisionID;
1399     UINT64                          Granularity;
1400     UINT64                          Minimum;
1401     UINT64                          Maximum;
1402     UINT64                          TranslationOffset;
1403     UINT64                          AddressLength;
1404     UINT64                          TypeSpecific;
1405
1406 } ACPI_RESOURCE_EXTENDED_ADDRESS64;
1407
1408 typedef struct acpi_resource_extended_irq
1409 {
1410     UINT8                           ProducerConsumer;
1411     UINT8                           Triggering;
1412     UINT8                           Polarity;
1413     UINT8                           Sharable;
1414     UINT8                           InterruptCount;
1415     ACPI_RESOURCE_SOURCE            ResourceSource;
1416     UINT32                          Interrupts[1];
1417
1418 } ACPI_RESOURCE_EXTENDED_IRQ;
1419
1420 typedef struct acpi_resource_generic_register
1421 {
1422     UINT8                           SpaceId;
1423     UINT8                           BitWidth;
1424     UINT8                           BitOffset;
1425     UINT8                           AccessSize;
1426     UINT64                          Address;
1427
1428 } ACPI_RESOURCE_GENERIC_REGISTER;
1429
1430
1431 /* ACPI_RESOURCE_TYPEs */
1432
1433 #define ACPI_RESOURCE_TYPE_IRQ                  0
1434 #define ACPI_RESOURCE_TYPE_DMA                  1
1435 #define ACPI_RESOURCE_TYPE_START_DEPENDENT      2
1436 #define ACPI_RESOURCE_TYPE_END_DEPENDENT        3
1437 #define ACPI_RESOURCE_TYPE_IO                   4
1438 #define ACPI_RESOURCE_TYPE_FIXED_IO             5
1439 #define ACPI_RESOURCE_TYPE_VENDOR               6
1440 #define ACPI_RESOURCE_TYPE_END_TAG              7
1441 #define ACPI_RESOURCE_TYPE_MEMORY24             8
1442 #define ACPI_RESOURCE_TYPE_MEMORY32             9
1443 #define ACPI_RESOURCE_TYPE_FIXED_MEMORY32       10
1444 #define ACPI_RESOURCE_TYPE_ADDRESS16            11
1445 #define ACPI_RESOURCE_TYPE_ADDRESS32            12
1446 #define ACPI_RESOURCE_TYPE_ADDRESS64            13
1447 #define ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64   14  /* ACPI 3.0 */
1448 #define ACPI_RESOURCE_TYPE_EXTENDED_IRQ         15
1449 #define ACPI_RESOURCE_TYPE_GENERIC_REGISTER     16
1450 #define ACPI_RESOURCE_TYPE_MAX                  16
1451
1452
1453 typedef union acpi_resource_data
1454 {
1455     ACPI_RESOURCE_IRQ                       Irq;
1456     ACPI_RESOURCE_DMA                       Dma;
1457     ACPI_RESOURCE_START_DEPENDENT           StartDpf;
1458     ACPI_RESOURCE_IO                        Io;
1459     ACPI_RESOURCE_FIXED_IO                  FixedIo;
1460     ACPI_RESOURCE_VENDOR                    Vendor;
1461     ACPI_RESOURCE_VENDOR_TYPED              VendorTyped;
1462     ACPI_RESOURCE_END_TAG                   EndTag;
1463     ACPI_RESOURCE_MEMORY24                  Memory24;
1464     ACPI_RESOURCE_MEMORY32                  Memory32;
1465     ACPI_RESOURCE_FIXED_MEMORY32            FixedMemory32;
1466     ACPI_RESOURCE_ADDRESS16                 Address16;
1467     ACPI_RESOURCE_ADDRESS32                 Address32;
1468     ACPI_RESOURCE_ADDRESS64                 Address64;
1469     ACPI_RESOURCE_EXTENDED_ADDRESS64        ExtAddress64;
1470     ACPI_RESOURCE_EXTENDED_IRQ              ExtendedIrq;
1471     ACPI_RESOURCE_GENERIC_REGISTER          GenericReg;
1472
1473     /* Common fields */
1474
1475     ACPI_RESOURCE_ADDRESS                   Address;        /* Common 16/32/64 address fields */
1476
1477 } ACPI_RESOURCE_DATA;
1478
1479
1480 typedef struct acpi_resource
1481 {
1482     UINT32                          Type;
1483     UINT32                          Length;
1484     ACPI_RESOURCE_DATA              Data;
1485
1486 } ACPI_RESOURCE;
1487
1488 /* restore default alignment */
1489
1490 #pragma pack()
1491
1492
1493 #define ACPI_RS_SIZE_MIN                    12
1494 #define ACPI_RS_SIZE_NO_DATA                8       /* Id + Length fields */
1495 #define ACPI_RS_SIZE(Type)                  (UINT32) (ACPI_RS_SIZE_NO_DATA + sizeof (Type))
1496
1497 #define ACPI_NEXT_RESOURCE(Res)             (ACPI_RESOURCE *)((UINT8 *) Res + Res->Length)
1498
1499
1500 typedef struct acpi_pci_routing_table
1501 {
1502     UINT32                          Length;
1503     UINT32                          Pin;
1504     ACPI_INTEGER                    Address;        /* here for 64-bit alignment */
1505     UINT32                          SourceIndex;
1506     char                            Source[4];      /* pad to 64 bits so sizeof() works in all cases */
1507
1508 } ACPI_PCI_ROUTING_TABLE;
1509
1510
1511 #endif /* __ACTYPES_H__ */