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