Raise WARNS to 6:
[dragonfly.git] / sys / contrib / dev / acpica / acobject.h
1
2 /******************************************************************************
3  *
4  * Name: acobject.h - Definition of ACPI_OPERAND_OBJECT  (Internal object only)
5  *       $Revision: 118 $
6  *
7  *****************************************************************************/
8
9 /******************************************************************************
10  *
11  * 1. Copyright Notice
12  *
13  * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp.
14  * All rights reserved.
15  *
16  * 2. License
17  *
18  * 2.1. This is your license from Intel Corp. under its intellectual property
19  * rights.  You may have additional license terms from the party that provided
20  * you this software, covering your right to use that party's intellectual
21  * property rights.
22  *
23  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
24  * copy of the source code appearing in this file ("Covered Code") an
25  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
26  * base code distributed originally by Intel ("Original Intel Code") to copy,
27  * make derivatives, distribute, use and display any portion of the Covered
28  * Code in any form, with the right to sublicense such rights; and
29  *
30  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
31  * license (with the right to sublicense), under only those claims of Intel
32  * patents that are infringed by the Original Intel Code, to make, use, sell,
33  * offer to sell, and import the Covered Code and derivative works thereof
34  * solely to the minimum extent necessary to exercise the above copyright
35  * license, and in no event shall the patent license extend to any additions
36  * to or modifications of the Original Intel Code.  No other license or right
37  * is granted directly or by implication, estoppel or otherwise;
38  *
39  * The above copyright and patent license is granted only if the following
40  * conditions are met:
41  *
42  * 3. Conditions
43  *
44  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
45  * Redistribution of source code of any substantial portion of the Covered
46  * Code or modification with rights to further distribute source must include
47  * the above Copyright Notice, the above License, this list of Conditions,
48  * and the following Disclaimer and Export Compliance provision.  In addition,
49  * Licensee must cause all Covered Code to which Licensee contributes to
50  * contain a file documenting the changes Licensee made to create that Covered
51  * Code and the date of any change.  Licensee must include in that file the
52  * documentation of any changes made by any predecessor Licensee.  Licensee
53  * must include a prominent statement that the modification is derived,
54  * directly or indirectly, from Original Intel Code.
55  *
56  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
57  * Redistribution of source code of any substantial portion of the Covered
58  * Code or modification without rights to further distribute source must
59  * include the following Disclaimer and Export Compliance provision in the
60  * documentation and/or other materials provided with distribution.  In
61  * addition, Licensee may not authorize further sublicense of source of any
62  * portion of the Covered Code, and must include terms to the effect that the
63  * license from Licensee to its licensee is limited to the intellectual
64  * property embodied in the software Licensee provides to its licensee, and
65  * not to intellectual property embodied in modifications its licensee may
66  * make.
67  *
68  * 3.3. Redistribution of Executable. Redistribution in executable form of any
69  * substantial portion of the Covered Code or modification must reproduce the
70  * above Copyright Notice, and the following Disclaimer and Export Compliance
71  * provision in the documentation and/or other materials provided with the
72  * distribution.
73  *
74  * 3.4. Intel retains all right, title, and interest in and to the Original
75  * Intel Code.
76  *
77  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
78  * Intel shall be used in advertising or otherwise to promote the sale, use or
79  * other dealings in products derived from or relating to the Covered Code
80  * without prior written authorization from Intel.
81  *
82  * 4. Disclaimer and Export Compliance
83  *
84  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
85  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
86  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
87  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
88  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
89  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
90  * PARTICULAR PURPOSE.
91  *
92  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
93  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
94  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
95  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
96  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
97  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
98  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
99  * LIMITED REMEDY.
100  *
101  * 4.3. Licensee shall not export, either directly or indirectly, any of this
102  * software or system incorporating such software without first obtaining any
103  * required license or other approval from the U. S. Department of Commerce or
104  * any other agency or department of the United States Government.  In the
105  * event Licensee exports any such software from the United States or
106  * re-exports any such software from a foreign destination, Licensee shall
107  * ensure that the distribution and export/re-export of the software is in
108  * compliance with all laws, regulations, orders, or other restrictions of the
109  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
110  * any of its subsidiaries will export/re-export any technical data, process,
111  * software, or service, directly or indirectly, to any country for which the
112  * United States government or any agency thereof requires an export license,
113  * other governmental approval, or letter of assurance, without first obtaining
114  * such license, approval or letter.
115  *
116  *****************************************************************************/
117 /* $DragonFly: src/sys/contrib/dev/acpica/Attic/acobject.h,v 1.1 2003/09/24 03:32:15 drhodus Exp $                                                               */
118
119 #ifndef _ACOBJECT_H
120 #define _ACOBJECT_H
121
122
123 /*
124  * The ACPI_OPERAND_OBJECT  is used to pass AML operands from the dispatcher
125  * to the interpreter, and to keep track of the various handlers such as
126  * address space handlers and notify handlers.  The object is a constant
127  * size in order to allow it to be cached and reused.
128  */
129
130 /*******************************************************************************
131  *
132  * Common Descriptors
133  *
134  ******************************************************************************/
135
136 /*
137  * Common area for all objects.
138  *
139  * DataType is used to differentiate between internal descriptors, and MUST
140  * be the first byte in this structure.
141  */
142 #define ACPI_OBJECT_COMMON_HEADER   /* SIZE/ALIGNMENT: 32 bits, one ptr plus trailing 8-bit flag */\
143     UINT8                           Descriptor;         /* To differentiate various internal objs */\
144     UINT8                           Type;               /* ACPI_OBJECT_TYPE */\
145     UINT16                          ReferenceCount;     /* For object deletion management */\
146     union acpi_operand_object       *NextObject;        /* Objects linked to parent NS node */\
147     UINT8                           Flags; \
148
149 /* Values for flag byte above */
150
151 #define AOPOBJ_AML_CONSTANT         0x01
152 #define AOPOBJ_STATIC_POINTER       0x02
153 #define AOPOBJ_DATA_VALID           0x04
154 #define AOPOBJ_OBJECT_INITIALIZED   0x08
155 #define AOPOBJ_SETUP_COMPLETE       0x10
156 #define AOPOBJ_SINGLE_DATUM         0x20
157
158
159 /*
160  * Common bitfield for the field objects
161  * "Field Datum"  -- a datum from the actual field object
162  * "Buffer Datum" -- a datum from a user buffer, read from or to be written to the field
163  */
164 #define ACPI_COMMON_FIELD_INFO      /* SIZE/ALIGNMENT: 24 bits + three 32-bit values */\
165     UINT8                           FieldFlags;         /* Access, update, and lock bits */\
166     UINT8                           Attribute;          /* From AccessAs keyword */\
167     UINT8                           AccessByteWidth;    /* Read/Write size in bytes */\
168     UINT32                          BitLength;          /* Length of field in bits */\
169     UINT32                          BaseByteOffset;     /* Byte offset within containing object */\
170     UINT8                           StartFieldBitOffset;/* Bit offset within first field datum (0-63) */\
171     UINT8                           DatumValidBits;     /* Valid bit in first "Field datum" */\
172     UINT8                           EndFieldValidBits;  /* Valid bits in the last "field datum" */\
173     UINT8                           EndBufferValidBits; /* Valid bits in the last "buffer datum" */\
174     UINT32                          Value;              /* Value to store into the Bank or Index register */\
175     ACPI_NAMESPACE_NODE             *Node;              /* Link back to parent node */
176
177
178 /*
179  * Fields common to both Strings and Buffers
180  */
181 #define ACPI_COMMON_BUFFER_INFO \
182     UINT32                          Length;
183
184
185 /*
186  * Common fields for objects that support ASL notifications
187  */
188 #define ACPI_COMMON_NOTIFY_INFO \
189     union acpi_operand_object       *SysHandler;         /* Handler for system notifies */\
190     union acpi_operand_object       *DrvHandler;         /* Handler for driver notifies */\
191     union acpi_operand_object       *AddrHandler;        /* Handler for Address space */
192
193
194 /******************************************************************************
195  *
196  * Basic data types
197  *
198  *****************************************************************************/
199
200 typedef struct acpi_object_common
201 {
202     ACPI_OBJECT_COMMON_HEADER
203
204 } ACPI_OBJECT_COMMON;
205
206
207 typedef struct acpi_object_integer
208 {
209     ACPI_OBJECT_COMMON_HEADER
210     ACPI_INTEGER                    Value;
211
212 } ACPI_OBJECT_INTEGER;
213
214
215 typedef struct acpi_object_string   /* Null terminated, ASCII characters only */
216 {
217     ACPI_OBJECT_COMMON_HEADER
218     ACPI_COMMON_BUFFER_INFO
219     char                            *Pointer;           /* String in AML stream or allocated string */
220
221 } ACPI_OBJECT_STRING;
222
223
224 typedef struct acpi_object_buffer
225 {
226     ACPI_OBJECT_COMMON_HEADER
227     ACPI_COMMON_BUFFER_INFO
228     UINT8                           *Pointer;           /* Buffer in AML stream or allocated buffer */
229     ACPI_NAMESPACE_NODE             *Node;              /* Link back to parent node */
230     UINT8                           *AmlStart;
231     UINT32                          AmlLength;
232
233 } ACPI_OBJECT_BUFFER;
234
235
236 typedef struct acpi_object_package
237 {
238     ACPI_OBJECT_COMMON_HEADER
239
240     UINT32                          Count;              /* # of elements in package */
241     UINT32                          AmlLength;
242     UINT8                           *AmlStart;
243     ACPI_NAMESPACE_NODE             *Node;              /* Link back to parent node */
244     union acpi_operand_object       **Elements;         /* Array of pointers to AcpiObjects */
245
246 } ACPI_OBJECT_PACKAGE;
247
248
249 /******************************************************************************
250  *
251  * Complex data types
252  *
253  *****************************************************************************/
254
255 typedef struct acpi_object_event
256 {
257     ACPI_OBJECT_COMMON_HEADER
258     void                            *Semaphore;
259
260 } ACPI_OBJECT_EVENT;
261
262
263 #define INFINITE_CONCURRENCY        0xFF
264
265 typedef struct acpi_object_method
266 {
267     ACPI_OBJECT_COMMON_HEADER
268     UINT8                           MethodFlags;
269     UINT8                           ParamCount;
270     UINT32                          AmlLength;
271     void                            *Semaphore;
272     UINT8                           *AmlStart;
273     UINT8                           Concurrency;
274     UINT8                           ThreadCount;
275     ACPI_OWNER_ID                   OwningId;
276
277 } ACPI_OBJECT_METHOD;
278
279
280 typedef struct acpi_object_mutex
281 {
282     ACPI_OBJECT_COMMON_HEADER
283     UINT16                          SyncLevel;
284     UINT16                          AcquisitionDepth;
285     struct acpi_thread_state        *OwnerThread;
286     void                            *Semaphore;
287     union acpi_operand_object       *Prev;              /* Link for list of acquired mutexes */
288     union acpi_operand_object       *Next;              /* Link for list of acquired mutexes */
289     ACPI_NAMESPACE_NODE             *Node;              /* containing object */
290
291 } ACPI_OBJECT_MUTEX;
292
293
294 typedef struct acpi_object_region
295 {
296     ACPI_OBJECT_COMMON_HEADER
297
298     UINT8                           SpaceId;
299     union acpi_operand_object       *AddrHandler;       /* Handler for system notifies */
300     ACPI_NAMESPACE_NODE             *Node;              /* containing object */
301     union acpi_operand_object       *Next;
302     UINT32                          Length;
303     ACPI_PHYSICAL_ADDRESS           Address;
304
305 } ACPI_OBJECT_REGION;
306
307
308 /******************************************************************************
309  *
310  * Objects that can be notified.  All share a common NotifyInfo area.
311  *
312  *****************************************************************************/
313
314 typedef struct acpi_object_notify_common    /* COMMON NOTIFY for POWER, PROCESSOR, DEVICE, and THERMAL */
315 {
316     ACPI_OBJECT_COMMON_HEADER
317     ACPI_COMMON_NOTIFY_INFO
318
319 } ACPI_OBJECT_NOTIFY_COMMON;
320
321
322 typedef struct acpi_object_device
323 {
324     ACPI_OBJECT_COMMON_HEADER
325     ACPI_COMMON_NOTIFY_INFO
326
327 } ACPI_OBJECT_DEVICE;
328
329
330 typedef struct acpi_object_power_resource
331 {
332     ACPI_OBJECT_COMMON_HEADER
333     ACPI_COMMON_NOTIFY_INFO
334     UINT32                          SystemLevel;
335     UINT32                          ResourceOrder;
336
337 } ACPI_OBJECT_POWER_RESOURCE;
338
339
340 typedef struct acpi_object_processor
341 {
342     ACPI_OBJECT_COMMON_HEADER
343     ACPI_COMMON_NOTIFY_INFO
344     UINT32                          ProcId;
345     UINT32                          Length;
346     ACPI_IO_ADDRESS                 Address;
347
348 } ACPI_OBJECT_PROCESSOR;
349
350
351 typedef struct acpi_object_thermal_zone
352 {
353     ACPI_OBJECT_COMMON_HEADER
354     ACPI_COMMON_NOTIFY_INFO
355
356 } ACPI_OBJECT_THERMAL_ZONE;
357
358
359 /******************************************************************************
360  *
361  * Fields.  All share a common header/info field.
362  *
363  *****************************************************************************/
364
365 typedef struct acpi_object_field_common                 /* COMMON FIELD (for BUFFER, REGION, BANK, and INDEX fields) */
366 {
367     ACPI_OBJECT_COMMON_HEADER
368     ACPI_COMMON_FIELD_INFO
369     union acpi_operand_object       *RegionObj;         /* Containing Operation Region object */
370                                                         /* (REGION/BANK fields only) */
371 } ACPI_OBJECT_FIELD_COMMON;
372
373
374 typedef struct acpi_object_region_field
375 {
376     ACPI_OBJECT_COMMON_HEADER
377     ACPI_COMMON_FIELD_INFO
378     union acpi_operand_object       *RegionObj;         /* Containing OpRegion object */
379
380 } ACPI_OBJECT_REGION_FIELD;
381
382
383 typedef struct acpi_object_bank_field
384 {
385     ACPI_OBJECT_COMMON_HEADER
386     ACPI_COMMON_FIELD_INFO
387     union acpi_operand_object       *RegionObj;         /* Containing OpRegion object */
388     union acpi_operand_object       *BankObj;           /* BankSelect Register object */
389
390 } ACPI_OBJECT_BANK_FIELD;
391
392
393 typedef struct acpi_object_index_field
394 {
395     ACPI_OBJECT_COMMON_HEADER
396     ACPI_COMMON_FIELD_INFO
397
398     /*
399      * No "RegionObj" pointer needed since the Index and Data registers
400      * are each field definitions unto themselves.
401      */
402     union acpi_operand_object       *IndexObj;          /* Index register */
403     union acpi_operand_object       *DataObj;           /* Data register */
404
405 } ACPI_OBJECT_INDEX_FIELD;
406
407
408 /* The BufferField is different in that it is part of a Buffer, not an OpRegion */
409
410 typedef struct acpi_object_buffer_field
411 {
412     ACPI_OBJECT_COMMON_HEADER
413     ACPI_COMMON_FIELD_INFO
414     union acpi_operand_object       *BufferObj;         /* Containing Buffer object */
415
416 } ACPI_OBJECT_BUFFER_FIELD;
417
418
419 /******************************************************************************
420  *
421  * Objects for handlers
422  *
423  *****************************************************************************/
424
425 typedef struct acpi_object_notify_handler
426 {
427     ACPI_OBJECT_COMMON_HEADER
428     ACPI_NAMESPACE_NODE             *Node;              /* Parent device */
429     ACPI_NOTIFY_HANDLER             Handler;
430     void                            *Context;
431
432 } ACPI_OBJECT_NOTIFY_HANDLER;
433
434
435 /* Flags for address handler */
436
437 #define ACPI_ADDR_HANDLER_DEFAULT_INSTALLED  0x1
438
439
440 typedef struct acpi_object_addr_handler
441 {
442     ACPI_OBJECT_COMMON_HEADER
443     UINT8                           SpaceId;
444     UINT16                          Hflags;
445     ACPI_ADR_SPACE_HANDLER          Handler;
446     ACPI_NAMESPACE_NODE             *Node;              /* Parent device */
447     void                            *Context;
448     ACPI_ADR_SPACE_SETUP            Setup;
449     union acpi_operand_object       *RegionList;        /* regions using this handler */
450     union acpi_operand_object       *Next;
451
452 } ACPI_OBJECT_ADDR_HANDLER;
453
454
455 /******************************************************************************
456  *
457  * Special internal objects
458  *
459  *****************************************************************************/
460
461 /*
462  * The Reference object type is used for these opcodes:
463  * Arg[0-6], Local[0-7], IndexOp, NameOp, ZeroOp, OneOp, OnesOp, DebugOp
464  */
465 typedef struct acpi_object_reference
466 {
467     ACPI_OBJECT_COMMON_HEADER
468     UINT8                           TargetType;         /* Used for IndexOp */
469     UINT16                          Opcode;
470     UINT32                          Offset;             /* Used for ArgOp, LocalOp, and IndexOp */
471     void                            *Object;            /* NameOp=>HANDLE to obj, IndexOp=>ACPI_OPERAND_OBJECT  */
472     ACPI_NAMESPACE_NODE             *Node;
473     union acpi_operand_object       **Where;
474
475 } ACPI_OBJECT_REFERENCE;
476
477
478 /*
479  * Extra object is used as additional storage for types that
480  * have AML code in their declarations (TermArgs) that must be
481  * evaluated at run time.
482  *
483  * Currently: Region and FieldUnit types
484  */
485 typedef struct acpi_object_extra
486 {
487     ACPI_OBJECT_COMMON_HEADER
488     UINT8                           ByteFill1;
489     UINT16                          WordFill1;
490     UINT32                          AmlLength;
491     UINT8                           *AmlStart;
492     ACPI_NAMESPACE_NODE             *Method_REG;        /* _REG method for this region (if any) */
493     void                            *RegionContext;     /* Region-specific data */
494
495 } ACPI_OBJECT_EXTRA;
496
497
498 /* Additional data that can be attached to namespace nodes */
499
500 typedef struct acpi_object_data
501 {
502     ACPI_OBJECT_COMMON_HEADER
503     ACPI_OBJECT_HANDLER             Handler;
504     void                            *Pointer;
505
506 } ACPI_OBJECT_DATA;
507
508
509 /* Structure used when objects are cached for reuse */
510
511 typedef struct acpi_object_cache_list
512 {
513     ACPI_OBJECT_COMMON_HEADER
514     union acpi_operand_object       *Next;              /* Link for object cache and internal lists*/
515
516 } ACPI_OBJECT_CACHE_LIST;
517
518
519 /******************************************************************************
520  *
521  * ACPI_OPERAND_OBJECT Descriptor - a giant union of all of the above
522  *
523  *****************************************************************************/
524
525 typedef union acpi_operand_object
526 {
527     ACPI_OBJECT_COMMON              Common;
528     ACPI_OBJECT_INTEGER             Integer;
529     ACPI_OBJECT_STRING              String;
530     ACPI_OBJECT_BUFFER              Buffer;
531     ACPI_OBJECT_PACKAGE             Package;
532     ACPI_OBJECT_EVENT               Event;
533     ACPI_OBJECT_METHOD              Method;
534     ACPI_OBJECT_MUTEX               Mutex;
535     ACPI_OBJECT_REGION              Region;
536     ACPI_OBJECT_NOTIFY_COMMON       CommonNotify;
537     ACPI_OBJECT_DEVICE              Device;
538     ACPI_OBJECT_POWER_RESOURCE      PowerResource;
539     ACPI_OBJECT_PROCESSOR           Processor;
540     ACPI_OBJECT_THERMAL_ZONE        ThermalZone;
541     ACPI_OBJECT_FIELD_COMMON        CommonField;
542     ACPI_OBJECT_REGION_FIELD        Field;
543     ACPI_OBJECT_BUFFER_FIELD        BufferField;
544     ACPI_OBJECT_BANK_FIELD          BankField;
545     ACPI_OBJECT_INDEX_FIELD         IndexField;
546     ACPI_OBJECT_NOTIFY_HANDLER      NotifyHandler;
547     ACPI_OBJECT_ADDR_HANDLER        AddrHandler;
548     ACPI_OBJECT_REFERENCE           Reference;
549     ACPI_OBJECT_EXTRA               Extra;
550     ACPI_OBJECT_DATA                Data;
551     ACPI_OBJECT_CACHE_LIST          Cache;
552
553 } ACPI_OPERAND_OBJECT;
554
555
556 /******************************************************************************
557  *
558  * ACPI_DESCRIPTOR - objects that share a common descriptor identifier
559  *
560  *****************************************************************************/
561
562
563 /* Object descriptor types */
564
565 #define ACPI_DESC_TYPE_CACHED           0x11        /* Used only when object is cached */
566 #define ACPI_DESC_TYPE_STATE            0x20
567 #define ACPI_DESC_TYPE_STATE_UPDATE     0x21
568 #define ACPI_DESC_TYPE_STATE_PACKAGE    0x22
569 #define ACPI_DESC_TYPE_STATE_CONTROL    0x23
570 #define ACPI_DESC_TYPE_STATE_RPSCOPE    0x24
571 #define ACPI_DESC_TYPE_STATE_PSCOPE     0x25
572 #define ACPI_DESC_TYPE_STATE_WSCOPE     0x26
573 #define ACPI_DESC_TYPE_STATE_RESULT     0x27
574 #define ACPI_DESC_TYPE_STATE_NOTIFY     0x28
575 #define ACPI_DESC_TYPE_STATE_THREAD     0x29
576 #define ACPI_DESC_TYPE_WALK             0x44
577 #define ACPI_DESC_TYPE_PARSER           0x66
578 #define ACPI_DESC_TYPE_OPERAND          0x88
579 #define ACPI_DESC_TYPE_NAMED            0xAA
580
581
582 typedef union acpi_descriptor
583 {
584     UINT8                           DescriptorId;   /* To differentiate various internal objs */\
585     ACPI_OPERAND_OBJECT             Object;
586     ACPI_NAMESPACE_NODE             Node;
587     ACPI_PARSE_OBJECT               Op;
588
589 } ACPI_DESCRIPTOR;
590
591
592 #endif /* _ACOBJECT_H */