import of ftp.dlink.com/GPL/DSMG-600_reB/ppclinux.tar.gz
[linux-2.4.21-pre4.git] / drivers / acpi / include / actypes.h
1 /******************************************************************************
2  *
3  * Name: actypes.h - Common data types for the entire ACPI subsystem
4  *       $Revision: 1.1.1.1 $
5  *
6  *****************************************************************************/
7
8 /*
9  *  Copyright (C) 2000, 2001 R. Byron Moore
10  *
11  *  This program is free software; you can redistribute it and/or modify
12  *  it under the terms of the GNU General Public License as published by
13  *  the Free Software Foundation; either version 2 of the License, or
14  *  (at your option) any later version.
15  *
16  *  This program is distributed in the hope that it will be useful,
17  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  *  GNU General Public License for more details.
20  *
21  *  You should have received a copy of the GNU General Public License
22  *  along with this program; if not, write to the Free Software
23  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24  */
25
26 #ifndef __ACTYPES_H__
27 #define __ACTYPES_H__
28
29 /*! [Begin] no source code translation (keep the typedefs) */
30
31 /*
32  * Data types - Fixed across all compilation models
33  *
34  * BOOLEAN      Logical Boolean.
35  *              1 byte value containing a 0 for FALSE or a 1 for TRUE.
36  *              Other values are undefined.
37  *
38  * INT8         8-bit  (1 byte) signed value
39  * UINT8        8-bit  (1 byte) unsigned value
40  * INT16        16-bit (2 byte) signed value
41  * UINT16       16-bit (2 byte) unsigned value
42  * INT32        32-bit (4 byte) signed value
43  * UINT32       32-bit (4 byte) unsigned value
44  * INT64        64-bit (8 byte) signed value
45  * UINT64       64-bit (8 byte) unsigned value
46  * NATIVE_INT   32-bit on IA-32, 64-bit on IA-64 signed value
47  * NATIVE_UINT  32-bit on IA-32, 64-bit on IA-64 unsigned value
48  * UCHAR        Character. 1 byte unsigned value.
49  */
50
51 #ifndef BITS_PER_LONG
52 #error "define BITS_PER_LONG"
53 #endif
54
55 #if BITS_PER_LONG == 64
56 /*
57  * 64-bit type definitions
58  */
59 typedef unsigned char                   UINT8;
60 typedef unsigned char                   BOOLEAN;
61 typedef unsigned char                   UCHAR;
62 typedef unsigned short                  UINT16;
63 typedef int                             INT32;
64 typedef unsigned int                    UINT32;
65 typedef COMPILER_DEPENDENT_UINT64       UINT64;
66
67 typedef UINT64                          NATIVE_UINT;
68 typedef long long                          NATIVE_INT;
69
70 typedef NATIVE_UINT                     ACPI_TBLPTR;
71 typedef UINT64                          ACPI_IO_ADDRESS;
72 typedef UINT64                          ACPI_PHYSICAL_ADDRESS;
73
74 #define ALIGNED_ADDRESS_BOUNDARY        0x00000008      /* No hardware alignment support in IA64 */
75 #define ACPI_USE_NATIVE_DIVIDE                          /* Native 64-bit integer support */
76
77
78 #elif BITS_PER_LONG == 16
79 /*
80  * 16-bit type definitions
81  */
82 typedef unsigned char                   UINT8;
83 typedef unsigned char                   BOOLEAN;
84 typedef unsigned char                   UCHAR;
85 typedef unsigned int                    UINT16;
86 typedef long                            INT32;
87 typedef int                             INT16;
88 typedef unsigned long                   UINT32;
89
90 typedef struct
91 {
92         UINT32                                  Lo;
93         UINT32                                  Hi;
94
95 } UINT64;
96
97 typedef UINT16                          NATIVE_UINT;
98 typedef INT16                           NATIVE_INT;
99
100 typedef UINT32                          ACPI_TBLPTR;
101 typedef UINT32                          ACPI_IO_ADDRESS;
102 typedef char                            *ACPI_PHYSICAL_ADDRESS;
103
104 #define ALIGNED_ADDRESS_BOUNDARY        0x00000002
105 #define _HW_ALIGNMENT_SUPPORT
106 #define ACPI_USE_NATIVE_DIVIDE                          /* No 64-bit integers, ok to use native divide */
107
108 /*
109  * (16-bit only) internal integers must be 32-bits, so
110  * 64-bit integers cannot be supported
111  */
112 #define ACPI_NO_INTEGER64_SUPPORT
113
114
115 #elif BITS_PER_LONG == 32
116 /*
117  * 32-bit type definitions (default)
118  */
119 typedef unsigned char                   UINT8;
120 typedef unsigned char                   BOOLEAN;
121 typedef unsigned char                   UCHAR;
122 typedef unsigned short                  UINT16;
123 typedef int                             INT32;
124 typedef unsigned int                    UINT32;
125 typedef COMPILER_DEPENDENT_UINT64       UINT64;
126
127 typedef UINT32                          NATIVE_UINT;
128 typedef INT32                           NATIVE_INT;
129
130 typedef NATIVE_UINT                     ACPI_TBLPTR;
131 typedef UINT32                          ACPI_IO_ADDRESS;
132 typedef UINT64                          ACPI_PHYSICAL_ADDRESS;
133
134 #define ALIGNED_ADDRESS_BOUNDARY        0x00000004
135 #define _HW_ALIGNMENT_SUPPORT
136
137 #else
138 #error "unknown BITS_PER_LONG"
139 #endif
140
141
142
143 /*
144  * Miscellaneous common types
145  */
146
147 typedef UINT32                          UINT32_BIT;
148 typedef NATIVE_UINT                     ACPI_PTRDIFF;
149 typedef char                            NATIVE_CHAR;
150
151
152 /*
153  * Data type ranges
154  */
155
156 #define ACPI_UINT8_MAX                  (UINT8)  0xFF
157 #define ACPI_UINT16_MAX                 (UINT16) 0xFFFF
158 #define ACPI_UINT32_MAX                 (UINT32) 0xFFFFFFFF
159 #define ACPI_UINT64_MAX                 (UINT64) 0xFFFFFFFFFFFFFFFF
160
161
162 #ifdef DEFINE_ALTERNATE_TYPES
163 /*
164  * Types used only in translated source
165  */
166 typedef INT32                           s32;
167 typedef UINT8                           u8;
168 typedef UINT16                          u16;
169 typedef UINT32                          u32;
170 typedef UINT64                          u64;
171 #endif
172 /*! [End] no source code translation !*/
173
174
175 /*
176  * Useful defines
177  */
178
179 #ifdef FALSE
180 #undef FALSE
181 #endif
182 #define FALSE                           (1 == 0)
183
184 #ifdef TRUE
185 #undef TRUE
186 #endif
187 #define TRUE                            (1 == 1)
188
189 #ifndef NULL
190 #define NULL                            (void *) 0
191 #endif
192
193
194 /*
195  * Local datatypes
196  */
197
198 typedef u32                             acpi_status;    /* All ACPI Exceptions */
199 typedef u32                             acpi_name;      /* 4-byte ACPI name */
200 typedef char*                           acpi_string;    /* Null terminated ASCII string */
201 typedef void*                           acpi_handle;    /* Actually a ptr to an Node */
202
203 typedef struct
204 {
205         u32                         lo;
206         u32                         hi;
207
208 } uint64_struct;
209
210 typedef union
211 {
212         u64                         full;
213         uint64_struct               part;
214
215 } uint64_overlay;
216
217
218 /*
219  * Acpi integer width. In ACPI version 1, integers are
220  * 32 bits.  In ACPI version 2, integers are 64 bits.
221  * Note that this pertains to the ACPI integer type only, not
222  * other integers used in the implementation of the ACPI CA
223  * subsystem.
224  */
225 #ifdef ACPI_NO_INTEGER64_SUPPORT
226
227 /* 32-bit integers only, no 64-bit support */
228
229 typedef u32                             acpi_integer;
230 #define ACPI_INTEGER_MAX                ACPI_UINT32_MAX
231 #define ACPI_INTEGER_BIT_SIZE           32
232 #define ACPI_MAX_BCD_VALUE              99999999
233 #define ACPI_MAX_BCD_DIGITS             8
234 #define ACPI_MAX_DECIMAL_DIGITS         10
235
236 #define ACPI_USE_NATIVE_DIVIDE          /* Use compiler native 32-bit divide */
237
238
239 #else
240
241 /* 64-bit integers */
242
243 typedef u64                             acpi_integer;
244 #define ACPI_INTEGER_MAX                ACPI_UINT64_MAX
245 #define ACPI_INTEGER_BIT_SIZE           64
246 #define ACPI_MAX_BCD_VALUE              9999999999999999
247 #define ACPI_MAX_BCD_DIGITS             16
248 #define ACPI_MAX_DECIMAL_DIGITS         19
249
250 #ifdef _IA64
251 #define ACPI_USE_NATIVE_DIVIDE          /* Use compiler native 64-bit divide */
252 #endif
253 #endif
254
255
256 /*
257  * Constants with special meanings
258  */
259
260 #define ACPI_ROOT_OBJECT                (acpi_handle)(-1)
261
262
263 /*
264  * Initialization sequence
265  */
266 #define ACPI_FULL_INITIALIZATION        0x00
267 #define ACPI_NO_ADDRESS_SPACE_INIT      0x01
268 #define ACPI_NO_HARDWARE_INIT           0x02
269 #define ACPI_NO_EVENT_INIT              0x04
270 #define ACPI_NO_ACPI_ENABLE             0x08
271 #define ACPI_NO_DEVICE_INIT             0x10
272 #define ACPI_NO_OBJECT_INIT             0x20
273
274 /*
275  * Initialization state
276  */
277 #define ACPI_INITIALIZED_OK             0x01
278
279 /*
280  * Power state values
281  */
282
283 #define ACPI_STATE_UNKNOWN              (u8) 0xFF
284
285 #define ACPI_STATE_S0                   (u8) 0
286 #define ACPI_STATE_S1                   (u8) 1
287 #define ACPI_STATE_S2                   (u8) 2
288 #define ACPI_STATE_S3                   (u8) 3
289 #define ACPI_STATE_S4                   (u8) 4
290 #define ACPI_STATE_S5                   (u8) 5
291 #define ACPI_S_STATES_MAX               ACPI_STATE_S5
292 #define ACPI_S_STATE_COUNT              6
293
294 #define ACPI_STATE_D0                   (u8) 0
295 #define ACPI_STATE_D1                   (u8) 1
296 #define ACPI_STATE_D2                   (u8) 2
297 #define ACPI_STATE_D3                   (u8) 3
298 #define ACPI_D_STATES_MAX               ACPI_STATE_D3
299 #define ACPI_D_STATE_COUNT              4
300
301 /*
302  * Standard notify values
303  */
304 #define ACPI_NOTIFY_BUS_CHECK           (u8) 0
305 #define ACPI_NOTIFY_DEVICE_CHECK        (u8) 1
306 #define ACPI_NOTIFY_DEVICE_WAKE         (u8) 2
307 #define ACPI_NOTIFY_EJECT_REQUEST       (u8) 3
308 #define ACPI_NOTIFY_DEVICE_CHECK_LIGHT  (u8) 4
309 #define ACPI_NOTIFY_FREQUENCY_MISMATCH  (u8) 5
310 #define ACPI_NOTIFY_BUS_MODE_MISMATCH   (u8) 6
311 #define ACPI_NOTIFY_POWER_FAULT         (u8) 7
312
313
314 /*
315  *  Table types.  These values are passed to the table related APIs
316  */
317
318 typedef u32                             acpi_table_type;
319
320 #define ACPI_TABLE_RSDP                 (acpi_table_type) 0
321 #define ACPI_TABLE_DSDT                 (acpi_table_type) 1
322 #define ACPI_TABLE_FADT                 (acpi_table_type) 2
323 #define ACPI_TABLE_FACS                 (acpi_table_type) 3
324 #define ACPI_TABLE_PSDT                 (acpi_table_type) 4
325 #define ACPI_TABLE_SSDT                 (acpi_table_type) 5
326 #define ACPI_TABLE_XSDT                 (acpi_table_type) 6
327 #define ACPI_TABLE_MAX                  6
328 #define NUM_ACPI_TABLES                 (ACPI_TABLE_MAX+1)
329
330
331 /*
332  * Types associated with names.  The first group of
333  * values correspond to the definition of the ACPI
334  * Object_type operator (See the ACPI Spec). Therefore,
335  * only add to the first group if the spec changes!
336  *
337  * Types must be kept in sync with the Acpi_ns_properties
338  * and Acpi_ns_type_names arrays
339  */
340
341 typedef u32                             acpi_object_type;
342 typedef u8                              acpi_object_type8;
343
344
345 #define ACPI_TYPE_ANY                   0  /* 0x00  */
346 #define ACPI_TYPE_INTEGER               1  /* 0x01  Byte/Word/Dword/Zero/One/Ones */
347 #define ACPI_TYPE_STRING                2  /* 0x02  */
348 #define ACPI_TYPE_BUFFER                3  /* 0x03  */
349 #define ACPI_TYPE_PACKAGE               4  /* 0x04  Byte_const, multiple Data_term/Constant/Super_name */
350 #define ACPI_TYPE_FIELD_UNIT            5  /* 0x05  */
351 #define ACPI_TYPE_DEVICE                6  /* 0x06  Name, multiple Node */
352 #define ACPI_TYPE_EVENT                 7  /* 0x07  */
353 #define ACPI_TYPE_METHOD                8  /* 0x08  Name, Byte_const, multiple Code */
354 #define ACPI_TYPE_MUTEX                 9  /* 0x09  */
355 #define ACPI_TYPE_REGION                10 /* 0x0A  */
356 #define ACPI_TYPE_POWER                 11 /* 0x0B  Name,Byte_const,Word_const,multi Node */
357 #define ACPI_TYPE_PROCESSOR             12 /* 0x0C  Name,Byte_const,DWord_const,Byte_const,multi Nm_o */
358 #define ACPI_TYPE_THERMAL               13 /* 0x0D  Name, multiple Node */
359 #define ACPI_TYPE_BUFFER_FIELD          14 /* 0x0E  */
360 #define ACPI_TYPE_DDB_HANDLE            15 /* 0x0F  */
361 #define ACPI_TYPE_DEBUG_OBJECT          16 /* 0x10  */
362
363 #define ACPI_TYPE_MAX                   16
364
365 /*
366  * This section contains object types that do not relate to the ACPI Object_type operator.
367  * They are used for various internal purposes only.  If new predefined ACPI_TYPEs are
368  * added (via the ACPI specification), these internal types must move upwards.
369  * Also, values exceeding the largest official ACPI Object_type must not overlap with
370  * defined AML opcodes.
371  */
372 #define INTERNAL_TYPE_BEGIN             17
373
374 #define INTERNAL_TYPE_REGION_FIELD      17 /* 0x11  */
375 #define INTERNAL_TYPE_BANK_FIELD        18 /* 0x12  */
376 #define INTERNAL_TYPE_INDEX_FIELD       19 /* 0x13  */
377 #define INTERNAL_TYPE_REFERENCE         20 /* 0x14  Arg#, Local#, Name, Debug; used only in descriptors */
378 #define INTERNAL_TYPE_ALIAS             21 /* 0x15  */
379 #define INTERNAL_TYPE_NOTIFY            22 /* 0x16  */
380 #define INTERNAL_TYPE_ADDRESS_HANDLER   23 /* 0x17  */
381 #define INTERNAL_TYPE_RESOURCE          24 /* 0x18  */
382 #define INTERNAL_TYPE_RESOURCE_FIELD    25 /* 0x19  */
383
384
385 #define INTERNAL_TYPE_NODE_MAX          25
386
387 /* These are pseudo-types because there are never any namespace nodes with these types */
388
389 #define INTERNAL_TYPE_FIELD_DEFN        26 /* 0x1A  Name, Byte_const, multiple Field_element */
390 #define INTERNAL_TYPE_BANK_FIELD_DEFN   27 /* 0x1B  2 Name,DWord_const,Byte_const,multi Field_element */
391 #define INTERNAL_TYPE_INDEX_FIELD_DEFN  28 /* 0x1C  2 Name, Byte_const, multiple Field_element */
392 #define INTERNAL_TYPE_IF                29 /* 0x1D  */
393 #define INTERNAL_TYPE_ELSE              30 /* 0x1E  */
394 #define INTERNAL_TYPE_WHILE             31 /* 0x1F  */
395 #define INTERNAL_TYPE_SCOPE             32 /* 0x20  Name, multiple Node */
396 #define INTERNAL_TYPE_DEF_ANY           33 /* 0x21  type is Any, suppress search of enclosing scopes */
397 #define INTERNAL_TYPE_EXTRA             34 /* 0x22  */
398
399 #define INTERNAL_TYPE_MAX               34
400
401 #define INTERNAL_TYPE_INVALID           35
402 #define ACPI_TYPE_NOT_FOUND             0xFF
403
404
405 /*
406  * Bitmapped ACPI types
407  * Used internally only
408  */
409 #define ACPI_BTYPE_ANY                  0x00000000
410 #define ACPI_BTYPE_INTEGER              0x00000001
411 #define ACPI_BTYPE_STRING               0x00000002
412 #define ACPI_BTYPE_BUFFER               0x00000004
413 #define ACPI_BTYPE_PACKAGE              0x00000008
414 #define ACPI_BTYPE_FIELD_UNIT           0x00000010
415 #define ACPI_BTYPE_DEVICE               0x00000020
416 #define ACPI_BTYPE_EVENT                0x00000040
417 #define ACPI_BTYPE_METHOD               0x00000080
418 #define ACPI_BTYPE_MUTEX                0x00000100
419 #define ACPI_BTYPE_REGION               0x00000200
420 #define ACPI_BTYPE_POWER                0x00000400
421 #define ACPI_BTYPE_PROCESSOR            0x00000800
422 #define ACPI_BTYPE_THERMAL              0x00001000
423 #define ACPI_BTYPE_BUFFER_FIELD         0x00002000
424 #define ACPI_BTYPE_DDB_HANDLE           0x00004000
425 #define ACPI_BTYPE_DEBUG_OBJECT         0x00008000
426 #define ACPI_BTYPE_REFERENCE            0x00010000
427 #define ACPI_BTYPE_RESOURCE             0x00020000
428
429 #define ACPI_BTYPE_COMPUTE_DATA         (ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER)
430
431 #define ACPI_BTYPE_DATA                 (ACPI_BTYPE_COMPUTE_DATA  | ACPI_BTYPE_PACKAGE)
432 #define ACPI_BTYPE_DATA_REFERENCE       (ACPI_BTYPE_DATA | ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE)
433 #define ACPI_BTYPE_DEVICE_OBJECTS       (ACPI_BTYPE_DEVICE | ACPI_BTYPE_THERMAL | ACPI_BTYPE_PROCESSOR)
434 #define ACPI_BTYPE_OBJECTS_AND_REFS     0x0001FFFF  /* ARG or LOCAL */
435 #define ACPI_BTYPE_ALL_OBJECTS          0x0000FFFF
436
437
438 /*
439  * Acpi_event Types:
440  * ------------
441  * Fixed & general purpose...
442  */
443
444 typedef u32                             acpi_event_type;
445
446 #define ACPI_EVENT_FIXED                (acpi_event_type) 0
447 #define ACPI_EVENT_GPE                  (acpi_event_type) 1
448
449 /*
450  * Fixed events
451  */
452
453 #define ACPI_EVENT_PMTIMER              (acpi_event_type) 0
454         /*
455          * There's no bus master event so index 1 is used for IRQ's that are not
456          * handled by the SCI handler
457          */
458 #define ACPI_EVENT_NOT_USED             (acpi_event_type) 1
459 #define ACPI_EVENT_GLOBAL               (acpi_event_type) 2
460 #define ACPI_EVENT_POWER_BUTTON         (acpi_event_type) 3
461 #define ACPI_EVENT_SLEEP_BUTTON         (acpi_event_type) 4
462 #define ACPI_EVENT_RTC                  (acpi_event_type) 5
463 #define ACPI_EVENT_GENERAL              (acpi_event_type) 6
464 #define ACPI_EVENT_MAX                  6
465 #define ACPI_NUM_FIXED_EVENTS           (acpi_event_type) 7
466
467 #define ACPI_GPE_INVALID                0xFF
468 #define ACPI_GPE_MAX                    0xFF
469 #define ACPI_NUM_GPE                    256
470
471 #define ACPI_EVENT_LEVEL_TRIGGERED      (acpi_event_type) 1
472 #define ACPI_EVENT_EDGE_TRIGGERED       (acpi_event_type) 2
473
474 /*
475  * GPEs
476  */
477 #define ACPI_EVENT_ENABLE               0x1
478 #define ACPI_EVENT_WAKE_ENABLE          0x2
479
480 #define ACPI_EVENT_DISABLE              0x1
481 #define ACPI_EVENT_WAKE_DISABLE         0x2
482
483
484 /*
485  * Acpi_event Status:
486  * -------------
487  * The encoding of acpi_event_status is illustrated below.
488  * Note that a set bit (1) indicates the property is TRUE
489  * (e.g. if bit 0 is set then the event is enabled).
490  * +-------------+-+-+-+
491  * |   Bits 31:3 |2|1|0|
492  * +-------------+-+-+-+
493  *          |     | | |
494  *          |     | | +- Enabled?
495  *          |     | +--- Enabled for wake?
496  *          |     +----- Set?
497  *          +----------- <Reserved>
498  */
499 typedef u32                             acpi_event_status;
500
501 #define ACPI_EVENT_FLAG_DISABLED        (acpi_event_status) 0x00
502 #define ACPI_EVENT_FLAG_ENABLED         (acpi_event_status) 0x01
503 #define ACPI_EVENT_FLAG_WAKE_ENABLED    (acpi_event_status) 0x02
504 #define ACPI_EVENT_FLAG_SET             (acpi_event_status) 0x04
505
506
507 /* Notify types */
508
509 #define ACPI_SYSTEM_NOTIFY              0
510 #define ACPI_DEVICE_NOTIFY              1
511 #define ACPI_MAX_NOTIFY_HANDLER_TYPE    1
512
513 #define MAX_SYS_NOTIFY                  0x7f
514
515
516 /* Address Space (Operation Region) Types */
517
518 typedef u8                              ACPI_ADR_SPACE_TYPE;
519
520 #define ACPI_ADR_SPACE_SYSTEM_MEMORY    (ACPI_ADR_SPACE_TYPE) 0
521 #define ACPI_ADR_SPACE_SYSTEM_IO        (ACPI_ADR_SPACE_TYPE) 1
522 #define ACPI_ADR_SPACE_PCI_CONFIG       (ACPI_ADR_SPACE_TYPE) 2
523 #define ACPI_ADR_SPACE_EC               (ACPI_ADR_SPACE_TYPE) 3
524 #define ACPI_ADR_SPACE_SMBUS            (ACPI_ADR_SPACE_TYPE) 4
525 #define ACPI_ADR_SPACE_CMOS             (ACPI_ADR_SPACE_TYPE) 5
526 #define ACPI_ADR_SPACE_PCI_BAR_TARGET   (ACPI_ADR_SPACE_TYPE) 6
527
528
529 /*
530  * External ACPI object definition
531  */
532
533 typedef union acpi_obj
534 {
535         acpi_object_type            type;   /* See definition of Acpi_ns_type for values */
536         struct
537         {
538                 acpi_object_type            type;
539                 acpi_integer                value;      /* The actual number */
540         } integer;
541
542         struct
543         {
544                 acpi_object_type            type;
545                 u32                         length;     /* # of bytes in string, excluding trailing null */
546                 NATIVE_CHAR                 *pointer;   /* points to the string value */
547         } string;
548
549         struct
550         {
551                 acpi_object_type            type;
552                 u32                         length;     /* # of bytes in buffer */
553                 u8                          *pointer;   /* points to the buffer */
554         } buffer;
555
556         struct
557         {
558                 acpi_object_type            type;
559                 u32                         fill1;
560                 acpi_handle                 handle;     /* object reference */
561         } reference;
562
563         struct
564         {
565                 acpi_object_type            type;
566                 u32                         count;      /* # of elements in package */
567                 union acpi_obj              *elements;  /* Pointer to an array of ACPI_OBJECTs */
568         } package;
569
570         struct
571         {
572                 acpi_object_type            type;
573                 u32                         proc_id;
574                 ACPI_IO_ADDRESS             pblk_address;
575                 u32                         pblk_length;
576         } processor;
577
578         struct
579         {
580                 acpi_object_type            type;
581                 u32                         system_level;
582                 u32                         resource_order;
583         } power_resource;
584
585 } acpi_object, *PACPI_OBJECT;
586
587
588 /*
589  * List of objects, used as a parameter list for control method evaluation
590  */
591
592 typedef struct acpi_obj_list
593 {
594         u32                         count;
595         acpi_object                 *pointer;
596
597 } acpi_object_list, *PACPI_OBJECT_LIST;
598
599
600 /*
601  * Miscellaneous common Data Structures used by the interfaces
602  */
603
604 typedef struct
605 {
606         u32                         length;         /* Length in bytes of the buffer */
607         void                        *pointer;       /* pointer to buffer */
608
609 } acpi_buffer;
610
611
612 /*
613  * Name_type for Acpi_get_name
614  */
615
616 #define ACPI_FULL_PATHNAME              0
617 #define ACPI_SINGLE_NAME                1
618 #define ACPI_NAME_TYPE_MAX              1
619
620
621 /*
622  * Structure and flags for Acpi_get_system_info
623  */
624
625 #define SYS_MODE_UNKNOWN                0x0000
626 #define SYS_MODE_ACPI                   0x0001
627 #define SYS_MODE_LEGACY                 0x0002
628 #define SYS_MODES_MASK                  0x0003
629
630
631 /*
632  * ACPI Table Info.  One per ACPI table _type_
633  */
634 typedef struct acpi_table_info
635 {
636         u32                         count;
637
638 } acpi_table_info;
639
640
641 /*
642  * System info returned by Acpi_get_system_info()
643  */
644
645 typedef struct _acpi_sys_info
646 {
647         u32                         acpi_ca_version;
648         u32                         flags;
649         u32                         timer_resolution;
650         u32                         reserved1;
651         u32                         reserved2;
652         u32                         debug_level;
653         u32                         debug_layer;
654         u32                         num_table_types;
655         acpi_table_info             table_info [NUM_ACPI_TABLES];
656
657 } acpi_system_info;
658
659
660 /*
661  * Various handlers and callback procedures
662  */
663
664 typedef
665 u32 (*acpi_event_handler) (
666         void                        *context);
667
668 typedef
669 void (*acpi_gpe_handler) (
670         void                        *context);
671
672 typedef
673 void (*acpi_notify_handler) (
674         acpi_handle                 device,
675         u32                         value,
676         void                        *context);
677
678
679 /* Address Spaces (Operation Regions */
680
681 #define ACPI_READ_ADR_SPACE     1
682 #define ACPI_WRITE_ADR_SPACE    2
683
684 typedef
685 acpi_status (*acpi_adr_space_handler) (
686         u32                         function,
687         ACPI_PHYSICAL_ADDRESS       address,
688         u32                         bit_width,
689         u32                         *value,
690         void                        *handler_context,
691         void                        *region_context);
692
693 #define ACPI_DEFAULT_HANDLER            ((acpi_adr_space_handler) NULL)
694
695
696 typedef
697 acpi_status (*acpi_adr_space_setup) (
698         acpi_handle                 region_handle,
699         u32                         function,
700         void                        *handler_context,
701         void                        **region_context);
702
703 #define ACPI_REGION_ACTIVATE    0
704 #define ACPI_REGION_DEACTIVATE  1
705
706 typedef
707 acpi_status (*acpi_walk_callback) (
708         acpi_handle                 obj_handle,
709         u32                         nesting_level,
710         void                        *context,
711         void                        **return_value);
712
713
714 /* Interrupt handler return values */
715
716 #define INTERRUPT_NOT_HANDLED           0x00
717 #define INTERRUPT_HANDLED               0x01
718
719
720 /* Structure and flags for Acpi_get_device_info */
721
722 #define ACPI_VALID_HID                  0x1
723 #define ACPI_VALID_UID                  0x2
724 #define ACPI_VALID_ADR                  0x4
725 #define ACPI_VALID_STA                  0x8
726
727
728 #define ACPI_COMMON_OBJ_INFO \
729         acpi_object_type            type;           /* ACPI object type */ \
730         acpi_name                   name            /* ACPI object Name */
731
732
733 typedef struct
734 {
735         ACPI_COMMON_OBJ_INFO;
736 } acpi_obj_info_header;
737
738
739 typedef struct
740 {
741         ACPI_COMMON_OBJ_INFO;
742
743         u32                         valid;              /*  Are the next bits legit? */
744         NATIVE_CHAR                 hardware_id[9];     /*  _HID value if any */
745         NATIVE_CHAR                 unique_id[9];       /*  _UID value if any */
746         acpi_integer                address;            /*  _ADR value if any */
747         u32                         current_status;     /*  _STA value */
748 } acpi_device_info;
749
750
751 /* Context structs for address space handlers */
752
753 typedef struct
754 {
755         u16                         segment;
756         u16                         bus;
757         u16                         device;
758         u16                         function;
759 } acpi_pci_id;
760
761
762 typedef struct
763 {
764         ACPI_PHYSICAL_ADDRESS       mapped_physical_address;
765         u8                          *mapped_logical_address;
766         u32                         mapped_length;
767 } acpi_mem_space_context;
768
769
770 /* Sleep states */
771
772 #define ACPI_NUM_SLEEP_STATES           7
773
774
775 /*
776  * Definitions for Resource Attributes
777  */
778
779 /*
780  *  Memory Attributes
781  */
782 #define READ_ONLY_MEMORY                (u8) 0x00
783 #define READ_WRITE_MEMORY               (u8) 0x01
784
785 #define NON_CACHEABLE_MEMORY            (u8) 0x00
786 #define CACHABLE_MEMORY                 (u8) 0x01
787 #define WRITE_COMBINING_MEMORY          (u8) 0x02
788 #define PREFETCHABLE_MEMORY             (u8) 0x03
789
790 /*
791  *  IO Attributes
792  *  The ISA IO ranges are:     n000-n0FFh,  n400-n4_fFh, n800-n8_fFh, n_c00-n_cFFh.
793  *  The non-ISA IO ranges are: n100-n3_fFh, n500-n7_fFh, n900-n_bFFh, n_cD0-n_fFFh.
794  */
795 #define NON_ISA_ONLY_RANGES             (u8) 0x01
796 #define ISA_ONLY_RANGES                 (u8) 0x02
797 #define ENTIRE_RANGE                    (NON_ISA_ONLY_RANGES | ISA_ONLY_RANGES)
798
799 /*
800  *  IO Port Descriptor Decode
801  */
802 #define DECODE_10                       (u8) 0x00    /* 10-bit IO address decode */
803 #define DECODE_16                       (u8) 0x01    /* 16-bit IO address decode */
804
805 /*
806  *  IRQ Attributes
807  */
808 #define EDGE_SENSITIVE                  (u8) 0x00
809 #define LEVEL_SENSITIVE                 (u8) 0x01
810
811 #define ACTIVE_HIGH                     (u8) 0x00
812 #define ACTIVE_LOW                      (u8) 0x01
813
814 #define EXCLUSIVE                       (u8) 0x00
815 #define SHARED                          (u8) 0x01
816
817 /*
818  *  DMA Attributes
819  */
820 #define COMPATIBILITY                   (u8) 0x00
821 #define TYPE_A                          (u8) 0x01
822 #define TYPE_B                          (u8) 0x02
823 #define TYPE_F                          (u8) 0x03
824
825 #define NOT_BUS_MASTER                  (u8) 0x00
826 #define BUS_MASTER                      (u8) 0x01
827
828 #define TRANSFER_8                      (u8) 0x00
829 #define TRANSFER_8_16                   (u8) 0x01
830 #define TRANSFER_16                     (u8) 0x02
831
832 /*
833  * Start Dependent Functions Priority definitions
834  */
835 #define GOOD_CONFIGURATION              (u8) 0x00
836 #define ACCEPTABLE_CONFIGURATION        (u8) 0x01
837 #define SUB_OPTIMAL_CONFIGURATION       (u8) 0x02
838
839 /*
840  *  16, 32 and 64-bit Address Descriptor resource types
841  */
842 #define MEMORY_RANGE                    (u8) 0x00
843 #define IO_RANGE                        (u8) 0x01
844 #define BUS_NUMBER_RANGE                (u8) 0x02
845
846 #define ADDRESS_NOT_FIXED               (u8) 0x00
847 #define ADDRESS_FIXED                   (u8) 0x01
848
849 #define POS_DECODE                      (u8) 0x00
850 #define SUB_DECODE                      (u8) 0x01
851
852 #define PRODUCER                        (u8) 0x00
853 #define CONSUMER                        (u8) 0x01
854
855
856 /*
857  *  Structures used to describe device resources
858  */
859 typedef struct
860 {
861         u32                         edge_level;
862         u32                         active_high_low;
863         u32                         shared_exclusive;
864         u32                         number_of_interrupts;
865         u32                         interrupts[1];
866
867 } acpi_resource_irq;
868
869 typedef struct
870 {
871         u32                         type;
872         u32                         bus_master;
873         u32                         transfer;
874         u32                         number_of_channels;
875         u32                         channels[1];
876
877 } acpi_resource_dma;
878
879 typedef struct
880 {
881         u32                         compatibility_priority;
882         u32                         performance_robustness;
883
884 } acpi_resource_start_dpf;
885
886 /*
887  * END_DEPENDENT_FUNCTIONS_RESOURCE struct is not
888  *  needed because it has no fields
889  */
890
891 typedef struct
892 {
893         u32                         io_decode;
894         u32                         min_base_address;
895         u32                         max_base_address;
896         u32                         alignment;
897         u32                         range_length;
898
899 } acpi_resource_io;
900
901 typedef struct
902 {
903         u32                         base_address;
904         u32                         range_length;
905
906 } acpi_resource_fixed_io;
907
908 typedef struct
909 {
910         u32                         length;
911         u8                          reserved[1];
912
913 } acpi_resource_vendor;
914
915 typedef struct
916 {
917         u32                         read_write_attribute;
918         u32                         min_base_address;
919         u32                         max_base_address;
920         u32                         alignment;
921         u32                         range_length;
922
923 } acpi_resource_mem24;
924
925 typedef struct
926 {
927         u32                         read_write_attribute;
928         u32                         min_base_address;
929         u32                         max_base_address;
930         u32                         alignment;
931         u32                         range_length;
932
933 } acpi_resource_mem32;
934
935 typedef struct
936 {
937         u32                         read_write_attribute;
938         u32                         range_base_address;
939         u32                         range_length;
940
941 } acpi_resource_fixed_mem32;
942
943 typedef struct
944 {
945         u16                         cache_attribute;
946         u16                         read_write_attribute;
947
948 } acpi_memory_attribute;
949
950 typedef struct
951 {
952         u16                         range_attribute;
953         u16                         reserved;
954
955 } acpi_io_attribute;
956
957 typedef struct
958 {
959         u16                         reserved1;
960         u16                         reserved2;
961
962 } acpi_bus_attribute;
963
964 typedef union
965 {
966         acpi_memory_attribute       memory;
967         acpi_io_attribute           io;
968         acpi_bus_attribute          bus;
969
970 } acpi_resource_attribute;
971
972 typedef struct
973 {
974         u32                         index;
975         u32                         string_length;
976         NATIVE_CHAR                 *string_ptr;
977
978 } acpi_resource_source;
979
980 typedef struct
981 {
982         u32                         resource_type;
983         u32                         producer_consumer;
984         u32                         decode;
985         u32                         min_address_fixed;
986         u32                         max_address_fixed;
987         acpi_resource_attribute     attribute;
988         u32                         granularity;
989         u32                         min_address_range;
990         u32                         max_address_range;
991         u32                         address_translation_offset;
992         u32                         address_length;
993         acpi_resource_source        resource_source;
994
995 } acpi_resource_address16;
996
997 typedef struct
998 {
999         u32                         resource_type;
1000         u32                         producer_consumer;
1001         u32                         decode;
1002         u32                         min_address_fixed;
1003         u32                         max_address_fixed;
1004         acpi_resource_attribute     attribute;
1005         u32                         granularity;
1006         u32                         min_address_range;
1007         u32                         max_address_range;
1008         u32                         address_translation_offset;
1009         u32                         address_length;
1010         acpi_resource_source        resource_source;
1011
1012 } acpi_resource_address32;
1013
1014 typedef struct
1015 {
1016         u32                         resource_type;
1017         u32                         producer_consumer;
1018         u32                         decode;
1019         u32                         min_address_fixed;
1020         u32                         max_address_fixed;
1021         acpi_resource_attribute     attribute;
1022         u64                         granularity;
1023         u64                         min_address_range;
1024         u64                         max_address_range;
1025         u64                         address_translation_offset;
1026         u64                         address_length;
1027         acpi_resource_source        resource_source;
1028
1029 } acpi_resource_address64;
1030
1031 typedef struct
1032 {
1033         u32                         producer_consumer;
1034         u32                         edge_level;
1035         u32                         active_high_low;
1036         u32                         shared_exclusive;
1037         u32                         number_of_interrupts;
1038         acpi_resource_source        resource_source;
1039         u32                         interrupts[1];
1040
1041 } acpi_resource_ext_irq;
1042
1043
1044 /* ACPI_RESOURCE_TYPEs */
1045
1046 #define ACPI_RSTYPE_IRQ                 0
1047 #define ACPI_RSTYPE_DMA                 1
1048 #define ACPI_RSTYPE_START_DPF           2
1049 #define ACPI_RSTYPE_END_DPF             3
1050 #define ACPI_RSTYPE_IO                  4
1051 #define ACPI_RSTYPE_FIXED_IO            5
1052 #define ACPI_RSTYPE_VENDOR              6
1053 #define ACPI_RSTYPE_END_TAG             7
1054 #define ACPI_RSTYPE_MEM24               8
1055 #define ACPI_RSTYPE_MEM32               9
1056 #define ACPI_RSTYPE_FIXED_MEM32         10
1057 #define ACPI_RSTYPE_ADDRESS16           11
1058 #define ACPI_RSTYPE_ADDRESS32           12
1059 #define ACPI_RSTYPE_ADDRESS64           13
1060 #define ACPI_RSTYPE_EXT_IRQ             14
1061
1062 typedef u32                     acpi_resource_type;
1063
1064 typedef union
1065 {
1066         acpi_resource_irq           irq;
1067         acpi_resource_dma           dma;
1068         acpi_resource_start_dpf     start_dpf;
1069         acpi_resource_io            io;
1070         acpi_resource_fixed_io      fixed_io;
1071         acpi_resource_vendor        vendor_specific;
1072         acpi_resource_mem24         memory24;
1073         acpi_resource_mem32         memory32;
1074         acpi_resource_fixed_mem32   fixed_memory32;
1075         acpi_resource_address16     address16;
1076         acpi_resource_address32     address32;
1077         acpi_resource_address64     address64;
1078         acpi_resource_ext_irq       extended_irq;
1079
1080 } acpi_resource_data;
1081
1082 typedef struct acpi_resource
1083 {
1084         acpi_resource_type          id;
1085         u32                         length;
1086         acpi_resource_data          data;
1087
1088 } acpi_resource;
1089
1090 #define ACPI_RESOURCE_LENGTH            12
1091 #define ACPI_RESOURCE_LENGTH_NO_DATA    8       /* Id + Length fields */
1092
1093 #define SIZEOF_RESOURCE(type)   (ACPI_RESOURCE_LENGTH_NO_DATA + sizeof (type))
1094
1095 #define NEXT_RESOURCE(res)      (acpi_resource *)((u8 *) res + res->length)
1096
1097
1098 /*
1099  * END: Definitions for Resource Attributes
1100  */
1101
1102
1103 typedef struct pci_routing_table
1104 {
1105         u32                         length;
1106         u32                         pin;
1107         acpi_integer                address;        /* here for 64-bit alignment */
1108         u32                         source_index;
1109         NATIVE_CHAR                 source[4];      /* pad to 64 bits so sizeof() works in all cases */
1110
1111 } pci_routing_table;
1112
1113
1114 /*
1115  * END: Definitions for PCI Routing tables
1116  */
1117
1118 #endif /* __ACTYPES_H__ */