]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/contrib/dev/acpica/actypes.h
This commit was generated by cvs2svn to compensate for changes in r155131,
[FreeBSD/FreeBSD.git] / sys / contrib / dev / acpica / actypes.h
1 /******************************************************************************
2  *
3  * Name: actypes.h - Common data types for the entire ACPI subsystem
4  *       $Revision: 1.288 $
5  *
6  *****************************************************************************/
7
8 /******************************************************************************
9  *
10  * 1. Copyright Notice
11  *
12  * Some or all of this work - Copyright (c) 1999 - 2005, 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 /*! [Begin] no source code translation (keep the typedefs) */
121
122
123
124 /*
125  * Data type ranges
126  * Note: These macros are designed to be compiler independent as well as
127  * working around problems that some 32-bit compilers have with 64-bit
128  * constants.
129  */
130 #define ACPI_UINT8_MAX                  (UINT8) (~((UINT8)  0)) /* 0xFF               */
131 #define ACPI_UINT16_MAX                 (UINT16)(~((UINT16) 0)) /* 0xFFFF             */
132 #define ACPI_UINT32_MAX                 (UINT32)(~((UINT32) 0)) /* 0xFFFFFFFF         */
133 #define ACPI_UINT64_MAX                 (UINT64)(~((UINT64) 0)) /* 0xFFFFFFFFFFFFFFFF */
134 #define ACPI_ASCII_MAX                  0x7F
135
136
137 #ifdef DEFINE_ALTERNATE_TYPES
138 /*
139  * Types used only in translated source, defined here to enable
140  * cross-platform compilation only.
141  */
142 typedef int                             s32;
143 typedef unsigned char                   u8;
144 typedef unsigned short                  u16;
145 typedef unsigned int                    u32;
146 typedef COMPILER_DEPENDENT_UINT64       u64;
147
148 #endif
149
150
151 /*
152  * Data types - Fixed across all compilation models (16/32/64)
153  *
154  * BOOLEAN          Logical Boolean.
155  * INT8             8-bit  (1 byte) signed value
156  * UINT8            8-bit  (1 byte) unsigned value
157  * INT16            16-bit (2 byte) signed value
158  * UINT16           16-bit (2 byte) unsigned value
159  * INT32            32-bit (4 byte) signed value
160  * UINT32           32-bit (4 byte) unsigned value
161  * INT64            64-bit (8 byte) signed value
162  * UINT64           64-bit (8 byte) unsigned value
163  * ACPI_NATIVE_INT  32-bit on IA-32, 64-bit on IA-64 signed value
164  * ACPI_NATIVE_UINT 32-bit on IA-32, 64-bit on IA-64 unsigned value
165  */
166
167 #ifndef ACPI_MACHINE_WIDTH
168 #error ACPI_MACHINE_WIDTH not defined
169 #endif
170
171 #if ACPI_MACHINE_WIDTH == 64
172
173 /*! [Begin] no source code translation (keep the typedefs) */
174
175 /*
176  * 64-bit type definitions
177  */
178 typedef unsigned char                   UINT8;
179 typedef unsigned char                   BOOLEAN;
180 typedef unsigned short                  UINT16;
181 typedef int                             INT32;
182 typedef unsigned int                    UINT32;
183 typedef COMPILER_DEPENDENT_INT64        INT64;
184 typedef COMPILER_DEPENDENT_UINT64       UINT64;
185
186 /*! [End] no source code translation !*/
187
188 typedef INT64                           ACPI_NATIVE_INT;
189 typedef UINT64                          ACPI_NATIVE_UINT;
190
191 typedef UINT64                          ACPI_TABLE_PTR;
192 typedef UINT64                          ACPI_IO_ADDRESS;
193 typedef UINT64                          ACPI_PHYSICAL_ADDRESS;
194 typedef UINT64                          ACPI_SIZE;
195
196 #define ALIGNED_ADDRESS_BOUNDARY        0x00000008      /* No hardware alignment support in IA64 */
197 #define ACPI_USE_NATIVE_DIVIDE                          /* Native 64-bit integer support */
198 #define ACPI_MAX_PTR                    ACPI_UINT64_MAX
199 #define ACPI_SIZE_MAX                   ACPI_UINT64_MAX
200
201 /*
202  * In the case of the Itanium Processor Family (IPF), the hardware does not
203  * support misaligned memory transfers. Set the MISALIGNMENT_NOT_SUPPORTED flag
204  * to indicate that special precautions must be taken to avoid alignment faults.
205  * (IA64 or ia64 is currently used by existing compilers to indicate IPF.)
206  *
207  * Note: EM64T and other X86-64 processors do support misaligned transfers,
208  * so there is no need to define this flag.
209  */
210 #if defined (__IA64__) || defined (__ia64__)
211 #define ACPI_MISALIGNMENT_NOT_SUPPORTED
212 #endif
213
214 #elif ACPI_MACHINE_WIDTH == 16
215
216 /*! [Begin] no source code translation (keep the typedefs as-is) */
217
218 /*
219  * 16-bit type definitions
220  */
221 typedef unsigned char                   UINT8;
222 typedef unsigned char                   BOOLEAN;
223 typedef unsigned int                    UINT16;
224 typedef long                            INT32;
225 typedef int                             INT16;
226 typedef unsigned long                   UINT32;
227
228 typedef struct
229 {
230     UINT32                                  Lo;
231     UINT32                                  Hi;
232
233 } UINT64;
234
235 /*! [End] no source code translation !*/
236
237 typedef UINT16                          ACPI_NATIVE_UINT;
238 typedef INT16                           ACPI_NATIVE_INT;
239
240 typedef UINT32                          ACPI_TABLE_PTR;
241 typedef UINT32                          ACPI_IO_ADDRESS;
242 typedef char                            *ACPI_PHYSICAL_ADDRESS;
243 typedef UINT16                          ACPI_SIZE;
244
245 #define ALIGNED_ADDRESS_BOUNDARY        0x00000002
246 #define ACPI_USE_NATIVE_DIVIDE                          /* No 64-bit integers, ok to use native divide */
247 #define ACPI_MAX_PTR                    ACPI_UINT16_MAX
248 #define ACPI_SIZE_MAX                   ACPI_UINT16_MAX
249
250 /*
251  * (16-bit only) internal integers must be 32-bits, so
252  * 64-bit integers cannot be supported
253  */
254 #define ACPI_NO_INTEGER64_SUPPORT
255
256
257 #elif ACPI_MACHINE_WIDTH == 32
258
259 /*! [Begin] no source code translation (keep the typedefs) */
260
261 /*
262  * 32-bit type definitions (default)
263  */
264 typedef unsigned char                   UINT8;
265 typedef unsigned char                   BOOLEAN;
266 typedef unsigned short                  UINT16;
267 typedef int                             INT32;
268 typedef unsigned int                    UINT32;
269 typedef COMPILER_DEPENDENT_INT64        INT64;
270 typedef COMPILER_DEPENDENT_UINT64       UINT64;
271
272 /*! [End] no source code translation !*/
273
274 typedef INT32                           ACPI_NATIVE_INT;
275 typedef UINT32                          ACPI_NATIVE_UINT;
276
277 typedef UINT64                          ACPI_TABLE_PTR;
278 typedef UINT32                          ACPI_IO_ADDRESS;
279 typedef UINT64                          ACPI_PHYSICAL_ADDRESS;
280 typedef UINT32                          ACPI_SIZE;
281
282 #define ALIGNED_ADDRESS_BOUNDARY        0x00000004
283 #define ACPI_MAX_PTR                    ACPI_UINT32_MAX
284 #define ACPI_SIZE_MAX                   ACPI_UINT32_MAX
285
286 #else
287 #error unknown ACPI_MACHINE_WIDTH
288 #endif
289
290
291 /*
292  * This type is used for bitfields in ACPI tables. The only type that is
293  * even remotely portable is UINT8. Anything else is not portable, so
294  * do not add any more bitfield types.
295  */
296 typedef UINT8                           UINT8_BIT;
297 typedef ACPI_NATIVE_UINT                ACPI_PTRDIFF;
298
299 /*
300  * Pointer overlays to avoid lots of typecasting for
301  * code that accepts both physical and logical pointers.
302  */
303 typedef union acpi_pointers
304 {
305     ACPI_PHYSICAL_ADDRESS       Physical;
306     void                        *Logical;
307     ACPI_TABLE_PTR              Value;
308
309 } ACPI_POINTERS;
310
311 typedef struct acpi_pointer
312 {
313     UINT32                      PointerType;
314     union acpi_pointers         Pointer;
315
316 } ACPI_POINTER;
317
318 /* PointerTypes for above */
319
320 #define ACPI_PHYSICAL_POINTER           0x01
321 #define ACPI_LOGICAL_POINTER            0x02
322
323 /* Processor mode */
324
325 #define ACPI_PHYSICAL_ADDRESSING        0x04
326 #define ACPI_LOGICAL_ADDRESSING         0x08
327 #define ACPI_MEMORY_MODE                0x0C
328
329 #define ACPI_PHYSMODE_PHYSPTR           ACPI_PHYSICAL_ADDRESSING | ACPI_PHYSICAL_POINTER
330 #define ACPI_LOGMODE_PHYSPTR            ACPI_LOGICAL_ADDRESSING  | ACPI_PHYSICAL_POINTER
331 #define ACPI_LOGMODE_LOGPTR             ACPI_LOGICAL_ADDRESSING  | ACPI_LOGICAL_POINTER
332
333 /*
334  * If ACPI_CACHE_T was not defined in the OS-dependent header,
335  * define it now. This is typically the case where the local cache
336  * manager implementation is to be used (ACPI_USE_LOCAL_CACHE)
337  */
338 #ifndef ACPI_CACHE_T
339 #define ACPI_CACHE_T                    ACPI_MEMORY_LIST
340 #endif
341
342 /*
343  * Useful defines
344  */
345 #ifdef FALSE
346 #undef FALSE
347 #endif
348 #define FALSE                           (1 == 0)
349
350 #ifdef TRUE
351 #undef TRUE
352 #endif
353 #define TRUE                            (1 == 1)
354
355 #ifndef NULL
356 #define NULL                            (void *) 0
357 #endif
358
359
360 /*
361  * Local datatypes
362  */
363 typedef UINT32                          ACPI_STATUS;    /* All ACPI Exceptions */
364 typedef UINT32                          ACPI_NAME;      /* 4-byte ACPI name */
365 typedef char *                          ACPI_STRING;    /* Null terminated ASCII string */
366 typedef void *                          ACPI_HANDLE;    /* Actually a ptr to an Node */
367
368 typedef struct uint64_struct
369 {
370     UINT32                      Lo;
371     UINT32                      Hi;
372
373 } UINT64_STRUCT;
374
375 typedef union uint64_overlay
376 {
377     UINT64                      Full;
378     UINT64_STRUCT               Part;
379
380 } UINT64_OVERLAY;
381
382 typedef struct uint32_struct
383 {
384     UINT32                      Lo;
385     UINT32                      Hi;
386
387 } UINT32_STRUCT;
388
389
390 /*
391  * Acpi integer width. In ACPI version 1, integers are
392  * 32 bits.  In ACPI version 2, integers are 64 bits.
393  * Note that this pertains to the ACPI integer type only, not
394  * other integers used in the implementation of the ACPI CA
395  * subsystem.
396  */
397 #ifdef ACPI_NO_INTEGER64_SUPPORT
398
399 /* 32-bit integers only, no 64-bit support */
400
401 typedef UINT32                          ACPI_INTEGER;
402 #define ACPI_INTEGER_MAX                ACPI_UINT32_MAX
403 #define ACPI_INTEGER_BIT_SIZE           32
404 #define ACPI_MAX_DECIMAL_DIGITS         10  /* 2^32 = 4,294,967,296 */
405
406 #define ACPI_USE_NATIVE_DIVIDE          /* Use compiler native 32-bit divide */
407
408
409 #else
410
411 /* 64-bit integers */
412
413 typedef UINT64                          ACPI_INTEGER;
414 #define ACPI_INTEGER_MAX                ACPI_UINT64_MAX
415 #define ACPI_INTEGER_BIT_SIZE           64
416 #define ACPI_MAX_DECIMAL_DIGITS         20  /* 2^64 = 18,446,744,073,709,551,616 */
417
418
419 #if ACPI_MACHINE_WIDTH == 64
420 #define ACPI_USE_NATIVE_DIVIDE          /* Use compiler native 64-bit divide */
421 #endif
422 #endif
423
424 #define ACPI_MAX64_DECIMAL_DIGITS       20
425 #define ACPI_MAX32_DECIMAL_DIGITS       10
426 #define ACPI_MAX16_DECIMAL_DIGITS        5
427 #define ACPI_MAX8_DECIMAL_DIGITS         3
428
429 /*
430  * Constants with special meanings
431  */
432 #define ACPI_ROOT_OBJECT                (ACPI_HANDLE) ACPI_PTR_ADD (char, NULL, ACPI_MAX_PTR)
433
434
435 /*
436  * Initialization sequence
437  */
438 #define ACPI_FULL_INITIALIZATION        0x00
439 #define ACPI_NO_ADDRESS_SPACE_INIT      0x01
440 #define ACPI_NO_HARDWARE_INIT           0x02
441 #define ACPI_NO_EVENT_INIT              0x04
442 #define ACPI_NO_HANDLER_INIT            0x08
443 #define ACPI_NO_ACPI_ENABLE             0x10
444 #define ACPI_NO_DEVICE_INIT             0x20
445 #define ACPI_NO_OBJECT_INIT             0x40
446
447 /*
448  * Initialization state
449  */
450 #define ACPI_INITIALIZED_OK             0x01
451
452 /*
453  * Power state values
454  */
455 #define ACPI_STATE_UNKNOWN              (UINT8) 0xFF
456
457 #define ACPI_STATE_S0                   (UINT8) 0
458 #define ACPI_STATE_S1                   (UINT8) 1
459 #define ACPI_STATE_S2                   (UINT8) 2
460 #define ACPI_STATE_S3                   (UINT8) 3
461 #define ACPI_STATE_S4                   (UINT8) 4
462 #define ACPI_STATE_S5                   (UINT8) 5
463 #define ACPI_S_STATES_MAX               ACPI_STATE_S5
464 #define ACPI_S_STATE_COUNT              6
465
466 #define ACPI_STATE_D0                   (UINT8) 0
467 #define ACPI_STATE_D1                   (UINT8) 1
468 #define ACPI_STATE_D2                   (UINT8) 2
469 #define ACPI_STATE_D3                   (UINT8) 3
470 #define ACPI_D_STATES_MAX               ACPI_STATE_D3
471 #define ACPI_D_STATE_COUNT              4
472
473 #define ACPI_STATE_C0                   (UINT8) 0
474 #define ACPI_STATE_C1                   (UINT8) 1
475 #define ACPI_STATE_C2                   (UINT8) 2
476 #define ACPI_STATE_C3                   (UINT8) 3
477 #define ACPI_C_STATES_MAX               ACPI_STATE_C3
478 #define ACPI_C_STATE_COUNT              4
479
480 /*
481  * Sleep type invalid value
482  */
483 #define ACPI_SLEEP_TYPE_MAX             0x7
484 #define ACPI_SLEEP_TYPE_INVALID         0xFF
485
486 /*
487  * Standard notify values
488  */
489 #define ACPI_NOTIFY_BUS_CHECK           (UINT8) 0
490 #define ACPI_NOTIFY_DEVICE_CHECK        (UINT8) 1
491 #define ACPI_NOTIFY_DEVICE_WAKE         (UINT8) 2
492 #define ACPI_NOTIFY_EJECT_REQUEST       (UINT8) 3
493 #define ACPI_NOTIFY_DEVICE_CHECK_LIGHT  (UINT8) 4
494 #define ACPI_NOTIFY_FREQUENCY_MISMATCH  (UINT8) 5
495 #define ACPI_NOTIFY_BUS_MODE_MISMATCH   (UINT8) 6
496 #define ACPI_NOTIFY_POWER_FAULT         (UINT8) 7
497
498 /*
499  *  Table types.  These values are passed to the table related APIs
500  */
501 typedef UINT32                          ACPI_TABLE_TYPE;
502
503 #define ACPI_TABLE_RSDP                 (ACPI_TABLE_TYPE) 0
504 #define ACPI_TABLE_DSDT                 (ACPI_TABLE_TYPE) 1
505 #define ACPI_TABLE_FADT                 (ACPI_TABLE_TYPE) 2
506 #define ACPI_TABLE_FACS                 (ACPI_TABLE_TYPE) 3
507 #define ACPI_TABLE_PSDT                 (ACPI_TABLE_TYPE) 4
508 #define ACPI_TABLE_SSDT                 (ACPI_TABLE_TYPE) 5
509 #define ACPI_TABLE_XSDT                 (ACPI_TABLE_TYPE) 6
510 #define ACPI_TABLE_MAX                  6
511 #define NUM_ACPI_TABLE_TYPES            (ACPI_TABLE_MAX+1)
512
513 /*
514  * Types associated with ACPI names and objects.  The first group of
515  * values (up to ACPI_TYPE_EXTERNAL_MAX) correspond to the definition
516  * of the ACPI ObjectType() operator (See the ACPI Spec).  Therefore,
517  * only add to the first group if the spec changes.
518  *
519  * NOTE: Types must be kept in sync with the global AcpiNsProperties
520  * and AcpiNsTypeNames arrays.
521  */
522 typedef UINT32                          ACPI_OBJECT_TYPE;
523
524 #define ACPI_TYPE_ANY                   0x00
525 #define ACPI_TYPE_INTEGER               0x01  /* Byte/Word/Dword/Zero/One/Ones */
526 #define ACPI_TYPE_STRING                0x02
527 #define ACPI_TYPE_BUFFER                0x03
528 #define ACPI_TYPE_PACKAGE               0x04  /* ByteConst, multiple DataTerm/Constant/SuperName */
529 #define ACPI_TYPE_FIELD_UNIT            0x05
530 #define ACPI_TYPE_DEVICE                0x06  /* Name, multiple Node */
531 #define ACPI_TYPE_EVENT                 0x07
532 #define ACPI_TYPE_METHOD                0x08  /* Name, ByteConst, multiple Code */
533 #define ACPI_TYPE_MUTEX                 0x09
534 #define ACPI_TYPE_REGION                0x0A
535 #define ACPI_TYPE_POWER                 0x0B  /* Name,ByteConst,WordConst,multi Node */
536 #define ACPI_TYPE_PROCESSOR             0x0C  /* Name,ByteConst,DWordConst,ByteConst,multi NmO */
537 #define ACPI_TYPE_THERMAL               0x0D  /* Name, multiple Node */
538 #define ACPI_TYPE_BUFFER_FIELD          0x0E
539 #define ACPI_TYPE_DDB_HANDLE            0x0F
540 #define ACPI_TYPE_DEBUG_OBJECT          0x10
541
542 #define ACPI_TYPE_EXTERNAL_MAX          0x10
543
544 /*
545  * These are object types that do not map directly to the ACPI
546  * ObjectType() operator. They are used for various internal purposes only.
547  * If new predefined ACPI_TYPEs are added (via the ACPI specification), these
548  * internal types must move upwards. (There is code that depends on these
549  * values being contiguous with the external types above.)
550  */
551 #define ACPI_TYPE_LOCAL_REGION_FIELD    0x11
552 #define ACPI_TYPE_LOCAL_BANK_FIELD      0x12
553 #define ACPI_TYPE_LOCAL_INDEX_FIELD     0x13
554 #define ACPI_TYPE_LOCAL_REFERENCE       0x14  /* Arg#, Local#, Name, Debug, RefOf, Index */
555 #define ACPI_TYPE_LOCAL_ALIAS           0x15
556 #define ACPI_TYPE_LOCAL_METHOD_ALIAS    0x16
557 #define ACPI_TYPE_LOCAL_NOTIFY          0x17
558 #define ACPI_TYPE_LOCAL_ADDRESS_HANDLER 0x18
559 #define ACPI_TYPE_LOCAL_RESOURCE        0x19
560 #define ACPI_TYPE_LOCAL_RESOURCE_FIELD  0x1A
561 #define ACPI_TYPE_LOCAL_SCOPE           0x1B  /* 1 Name, multiple ObjectList Nodes */
562
563 #define ACPI_TYPE_NS_NODE_MAX           0x1B  /* Last typecode used within a NS Node */
564
565 /*
566  * These are special object types that never appear in
567  * a Namespace node, only in an ACPI_OPERAND_OBJECT
568  */
569 #define ACPI_TYPE_LOCAL_EXTRA           0x1C
570 #define ACPI_TYPE_LOCAL_DATA            0x1D
571
572 #define ACPI_TYPE_LOCAL_MAX             0x1D
573
574 /* All types above here are invalid */
575
576 #define ACPI_TYPE_INVALID               0x1E
577 #define ACPI_TYPE_NOT_FOUND             0xFF
578
579 /*
580  * Bitmapped ACPI types.  Used internally only
581  */
582 #define ACPI_BTYPE_ANY                  0x00000000
583 #define ACPI_BTYPE_INTEGER              0x00000001
584 #define ACPI_BTYPE_STRING               0x00000002
585 #define ACPI_BTYPE_BUFFER               0x00000004
586 #define ACPI_BTYPE_PACKAGE              0x00000008
587 #define ACPI_BTYPE_FIELD_UNIT           0x00000010
588 #define ACPI_BTYPE_DEVICE               0x00000020
589 #define ACPI_BTYPE_EVENT                0x00000040
590 #define ACPI_BTYPE_METHOD               0x00000080
591 #define ACPI_BTYPE_MUTEX                0x00000100
592 #define ACPI_BTYPE_REGION               0x00000200
593 #define ACPI_BTYPE_POWER                0x00000400
594 #define ACPI_BTYPE_PROCESSOR            0x00000800
595 #define ACPI_BTYPE_THERMAL              0x00001000
596 #define ACPI_BTYPE_BUFFER_FIELD         0x00002000
597 #define ACPI_BTYPE_DDB_HANDLE           0x00004000
598 #define ACPI_BTYPE_DEBUG_OBJECT         0x00008000
599 #define ACPI_BTYPE_REFERENCE            0x00010000
600 #define ACPI_BTYPE_RESOURCE             0x00020000
601
602 #define ACPI_BTYPE_COMPUTE_DATA         (ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER)
603
604 #define ACPI_BTYPE_DATA                 (ACPI_BTYPE_COMPUTE_DATA  | ACPI_BTYPE_PACKAGE)
605 #define ACPI_BTYPE_DATA_REFERENCE       (ACPI_BTYPE_DATA | ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE)
606 #define ACPI_BTYPE_DEVICE_OBJECTS       (ACPI_BTYPE_DEVICE | ACPI_BTYPE_THERMAL | ACPI_BTYPE_PROCESSOR)
607 #define ACPI_BTYPE_OBJECTS_AND_REFS     0x0001FFFF  /* ARG or LOCAL */
608 #define ACPI_BTYPE_ALL_OBJECTS          0x0000FFFF
609
610 /*
611  * All I/O
612  */
613 #define ACPI_READ                       0
614 #define ACPI_WRITE                      1
615 #define ACPI_IO_MASK                    1
616
617 /*
618  * Event Types: Fixed & General Purpose
619  */
620 typedef UINT32                          ACPI_EVENT_TYPE;
621
622 /*
623  * Fixed events
624  */
625 #define ACPI_EVENT_PMTIMER              0
626 #define ACPI_EVENT_GLOBAL               1
627 #define ACPI_EVENT_POWER_BUTTON         2
628 #define ACPI_EVENT_SLEEP_BUTTON         3
629 #define ACPI_EVENT_RTC                  4
630 #define ACPI_EVENT_MAX                  4
631 #define ACPI_NUM_FIXED_EVENTS           ACPI_EVENT_MAX + 1
632
633 /*
634  * Event Status - Per event
635  * -------------
636  * The encoding of ACPI_EVENT_STATUS is illustrated below.
637  * Note that a set bit (1) indicates the property is TRUE
638  * (e.g. if bit 0 is set then the event is enabled).
639  * +-------------+-+-+-+
640  * |   Bits 31:3 |2|1|0|
641  * +-------------+-+-+-+
642  *          |     | | |
643  *          |     | | +- Enabled?
644  *          |     | +--- Enabled for wake?
645  *          |     +----- Set?
646  *          +----------- <Reserved>
647  */
648 typedef UINT32                          ACPI_EVENT_STATUS;
649
650 #define ACPI_EVENT_FLAG_DISABLED        (ACPI_EVENT_STATUS) 0x00
651 #define ACPI_EVENT_FLAG_ENABLED         (ACPI_EVENT_STATUS) 0x01
652 #define ACPI_EVENT_FLAG_WAKE_ENABLED    (ACPI_EVENT_STATUS) 0x02
653 #define ACPI_EVENT_FLAG_SET             (ACPI_EVENT_STATUS) 0x04
654
655 /*
656  * General Purpose Events (GPE)
657  */
658 #define ACPI_GPE_INVALID                0xFF
659 #define ACPI_GPE_MAX                    0xFF
660 #define ACPI_NUM_GPE                    256
661
662 #define ACPI_GPE_ENABLE                 0
663 #define ACPI_GPE_DISABLE                1
664
665
666 /*
667  * GPE info flags - Per GPE
668  * +-+-+-+---+---+-+
669  * |7|6|5|4:3|2:1|0|
670  * +-+-+-+---+---+-+
671  *  | | |  |   |  |
672  *  | | |  |   |  +--- Interrupt type: Edge or Level Triggered
673  *  | | |  |   +--- Type: Wake-only, Runtime-only, or wake/runtime
674  *  | | |  +--- Type of dispatch -- to method, handler, or none
675  *  | | +--- Enabled for runtime?
676  *  | +--- Enabled for wake?
677  *  +--- System state when GPE ocurred (running/waking)
678  */
679 #define ACPI_GPE_XRUPT_TYPE_MASK        (UINT8) 0x01
680 #define ACPI_GPE_LEVEL_TRIGGERED        (UINT8) 0x01
681 #define ACPI_GPE_EDGE_TRIGGERED         (UINT8) 0x00
682
683 #define ACPI_GPE_TYPE_MASK              (UINT8) 0x06
684 #define ACPI_GPE_TYPE_WAKE_RUN          (UINT8) 0x06
685 #define ACPI_GPE_TYPE_WAKE              (UINT8) 0x02
686 #define ACPI_GPE_TYPE_RUNTIME           (UINT8) 0x04    /* Default */
687
688 #define ACPI_GPE_DISPATCH_MASK          (UINT8) 0x18
689 #define ACPI_GPE_DISPATCH_HANDLER       (UINT8) 0x08
690 #define ACPI_GPE_DISPATCH_METHOD        (UINT8) 0x10
691 #define ACPI_GPE_DISPATCH_NOT_USED      (UINT8) 0x00    /* Default */
692
693 #define ACPI_GPE_RUN_ENABLE_MASK        (UINT8) 0x20
694 #define ACPI_GPE_RUN_ENABLED            (UINT8) 0x20
695 #define ACPI_GPE_RUN_DISABLED           (UINT8) 0x00    /* Default */
696
697 #define ACPI_GPE_WAKE_ENABLE_MASK       (UINT8) 0x40
698 #define ACPI_GPE_WAKE_ENABLED           (UINT8) 0x40
699 #define ACPI_GPE_WAKE_DISABLED          (UINT8) 0x00    /* Default */
700
701 #define ACPI_GPE_ENABLE_MASK            (UINT8) 0x60    /* Both run/wake */
702
703 #define ACPI_GPE_SYSTEM_MASK            (UINT8) 0x80
704 #define ACPI_GPE_SYSTEM_RUNNING         (UINT8) 0x80
705 #define ACPI_GPE_SYSTEM_WAKING          (UINT8) 0x00
706
707 /*
708  * Flags for GPE and Lock interfaces
709  */
710 #define ACPI_EVENT_WAKE_ENABLE          0x2             /* AcpiGpeEnable */
711 #define ACPI_EVENT_WAKE_DISABLE         0x2             /* AcpiGpeDisable */
712
713 #define ACPI_NOT_ISR                    0x1
714 #define ACPI_ISR                        0x0
715
716
717 /* Notify types */
718
719 #define ACPI_SYSTEM_NOTIFY              0x1
720 #define ACPI_DEVICE_NOTIFY              0x2
721 #define ACPI_ALL_NOTIFY                 0x3
722 #define ACPI_MAX_NOTIFY_HANDLER_TYPE    0x3
723
724 #define ACPI_MAX_SYS_NOTIFY             0x7f
725
726
727 /* Address Space (Operation Region) Types */
728
729 typedef UINT8                           ACPI_ADR_SPACE_TYPE;
730
731 #define ACPI_ADR_SPACE_SYSTEM_MEMORY    (ACPI_ADR_SPACE_TYPE) 0
732 #define ACPI_ADR_SPACE_SYSTEM_IO        (ACPI_ADR_SPACE_TYPE) 1
733 #define ACPI_ADR_SPACE_PCI_CONFIG       (ACPI_ADR_SPACE_TYPE) 2
734 #define ACPI_ADR_SPACE_EC               (ACPI_ADR_SPACE_TYPE) 3
735 #define ACPI_ADR_SPACE_SMBUS            (ACPI_ADR_SPACE_TYPE) 4
736 #define ACPI_ADR_SPACE_CMOS             (ACPI_ADR_SPACE_TYPE) 5
737 #define ACPI_ADR_SPACE_PCI_BAR_TARGET   (ACPI_ADR_SPACE_TYPE) 6
738 #define ACPI_ADR_SPACE_DATA_TABLE       (ACPI_ADR_SPACE_TYPE) 7
739 #define ACPI_ADR_SPACE_FIXED_HARDWARE   (ACPI_ADR_SPACE_TYPE) 127
740
741
742 /*
743  * BitRegister IDs
744  * These are bitfields defined within the full ACPI registers
745  */
746 #define ACPI_BITREG_TIMER_STATUS                0x00
747 #define ACPI_BITREG_BUS_MASTER_STATUS           0x01
748 #define ACPI_BITREG_GLOBAL_LOCK_STATUS          0x02
749 #define ACPI_BITREG_POWER_BUTTON_STATUS         0x03
750 #define ACPI_BITREG_SLEEP_BUTTON_STATUS         0x04
751 #define ACPI_BITREG_RT_CLOCK_STATUS             0x05
752 #define ACPI_BITREG_WAKE_STATUS                 0x06
753 #define ACPI_BITREG_PCIEXP_WAKE_STATUS          0x07
754
755 #define ACPI_BITREG_TIMER_ENABLE                0x08
756 #define ACPI_BITREG_GLOBAL_LOCK_ENABLE          0x09
757 #define ACPI_BITREG_POWER_BUTTON_ENABLE         0x0A
758 #define ACPI_BITREG_SLEEP_BUTTON_ENABLE         0x0B
759 #define ACPI_BITREG_RT_CLOCK_ENABLE             0x0C
760 #define ACPI_BITREG_WAKE_ENABLE                 0x0D
761 #define ACPI_BITREG_PCIEXP_WAKE_DISABLE         0x0E
762
763 #define ACPI_BITREG_SCI_ENABLE                  0x0F
764 #define ACPI_BITREG_BUS_MASTER_RLD              0x10
765 #define ACPI_BITREG_GLOBAL_LOCK_RELEASE         0x11
766 #define ACPI_BITREG_SLEEP_TYPE_A                0x12
767 #define ACPI_BITREG_SLEEP_TYPE_B                0x13
768 #define ACPI_BITREG_SLEEP_ENABLE                0x14
769
770 #define ACPI_BITREG_ARB_DISABLE                 0x15
771
772 #define ACPI_BITREG_MAX                         0x15
773 #define ACPI_NUM_BITREG                         ACPI_BITREG_MAX + 1
774
775
776 /*
777  * External ACPI object definition
778  */
779 typedef union acpi_object
780 {
781     ACPI_OBJECT_TYPE            Type;   /* See definition of AcpiNsType for values */
782     struct
783     {
784         ACPI_OBJECT_TYPE            Type;
785         ACPI_INTEGER                Value;      /* The actual number */
786     } Integer;
787
788     struct
789     {
790         ACPI_OBJECT_TYPE            Type;
791         UINT32                      Length;     /* # of bytes in string, excluding trailing null */
792         char                        *Pointer;   /* points to the string value */
793     } String;
794
795     struct
796     {
797         ACPI_OBJECT_TYPE            Type;
798         UINT32                      Length;     /* # of bytes in buffer */
799         UINT8                       *Pointer;   /* points to the buffer */
800     } Buffer;
801
802     struct
803     {
804         ACPI_OBJECT_TYPE            Type;
805         UINT32                      Fill1;
806         ACPI_HANDLE                 Handle;     /* object reference */
807     } Reference;
808
809     struct
810     {
811         ACPI_OBJECT_TYPE            Type;
812         UINT32                      Count;      /* # of elements in package */
813         union acpi_object           *Elements;  /* Pointer to an array of ACPI_OBJECTs */
814     } Package;
815
816     struct
817     {
818         ACPI_OBJECT_TYPE            Type;
819         UINT32                      ProcId;
820         ACPI_IO_ADDRESS             PblkAddress;
821         UINT32                      PblkLength;
822     } Processor;
823
824     struct
825     {
826         ACPI_OBJECT_TYPE            Type;
827         UINT32                      SystemLevel;
828         UINT32                      ResourceOrder;
829     } PowerResource;
830
831 } ACPI_OBJECT;
832
833
834 /*
835  * List of objects, used as a parameter list for control method evaluation
836  */
837 typedef struct acpi_object_list
838 {
839     UINT32                      Count;
840     ACPI_OBJECT                 *Pointer;
841
842 } ACPI_OBJECT_LIST;
843
844
845 /*
846  * Miscellaneous common Data Structures used by the interfaces
847  */
848 #define ACPI_NO_BUFFER              0
849 #define ACPI_ALLOCATE_BUFFER        (ACPI_SIZE) (-1)
850 #define ACPI_ALLOCATE_LOCAL_BUFFER  (ACPI_SIZE) (-2)
851
852 typedef struct acpi_buffer
853 {
854     ACPI_SIZE                   Length;         /* Length in bytes of the buffer */
855     void                        *Pointer;       /* pointer to buffer */
856
857 } ACPI_BUFFER;
858
859
860 /*
861  * NameType for AcpiGetName
862  */
863 #define ACPI_FULL_PATHNAME              0
864 #define ACPI_SINGLE_NAME                1
865 #define ACPI_NAME_TYPE_MAX              1
866
867
868 /*
869  * Structure and flags for AcpiGetSystemInfo
870  */
871 #define ACPI_SYS_MODE_UNKNOWN           0x0000
872 #define ACPI_SYS_MODE_ACPI              0x0001
873 #define ACPI_SYS_MODE_LEGACY            0x0002
874 #define ACPI_SYS_MODES_MASK             0x0003
875
876
877 /*
878  * ACPI Table Info.  One per ACPI table _type_
879  */
880 typedef struct acpi_table_info
881 {
882     UINT32                      Count;
883
884 } ACPI_TABLE_INFO;
885
886
887 /*
888  * System info returned by AcpiGetSystemInfo()
889  */
890 typedef struct acpi_system_info
891 {
892     UINT32                      AcpiCaVersion;
893     UINT32                      Flags;
894     UINT32                      TimerResolution;
895     UINT32                      Reserved1;
896     UINT32                      Reserved2;
897     UINT32                      DebugLevel;
898     UINT32                      DebugLayer;
899     UINT32                      NumTableTypes;
900     ACPI_TABLE_INFO             TableInfo [NUM_ACPI_TABLE_TYPES];
901
902 } ACPI_SYSTEM_INFO;
903
904
905 /*
906  * Types specific to the OS service interfaces
907  */
908 typedef UINT32
909 (ACPI_SYSTEM_XFACE *ACPI_OSD_HANDLER) (
910     void                    *Context);
911
912 typedef void
913 (ACPI_SYSTEM_XFACE *ACPI_OSD_EXEC_CALLBACK) (
914     void                    *Context);
915
916 /*
917  * Various handlers and callback procedures
918  */
919 typedef
920 UINT32 (*ACPI_EVENT_HANDLER) (
921     void                        *Context);
922
923 typedef
924 void (*ACPI_NOTIFY_HANDLER) (
925     ACPI_HANDLE                 Device,
926     UINT32                      Value,
927     void                        *Context);
928
929 typedef
930 void (*ACPI_OBJECT_HANDLER) (
931     ACPI_HANDLE                 Object,
932     UINT32                      Function,
933     void                        *Data);
934
935 typedef
936 ACPI_STATUS (*ACPI_INIT_HANDLER) (
937     ACPI_HANDLE                 Object,
938     UINT32                      Function);
939
940 #define ACPI_INIT_DEVICE_INI        1
941
942 typedef
943 ACPI_STATUS (*ACPI_EXCEPTION_HANDLER) (
944     ACPI_STATUS             AmlStatus,
945     ACPI_NAME               Name,
946     UINT16                  Opcode,
947     UINT32                  AmlOffset,
948     void                    *Context);
949
950
951 /* Address Spaces (For Operation Regions) */
952
953 typedef
954 ACPI_STATUS (*ACPI_ADR_SPACE_HANDLER) (
955     UINT32                      Function,
956     ACPI_PHYSICAL_ADDRESS       Address,
957     UINT32                      BitWidth,
958     ACPI_INTEGER                *Value,
959     void                        *HandlerContext,
960     void                        *RegionContext);
961
962 #define ACPI_DEFAULT_HANDLER        NULL
963
964
965 typedef
966 ACPI_STATUS (*ACPI_ADR_SPACE_SETUP) (
967     ACPI_HANDLE                 RegionHandle,
968     UINT32                      Function,
969     void                        *HandlerContext,
970     void                        **RegionContext);
971
972 #define ACPI_REGION_ACTIVATE    0
973 #define ACPI_REGION_DEACTIVATE  1
974
975 typedef
976 ACPI_STATUS (*ACPI_WALK_CALLBACK) (
977     ACPI_HANDLE                 ObjHandle,
978     UINT32                      NestingLevel,
979     void                        *Context,
980     void                        **ReturnValue);
981
982
983 /* Interrupt handler return values */
984
985 #define ACPI_INTERRUPT_NOT_HANDLED      0x00
986 #define ACPI_INTERRUPT_HANDLED          0x01
987
988
989 /* Common string version of device HIDs and UIDs */
990
991 typedef struct acpi_device_id
992 {
993     char                    Value[ACPI_DEVICE_ID_LENGTH];
994
995 } ACPI_DEVICE_ID;
996
997 /* Common string version of device CIDs */
998
999 typedef struct acpi_compatible_id
1000 {
1001     char                    Value[ACPI_MAX_CID_LENGTH];
1002
1003 } ACPI_COMPATIBLE_ID;
1004
1005 typedef struct acpi_compatible_id_list
1006 {
1007     UINT32                  Count;
1008     UINT32                  Size;
1009     ACPI_COMPATIBLE_ID      Id[1];
1010
1011 } ACPI_COMPATIBLE_ID_LIST;
1012
1013
1014 /* Structure and flags for AcpiGetObjectInfo */
1015
1016 #define ACPI_VALID_STA                  0x0001
1017 #define ACPI_VALID_ADR                  0x0002
1018 #define ACPI_VALID_HID                  0x0004
1019 #define ACPI_VALID_UID                  0x0008
1020 #define ACPI_VALID_CID                  0x0010
1021 #define ACPI_VALID_SXDS                 0x0020
1022
1023
1024 #define ACPI_COMMON_OBJ_INFO \
1025     ACPI_OBJECT_TYPE            Type;           /* ACPI object type */ \
1026     ACPI_NAME                   Name            /* ACPI object Name */
1027
1028
1029 typedef struct acpi_obj_info_header
1030 {
1031     ACPI_COMMON_OBJ_INFO;
1032
1033 } ACPI_OBJ_INFO_HEADER;
1034
1035
1036 /* Structure returned from Get Object Info */
1037
1038 typedef struct acpi_device_info
1039 {
1040     ACPI_COMMON_OBJ_INFO;
1041
1042     UINT32                      Valid;              /* Indicates which fields below are valid */
1043     UINT32                      CurrentStatus;      /* _STA value */
1044     ACPI_INTEGER                Address;            /* _ADR value if any */
1045     ACPI_DEVICE_ID              HardwareId;         /* _HID value if any */
1046     ACPI_DEVICE_ID              UniqueId;           /* _UID value if any */
1047     UINT8                       HighestDstates[4];  /* _SxD values: 0xFF indicates not valid */
1048     ACPI_COMPATIBLE_ID_LIST     CompatibilityId;    /* List of _CIDs if any */
1049
1050 } ACPI_DEVICE_INFO;
1051
1052
1053 /* Context structs for address space handlers */
1054
1055 typedef struct acpi_pci_id
1056 {
1057     UINT16                      Segment;
1058     UINT16                      Bus;
1059     UINT16                      Device;
1060     UINT16                      Function;
1061
1062 } ACPI_PCI_ID;
1063
1064
1065 typedef struct acpi_mem_space_context
1066 {
1067     UINT32                      Length;
1068     ACPI_PHYSICAL_ADDRESS       Address;
1069     ACPI_PHYSICAL_ADDRESS       MappedPhysicalAddress;
1070     UINT8                       *MappedLogicalAddress;
1071     ACPI_SIZE                   MappedLength;
1072
1073 } ACPI_MEM_SPACE_CONTEXT;
1074
1075
1076 /*
1077  * Definitions for Resource Attributes
1078  */
1079 typedef UINT16                          ACPI_RS_LENGTH;    /* Resource Length field is fixed at 16 bits */
1080 typedef UINT32                          ACPI_RSDESC_SIZE;  /* Max Resource Descriptor size is (Length+3) = (64K-1)+3 */
1081
1082 /*
1083  *  Memory Attributes
1084  */
1085 #define ACPI_READ_ONLY_MEMORY           (UINT8) 0x00
1086 #define ACPI_READ_WRITE_MEMORY          (UINT8) 0x01
1087
1088 #define ACPI_NON_CACHEABLE_MEMORY       (UINT8) 0x00
1089 #define ACPI_CACHABLE_MEMORY            (UINT8) 0x01
1090 #define ACPI_WRITE_COMBINING_MEMORY     (UINT8) 0x02
1091 #define ACPI_PREFETCHABLE_MEMORY        (UINT8) 0x03
1092
1093 /*
1094  *  IO Attributes
1095  *  The ISA IO ranges are:     n000-n0FFh,  n400-n4FFh, n800-n8FFh, nC00-nCFFh.
1096  *  The non-ISA IO ranges are: n100-n3FFh,  n500-n7FFh, n900-nBFFh, nCD0-nFFFh.
1097  */
1098 #define ACPI_NON_ISA_ONLY_RANGES        (UINT8) 0x01
1099 #define ACPI_ISA_ONLY_RANGES            (UINT8) 0x02
1100 #define ACPI_ENTIRE_RANGE               (ACPI_NON_ISA_ONLY_RANGES | ACPI_ISA_ONLY_RANGES)
1101
1102 #define ACPI_SPARSE_TRANSLATION         (UINT8) 0x03
1103
1104 /*
1105  *  IO Port Descriptor Decode
1106  */
1107 #define ACPI_DECODE_10                  (UINT8) 0x00    /* 10-bit IO address decode */
1108 #define ACPI_DECODE_16                  (UINT8) 0x01    /* 16-bit IO address decode */
1109
1110 /*
1111  *  IRQ Attributes
1112  */
1113 #define ACPI_LEVEL_SENSITIVE            (UINT8) 0x00
1114 #define ACPI_EDGE_SENSITIVE             (UINT8) 0x01
1115
1116 #define ACPI_ACTIVE_HIGH                (UINT8) 0x00
1117 #define ACPI_ACTIVE_LOW                 (UINT8) 0x01
1118
1119 #define ACPI_EXCLUSIVE                  (UINT8) 0x00
1120 #define ACPI_SHARED                     (UINT8) 0x01
1121
1122 /*
1123  *  DMA Attributes
1124  */
1125 #define ACPI_COMPATIBILITY              (UINT8) 0x00
1126 #define ACPI_TYPE_A                     (UINT8) 0x01
1127 #define ACPI_TYPE_B                     (UINT8) 0x02
1128 #define ACPI_TYPE_F                     (UINT8) 0x03
1129
1130 #define ACPI_NOT_BUS_MASTER             (UINT8) 0x00
1131 #define ACPI_BUS_MASTER                 (UINT8) 0x01
1132
1133 #define ACPI_TRANSFER_8                 (UINT8) 0x00
1134 #define ACPI_TRANSFER_8_16              (UINT8) 0x01
1135 #define ACPI_TRANSFER_16                (UINT8) 0x02
1136
1137 /*
1138  * Start Dependent Functions Priority definitions
1139  */
1140 #define ACPI_GOOD_CONFIGURATION         (UINT8) 0x00
1141 #define ACPI_ACCEPTABLE_CONFIGURATION   (UINT8) 0x01
1142 #define ACPI_SUB_OPTIMAL_CONFIGURATION  (UINT8) 0x02
1143
1144 /*
1145  *  16, 32 and 64-bit Address Descriptor resource types
1146  */
1147 #define ACPI_MEMORY_RANGE               (UINT8) 0x00
1148 #define ACPI_IO_RANGE                   (UINT8) 0x01
1149 #define ACPI_BUS_NUMBER_RANGE           (UINT8) 0x02
1150
1151 #define ACPI_ADDRESS_NOT_FIXED          (UINT8) 0x00
1152 #define ACPI_ADDRESS_FIXED              (UINT8) 0x01
1153
1154 #define ACPI_POS_DECODE                 (UINT8) 0x00
1155 #define ACPI_SUB_DECODE                 (UINT8) 0x01
1156
1157 #define ACPI_PRODUCER                   (UINT8) 0x00
1158 #define ACPI_CONSUMER                   (UINT8) 0x01
1159
1160
1161 /*
1162  * If possible, pack the following structures to byte alignment
1163  */
1164 #ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED
1165 #pragma pack(1)
1166 #endif
1167
1168 /*
1169  *  Structures used to describe device resources
1170  */
1171 typedef struct acpi_resource_irq
1172 {
1173     UINT8                       Triggering;
1174     UINT8                       Polarity;
1175     UINT8                       Sharable;
1176     UINT8                       InterruptCount;
1177     UINT8                       Interrupts[1];
1178
1179 } ACPI_RESOURCE_IRQ;
1180
1181
1182 typedef struct ACPI_RESOURCE_DMA
1183 {
1184     UINT8                       Type;
1185     UINT8                       BusMaster;
1186     UINT8                       Transfer;
1187     UINT8                       ChannelCount;
1188     UINT8                       Channels[1];
1189
1190 } ACPI_RESOURCE_DMA;
1191
1192
1193 typedef struct acpi_resource_start_dependent
1194 {
1195     UINT8                       CompatibilityPriority;
1196     UINT8                       PerformanceRobustness;
1197
1198 } ACPI_RESOURCE_START_DEPENDENT;
1199
1200
1201 /*
1202  * END_DEPENDENT_FUNCTIONS_RESOURCE struct is not
1203  * needed because it has no fields
1204  */
1205
1206
1207 typedef struct acpi_resource_io
1208 {
1209     UINT8                       IoDecode;
1210     UINT8                       Alignment;
1211     UINT8                       AddressLength;
1212     UINT16                      Minimum;
1213     UINT16                      Maximum;
1214
1215 } ACPI_RESOURCE_IO;
1216
1217 typedef struct acpi_resource_fixed_io
1218 {
1219     UINT16                      Address;
1220     UINT8                       AddressLength;
1221
1222 } ACPI_RESOURCE_FIXED_IO;
1223
1224 typedef struct acpi_resource_vendor
1225 {
1226     UINT16                      ByteLength;
1227     UINT8                       ByteData[1];
1228
1229 } ACPI_RESOURCE_VENDOR;
1230
1231 typedef struct acpi_resource_end_tag
1232 {
1233     UINT8                       Checksum;
1234
1235 } ACPI_RESOURCE_END_TAG;
1236
1237 typedef struct acpi_resource_memory24
1238 {
1239     UINT8                       WriteProtect;
1240     UINT16                      Minimum;
1241     UINT16                      Maximum;
1242     UINT16                      Alignment;
1243     UINT16                      AddressLength;
1244
1245 } ACPI_RESOURCE_MEMORY24;
1246
1247 typedef struct acpi_resource_memory32
1248 {
1249     UINT8                       WriteProtect;
1250     UINT32                      Minimum;
1251     UINT32                      Maximum;
1252     UINT32                      Alignment;
1253     UINT32                      AddressLength;
1254
1255 } ACPI_RESOURCE_MEMORY32;
1256
1257 typedef struct acpi_resource_fixed_memory32
1258 {
1259     UINT8                       WriteProtect;
1260     UINT32                      Address;
1261     UINT32                      AddressLength;
1262
1263 } ACPI_RESOURCE_FIXED_MEMORY32;
1264
1265 typedef struct acpi_memory_attribute
1266 {
1267     UINT8                       WriteProtect;
1268     UINT8                       Caching;
1269     UINT8                       RangeType;
1270     UINT8                       Translation;
1271
1272 } ACPI_MEMORY_ATTRIBUTE;
1273
1274 typedef struct acpi_io_attribute
1275 {
1276     UINT8                       RangeType;
1277     UINT8                       Translation;
1278     UINT8                       TranslationType;
1279     UINT8                       Reserved1;
1280
1281 } ACPI_IO_ATTRIBUTE;
1282
1283 typedef union acpi_resource_attribute
1284 {
1285     ACPI_MEMORY_ATTRIBUTE       Mem;
1286     ACPI_IO_ATTRIBUTE           Io;
1287
1288     /* Used for the *WordSpace macros */
1289
1290     UINT8                       TypeSpecific;
1291
1292 } ACPI_RESOURCE_ATTRIBUTE;
1293
1294 typedef struct acpi_resource_source
1295 {
1296     UINT8                       Index;
1297     UINT16                      StringLength;
1298     char                        *StringPtr;
1299
1300 } ACPI_RESOURCE_SOURCE;
1301
1302 /* Fields common to all address descriptors, 16/32/64 bit */
1303
1304 #define ACPI_RESOURCE_ADDRESS_COMMON \
1305     UINT8                       ResourceType; \
1306     UINT8                       ProducerConsumer; \
1307     UINT8                       Decode; \
1308     UINT8                       MinAddressFixed; \
1309     UINT8                       MaxAddressFixed; \
1310     ACPI_RESOURCE_ATTRIBUTE     Info;
1311
1312 typedef struct acpi_resource_address
1313 {
1314     ACPI_RESOURCE_ADDRESS_COMMON
1315
1316 } ACPI_RESOURCE_ADDRESS;
1317
1318 typedef struct acpi_resource_address16
1319 {
1320     ACPI_RESOURCE_ADDRESS_COMMON
1321     UINT16                      Granularity;
1322     UINT16                      Minimum;
1323     UINT16                      Maximum;
1324     UINT16                      TranslationOffset;
1325     UINT16                      AddressLength;
1326     ACPI_RESOURCE_SOURCE        ResourceSource;
1327
1328 } ACPI_RESOURCE_ADDRESS16;
1329
1330 typedef struct acpi_resource_address32
1331 {
1332     ACPI_RESOURCE_ADDRESS_COMMON
1333     UINT32                      Granularity;
1334     UINT32                      Minimum;
1335     UINT32                      Maximum;
1336     UINT32                      TranslationOffset;
1337     UINT32                      AddressLength;
1338     ACPI_RESOURCE_SOURCE        ResourceSource;
1339
1340 } ACPI_RESOURCE_ADDRESS32;
1341
1342 typedef struct acpi_resource_address64
1343 {
1344     ACPI_RESOURCE_ADDRESS_COMMON
1345     UINT64                      Granularity;
1346     UINT64                      Minimum;
1347     UINT64                      Maximum;
1348     UINT64                      TranslationOffset;
1349     UINT64                      AddressLength;
1350     ACPI_RESOURCE_SOURCE        ResourceSource;
1351
1352 } ACPI_RESOURCE_ADDRESS64;
1353
1354 typedef struct acpi_resource_extended_address64
1355 {
1356     ACPI_RESOURCE_ADDRESS_COMMON
1357     UINT8                       RevisionID;
1358     UINT64                      Granularity;
1359     UINT64                      Minimum;
1360     UINT64                      Maximum;
1361     UINT64                      TranslationOffset;
1362     UINT64                      AddressLength;
1363     UINT64                      TypeSpecific;
1364
1365 } ACPI_RESOURCE_EXTENDED_ADDRESS64;
1366
1367 typedef struct acpi_resource_extended_irq
1368 {
1369     UINT8                       ProducerConsumer;
1370     UINT8                       Triggering;
1371     UINT8                       Polarity;
1372     UINT8                       Sharable;
1373     UINT8                       InterruptCount;
1374     ACPI_RESOURCE_SOURCE        ResourceSource;
1375     UINT32                      Interrupts[1];
1376
1377 } ACPI_RESOURCE_EXTENDED_IRQ;
1378
1379 typedef struct acpi_resource_generic_register
1380 {
1381     UINT8                       SpaceId;
1382     UINT8                       BitWidth;
1383     UINT8                       BitOffset;
1384     UINT8                       AccessSize;
1385     UINT64                      Address;
1386
1387 } ACPI_RESOURCE_GENERIC_REGISTER;
1388
1389
1390 /* ACPI_RESOURCE_TYPEs */
1391
1392 #define ACPI_RESOURCE_TYPE_IRQ                  0
1393 #define ACPI_RESOURCE_TYPE_DMA                  1
1394 #define ACPI_RESOURCE_TYPE_START_DEPENDENT      2
1395 #define ACPI_RESOURCE_TYPE_END_DEPENDENT        3
1396 #define ACPI_RESOURCE_TYPE_IO                   4
1397 #define ACPI_RESOURCE_TYPE_FIXED_IO             5
1398 #define ACPI_RESOURCE_TYPE_VENDOR               6
1399 #define ACPI_RESOURCE_TYPE_END_TAG              7
1400 #define ACPI_RESOURCE_TYPE_MEMORY24             8
1401 #define ACPI_RESOURCE_TYPE_MEMORY32             9
1402 #define ACPI_RESOURCE_TYPE_FIXED_MEMORY32       10
1403 #define ACPI_RESOURCE_TYPE_ADDRESS16            11
1404 #define ACPI_RESOURCE_TYPE_ADDRESS32            12
1405 #define ACPI_RESOURCE_TYPE_ADDRESS64            13
1406 #define ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64   14  /* ACPI 3.0 */
1407 #define ACPI_RESOURCE_TYPE_EXTENDED_IRQ         15
1408 #define ACPI_RESOURCE_TYPE_GENERIC_REGISTER     16
1409 #define ACPI_RESOURCE_TYPE_MAX                  16
1410
1411
1412 typedef union acpi_resource_data
1413 {
1414     ACPI_RESOURCE_IRQ                   Irq;
1415     ACPI_RESOURCE_DMA                   Dma;
1416     ACPI_RESOURCE_START_DEPENDENT       StartDpf;
1417     ACPI_RESOURCE_IO                    Io;
1418     ACPI_RESOURCE_FIXED_IO              FixedIo;
1419     ACPI_RESOURCE_VENDOR                Vendor;
1420     ACPI_RESOURCE_END_TAG               EndTag;
1421     ACPI_RESOURCE_MEMORY24              Memory24;
1422     ACPI_RESOURCE_MEMORY32              Memory32;
1423     ACPI_RESOURCE_FIXED_MEMORY32        FixedMemory32;
1424     ACPI_RESOURCE_ADDRESS16             Address16;
1425     ACPI_RESOURCE_ADDRESS32             Address32;
1426     ACPI_RESOURCE_ADDRESS64             Address64;
1427     ACPI_RESOURCE_EXTENDED_ADDRESS64    ExtAddress64;
1428     ACPI_RESOURCE_EXTENDED_IRQ          ExtendedIrq;
1429     ACPI_RESOURCE_GENERIC_REGISTER      GenericReg;
1430
1431     /* Common fields */
1432
1433     ACPI_RESOURCE_ADDRESS               Address;        /* Common 16/32/64 address fields */
1434
1435 } ACPI_RESOURCE_DATA;
1436
1437
1438 typedef struct acpi_resource
1439 {
1440     UINT32                      Type;
1441     UINT32                      Length;
1442     ACPI_RESOURCE_DATA          Data;
1443
1444 } ACPI_RESOURCE;
1445
1446 /* restore default alignment */
1447
1448 #pragma pack()
1449
1450
1451 #define ACPI_RS_SIZE_MIN                    12
1452 #define ACPI_RS_SIZE_NO_DATA                8       /* Id + Length fields */
1453 #define ACPI_RS_SIZE(Type)                  (UINT32) (ACPI_RS_SIZE_NO_DATA + sizeof (Type))
1454
1455 #define ACPI_NEXT_RESOURCE(Res)             (ACPI_RESOURCE *)((UINT8 *) Res + Res->Length)
1456
1457 #ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED
1458 #define ACPI_ALIGN_RESOURCE_SIZE(Length)    (Length)
1459 #else
1460 #define ACPI_ALIGN_RESOURCE_SIZE(Length)    ACPI_ROUND_UP_TO_NATIVE_WORD(Length)
1461 #endif
1462
1463 /*
1464  * END: of definitions for Resource Attributes
1465  */
1466
1467
1468 typedef struct acpi_pci_routing_table
1469 {
1470     UINT32                      Length;
1471     UINT32                      Pin;
1472     ACPI_INTEGER                Address;        /* here for 64-bit alignment */
1473     UINT32                      SourceIndex;
1474     char                        Source[4];      /* pad to 64 bits so sizeof() works in all cases */
1475
1476 } ACPI_PCI_ROUTING_TABLE;
1477
1478 /*
1479  * END: of definitions for PCI Routing tables
1480  */
1481
1482
1483 #endif /* __ACTYPES_H__ */