* Intel ACPI 20030228 distribution with local DragonFly changes.
[dragonfly.git] / sys / contrib / dev / acpica / aclocal.h
1 /******************************************************************************
2  *
3  * Name: aclocal.h - Internal data types used across the ACPI subsystem
4  *       $Revision: 189 $
5  *
6  *****************************************************************************/
7
8 /******************************************************************************
9  *
10  * 1. Copyright Notice
11  *
12  * Some or all of this work - Copyright (c) 1999 - 2003, 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 /* $DragonFly: src/sys/contrib/dev/acpica/Attic/aclocal.h,v 1.1 2003/09/24 03:32:15 drhodus Exp $                                                               */
117
118 #ifndef __ACLOCAL_H__
119 #define __ACLOCAL_H__
120
121
122 #define ACPI_WAIT_FOREVER               0xFFFF  /* UINT16, as per ACPI spec */
123
124 typedef void *                          ACPI_MUTEX;
125 typedef UINT32                          ACPI_MUTEX_HANDLE;
126
127
128 /* Total number of aml opcodes defined */
129
130 #define AML_NUM_OPCODES                 0x7E
131
132
133 /*****************************************************************************
134  *
135  * Mutex typedefs and structs
136  *
137  ****************************************************************************/
138
139
140 /*
141  * Predefined handles for the mutex objects used within the subsystem
142  * All mutex objects are automatically created by AcpiUtMutexInitialize.
143  *
144  * The acquire/release ordering protocol is implied via this list.  Mutexes
145  * with a lower value must be acquired before mutexes with a higher value.
146  *
147  * NOTE: any changes here must be reflected in the AcpiGbl_MutexNames table also!
148  */
149
150 #define ACPI_MTX_EXECUTE                0
151 #define ACPI_MTX_INTERPRETER            1
152 #define ACPI_MTX_PARSER                 2
153 #define ACPI_MTX_DISPATCHER             3
154 #define ACPI_MTX_TABLES                 4
155 #define ACPI_MTX_OP_REGIONS             5
156 #define ACPI_MTX_NAMESPACE              6
157 #define ACPI_MTX_EVENTS                 7
158 #define ACPI_MTX_HARDWARE               8
159 #define ACPI_MTX_CACHES                 9
160 #define ACPI_MTX_MEMORY                 10
161 #define ACPI_MTX_DEBUG_CMD_COMPLETE     11
162 #define ACPI_MTX_DEBUG_CMD_READY        12
163
164 #define MAX_MTX                         12
165 #define NUM_MTX                         MAX_MTX+1
166
167
168 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
169 #ifdef DEFINE_ACPI_GLOBALS
170
171 /* Names for the mutexes used in the subsystem */
172
173 static char                 *AcpiGbl_MutexNames[] =
174 {
175     "ACPI_MTX_Execute",
176     "ACPI_MTX_Interpreter",
177     "ACPI_MTX_Parser",
178     "ACPI_MTX_Dispatcher",
179     "ACPI_MTX_Tables",
180     "ACPI_MTX_OpRegions",
181     "ACPI_MTX_Namespace",
182     "ACPI_MTX_Events",
183     "ACPI_MTX_Hardware",
184     "ACPI_MTX_Caches",
185     "ACPI_MTX_Memory",
186     "ACPI_MTX_DebugCmdComplete",
187     "ACPI_MTX_DebugCmdReady",
188 };
189
190 #endif
191 #endif
192
193
194 /* Table for the global mutexes */
195
196 typedef struct acpi_mutex_info
197 {
198     ACPI_MUTEX                  Mutex;
199     UINT32                      UseCount;
200     UINT32                      OwnerId;
201
202 } ACPI_MUTEX_INFO;
203
204 /* This owner ID means that the mutex is not in use (unlocked) */
205
206 #define ACPI_MUTEX_NOT_ACQUIRED         (UINT32) (-1)
207
208
209 /* Lock flag parameter for various interfaces */
210
211 #define ACPI_MTX_DO_NOT_LOCK            0
212 #define ACPI_MTX_LOCK                   1
213
214
215 typedef UINT16                          ACPI_OWNER_ID;
216 #define ACPI_OWNER_TYPE_TABLE           0x0
217 #define ACPI_OWNER_TYPE_METHOD          0x1
218 #define ACPI_FIRST_METHOD_ID            0x0000
219 #define ACPI_FIRST_TABLE_ID             0x8000
220
221 /* TBD: [Restructure] get rid of the need for this! */
222
223 #define TABLE_ID_DSDT                   (ACPI_OWNER_ID) 0x8000
224
225
226 /* Field access granularities */
227
228 #define ACPI_FIELD_BYTE_GRANULARITY     1
229 #define ACPI_FIELD_WORD_GRANULARITY     2
230 #define ACPI_FIELD_DWORD_GRANULARITY    4
231 #define ACPI_FIELD_QWORD_GRANULARITY    8
232
233 /*****************************************************************************
234  *
235  * Namespace typedefs and structs
236  *
237  ****************************************************************************/
238
239
240 /* Operational modes of the AML interpreter/scanner */
241
242 typedef enum
243 {
244     ACPI_IMODE_LOAD_PASS1               = 0x01,
245     ACPI_IMODE_LOAD_PASS2               = 0x02,
246     ACPI_IMODE_EXECUTE                  = 0x0E
247
248 } ACPI_INTERPRETER_MODE;
249
250
251 /*
252  * The Node describes a named object that appears in the AML
253  * An AcpiNode is used to store Nodes.
254  *
255  * DataType is used to differentiate between internal descriptors, and MUST
256  * be the first byte in this structure.
257  */
258
259 typedef union acpi_name_union
260 {
261     UINT32                      Integer;
262     char                        Ascii[4];
263
264 } ACPI_NAME_UNION;
265
266 typedef struct acpi_namespace_node
267 {
268     UINT8                       Descriptor;     /* Used to differentiate object descriptor types */
269     UINT8                       Type;           /* Type associated with this name */
270     UINT16                      OwnerId;
271     ACPI_NAME_UNION             Name;           /* ACPI Name, always 4 chars per ACPI spec */
272
273
274     union acpi_operand_object   *Object;        /* Pointer to attached ACPI object (optional) */
275     struct acpi_namespace_node  *Child;         /* first child */
276     struct acpi_namespace_node  *Peer;          /* Next peer*/
277     UINT16                      ReferenceCount; /* Current count of references and children */
278     UINT8                       Flags;
279
280 } ACPI_NAMESPACE_NODE;
281
282
283 #define ACPI_ENTRY_NOT_FOUND            NULL
284
285
286 /* Node flags */
287
288 #define ANOBJ_RESERVED                  0x01
289 #define ANOBJ_END_OF_PEER_LIST          0x02
290 #define ANOBJ_DATA_WIDTH_32             0x04     /* Parent table is 64-bits */
291 #define ANOBJ_METHOD_ARG                0x08
292 #define ANOBJ_METHOD_LOCAL              0x10
293 #define ANOBJ_METHOD_NO_RETVAL          0x20
294 #define ANOBJ_METHOD_SOME_NO_RETVAL     0x40
295
296 #define ANOBJ_IS_BIT_OFFSET             0x80
297
298
299 /*
300  * ACPI Table Descriptor.  One per ACPI table
301  */
302 typedef struct acpi_table_desc
303 {
304     struct acpi_table_desc  *Prev;
305     struct acpi_table_desc  *Next;
306     struct acpi_table_desc  *InstalledDesc;
307     ACPI_TABLE_HEADER       *Pointer;
308     UINT8                   *AmlStart;
309     UINT64                  PhysicalAddress;
310     UINT32                  AmlLength;
311     ACPI_SIZE               Length;
312     UINT32                  Count;
313     ACPI_OWNER_ID           TableId;
314     UINT8                   Type;
315     UINT8                   Allocation;
316     BOOLEAN                 LoadedIntoNamespace;
317
318 } ACPI_TABLE_DESC;
319
320
321 typedef struct acpi_find_context
322 {
323     char                    *SearchFor;
324     ACPI_HANDLE             *List;
325     UINT32                  *Count;
326
327 } ACPI_FIND_CONTEXT;
328
329
330 typedef struct acpi_ns_search_data
331 {
332     ACPI_NAMESPACE_NODE     *Node;
333
334 } ACPI_NS_SEARCH_DATA;
335
336
337 /*
338  * Predefined Namespace items
339  */
340 typedef struct acpi_predefined_names
341 {
342     char                    *Name;
343     UINT8                   Type;
344     char                    *Val;
345
346 } ACPI_PREDEFINED_NAMES;
347
348
349 /* Object types used during package copies */
350
351
352 #define ACPI_COPY_TYPE_SIMPLE           0
353 #define ACPI_COPY_TYPE_PACKAGE          1
354
355 /* Info structure used to convert external<->internal namestrings */
356
357 typedef struct acpi_namestring_info
358 {
359     char                    *ExternalName;
360     char                    *NextExternalChar;
361     char                    *InternalName;
362     UINT32                  Length;
363     UINT32                  NumSegments;
364     UINT32                  NumCarats;
365     BOOLEAN                 FullyQualified;
366
367 } ACPI_NAMESTRING_INFO;
368
369
370 /* Field creation info */
371
372 typedef struct acpi_create_field_info
373 {
374     ACPI_NAMESPACE_NODE     *RegionNode;
375     ACPI_NAMESPACE_NODE     *FieldNode;
376     ACPI_NAMESPACE_NODE     *RegisterNode;
377     ACPI_NAMESPACE_NODE     *DataRegisterNode;
378     UINT32                  BankValue;
379     UINT32                  FieldBitPosition;
380     UINT32                  FieldBitLength;
381     UINT8                   FieldFlags;
382     UINT8                   Attribute;
383     UINT8                   FieldType;
384
385 } ACPI_CREATE_FIELD_INFO;
386
387
388 /*****************************************************************************
389  *
390  * Event typedefs and structs
391  *
392  ****************************************************************************/
393
394 /* Information about each particular GPE level */
395
396 typedef struct acpi_gpe_event_info
397 {
398     ACPI_NAMESPACE_NODE             *MethodNode;    /* Method node for this GPE level */
399     ACPI_GPE_HANDLER                Handler;        /* Address of handler, if any */
400     void                            *Context;       /* Context to be passed to handler */
401     struct acpi_gpe_register_info   *RegisterInfo;
402     UINT8                           Type;           /* Level or Edge */
403     UINT8                           BitMask;
404
405 } ACPI_GPE_EVENT_INFO;
406
407 /* Information about a particular GPE register pair */
408
409 typedef struct acpi_gpe_register_info
410 {
411     ACPI_GENERIC_ADDRESS            StatusAddress;  /* Address of status reg */
412     ACPI_GENERIC_ADDRESS            EnableAddress;  /* Address of enable reg */
413     UINT8                           Status;         /* Current value of status reg */
414     UINT8                           Enable;         /* Current value of enable reg */
415     UINT8                           WakeEnable;     /* Mask of bits to keep enabled when sleeping */
416     UINT8                           BaseGpeNumber;  /* Base GPE number for this register */
417
418 } ACPI_GPE_REGISTER_INFO;
419
420
421 #define ACPI_GPE_LEVEL_TRIGGERED        1
422 #define ACPI_GPE_EDGE_TRIGGERED         2
423
424
425 /* Information about each GPE register block */
426
427 typedef struct acpi_gpe_block_info
428 {
429     struct acpi_gpe_block_info      *Previous;
430     struct acpi_gpe_block_info      *Next;
431     struct acpi_gpe_block_info      *NextOnInterrupt;
432     ACPI_GPE_REGISTER_INFO          *RegisterInfo;
433     ACPI_GPE_EVENT_INFO             *EventInfo;
434     ACPI_GENERIC_ADDRESS            BlockAddress;
435     UINT32                          RegisterCount;
436     UINT8                           BlockBaseNumber;
437
438 } ACPI_GPE_BLOCK_INFO;
439
440
441 /* Information about each particular fixed event */
442
443 typedef struct acpi_fixed_event_handler
444 {
445     ACPI_EVENT_HANDLER      Handler;        /* Address of handler. */
446     void                    *Context;       /* Context to be passed to handler */
447
448 } ACPI_FIXED_EVENT_HANDLER;
449
450
451 typedef struct acpi_fixed_event_info
452 {
453     UINT8                   StatusRegisterId;
454     UINT8                   EnableRegisterId;
455     UINT16                  StatusBitMask;
456     UINT16                  EnableBitMask;
457
458 } ACPI_FIXED_EVENT_INFO;
459
460 /* Information used during field processing */
461
462 typedef struct acpi_field_info
463 {
464     UINT8                   SkipField;
465     UINT8                   FieldFlag;
466     UINT32                  PkgLength;
467
468 } ACPI_FIELD_INFO;
469
470
471 /*****************************************************************************
472  *
473  * Generic "state" object for stacks
474  *
475  ****************************************************************************/
476
477
478 #define ACPI_CONTROL_NORMAL                  0xC0
479 #define ACPI_CONTROL_CONDITIONAL_EXECUTING   0xC1
480 #define ACPI_CONTROL_PREDICATE_EXECUTING     0xC2
481 #define ACPI_CONTROL_PREDICATE_FALSE         0xC3
482 #define ACPI_CONTROL_PREDICATE_TRUE          0xC4
483
484
485 /* Forward declarations */
486 struct acpi_walk_state;
487 struct acpi_obj_mutex;
488 union acpi_parse_object;
489
490
491 #define ACPI_STATE_COMMON                  /* Two 32-bit fields and a pointer */\
492     UINT8                       DataType;           /* To differentiate various internal objs */\
493     UINT8                       Flags;      \
494     UINT16                      Value;      \
495     UINT16                      State;      \
496     UINT16                      Reserved;   \
497     void                        *Next;      \
498
499 typedef struct acpi_common_state
500 {
501     ACPI_STATE_COMMON
502 } ACPI_COMMON_STATE;
503
504
505 /*
506  * Update state - used to traverse complex objects such as packages
507  */
508 typedef struct acpi_update_state
509 {
510     ACPI_STATE_COMMON
511     union acpi_operand_object   *Object;
512
513 } ACPI_UPDATE_STATE;
514
515
516 /*
517  * Pkg state - used to traverse nested package structures
518  */
519 typedef struct acpi_pkg_state
520 {
521     ACPI_STATE_COMMON
522     union acpi_operand_object   *SourceObject;
523     union acpi_operand_object   *DestObject;
524     struct acpi_walk_state      *WalkState;
525     void                        *ThisTargetObj;
526     UINT32                      NumPackages;
527     UINT16                      Index;
528
529 } ACPI_PKG_STATE;
530
531
532 /*
533  * Control state - one per if/else and while constructs.
534  * Allows nesting of these constructs
535  */
536 typedef struct acpi_control_state
537 {
538     ACPI_STATE_COMMON
539     union acpi_parse_object     *PredicateOp;
540     UINT8                       *AmlPredicateStart;     /* Start of if/while predicate */
541     UINT8                       *PackageEnd;            /* End of if/while block */
542     UINT16                      Opcode;
543
544 } ACPI_CONTROL_STATE;
545
546
547 /*
548  * Scope state - current scope during namespace lookups
549  */
550 typedef struct acpi_scope_state
551 {
552     ACPI_STATE_COMMON
553     ACPI_NAMESPACE_NODE         *Node;
554
555 } ACPI_SCOPE_STATE;
556
557
558 typedef struct acpi_pscope_state
559 {
560     ACPI_STATE_COMMON
561     union acpi_parse_object     *Op;                    /* current op being parsed */
562     UINT8                       *ArgEnd;                /* current argument end */
563     UINT8                       *PkgEnd;                /* current package end */
564     UINT32                      ArgList;                /* next argument to parse */
565     UINT32                      ArgCount;               /* Number of fixed arguments */
566
567 } ACPI_PSCOPE_STATE;
568
569
570 /*
571  * Thread state - one per thread across multiple walk states.  Multiple walk
572  * states are created when there are nested control methods executing.
573  */
574 typedef struct acpi_thread_state
575 {
576     ACPI_STATE_COMMON
577     struct acpi_walk_state      *WalkStateList;         /* Head of list of WalkStates for this thread */
578     union acpi_operand_object   *AcquiredMutexList;     /* List of all currently acquired mutexes */
579     UINT32                      ThreadId;               /* Running thread ID */
580     UINT16                      CurrentSyncLevel;       /* Mutex Sync (nested acquire) level */
581
582 } ACPI_THREAD_STATE;
583
584
585 /*
586  * Result values - used to accumulate the results of nested
587  * AML arguments
588  */
589 typedef struct acpi_result_values
590 {
591     ACPI_STATE_COMMON
592     union acpi_operand_object   *ObjDesc [ACPI_OBJ_NUM_OPERANDS];
593     UINT8                       NumResults;
594     UINT8                       LastInsert;
595
596 } ACPI_RESULT_VALUES;
597
598
599 typedef
600 ACPI_STATUS (*ACPI_PARSE_DOWNWARDS) (
601     struct acpi_walk_state      *WalkState,
602     union acpi_parse_object     **OutOp);
603
604 typedef
605 ACPI_STATUS (*ACPI_PARSE_UPWARDS) (
606     struct acpi_walk_state      *WalkState);
607
608
609 /*
610  * Notify info - used to pass info to the deferred notify
611  * handler/dispatcher.
612  */
613 typedef struct acpi_notify_info
614 {
615     ACPI_STATE_COMMON
616     ACPI_NAMESPACE_NODE         *Node;
617     union acpi_operand_object   *HandlerObj;
618
619 } ACPI_NOTIFY_INFO;
620
621
622 /* Generic state is union of structs above */
623
624 typedef union acpi_generic_state
625 {
626     ACPI_COMMON_STATE           Common;
627     ACPI_CONTROL_STATE          Control;
628     ACPI_UPDATE_STATE           Update;
629     ACPI_SCOPE_STATE            Scope;
630     ACPI_PSCOPE_STATE           ParseScope;
631     ACPI_PKG_STATE              Pkg;
632     ACPI_THREAD_STATE           Thread;
633     ACPI_RESULT_VALUES          Results;
634     ACPI_NOTIFY_INFO            Notify;
635
636 } ACPI_GENERIC_STATE;
637
638
639 /*****************************************************************************
640  *
641  * Interpreter typedefs and structs
642  *
643  ****************************************************************************/
644
645 typedef
646 ACPI_STATUS (*ACPI_EXECUTE_OP) (
647     struct acpi_walk_state      *WalkState);
648
649
650 /*****************************************************************************
651  *
652  * Parser typedefs and structs
653  *
654  ****************************************************************************/
655
656 /*
657  * AML opcode, name, and argument layout
658  */
659 typedef struct acpi_opcode_info
660 {
661 #if defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUG_OUTPUT)
662     char                        *Name;          /* Opcode name (disassembler/debug only) */
663 #endif
664     UINT32                      ParseArgs;      /* Grammar/Parse time arguments */
665     UINT32                      RuntimeArgs;    /* Interpret time arguments */
666     UINT32                      Flags;          /* Misc flags */
667     UINT8                       ObjectType;     /* Corresponding internal object type */
668     UINT8                       Class;          /* Opcode class */
669     UINT8                       Type;           /* Opcode type */
670
671 } ACPI_OPCODE_INFO;
672
673
674 typedef union acpi_parse_value
675 {
676     ACPI_INTEGER                Integer;        /* integer constant (Up to 64 bits) */
677     UINT64_STRUCT               Integer64;      /* Structure overlay for 2 32-bit Dwords */
678     UINT32                      Integer32;      /* integer constant, 32 bits only */
679     UINT16                      Integer16;      /* integer constant, 16 bits only */
680     UINT8                       Integer8;       /* integer constant, 8 bits only */
681     UINT32                      Size;           /* bytelist or field size */
682     char                        *String;        /* NULL terminated string */
683     UINT8                       *Buffer;        /* buffer or string */
684     char                        *Name;          /* NULL terminated string */
685     union acpi_parse_object     *Arg;           /* arguments and contained ops */
686
687 } ACPI_PARSE_VALUE;
688
689
690 #define ACPI_PARSE_COMMON \
691     UINT8                       DataType;       /* To differentiate various internal objs */\
692     UINT8                       Flags;          /* Type of Op */\
693     UINT16                      AmlOpcode;      /* AML opcode */\
694     UINT32                      AmlOffset;      /* offset of declaration in AML */\
695     union acpi_parse_object     *Parent;        /* parent op */\
696     union acpi_parse_object     *Next;          /* next op */\
697     ACPI_DISASM_ONLY_MEMBERS (\
698     UINT8                       DisasmFlags;    /* Used during AML disassembly */\
699     UINT8                       DisasmOpcode;   /* Subtype used for disassembly */\
700     char                        AmlOpName[16])  /* op name (debug only) */\
701                                                 /* NON-DEBUG members below: */\
702     ACPI_NAMESPACE_NODE         *Node;          /* for use by interpreter */\
703     ACPI_PARSE_VALUE            Value;          /* Value or args associated with the opcode */\
704
705
706 #define ACPI_DASM_BUFFER        0x00
707 #define ACPI_DASM_RESOURCE      0x01
708 #define ACPI_DASM_STRING        0x02
709 #define ACPI_DASM_UNICODE       0x03
710 #define ACPI_DASM_EISAID        0x04
711 #define ACPI_DASM_MATCHOP       0x05
712
713 /*
714  * generic operation (for example:  If, While, Store)
715  */
716 typedef struct acpi_parse_obj_common
717 {
718     ACPI_PARSE_COMMON
719 } ACPI_PARSE_OBJ_COMMON;
720
721
722 /*
723  * Extended Op for named ops (Scope, Method, etc.), deferred ops (Methods and OpRegions),
724  * and bytelists.
725  */
726 typedef struct acpi_parse_obj_named
727 {
728     ACPI_PARSE_COMMON
729     UINT8                       *Path;
730     UINT8                       *Data;          /* AML body or bytelist data */
731     UINT32                      Length;         /* AML length */
732     UINT32                      Name;           /* 4-byte name or zero if no name */
733
734 } ACPI_PARSE_OBJ_NAMED;
735
736
737 /* The parse node is the fundamental element of the parse tree */
738
739 typedef struct acpi_parse_obj_asl
740 {
741     ACPI_PARSE_COMMON
742     union acpi_parse_object     *Child;
743     union acpi_parse_object     *ParentMethod;
744     char                        *Filename;
745     char                        *ExternalName;
746     char                        *Namepath;
747     char                        NameSeg[4];
748     UINT32                      ExtraValue;
749     UINT32                      Column;
750     UINT32                      LineNumber;
751     UINT32                      LogicalLineNumber;
752     UINT32                      LogicalByteOffset;
753     UINT32                      EndLine;
754     UINT32                      EndLogicalLine;
755     UINT32                      AcpiBtype;
756     UINT32                      AmlLength;
757     UINT32                      AmlSubtreeLength;
758     UINT32                      FinalAmlLength;
759     UINT32                      FinalAmlOffset;
760     UINT32                      CompileFlags;
761     UINT16                      ParseOpcode;
762     UINT8                       AmlOpcodeLength;
763     UINT8                       AmlPkgLenBytes;
764     UINT8                       Extra;
765     char                        ParseOpName[12];
766
767 } ACPI_PARSE_OBJ_ASL;
768
769
770 typedef union acpi_parse_object
771 {
772     ACPI_PARSE_OBJ_COMMON       Common;
773     ACPI_PARSE_OBJ_NAMED        Named;
774     ACPI_PARSE_OBJ_ASL          Asl;
775
776 } ACPI_PARSE_OBJECT;
777
778
779 /*
780  * Parse state - one state per parser invocation and each control
781  * method.
782  */
783 typedef struct acpi_parse_state
784 {
785     UINT32                      AmlSize;
786     UINT8                       *AmlStart;      /* first AML byte */
787     UINT8                       *Aml;           /* next AML byte */
788     UINT8                       *AmlEnd;        /* (last + 1) AML byte */
789     UINT8                       *PkgStart;      /* current package begin */
790     UINT8                       *PkgEnd;        /* current package end */
791     union acpi_parse_object     *StartOp;       /* root of parse tree */
792     struct acpi_namespace_node  *StartNode;
793     union acpi_generic_state    *Scope;         /* current scope */
794     union acpi_parse_object     *StartScope;
795
796 } ACPI_PARSE_STATE;
797
798
799 /* Parse object flags */
800
801 #define ACPI_PARSEOP_GENERIC                    0x01
802 #define ACPI_PARSEOP_NAMED                      0x02
803 #define ACPI_PARSEOP_DEFERRED                   0x04
804 #define ACPI_PARSEOP_BYTELIST                   0x08
805 #define ACPI_PARSEOP_IN_CACHE                   0x80
806
807 /* Parse object DisasmFlags */
808
809 #define ACPI_PARSEOP_IGNORE                     0x01
810 #define ACPI_PARSEOP_PARAMLIST                  0x02
811 #define ACPI_PARSEOP_EMPTY_TERMLIST             0x04
812 #define ACPI_PARSEOP_SPECIAL                    0x10
813
814
815 /*****************************************************************************
816  *
817  * Hardware (ACPI registers) and PNP
818  *
819  ****************************************************************************/
820
821 #define PCI_ROOT_HID_STRING         "PNP0A03"
822
823 typedef struct acpi_bit_register_info
824 {
825     UINT8                       ParentRegister;
826     UINT8                       BitPosition;
827     UINT16                      AccessBitMask;
828
829 } ACPI_BIT_REGISTER_INFO;
830
831
832 /*
833  * Register IDs
834  * These are the full ACPI registers
835  */
836 #define ACPI_REGISTER_PM1_STATUS                0x01
837 #define ACPI_REGISTER_PM1_ENABLE                0x02
838 #define ACPI_REGISTER_PM1_CONTROL               0x03
839 #define ACPI_REGISTER_PM1A_CONTROL              0x04
840 #define ACPI_REGISTER_PM1B_CONTROL              0x05
841 #define ACPI_REGISTER_PM2_CONTROL               0x06
842 #define ACPI_REGISTER_PM_TIMER                  0x07
843 #define ACPI_REGISTER_PROCESSOR_BLOCK           0x08
844 #define ACPI_REGISTER_SMI_COMMAND_BLOCK         0x09
845
846
847 /* Masks used to access the BitRegisters */
848
849 #define ACPI_BITMASK_TIMER_STATUS               0x0001
850 #define ACPI_BITMASK_BUS_MASTER_STATUS          0x0010
851 #define ACPI_BITMASK_GLOBAL_LOCK_STATUS         0x0020
852 #define ACPI_BITMASK_POWER_BUTTON_STATUS        0x0100
853 #define ACPI_BITMASK_SLEEP_BUTTON_STATUS        0x0200
854 #define ACPI_BITMASK_RT_CLOCK_STATUS            0x0400
855 #define ACPI_BITMASK_WAKE_STATUS                0x8000
856
857 #define ACPI_BITMASK_ALL_FIXED_STATUS           (ACPI_BITMASK_TIMER_STATUS          | \
858                                                  ACPI_BITMASK_BUS_MASTER_STATUS     | \
859                                                  ACPI_BITMASK_GLOBAL_LOCK_STATUS    | \
860                                                  ACPI_BITMASK_POWER_BUTTON_STATUS   | \
861                                                  ACPI_BITMASK_SLEEP_BUTTON_STATUS   | \
862                                                  ACPI_BITMASK_RT_CLOCK_STATUS       | \
863                                                  ACPI_BITMASK_WAKE_STATUS)
864
865 #define ACPI_BITMASK_TIMER_ENABLE               0x0001
866 #define ACPI_BITMASK_GLOBAL_LOCK_ENABLE         0x0020
867 #define ACPI_BITMASK_POWER_BUTTON_ENABLE        0x0100
868 #define ACPI_BITMASK_SLEEP_BUTTON_ENABLE        0x0200
869 #define ACPI_BITMASK_RT_CLOCK_ENABLE            0x0400
870
871 #define ACPI_BITMASK_SCI_ENABLE                 0x0001
872 #define ACPI_BITMASK_BUS_MASTER_RLD             0x0002
873 #define ACPI_BITMASK_GLOBAL_LOCK_RELEASE        0x0004
874 #define ACPI_BITMASK_SLEEP_TYPE_X               0x1C00
875 #define ACPI_BITMASK_SLEEP_ENABLE               0x2000
876
877 #define ACPI_BITMASK_ARB_DISABLE                0x0001
878
879
880 /* Raw bit position of each BitRegister */
881
882 #define ACPI_BITPOSITION_TIMER_STATUS           0x00
883 #define ACPI_BITPOSITION_BUS_MASTER_STATUS      0x04
884 #define ACPI_BITPOSITION_GLOBAL_LOCK_STATUS     0x05
885 #define ACPI_BITPOSITION_POWER_BUTTON_STATUS    0x08
886 #define ACPI_BITPOSITION_SLEEP_BUTTON_STATUS    0x09
887 #define ACPI_BITPOSITION_RT_CLOCK_STATUS        0x0A
888 #define ACPI_BITPOSITION_WAKE_STATUS            0x0F
889
890 #define ACPI_BITPOSITION_TIMER_ENABLE           0x00
891 #define ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE     0x05
892 #define ACPI_BITPOSITION_POWER_BUTTON_ENABLE    0x08
893 #define ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE    0x09
894 #define ACPI_BITPOSITION_RT_CLOCK_ENABLE        0x0A
895
896 #define ACPI_BITPOSITION_SCI_ENABLE             0x00
897 #define ACPI_BITPOSITION_BUS_MASTER_RLD         0x01
898 #define ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE    0x02
899 #define ACPI_BITPOSITION_SLEEP_TYPE_X           0x0A
900 #define ACPI_BITPOSITION_SLEEP_ENABLE           0x0D
901
902 #define ACPI_BITPOSITION_ARB_DISABLE            0x00
903
904
905 /*****************************************************************************
906  *
907  * Resource descriptors
908  *
909  ****************************************************************************/
910
911
912 /* ResourceType values */
913
914 #define ACPI_RESOURCE_TYPE_MEMORY_RANGE         0
915 #define ACPI_RESOURCE_TYPE_IO_RANGE             1
916 #define ACPI_RESOURCE_TYPE_BUS_NUMBER_RANGE     2
917
918 /* Resource descriptor types and masks */
919
920 #define ACPI_RDESC_TYPE_LARGE                   0x80
921 #define ACPI_RDESC_TYPE_SMALL                   0x00
922
923 #define ACPI_RDESC_TYPE_MASK                    0x80
924 #define ACPI_RDESC_SMALL_MASK                   0x78 /* Only bits 6:3 contain the type */
925
926
927 /*
928  * Small resource descriptor types
929  * Note: The 3 length bits (2:0) must be zero
930  */
931 #define ACPI_RDESC_TYPE_IRQ_FORMAT              0x20
932 #define ACPI_RDESC_TYPE_DMA_FORMAT              0x28
933 #define ACPI_RDESC_TYPE_START_DEPENDENT         0x30
934 #define ACPI_RDESC_TYPE_END_DEPENDENT           0x38
935 #define ACPI_RDESC_TYPE_IO_PORT                 0x40
936 #define ACPI_RDESC_TYPE_FIXED_IO_PORT           0x48
937 #define ACPI_RDESC_TYPE_SMALL_VENDOR            0x70
938 #define ACPI_RDESC_TYPE_END_TAG                 0x78
939
940 /*
941  * Large resource descriptor types
942  */
943
944 #define ACPI_RDESC_TYPE_MEMORY_24               0x81
945 #define ACPI_RDESC_TYPE_GENERAL_REGISTER        0x82
946 #define ACPI_RDESC_TYPE_LARGE_VENDOR            0x84
947 #define ACPI_RDESC_TYPE_MEMORY_32               0x85
948 #define ACPI_RDESC_TYPE_FIXED_MEMORY_32         0x86
949 #define ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE     0x87
950 #define ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE      0x88
951 #define ACPI_RDESC_TYPE_EXTENDED_XRUPT          0x89
952 #define ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE     0x8A
953
954
955 /* String version of device HIDs and UIDs */
956
957 #define ACPI_DEVICE_ID_LENGTH                   0x09
958
959 typedef struct acpi_device_id
960 {
961     char            Buffer[ACPI_DEVICE_ID_LENGTH];
962
963 } ACPI_DEVICE_ID;
964
965
966 /*****************************************************************************
967  *
968  * Miscellaneous
969  *
970  ****************************************************************************/
971
972 #define ACPI_ASCII_ZERO                      0x30
973
974
975 /*****************************************************************************
976  *
977  * Debugger
978  *
979  ****************************************************************************/
980
981 typedef struct acpi_db_method_info
982 {
983     ACPI_HANDLE             ThreadGate;
984     char                    *Name;
985     char                    **Args;
986     UINT32                  Flags;
987     UINT32                  NumLoops;
988     char                    Pathname[128];
989
990 } ACPI_DB_METHOD_INFO;
991
992 typedef struct acpi_integrity_info
993 {
994     UINT32              Nodes;
995     UINT32              Objects;
996
997 } ACPI_INTEGRITY_INFO;
998
999
1000 #define ACPI_DB_REDIRECTABLE_OUTPUT  0x01
1001 #define ACPI_DB_CONSOLE_OUTPUT       0x02
1002 #define ACPI_DB_DUPLICATE_OUTPUT     0x03
1003
1004
1005 /*****************************************************************************
1006  *
1007  * Debug
1008  *
1009  ****************************************************************************/
1010
1011 typedef struct acpi_debug_print_info
1012 {
1013     UINT32                  ComponentId;
1014     char                    *ProcName;
1015     char                    *ModuleName;
1016
1017 } ACPI_DEBUG_PRINT_INFO;
1018
1019
1020 /* Entry for a memory allocation (debug only) */
1021
1022 #define ACPI_MEM_MALLOC                      0
1023 #define ACPI_MEM_CALLOC                      1
1024 #define ACPI_MAX_MODULE_NAME                 16
1025
1026 #define ACPI_COMMON_DEBUG_MEM_HEADER \
1027     struct acpi_debug_mem_block *Previous; \
1028     struct acpi_debug_mem_block *Next; \
1029     UINT32                      Size; \
1030     UINT32                      Component; \
1031     UINT32                      Line; \
1032     char                        Module[ACPI_MAX_MODULE_NAME]; \
1033     UINT8                       AllocType;
1034
1035 typedef struct acpi_debug_mem_header
1036 {
1037     ACPI_COMMON_DEBUG_MEM_HEADER
1038
1039 } ACPI_DEBUG_MEM_HEADER;
1040
1041 typedef struct acpi_debug_mem_block
1042 {
1043     ACPI_COMMON_DEBUG_MEM_HEADER
1044     UINT64                      UserSpace;
1045
1046 } ACPI_DEBUG_MEM_BLOCK;
1047
1048
1049 #define ACPI_MEM_LIST_GLOBAL            0
1050 #define ACPI_MEM_LIST_NSNODE            1
1051
1052 #define ACPI_MEM_LIST_FIRST_CACHE_LIST  2
1053 #define ACPI_MEM_LIST_STATE             2
1054 #define ACPI_MEM_LIST_PSNODE            3
1055 #define ACPI_MEM_LIST_PSNODE_EXT        4
1056 #define ACPI_MEM_LIST_OPERAND           5
1057 #define ACPI_MEM_LIST_WALK              6
1058 #define ACPI_MEM_LIST_MAX               6
1059 #define ACPI_NUM_MEM_LISTS              7
1060
1061
1062 typedef struct acpi_memory_list
1063 {
1064     void                        *ListHead;
1065     UINT16                      LinkOffset;
1066     UINT16                      MaxCacheDepth;
1067     UINT16                      CacheDepth;
1068     UINT16                      ObjectSize;
1069
1070 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
1071
1072     /* Statistics for debug memory tracking only */
1073
1074     UINT32                      TotalAllocated;
1075     UINT32                      TotalFreed;
1076     UINT32                      CurrentTotalSize;
1077     UINT32                      CacheRequests;
1078     UINT32                      CacheHits;
1079     char                        *ListName;
1080 #endif
1081
1082 } ACPI_MEMORY_LIST;
1083
1084
1085 #endif /* __ACLOCAL_H__ */