xref: /titanic_44/usr/src/uts/intel/sys/acpi/aclocal.h (revision 8eea8e29cc4374d1ee24c25a07f45af132db3499)
1 /******************************************************************************
2  *
3  * Name: aclocal.h - Internal data types used across the ACPI subsystem
4  *       $Revision: 206 $
5  *
6  *****************************************************************************/
7 
8 /******************************************************************************
9  *
10  * 1. Copyright Notice
11  *
12  * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp.
13  * All rights reserved.
14  *
15  * 2. License
16  *
17  * 2.1. This is your license from Intel Corp. under its intellectual property
18  * rights.  You may have additional license terms from the party that provided
19  * you this software, covering your right to use that party's intellectual
20  * property rights.
21  *
22  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23  * copy of the source code appearing in this file ("Covered Code") an
24  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25  * base code distributed originally by Intel ("Original Intel Code") to copy,
26  * make derivatives, distribute, use and display any portion of the Covered
27  * Code in any form, with the right to sublicense such rights; and
28  *
29  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30  * license (with the right to sublicense), under only those claims of Intel
31  * patents that are infringed by the Original Intel Code, to make, use, sell,
32  * offer to sell, and import the Covered Code and derivative works thereof
33  * solely to the minimum extent necessary to exercise the above copyright
34  * license, and in no event shall the patent license extend to any additions
35  * to or modifications of the Original Intel Code.  No other license or right
36  * is granted directly or by implication, estoppel or otherwise;
37  *
38  * The above copyright and patent license is granted only if the following
39  * conditions are met:
40  *
41  * 3. Conditions
42  *
43  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44  * Redistribution of source code of any substantial portion of the Covered
45  * Code or modification with rights to further distribute source must include
46  * the above Copyright Notice, the above License, this list of Conditions,
47  * and the following Disclaimer and Export Compliance provision.  In addition,
48  * Licensee must cause all Covered Code to which Licensee contributes to
49  * contain a file documenting the changes Licensee made to create that Covered
50  * Code and the date of any change.  Licensee must include in that file the
51  * documentation of any changes made by any predecessor Licensee.  Licensee
52  * must include a prominent statement that the modification is derived,
53  * directly or indirectly, from Original Intel Code.
54  *
55  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56  * Redistribution of source code of any substantial portion of the Covered
57  * Code or modification without rights to further distribute source must
58  * include the following Disclaimer and Export Compliance provision in the
59  * documentation and/or other materials provided with distribution.  In
60  * addition, Licensee may not authorize further sublicense of source of any
61  * portion of the Covered Code, and must include terms to the effect that the
62  * license from Licensee to its licensee is limited to the intellectual
63  * property embodied in the software Licensee provides to its licensee, and
64  * not to intellectual property embodied in modifications its licensee may
65  * make.
66  *
67  * 3.3. Redistribution of Executable. Redistribution in executable form of any
68  * substantial portion of the Covered Code or modification must reproduce the
69  * above Copyright Notice, and the following Disclaimer and Export Compliance
70  * provision in the documentation and/or other materials provided with the
71  * distribution.
72  *
73  * 3.4. Intel retains all right, title, and interest in and to the Original
74  * Intel Code.
75  *
76  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77  * Intel shall be used in advertising or otherwise to promote the sale, use or
78  * other dealings in products derived from or relating to the Covered Code
79  * without prior written authorization from Intel.
80  *
81  * 4. Disclaimer and Export Compliance
82  *
83  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
86  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
87  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
88  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89  * PARTICULAR PURPOSE.
90  *
91  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
97  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98  * LIMITED REMEDY.
99  *
100  * 4.3. Licensee shall not export, either directly or indirectly, any of this
101  * software or system incorporating such software without first obtaining any
102  * required license or other approval from the U. S. Department of Commerce or
103  * any other agency or department of the United States Government.  In the
104  * event Licensee exports any such software from the United States or
105  * re-exports any such software from a foreign destination, Licensee shall
106  * ensure that the distribution and export/re-export of the software is in
107  * compliance with all laws, regulations, orders, or other restrictions of the
108  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109  * any of its subsidiaries will export/re-export any technical data, process,
110  * software, or service, directly or indirectly, to any country for which the
111  * United States government or any agency thereof requires an export license,
112  * other governmental approval, or letter of assurance, without first obtaining
113  * such license, approval or letter.
114  *
115  *****************************************************************************/
116 
117 #ifndef __ACLOCAL_H__
118 #define __ACLOCAL_H__
119 
120 
121 #define ACPI_WAIT_FOREVER               0xFFFF  /* UINT16, as per ACPI spec */
122 
123 typedef void *                          ACPI_MUTEX;
124 typedef UINT32                          ACPI_MUTEX_HANDLE;
125 
126 
127 /* Total number of aml opcodes defined */
128 
129 #define AML_NUM_OPCODES                 0x7F
130 
131 
132 /*****************************************************************************
133  *
134  * Mutex typedefs and structs
135  *
136  ****************************************************************************/
137 
138 
139 /*
140  * Predefined handles for the mutex objects used within the subsystem
141  * All mutex objects are automatically created by AcpiUtMutexInitialize.
142  *
143  * The acquire/release ordering protocol is implied via this list.  Mutexes
144  * with a lower value must be acquired before mutexes with a higher value.
145  *
146  * NOTE: any changes here must be reflected in the AcpiGbl_MutexNames table also!
147  */
148 #define ACPI_MTX_EXECUTE                0
149 #define ACPI_MTX_INTERPRETER            1
150 #define ACPI_MTX_PARSER                 2
151 #define ACPI_MTX_DISPATCHER             3
152 #define ACPI_MTX_TABLES                 4
153 #define ACPI_MTX_OP_REGIONS             5
154 #define ACPI_MTX_NAMESPACE              6
155 #define ACPI_MTX_EVENTS                 7
156 #define ACPI_MTX_HARDWARE               8
157 #define ACPI_MTX_CACHES                 9
158 #define ACPI_MTX_MEMORY                 10
159 #define ACPI_MTX_DEBUG_CMD_COMPLETE     11
160 #define ACPI_MTX_DEBUG_CMD_READY        12
161 
162 #define MAX_MUTEX                       12
163 #define NUM_MUTEX                       MAX_MUTEX+1
164 
165 
166 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
167 #ifdef DEFINE_ACPI_GLOBALS
168 
169 /* Names for the mutexes used in the subsystem */
170 
171 static char                 *AcpiGbl_MutexNames[] =
172 {
173     "ACPI_MTX_Execute",
174     "ACPI_MTX_Interpreter",
175     "ACPI_MTX_Parser",
176     "ACPI_MTX_Dispatcher",
177     "ACPI_MTX_Tables",
178     "ACPI_MTX_OpRegions",
179     "ACPI_MTX_Namespace",
180     "ACPI_MTX_Events",
181     "ACPI_MTX_Hardware",
182     "ACPI_MTX_Caches",
183     "ACPI_MTX_Memory",
184     "ACPI_MTX_DebugCmdComplete",
185     "ACPI_MTX_DebugCmdReady",
186 };
187 
188 #endif
189 #endif
190 
191 
192 /* Table for the global mutexes */
193 
194 typedef struct acpi_mutex_info
195 {
196     ACPI_MUTEX                  Mutex;
197     UINT32                      UseCount;
198     UINT32                      OwnerId;
199 
200 } ACPI_MUTEX_INFO;
201 
202 /* This owner ID means that the mutex is not in use (unlocked) */
203 
204 #define ACPI_MUTEX_NOT_ACQUIRED         (UINT32) (-1)
205 
206 
207 /* Lock flag parameter for various interfaces */
208 
209 #define ACPI_MTX_DO_NOT_LOCK            0
210 #define ACPI_MTX_LOCK                   1
211 
212 
213 typedef UINT16                          ACPI_OWNER_ID;
214 #define ACPI_OWNER_TYPE_TABLE           0x0
215 #define ACPI_OWNER_TYPE_METHOD          0x1
216 #define ACPI_FIRST_METHOD_ID            0x0001
217 #define ACPI_FIRST_TABLE_ID             0xF000
218 
219 
220 /* Field access granularities */
221 
222 #define ACPI_FIELD_BYTE_GRANULARITY     1
223 #define ACPI_FIELD_WORD_GRANULARITY     2
224 #define ACPI_FIELD_DWORD_GRANULARITY    4
225 #define ACPI_FIELD_QWORD_GRANULARITY    8
226 
227 
228 /*****************************************************************************
229  *
230  * Namespace typedefs and structs
231  *
232  ****************************************************************************/
233 
234 /* Operational modes of the AML interpreter/scanner */
235 
236 typedef enum
237 {
238     ACPI_IMODE_LOAD_PASS1               = 0x01,
239     ACPI_IMODE_LOAD_PASS2               = 0x02,
240     ACPI_IMODE_EXECUTE                  = 0x0E
241 
242 } ACPI_INTERPRETER_MODE;
243 
244 
245 /*
246  * The Node describes a named object that appears in the AML
247  * An AcpiNode is used to store Nodes.
248  *
249  * DataType is used to differentiate between internal descriptors, and MUST
250  * be the first byte in this structure.
251  */
252 typedef union acpi_name_union
253 {
254     UINT32                      Integer;
255     char                        Ascii[4];
256 
257 } ACPI_NAME_UNION;
258 
259 typedef struct acpi_namespace_node
260 {
261     UINT8                       Descriptor;     /* Used to differentiate object descriptor types */
262     UINT8                       Type;           /* Type associated with this name */
263     UINT16                      OwnerId;
264     ACPI_NAME_UNION             Name;           /* ACPI Name, always 4 chars per ACPI spec */
265     union acpi_operand_object   *Object;        /* Pointer to attached ACPI object (optional) */
266     struct acpi_namespace_node  *Child;         /* First child */
267     struct acpi_namespace_node  *Peer;          /* Next peer*/
268     UINT16                      ReferenceCount; /* Current count of references and children */
269     UINT8                       Flags;
270 
271 } ACPI_NAMESPACE_NODE;
272 
273 
274 #define ACPI_ENTRY_NOT_FOUND            NULL
275 
276 
277 /* Node flags */
278 
279 #define ANOBJ_RESERVED                  0x01
280 #define ANOBJ_END_OF_PEER_LIST          0x02
281 #define ANOBJ_DATA_WIDTH_32             0x04     /* Parent table is 64-bits */
282 #define ANOBJ_METHOD_ARG                0x08
283 #define ANOBJ_METHOD_LOCAL              0x10
284 #define ANOBJ_METHOD_NO_RETVAL          0x20
285 #define ANOBJ_METHOD_SOME_NO_RETVAL     0x40
286 #define ANOBJ_IS_BIT_OFFSET             0x80
287 
288 /*
289  * ACPI Table Descriptor.  One per ACPI table
290  */
291 typedef struct acpi_table_desc
292 {
293     struct acpi_table_desc  *Prev;
294     struct acpi_table_desc  *Next;
295     struct acpi_table_desc  *InstalledDesc;
296     ACPI_TABLE_HEADER       *Pointer;
297     UINT8                   *AmlStart;
298     UINT64                  PhysicalAddress;
299     UINT32                  AmlLength;
300     ACPI_SIZE               Length;
301     ACPI_OWNER_ID           TableId;
302     UINT8                   Type;
303     UINT8                   Allocation;
304     BOOLEAN                 LoadedIntoNamespace;
305 
306 } ACPI_TABLE_DESC;
307 
308 typedef struct acpi_table_list
309 {
310     struct acpi_table_desc  *Next;
311     UINT32                  Count;
312 
313 } ACPI_TABLE_LIST;
314 
315 
316 typedef struct acpi_find_context
317 {
318     char                    *SearchFor;
319     ACPI_HANDLE             *List;
320     UINT32                  *Count;
321 
322 } ACPI_FIND_CONTEXT;
323 
324 
325 typedef struct acpi_ns_search_data
326 {
327     ACPI_NAMESPACE_NODE     *Node;
328 
329 } ACPI_NS_SEARCH_DATA;
330 
331 
332 /*
333  * Predefined Namespace items
334  */
335 typedef struct acpi_predefined_names
336 {
337     char                    *Name;
338     UINT8                   Type;
339     char                    *Val;
340 
341 } ACPI_PREDEFINED_NAMES;
342 
343 
344 /* Object types used during package copies */
345 
346 
347 #define ACPI_COPY_TYPE_SIMPLE           0
348 #define ACPI_COPY_TYPE_PACKAGE          1
349 
350 /* Info structure used to convert external<->internal namestrings */
351 
352 typedef struct acpi_namestring_info
353 {
354     char                    *ExternalName;
355     char                    *NextExternalChar;
356     char                    *InternalName;
357     UINT32                  Length;
358     UINT32                  NumSegments;
359     UINT32                  NumCarats;
360     BOOLEAN                 FullyQualified;
361 
362 } ACPI_NAMESTRING_INFO;
363 
364 
365 /* Field creation info */
366 
367 typedef struct acpi_create_field_info
368 {
369     ACPI_NAMESPACE_NODE     *RegionNode;
370     ACPI_NAMESPACE_NODE     *FieldNode;
371     ACPI_NAMESPACE_NODE     *RegisterNode;
372     ACPI_NAMESPACE_NODE     *DataRegisterNode;
373     UINT32                  BankValue;
374     UINT32                  FieldBitPosition;
375     UINT32                  FieldBitLength;
376     UINT8                   FieldFlags;
377     UINT8                   Attribute;
378     UINT8                   FieldType;
379 
380 } ACPI_CREATE_FIELD_INFO;
381 
382 
383 /*****************************************************************************
384  *
385  * Event typedefs and structs
386  *
387  ****************************************************************************/
388 
389 /* Dispatch info for each GPE -- either a method or handler, cannot be both */
390 
391 typedef struct acpi_handler_info
392 {
393     ACPI_EVENT_HANDLER              Address;        /* Address of handler, if any */
394     void                            *Context;       /* Context to be passed to handler */
395     ACPI_NAMESPACE_NODE             *MethodNode;    /* Method node for this GPE level (saved) */
396 
397 } ACPI_HANDLER_INFO;
398 
399 typedef union acpi_gpe_dispatch_info
400 {
401     ACPI_NAMESPACE_NODE             *MethodNode;    /* Method node for this GPE level */
402     struct acpi_handler_info        *Handler;
403 
404 } ACPI_GPE_DISPATCH_INFO;
405 
406 /*
407  * Information about a GPE, one per each GPE in an array.
408  * NOTE: Important to keep this struct as small as possible.
409  */
410 typedef struct acpi_gpe_event_info
411 {
412     union acpi_gpe_dispatch_info    Dispatch;       /* Either Method or Handler */
413     struct acpi_gpe_register_info   *RegisterInfo;  /* Backpointer to register info */
414     UINT8                           Flags;          /* Misc info about this GPE */
415     UINT8                           RegisterBit;    /* This GPE bit within the register */
416 
417 } ACPI_GPE_EVENT_INFO;
418 
419 /* Information about a GPE register pair, one per each status/enable pair in an array */
420 
421 typedef struct acpi_gpe_register_info
422 {
423     ACPI_GENERIC_ADDRESS            StatusAddress;  /* Address of status reg */
424     ACPI_GENERIC_ADDRESS            EnableAddress;  /* Address of enable reg */
425     UINT8                           EnableForWake;  /* GPEs to keep enabled when sleeping */
426     UINT8                           EnableForRun;   /* GPEs to keep enabled when running */
427     UINT8                           BaseGpeNumber;  /* Base GPE number for this register */
428 
429 } ACPI_GPE_REGISTER_INFO;
430 
431 /*
432  * Information about a GPE register block, one per each installed block --
433  * GPE0, GPE1, and one per each installed GPE Block Device.
434  */
435 typedef struct acpi_gpe_block_info
436 {
437     ACPI_NAMESPACE_NODE             *Node;
438     struct acpi_gpe_block_info      *Previous;
439     struct acpi_gpe_block_info      *Next;
440     struct acpi_gpe_xrupt_info      *XruptBlock;    /* Backpointer to interrupt block */
441     ACPI_GPE_REGISTER_INFO          *RegisterInfo;  /* One per GPE register pair */
442     ACPI_GPE_EVENT_INFO             *EventInfo;     /* One for each GPE */
443     ACPI_GENERIC_ADDRESS            BlockAddress;   /* Base address of the block */
444     UINT32                          RegisterCount;  /* Number of register pairs in block */
445     UINT8                           BlockBaseNumber;/* Base GPE number for this block */
446 
447 } ACPI_GPE_BLOCK_INFO;
448 
449 /* Information about GPE interrupt handlers, one per each interrupt level used for GPEs */
450 
451 typedef struct acpi_gpe_xrupt_info
452 {
453     struct acpi_gpe_xrupt_info      *Previous;
454     struct acpi_gpe_xrupt_info      *Next;
455     ACPI_GPE_BLOCK_INFO             *GpeBlockListHead;  /* List of GPE blocks for this xrupt */
456     UINT32                          InterruptLevel;     /* System interrupt level */
457 
458 } ACPI_GPE_XRUPT_INFO;
459 
460 
461 typedef struct acpi_gpe_walk_info
462 {
463     ACPI_NAMESPACE_NODE             *GpeDevice;
464     ACPI_GPE_BLOCK_INFO             *GpeBlock;
465 
466 } ACPI_GPE_WALK_INFO;
467 
468 
469 typedef ACPI_STATUS (*ACPI_GPE_CALLBACK) (
470     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
471     ACPI_GPE_BLOCK_INFO     *GpeBlock);
472 
473 
474 /* Information about each particular fixed event */
475 
476 typedef struct acpi_fixed_event_handler
477 {
478     ACPI_EVENT_HANDLER      Handler;        /* Address of handler. */
479     void                    *Context;       /* Context to be passed to handler */
480 
481 } ACPI_FIXED_EVENT_HANDLER;
482 
483 typedef struct acpi_fixed_event_info
484 {
485     UINT8                   StatusRegisterId;
486     UINT8                   EnableRegisterId;
487     UINT16                  StatusBitMask;
488     UINT16                  EnableBitMask;
489 
490 } ACPI_FIXED_EVENT_INFO;
491 
492 /* Information used during field processing */
493 
494 typedef struct acpi_field_info
495 {
496     UINT8                   SkipField;
497     UINT8                   FieldFlag;
498     UINT32                  PkgLength;
499 
500 } ACPI_FIELD_INFO;
501 
502 
503 /*****************************************************************************
504  *
505  * Generic "state" object for stacks
506  *
507  ****************************************************************************/
508 
509 #define ACPI_CONTROL_NORMAL                  0xC0
510 #define ACPI_CONTROL_CONDITIONAL_EXECUTING   0xC1
511 #define ACPI_CONTROL_PREDICATE_EXECUTING     0xC2
512 #define ACPI_CONTROL_PREDICATE_FALSE         0xC3
513 #define ACPI_CONTROL_PREDICATE_TRUE          0xC4
514 
515 
516 /* Forward declarations */
517 
518 struct acpi_walk_state;
519 struct acpi_obj_mutex;
520 union acpi_parse_object;
521 
522 
523 #define ACPI_STATE_COMMON                  /* Two 32-bit fields and a pointer */\
524     UINT8                       DataType;           /* To differentiate various internal objs */\
525     UINT8                       Flags;      \
526     UINT16                      Value;      \
527     UINT16                      State;      \
528     UINT16                      Reserved;   \
529     void                        *Next;      \
530 
531 typedef struct acpi_common_state
532 {
533     ACPI_STATE_COMMON
534 } ACPI_COMMON_STATE;
535 
536 
537 /*
538  * Update state - used to traverse complex objects such as packages
539  */
540 typedef struct acpi_update_state
541 {
542     ACPI_STATE_COMMON
543     union acpi_operand_object   *Object;
544 
545 } ACPI_UPDATE_STATE;
546 
547 
548 /*
549  * Pkg state - used to traverse nested package structures
550  */
551 typedef struct acpi_pkg_state
552 {
553     ACPI_STATE_COMMON
554     union acpi_operand_object   *SourceObject;
555     union acpi_operand_object   *DestObject;
556     struct acpi_walk_state      *WalkState;
557     void                        *ThisTargetObj;
558     UINT32                      NumPackages;
559     UINT16                      Index;
560 
561 } ACPI_PKG_STATE;
562 
563 
564 /*
565  * Control state - one per if/else and while constructs.
566  * Allows nesting of these constructs
567  */
568 typedef struct acpi_control_state
569 {
570     ACPI_STATE_COMMON
571     union acpi_parse_object     *PredicateOp;
572     UINT8                       *AmlPredicateStart;     /* Start of if/while predicate */
573     UINT8                       *PackageEnd;            /* End of if/while block */
574     UINT16                      Opcode;
575 
576 } ACPI_CONTROL_STATE;
577 
578 
579 /*
580  * Scope state - current scope during namespace lookups
581  */
582 typedef struct acpi_scope_state
583 {
584     ACPI_STATE_COMMON
585     ACPI_NAMESPACE_NODE         *Node;
586 
587 } ACPI_SCOPE_STATE;
588 
589 
590 typedef struct acpi_pscope_state
591 {
592     ACPI_STATE_COMMON
593     union acpi_parse_object     *Op;                    /* Current op being parsed */
594     UINT8                       *ArgEnd;                /* Current argument end */
595     UINT8                       *PkgEnd;                /* Current package end */
596     UINT32                      ArgList;                /* Next argument to parse */
597     UINT32                      ArgCount;               /* Number of fixed arguments */
598 
599 } ACPI_PSCOPE_STATE;
600 
601 
602 /*
603  * Thread state - one per thread across multiple walk states.  Multiple walk
604  * states are created when there are nested control methods executing.
605  */
606 typedef struct acpi_thread_state
607 {
608     ACPI_STATE_COMMON
609     struct acpi_walk_state      *WalkStateList;         /* Head of list of WalkStates for this thread */
610     union acpi_operand_object   *AcquiredMutexList;     /* List of all currently acquired mutexes */
611     UINT32                      ThreadId;               /* Running thread ID */
612     UINT8                       CurrentSyncLevel;       /* Mutex Sync (nested acquire) level */
613 
614 } ACPI_THREAD_STATE;
615 
616 
617 /*
618  * Result values - used to accumulate the results of nested
619  * AML arguments
620  */
621 typedef struct acpi_result_values
622 {
623     ACPI_STATE_COMMON
624     union acpi_operand_object   *ObjDesc [ACPI_OBJ_NUM_OPERANDS];
625     UINT8                       NumResults;
626     UINT8                       LastInsert;
627 
628 } ACPI_RESULT_VALUES;
629 
630 
631 typedef
632 ACPI_STATUS (*ACPI_PARSE_DOWNWARDS) (
633     struct acpi_walk_state      *WalkState,
634     union acpi_parse_object     **OutOp);
635 
636 typedef
637 ACPI_STATUS (*ACPI_PARSE_UPWARDS) (
638     struct acpi_walk_state      *WalkState);
639 
640 
641 /*
642  * Notify info - used to pass info to the deferred notify
643  * handler/dispatcher.
644  */
645 typedef struct acpi_notify_info
646 {
647     ACPI_STATE_COMMON
648     ACPI_NAMESPACE_NODE         *Node;
649     union acpi_operand_object   *HandlerObj;
650 
651 } ACPI_NOTIFY_INFO;
652 
653 
654 /* Generic state is union of structs above */
655 
656 typedef union acpi_generic_state
657 {
658     ACPI_COMMON_STATE           Common;
659     ACPI_CONTROL_STATE          Control;
660     ACPI_UPDATE_STATE           Update;
661     ACPI_SCOPE_STATE            Scope;
662     ACPI_PSCOPE_STATE           ParseScope;
663     ACPI_PKG_STATE              Pkg;
664     ACPI_THREAD_STATE           Thread;
665     ACPI_RESULT_VALUES          Results;
666     ACPI_NOTIFY_INFO            Notify;
667 
668 } ACPI_GENERIC_STATE;
669 
670 
671 /*****************************************************************************
672  *
673  * Interpreter typedefs and structs
674  *
675  ****************************************************************************/
676 
677 typedef
678 ACPI_STATUS (*ACPI_EXECUTE_OP) (
679     struct acpi_walk_state      *WalkState);
680 
681 
682 /*****************************************************************************
683  *
684  * Parser typedefs and structs
685  *
686  ****************************************************************************/
687 
688 /*
689  * AML opcode, name, and argument layout
690  */
691 typedef struct acpi_opcode_info
692 {
693 #if defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUG_OUTPUT)
694     char                        *Name;          /* Opcode name (disassembler/debug only) */
695 #endif
696     UINT32                      ParseArgs;      /* Grammar/Parse time arguments */
697     UINT32                      RuntimeArgs;    /* Interpret time arguments */
698     UINT32                      Flags;          /* Misc flags */
699     UINT8                       ObjectType;     /* Corresponding internal object type */
700     UINT8                       Class;          /* Opcode class */
701     UINT8                       Type;           /* Opcode type */
702 
703 } ACPI_OPCODE_INFO;
704 
705 typedef union acpi_parse_value
706 {
707     ACPI_INTEGER                Integer;        /* Integer constant (Up to 64 bits) */
708     UINT64_STRUCT               Integer64;      /* Structure overlay for 2 32-bit Dwords */
709     UINT32                      Size;           /* bytelist or field size */
710     char                        *String;        /* NULL terminated string */
711     UINT8                       *Buffer;        /* buffer or string */
712     char                        *Name;          /* NULL terminated string */
713     union acpi_parse_object     *Arg;           /* arguments and contained ops */
714 
715 } ACPI_PARSE_VALUE;
716 
717 #define ACPI_PARSE_COMMON \
718     UINT8                       DataType;       /* To differentiate various internal objs */\
719     UINT8                       Flags;          /* Type of Op */\
720     UINT16                      AmlOpcode;      /* AML opcode */\
721     UINT32                      AmlOffset;      /* Offset of declaration in AML */\
722     union acpi_parse_object     *Parent;        /* Parent op */\
723     union acpi_parse_object     *Next;          /* Next op */\
724     ACPI_DISASM_ONLY_MEMBERS (\
725     UINT8                       DisasmFlags;    /* Used during AML disassembly */\
726     UINT8                       DisasmOpcode;   /* Subtype used for disassembly */\
727     char                        AmlOpName[16])  /* Op name (debug only) */\
728                                                 /* NON-DEBUG members below: */\
729     ACPI_NAMESPACE_NODE         *Node;          /* For use by interpreter */\
730     ACPI_PARSE_VALUE            Value;          /* Value or args associated with the opcode */\
731 
732 
733 #define ACPI_DASM_BUFFER        0x00
734 #define ACPI_DASM_RESOURCE      0x01
735 #define ACPI_DASM_STRING        0x02
736 #define ACPI_DASM_UNICODE       0x03
737 #define ACPI_DASM_EISAID        0x04
738 #define ACPI_DASM_MATCHOP       0x05
739 
740 /*
741  * generic operation (for example:  If, While, Store)
742  */
743 typedef struct acpi_parse_obj_common
744 {
745     ACPI_PARSE_COMMON
746 } ACPI_PARSE_OBJ_COMMON;
747 
748 
749 /*
750  * Extended Op for named ops (Scope, Method, etc.), deferred ops (Methods and OpRegions),
751  * and bytelists.
752  */
753 typedef struct acpi_parse_obj_named
754 {
755     ACPI_PARSE_COMMON
756     UINT8                       *Path;
757     UINT8                       *Data;          /* AML body or bytelist data */
758     UINT32                      Length;         /* AML length */
759     UINT32                      Name;           /* 4-byte name or zero if no name */
760 
761 } ACPI_PARSE_OBJ_NAMED;
762 
763 
764 /* The parse node is the fundamental element of the parse tree */
765 
766 typedef struct acpi_parse_obj_asl
767 {
768     ACPI_PARSE_COMMON
769     union acpi_parse_object     *Child;
770     union acpi_parse_object     *ParentMethod;
771     char                        *Filename;
772     char                        *ExternalName;
773     char                        *Namepath;
774     char                        NameSeg[4];
775     UINT32                      ExtraValue;
776     UINT32                      Column;
777     UINT32                      LineNumber;
778     UINT32                      LogicalLineNumber;
779     UINT32                      LogicalByteOffset;
780     UINT32                      EndLine;
781     UINT32                      EndLogicalLine;
782     UINT32                      AcpiBtype;
783     UINT32                      AmlLength;
784     UINT32                      AmlSubtreeLength;
785     UINT32                      FinalAmlLength;
786     UINT32                      FinalAmlOffset;
787     UINT32                      CompileFlags;
788     UINT16                      ParseOpcode;
789     UINT8                       AmlOpcodeLength;
790     UINT8                       AmlPkgLenBytes;
791     UINT8                       Extra;
792     char                        ParseOpName[12];
793 
794 } ACPI_PARSE_OBJ_ASL;
795 
796 typedef union acpi_parse_object
797 {
798     ACPI_PARSE_OBJ_COMMON       Common;
799     ACPI_PARSE_OBJ_NAMED        Named;
800     ACPI_PARSE_OBJ_ASL          Asl;
801 
802 } ACPI_PARSE_OBJECT;
803 
804 
805 /*
806  * Parse state - one state per parser invocation and each control
807  * method.
808  */
809 typedef struct acpi_parse_state
810 {
811     UINT32                      AmlSize;
812     UINT8                       *AmlStart;      /* First AML byte */
813     UINT8                       *Aml;           /* Next AML byte */
814     UINT8                       *AmlEnd;        /* (last + 1) AML byte */
815     UINT8                       *PkgStart;      /* Current package begin */
816     UINT8                       *PkgEnd;        /* Current package end */
817     union acpi_parse_object     *StartOp;       /* Root of parse tree */
818     struct acpi_namespace_node  *StartNode;
819     union acpi_generic_state    *Scope;         /* Current scope */
820     union acpi_parse_object     *StartScope;
821 
822 } ACPI_PARSE_STATE;
823 
824 
825 /* Parse object flags */
826 
827 #define ACPI_PARSEOP_GENERIC                    0x01
828 #define ACPI_PARSEOP_NAMED                      0x02
829 #define ACPI_PARSEOP_DEFERRED                   0x04
830 #define ACPI_PARSEOP_BYTELIST                   0x08
831 #define ACPI_PARSEOP_IN_CACHE                   0x80
832 
833 /* Parse object DisasmFlags */
834 
835 #define ACPI_PARSEOP_IGNORE                     0x01
836 #define ACPI_PARSEOP_PARAMLIST                  0x02
837 #define ACPI_PARSEOP_EMPTY_TERMLIST             0x04
838 #define ACPI_PARSEOP_SPECIAL                    0x10
839 
840 
841 /*****************************************************************************
842  *
843  * Hardware (ACPI registers) and PNP
844  *
845  ****************************************************************************/
846 
847 #define PCI_ROOT_HID_STRING         "PNP0A03"
848 
849 typedef struct acpi_bit_register_info
850 {
851     UINT8                       ParentRegister;
852     UINT8                       BitPosition;
853     UINT16                      AccessBitMask;
854 
855 } ACPI_BIT_REGISTER_INFO;
856 
857 
858 /*
859  * Register IDs
860  * These are the full ACPI registers
861  */
862 #define ACPI_REGISTER_PM1_STATUS                0x01
863 #define ACPI_REGISTER_PM1_ENABLE                0x02
864 #define ACPI_REGISTER_PM1_CONTROL               0x03
865 #define ACPI_REGISTER_PM1A_CONTROL              0x04
866 #define ACPI_REGISTER_PM1B_CONTROL              0x05
867 #define ACPI_REGISTER_PM2_CONTROL               0x06
868 #define ACPI_REGISTER_PM_TIMER                  0x07
869 #define ACPI_REGISTER_PROCESSOR_BLOCK           0x08
870 #define ACPI_REGISTER_SMI_COMMAND_BLOCK         0x09
871 
872 
873 /* Masks used to access the BitRegisters */
874 
875 #define ACPI_BITMASK_TIMER_STATUS               0x0001
876 #define ACPI_BITMASK_BUS_MASTER_STATUS          0x0010
877 #define ACPI_BITMASK_GLOBAL_LOCK_STATUS         0x0020
878 #define ACPI_BITMASK_POWER_BUTTON_STATUS        0x0100
879 #define ACPI_BITMASK_SLEEP_BUTTON_STATUS        0x0200
880 #define ACPI_BITMASK_RT_CLOCK_STATUS            0x0400
881 #define ACPI_BITMASK_PCIEXP_WAKE_STATUS         0x4000    /* ACPI 3.0 */
882 #define ACPI_BITMASK_WAKE_STATUS                0x8000
883 
884 #define ACPI_BITMASK_ALL_FIXED_STATUS           (ACPI_BITMASK_TIMER_STATUS          | \
885                                                  ACPI_BITMASK_BUS_MASTER_STATUS     | \
886                                                  ACPI_BITMASK_GLOBAL_LOCK_STATUS    | \
887                                                  ACPI_BITMASK_POWER_BUTTON_STATUS   | \
888                                                  ACPI_BITMASK_SLEEP_BUTTON_STATUS   | \
889                                                  ACPI_BITMASK_RT_CLOCK_STATUS       | \
890                                                  ACPI_BITMASK_WAKE_STATUS)
891 
892 #define ACPI_BITMASK_TIMER_ENABLE               0x0001
893 #define ACPI_BITMASK_GLOBAL_LOCK_ENABLE         0x0020
894 #define ACPI_BITMASK_POWER_BUTTON_ENABLE        0x0100
895 #define ACPI_BITMASK_SLEEP_BUTTON_ENABLE        0x0200
896 #define ACPI_BITMASK_RT_CLOCK_ENABLE            0x0400
897 #define ACPI_BITMASK_PCIEXP_WAKE_DISABLE        0x4000    /* ACPI 3.0 */
898 
899 #define ACPI_BITMASK_SCI_ENABLE                 0x0001
900 #define ACPI_BITMASK_BUS_MASTER_RLD             0x0002
901 #define ACPI_BITMASK_GLOBAL_LOCK_RELEASE        0x0004
902 #define ACPI_BITMASK_SLEEP_TYPE_X               0x1C00
903 #define ACPI_BITMASK_SLEEP_ENABLE               0x2000
904 
905 #define ACPI_BITMASK_ARB_DISABLE                0x0001
906 
907 
908 /* Raw bit position of each BitRegister */
909 
910 #define ACPI_BITPOSITION_TIMER_STATUS           0x00
911 #define ACPI_BITPOSITION_BUS_MASTER_STATUS      0x04
912 #define ACPI_BITPOSITION_GLOBAL_LOCK_STATUS     0x05
913 #define ACPI_BITPOSITION_POWER_BUTTON_STATUS    0x08
914 #define ACPI_BITPOSITION_SLEEP_BUTTON_STATUS    0x09
915 #define ACPI_BITPOSITION_RT_CLOCK_STATUS        0x0A
916 #define ACPI_BITPOSITION_PCIEXP_WAKE_STATUS     0x0E    /* ACPI 3.0 */
917 #define ACPI_BITPOSITION_WAKE_STATUS            0x0F
918 
919 #define ACPI_BITPOSITION_TIMER_ENABLE           0x00
920 #define ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE     0x05
921 #define ACPI_BITPOSITION_POWER_BUTTON_ENABLE    0x08
922 #define ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE    0x09
923 #define ACPI_BITPOSITION_RT_CLOCK_ENABLE        0x0A
924 #define ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE    0x0E    /* ACPI 3.0 */
925 
926 #define ACPI_BITPOSITION_SCI_ENABLE             0x00
927 #define ACPI_BITPOSITION_BUS_MASTER_RLD         0x01
928 #define ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE    0x02
929 #define ACPI_BITPOSITION_SLEEP_TYPE_X           0x0A
930 #define ACPI_BITPOSITION_SLEEP_ENABLE           0x0D
931 
932 #define ACPI_BITPOSITION_ARB_DISABLE            0x00
933 
934 
935 /*****************************************************************************
936  *
937  * Resource descriptors
938  *
939  ****************************************************************************/
940 
941 /* ResourceType values */
942 
943 #define ACPI_RESOURCE_TYPE_MEMORY_RANGE         0
944 #define ACPI_RESOURCE_TYPE_IO_RANGE             1
945 #define ACPI_RESOURCE_TYPE_BUS_NUMBER_RANGE     2
946 
947 /* Resource descriptor types and masks */
948 
949 #define ACPI_RDESC_TYPE_LARGE                   0x80
950 #define ACPI_RDESC_TYPE_SMALL                   0x00
951 
952 #define ACPI_RDESC_TYPE_MASK                    0x80
953 #define ACPI_RDESC_SMALL_MASK                   0x78 /* Only bits 6:3 contain the type */
954 
955 
956 /*
957  * Small resource descriptor types
958  * Note: The 3 length bits (2:0) must be zero
959  */
960 #define ACPI_RDESC_TYPE_IRQ_FORMAT              0x20
961 #define ACPI_RDESC_TYPE_DMA_FORMAT              0x28
962 #define ACPI_RDESC_TYPE_START_DEPENDENT         0x30
963 #define ACPI_RDESC_TYPE_END_DEPENDENT           0x38
964 #define ACPI_RDESC_TYPE_IO_PORT                 0x40
965 #define ACPI_RDESC_TYPE_FIXED_IO_PORT           0x48
966 #define ACPI_RDESC_TYPE_SMALL_VENDOR            0x70
967 #define ACPI_RDESC_TYPE_END_TAG                 0x78
968 
969 /*
970  * Large resource descriptor types
971  */
972 #define ACPI_RDESC_TYPE_MEMORY_24               0x81
973 #define ACPI_RDESC_TYPE_GENERAL_REGISTER        0x82
974 #define ACPI_RDESC_TYPE_LARGE_VENDOR            0x84
975 #define ACPI_RDESC_TYPE_MEMORY_32               0x85
976 #define ACPI_RDESC_TYPE_FIXED_MEMORY_32         0x86
977 #define ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE     0x87
978 #define ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE      0x88
979 #define ACPI_RDESC_TYPE_EXTENDED_XRUPT          0x89
980 #define ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE     0x8A
981 #define ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE  0x8B
982 
983 
984 /*****************************************************************************
985  *
986  * Miscellaneous
987  *
988  ****************************************************************************/
989 
990 #define ACPI_ASCII_ZERO                      0x30
991 
992 
993 /*****************************************************************************
994  *
995  * Debugger
996  *
997  ****************************************************************************/
998 
999 typedef struct acpi_db_method_info
1000 {
1001     ACPI_HANDLE             ThreadGate;
1002     char                    *Name;
1003     char                    **Args;
1004     UINT32                  Flags;
1005     UINT32                  NumLoops;
1006     char                    Pathname[128];
1007 
1008 } ACPI_DB_METHOD_INFO;
1009 
1010 typedef struct acpi_integrity_info
1011 {
1012     UINT32              Nodes;
1013     UINT32              Objects;
1014 
1015 } ACPI_INTEGRITY_INFO;
1016 
1017 
1018 #define ACPI_DB_REDIRECTABLE_OUTPUT  0x01
1019 #define ACPI_DB_CONSOLE_OUTPUT       0x02
1020 #define ACPI_DB_DUPLICATE_OUTPUT     0x03
1021 
1022 
1023 /*****************************************************************************
1024  *
1025  * Debug
1026  *
1027  ****************************************************************************/
1028 
1029 typedef struct acpi_debug_print_info
1030 {
1031     UINT32                  ComponentId;
1032     char                    *ProcName;
1033     char                    *ModuleName;
1034 
1035 } ACPI_DEBUG_PRINT_INFO;
1036 
1037 
1038 /* Entry for a memory allocation (debug only) */
1039 
1040 #define ACPI_MEM_MALLOC                      0
1041 #define ACPI_MEM_CALLOC                      1
1042 #define ACPI_MAX_MODULE_NAME                 16
1043 
1044 #define ACPI_COMMON_DEBUG_MEM_HEADER \
1045     struct acpi_debug_mem_block *Previous; \
1046     struct acpi_debug_mem_block *Next; \
1047     UINT32                      Size; \
1048     UINT32                      Component; \
1049     UINT32                      Line; \
1050     char                        Module[ACPI_MAX_MODULE_NAME]; \
1051     UINT8                       AllocType;
1052 
1053 typedef struct acpi_debug_mem_header
1054 {
1055     ACPI_COMMON_DEBUG_MEM_HEADER
1056 
1057 } ACPI_DEBUG_MEM_HEADER;
1058 
1059 typedef struct acpi_debug_mem_block
1060 {
1061     ACPI_COMMON_DEBUG_MEM_HEADER
1062     UINT64                      UserSpace;
1063 
1064 } ACPI_DEBUG_MEM_BLOCK;
1065 
1066 
1067 #define ACPI_MEM_LIST_GLOBAL            0
1068 #define ACPI_MEM_LIST_NSNODE            1
1069 
1070 #define ACPI_MEM_LIST_FIRST_CACHE_LIST  2
1071 #define ACPI_MEM_LIST_STATE             2
1072 #define ACPI_MEM_LIST_PSNODE            3
1073 #define ACPI_MEM_LIST_PSNODE_EXT        4
1074 #define ACPI_MEM_LIST_OPERAND           5
1075 #define ACPI_MEM_LIST_WALK              6
1076 #define ACPI_MEM_LIST_MAX               6
1077 #define ACPI_NUM_MEM_LISTS              7
1078 
1079 
1080 typedef struct acpi_memory_list
1081 {
1082     void                        *ListHead;
1083     UINT16                      LinkOffset;
1084     UINT16                      MaxCacheDepth;
1085     UINT16                      CacheDepth;
1086     UINT16                      ObjectSize;
1087 
1088 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
1089 
1090     /* Statistics for debug memory tracking only */
1091 
1092     UINT32                      TotalAllocated;
1093     UINT32                      TotalFreed;
1094     UINT32                      CurrentTotalSize;
1095     UINT32                      CacheRequests;
1096     UINT32                      CacheHits;
1097     char                        *ListName;
1098 #endif
1099 
1100 } ACPI_MEMORY_LIST;
1101 
1102 
1103 #endif /* __ACLOCAL_H__ */
1104