import of ftp.dlink.com/GPL/DSMG-600_reB/ppclinux.tar.gz
[linux-2.4.21-pre4.git] / drivers / acpi / include / acobject.h
1
2 /******************************************************************************
3  *
4  * Name: acobject.h - Definition of acpi_operand_object  (Internal object only)
5  *       $Revision: 1.1.1.1 $
6  *
7  *****************************************************************************/
8
9 /*
10  *  Copyright (C) 2000, 2001 R. Byron Moore
11  *
12  *  This program is free software; you can redistribute it and/or modify
13  *  it under the terms of the GNU General Public License as published by
14  *  the Free Software Foundation; either version 2 of the License, or
15  *  (at your option) any later version.
16  *
17  *  This program is distributed in the hope that it will be useful,
18  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  *  GNU General Public License for more details.
21  *
22  *  You should have received a copy of the GNU General Public License
23  *  along with this program; if not, write to the Free Software
24  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25  */
26
27 #ifndef _ACOBJECT_H
28 #define _ACOBJECT_H
29
30
31 /*
32  * The acpi_operand_object  is used to pass AML operands from the dispatcher
33  * to the interpreter, and to keep track of the various handlers such as
34  * address space handlers and notify handlers.  The object is a constant
35  * size in order to allow them to be cached and reused.
36  *
37  * All variants of the acpi_operand_object  are defined with the same
38  * sequence of field types, with fields that are not used in a particular
39  * variant being named "Reserved".  This is not strictly necessary, but
40  * may in some circumstances simplify understanding if these structures
41  * need to be displayed in a debugger having limited (or no) support for
42  * union types.  It also simplifies some debug code in Dump_table() which
43  * dumps multi-level values: fetching Buffer.Pointer suffices to pick up
44  * the value or next level for any of several types.
45  */
46
47 /******************************************************************************
48  *
49  * Common Descriptors
50  *
51  *****************************************************************************/
52
53 /*
54  * Common area for all objects.
55  *
56  * Data_type is used to differentiate between internal descriptors, and MUST
57  * be the first byte in this structure.
58  */
59
60
61 #define ACPI_OBJECT_COMMON_HEADER           /* SIZE/ALIGNMENT: 32-bits plus trailing 8-bit flag */\
62         u8                          data_type;          /* To differentiate various internal objs */\
63         u8                          type;               /* acpi_object_type */\
64         u16                         reference_count;    /* For object deletion management */\
65         u8                          flags; \
66
67 /* Defines for flag byte above */
68
69 #define AOPOBJ_STATIC_ALLOCATION    0x1
70 #define AOPOBJ_STATIC_POINTER       0x2
71 #define AOPOBJ_DATA_VALID           0x4
72 #define AOPOBJ_ZERO_CONST           0x4
73 #define AOPOBJ_INITIALIZED          0x8
74
75
76 /*
77  * Common bitfield for the field objects
78  * "Field Datum"    -- a datum from the actual field object
79  * "Buffer Datum"   -- a datum from a user buffer, read from or to be written to the field
80  */
81 #define ACPI_COMMON_FIELD_INFO              /* SIZE/ALIGNMENT: 24 bits + three 32-bit values */\
82         u8                          access_flags;\
83         u16                         bit_length;         /* Length of field in bits */\
84         u32                         base_byte_offset;   /* Byte offset within containing object */\
85         u8                          access_bit_width;   /* Read/Write size in bits (from ASL Access_type)*/\
86         u8                          access_byte_width;  /* Read/Write size in bytes */\
87         u8                          update_rule;        /* How neighboring field bits are handled */\
88         u8                          lock_rule;          /* Global Lock: 1 = "Must Lock" */\
89         u8                          start_field_bit_offset;/* Bit offset within first field datum (0-63) */\
90         u8                          datum_valid_bits;   /* Valid bit in first "Field datum" */\
91         u8                          end_field_valid_bits; /* Valid bits in the last "field datum" */\
92         u8                          end_buffer_valid_bits; /* Valid bits in the last "buffer datum" */\
93         u32                         value;              /* Value to store into the Bank or Index register */
94
95
96 /* Access flag bits */
97
98 #define AFIELD_SINGLE_DATUM         0x1
99
100
101 /*
102  * Fields common to both Strings and Buffers
103  */
104 #define ACPI_COMMON_BUFFER_INFO \
105         u32                         length;
106
107
108 /******************************************************************************
109  *
110  * Individual Object Descriptors
111  *
112  *****************************************************************************/
113
114
115 typedef struct /* COMMON */
116 {
117         ACPI_OBJECT_COMMON_HEADER
118
119 } ACPI_OBJECT_COMMON;
120
121
122 typedef struct /* CACHE_LIST */
123 {
124         ACPI_OBJECT_COMMON_HEADER
125         union acpi_operand_obj      *next;              /* Link for object cache and internal lists*/
126
127 } ACPI_OBJECT_CACHE_LIST;
128
129
130 typedef struct /* NUMBER - has value */
131 {
132         ACPI_OBJECT_COMMON_HEADER
133
134         acpi_integer                value;
135
136 } ACPI_OBJECT_INTEGER;
137
138
139 typedef struct /* STRING - has length and pointer - Null terminated, ASCII characters only */
140 {
141         ACPI_OBJECT_COMMON_HEADER
142         ACPI_COMMON_BUFFER_INFO
143         NATIVE_CHAR                 *pointer;           /* String value in AML stream or in allocated space */
144
145 } ACPI_OBJECT_STRING;
146
147
148 typedef struct /* BUFFER - has length and pointer - not null terminated */
149 {
150         ACPI_OBJECT_COMMON_HEADER
151         ACPI_COMMON_BUFFER_INFO
152         u8                          *pointer;           /* Buffer value in AML stream or in allocated space */
153
154 } ACPI_OBJECT_BUFFER;
155
156
157 typedef struct /* PACKAGE - has count, elements, next element */
158 {
159         ACPI_OBJECT_COMMON_HEADER
160
161         u32                         count;              /* # of elements in package */
162         union acpi_operand_obj      **elements;         /* Array of pointers to Acpi_objects */
163         union acpi_operand_obj      **next_element;     /* used only while initializing */
164
165 } ACPI_OBJECT_PACKAGE;
166
167
168 typedef struct /* DEVICE - has handle and notification handler/context */
169 {
170         ACPI_OBJECT_COMMON_HEADER
171
172         union acpi_operand_obj      *sys_handler;        /* Handler for system notifies */
173         union acpi_operand_obj      *drv_handler;        /* Handler for driver notifies */
174         union acpi_operand_obj      *addr_handler;       /* Handler for Address space */
175
176 } ACPI_OBJECT_DEVICE;
177
178
179 typedef struct /* EVENT */
180 {
181         ACPI_OBJECT_COMMON_HEADER
182         void                        *semaphore;
183
184 } ACPI_OBJECT_EVENT;
185
186
187 #define INFINITE_CONCURRENCY        0xFF
188
189 typedef struct /* METHOD */
190 {
191         ACPI_OBJECT_COMMON_HEADER
192         u8                          method_flags;
193         u8                          param_count;
194
195         u32                         aml_length;
196
197         void                        *semaphore;
198         u8                          *aml_start;
199
200         u8                          concurrency;
201         u8                          thread_count;
202         acpi_owner_id               owning_id;
203
204 } ACPI_OBJECT_METHOD;
205
206
207 typedef struct acpi_obj_mutex /* MUTEX */
208 {
209         ACPI_OBJECT_COMMON_HEADER
210         u16                         sync_level;
211         u16                         acquisition_depth;
212
213         void                        *semaphore;
214         void                        *owner;
215         union acpi_operand_obj      *prev;              /* Link for list of acquired mutexes */
216         union acpi_operand_obj      *next;              /* Link for list of acquired mutexes */
217
218 } ACPI_OBJECT_MUTEX;
219
220
221 typedef struct /* REGION */
222 {
223         ACPI_OBJECT_COMMON_HEADER
224
225         u8                          space_id;
226         u32                         length;
227         ACPI_PHYSICAL_ADDRESS       address;
228         union acpi_operand_obj      *extra;             /* Pointer to executable AML (in region definition) */
229
230         union acpi_operand_obj      *addr_handler;      /* Handler for system notifies */
231         acpi_namespace_node         *node;              /* containing object */
232         union acpi_operand_obj      *next;
233
234 } ACPI_OBJECT_REGION;
235
236
237 typedef struct /* POWER RESOURCE - has Handle and notification handler/context*/
238 {
239         ACPI_OBJECT_COMMON_HEADER
240
241         u32                         system_level;
242         u32                         resource_order;
243
244         union acpi_operand_obj      *sys_handler;       /* Handler for system notifies */
245         union acpi_operand_obj      *drv_handler;       /* Handler for driver notifies */
246
247 } ACPI_OBJECT_POWER_RESOURCE;
248
249
250 typedef struct /* PROCESSOR - has Handle and notification handler/context*/
251 {
252         ACPI_OBJECT_COMMON_HEADER
253
254         u32                         proc_id;
255         u32                         length;
256         ACPI_IO_ADDRESS             address;
257
258         union acpi_operand_obj      *sys_handler;       /* Handler for system notifies */
259         union acpi_operand_obj      *drv_handler;       /* Handler for driver notifies */
260         union acpi_operand_obj      *addr_handler;      /* Handler for Address space */
261
262 } ACPI_OBJECT_PROCESSOR;
263
264
265 typedef struct /* THERMAL ZONE - has Handle and Handler/Context */
266 {
267         ACPI_OBJECT_COMMON_HEADER
268
269         union acpi_operand_obj      *sys_handler;       /* Handler for system notifies */
270         union acpi_operand_obj      *drv_handler;       /* Handler for driver notifies */
271         union acpi_operand_obj      *addr_handler;      /* Handler for Address space */
272
273 } ACPI_OBJECT_THERMAL_ZONE;
274
275
276 /*
277  * Fields.  All share a common header/info field.
278  */
279
280 typedef struct /* COMMON FIELD (for BUFFER, REGION, BANK, and INDEX fields) */
281 {
282         ACPI_OBJECT_COMMON_HEADER
283         ACPI_COMMON_FIELD_INFO
284         union acpi_operand_obj      *region_obj;        /* Containing Operation Region object */
285                          /* (REGION/BANK fields only) */
286 } ACPI_OBJECT_FIELD_COMMON;
287
288
289 typedef struct /* REGION FIELD */
290 {
291         ACPI_OBJECT_COMMON_HEADER
292         ACPI_COMMON_FIELD_INFO
293         union acpi_operand_obj      *region_obj;        /* Containing Op_region object */
294
295 } ACPI_OBJECT_REGION_FIELD;
296
297
298 typedef struct /* BANK FIELD */
299 {
300         ACPI_OBJECT_COMMON_HEADER
301         ACPI_COMMON_FIELD_INFO
302
303         union acpi_operand_obj      *region_obj;        /* Containing Op_region object */
304         union acpi_operand_obj      *bank_register_obj; /* Bank_select Register object */
305
306 } ACPI_OBJECT_BANK_FIELD;
307
308
309 typedef struct /* INDEX FIELD */
310 {
311         ACPI_OBJECT_COMMON_HEADER
312         ACPI_COMMON_FIELD_INFO
313
314         /*
315          * No "Region_obj" pointer needed since the Index and Data registers
316          * are each field definitions unto themselves.
317          */
318         union acpi_operand_obj      *index_obj;         /* Index register */
319         union acpi_operand_obj      *data_obj;          /* Data register */
320
321
322 } ACPI_OBJECT_INDEX_FIELD;
323
324
325 /* The Buffer_field is different in that it is part of a Buffer, not an Op_region */
326
327 typedef struct /* BUFFER FIELD */
328 {
329         ACPI_OBJECT_COMMON_HEADER
330         ACPI_COMMON_FIELD_INFO
331
332         union acpi_operand_obj      *extra;             /* Pointer to executable AML (in field definition) */
333         acpi_namespace_node         *node;              /* Parent (containing) object node */
334         union acpi_operand_obj      *buffer_obj;        /* Containing Buffer object */
335
336 } ACPI_OBJECT_BUFFER_FIELD;
337
338
339 /*
340  * Handlers
341  */
342
343 typedef struct /* NOTIFY HANDLER */
344 {
345         ACPI_OBJECT_COMMON_HEADER
346
347         acpi_namespace_node         *node;               /* Parent device */
348         acpi_notify_handler         handler;
349         void                        *context;
350
351 } ACPI_OBJECT_NOTIFY_HANDLER;
352
353
354 /* Flags for address handler */
355
356 #define ADDR_HANDLER_DEFAULT_INSTALLED  0x1
357
358
359 typedef struct /* ADDRESS HANDLER */
360 {
361         ACPI_OBJECT_COMMON_HEADER
362
363         u8                          space_id;
364         u16                         hflags;
365         acpi_adr_space_handler      handler;
366
367         acpi_namespace_node         *node;              /* Parent device */
368         void                        *context;
369         acpi_adr_space_setup        setup;
370         union acpi_operand_obj      *region_list;       /* regions using this handler */
371         union acpi_operand_obj      *next;
372
373 } ACPI_OBJECT_ADDR_HANDLER;
374
375
376 /*
377  * The Reference object type is used for these opcodes:
378  * Arg[0-6], Local[0-7], Index_op, Name_op, Zero_op, One_op, Ones_op, Debug_op
379  */
380
381 typedef struct /* Reference - Local object type */
382 {
383         ACPI_OBJECT_COMMON_HEADER
384
385         u8                          target_type;        /* Used for Index_op */
386         u16                         opcode;
387         u32                         offset;             /* Used for Arg_op, Local_op, and Index_op */
388
389         void                        *object;            /* Name_op=>HANDLE to obj, Index_op=>acpi_operand_object */
390         acpi_namespace_node         *node;
391         union acpi_operand_obj      **where;
392
393 } ACPI_OBJECT_REFERENCE;
394
395
396 /*
397  * Extra object is used as additional storage for types that
398  * have AML code in their declarations (Term_args) that must be
399  * evaluated at run time.
400  *
401  * Currently: Region and Field_unit types
402  */
403
404 typedef struct /* EXTRA */
405 {
406         ACPI_OBJECT_COMMON_HEADER
407         u8                          byte_fill1;
408         u16                         word_fill1;
409         u32                         aml_length;
410         u8                          *aml_start;
411         acpi_namespace_node         *method_REG;        /* _REG method for this region (if any) */
412         void                        *region_context;    /* Region-specific data */
413
414 } ACPI_OBJECT_EXTRA;
415
416
417 /******************************************************************************
418  *
419  * acpi_operand_object  Descriptor - a giant union of all of the above
420  *
421  *****************************************************************************/
422
423 typedef union acpi_operand_obj
424 {
425         ACPI_OBJECT_COMMON          common;
426         ACPI_OBJECT_CACHE_LIST      cache;
427         ACPI_OBJECT_INTEGER         integer;
428         ACPI_OBJECT_STRING          string;
429         ACPI_OBJECT_BUFFER          buffer;
430         ACPI_OBJECT_PACKAGE         package;
431         ACPI_OBJECT_BUFFER_FIELD    buffer_field;
432         ACPI_OBJECT_DEVICE          device;
433         ACPI_OBJECT_EVENT           event;
434         ACPI_OBJECT_METHOD          method;
435         ACPI_OBJECT_MUTEX           mutex;
436         ACPI_OBJECT_REGION          region;
437         ACPI_OBJECT_POWER_RESOURCE  power_resource;
438         ACPI_OBJECT_PROCESSOR       processor;
439         ACPI_OBJECT_THERMAL_ZONE    thermal_zone;
440         ACPI_OBJECT_FIELD_COMMON    common_field;
441         ACPI_OBJECT_REGION_FIELD    field;
442         ACPI_OBJECT_BANK_FIELD      bank_field;
443         ACPI_OBJECT_INDEX_FIELD     index_field;
444         ACPI_OBJECT_REFERENCE       reference;
445         ACPI_OBJECT_NOTIFY_HANDLER  notify_handler;
446         ACPI_OBJECT_ADDR_HANDLER    addr_handler;
447         ACPI_OBJECT_EXTRA           extra;
448
449 } acpi_operand_object;
450
451 #endif /* _ACOBJECT_H */