xref: /titanic_44/usr/src/uts/intel/sys/acpi/aclocal.h (revision f2f278521a1d65f81d30778b7bd252147b2d325f)
1 /******************************************************************************
2  *
3  * Name: aclocal.h - Internal data types used across the ACPI subsystem
4  *       $Revision: 1.220 $
5  *
6  *****************************************************************************/
7 
8 /******************************************************************************
9  *
10  * 1. Copyright Notice
11  *
12  * Some or all of this work - Copyright (c) 1999 - 2006, 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  * Bitmapped ACPI types.  Used internally only
397  */
398 #define ACPI_BTYPE_ANY                  0x00000000
399 #define ACPI_BTYPE_INTEGER              0x00000001
400 #define ACPI_BTYPE_STRING               0x00000002
401 #define ACPI_BTYPE_BUFFER               0x00000004
402 #define ACPI_BTYPE_PACKAGE              0x00000008
403 #define ACPI_BTYPE_FIELD_UNIT           0x00000010
404 #define ACPI_BTYPE_DEVICE               0x00000020
405 #define ACPI_BTYPE_EVENT                0x00000040
406 #define ACPI_BTYPE_METHOD               0x00000080
407 #define ACPI_BTYPE_MUTEX                0x00000100
408 #define ACPI_BTYPE_REGION               0x00000200
409 #define ACPI_BTYPE_POWER                0x00000400
410 #define ACPI_BTYPE_PROCESSOR            0x00000800
411 #define ACPI_BTYPE_THERMAL              0x00001000
412 #define ACPI_BTYPE_BUFFER_FIELD         0x00002000
413 #define ACPI_BTYPE_DDB_HANDLE           0x00004000
414 #define ACPI_BTYPE_DEBUG_OBJECT         0x00008000
415 #define ACPI_BTYPE_REFERENCE            0x00010000
416 #define ACPI_BTYPE_RESOURCE             0x00020000
417 
418 #define ACPI_BTYPE_COMPUTE_DATA         (ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER)
419 
420 #define ACPI_BTYPE_DATA                 (ACPI_BTYPE_COMPUTE_DATA  | ACPI_BTYPE_PACKAGE)
421 #define ACPI_BTYPE_DATA_REFERENCE       (ACPI_BTYPE_DATA | ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE)
422 #define ACPI_BTYPE_DEVICE_OBJECTS       (ACPI_BTYPE_DEVICE | ACPI_BTYPE_THERMAL | ACPI_BTYPE_PROCESSOR)
423 #define ACPI_BTYPE_OBJECTS_AND_REFS     0x0001FFFF  /* ARG or LOCAL */
424 #define ACPI_BTYPE_ALL_OBJECTS          0x0000FFFF
425 
426 
427 /*****************************************************************************
428  *
429  * Event typedefs and structs
430  *
431  ****************************************************************************/
432 
433 /* Dispatch info for each GPE -- either a method or handler, cannot be both */
434 
435 typedef struct acpi_handler_info
436 {
437     ACPI_EVENT_HANDLER              Address;        /* Address of handler, if any */
438     void                            *Context;       /* Context to be passed to handler */
439     ACPI_NAMESPACE_NODE             *MethodNode;    /* Method node for this GPE level (saved) */
440 
441 } ACPI_HANDLER_INFO;
442 
443 typedef union acpi_gpe_dispatch_info
444 {
445     ACPI_NAMESPACE_NODE             *MethodNode;    /* Method node for this GPE level */
446     struct acpi_handler_info        *Handler;
447 
448 } ACPI_GPE_DISPATCH_INFO;
449 
450 /*
451  * Information about a GPE, one per each GPE in an array.
452  * NOTE: Important to keep this struct as small as possible.
453  */
454 typedef struct acpi_gpe_event_info
455 {
456     union acpi_gpe_dispatch_info    Dispatch;       /* Either Method or Handler */
457     struct acpi_gpe_register_info   *RegisterInfo;  /* Backpointer to register info */
458     UINT8                           Flags;          /* Misc info about this GPE */
459     UINT8                           RegisterBit;    /* This GPE bit within the register */
460 
461 } ACPI_GPE_EVENT_INFO;
462 
463 /* Information about a GPE register pair, one per each status/enable pair in an array */
464 
465 typedef struct acpi_gpe_register_info
466 {
467     ACPI_GENERIC_ADDRESS            StatusAddress;  /* Address of status reg */
468     ACPI_GENERIC_ADDRESS            EnableAddress;  /* Address of enable reg */
469     UINT8                           EnableForWake;  /* GPEs to keep enabled when sleeping */
470     UINT8                           EnableForRun;   /* GPEs to keep enabled when running */
471     UINT8                           BaseGpeNumber;  /* Base GPE number for this register */
472 
473 } ACPI_GPE_REGISTER_INFO;
474 
475 /*
476  * Information about a GPE register block, one per each installed block --
477  * GPE0, GPE1, and one per each installed GPE Block Device.
478  */
479 typedef struct acpi_gpe_block_info
480 {
481     ACPI_NAMESPACE_NODE             *Node;
482     struct acpi_gpe_block_info      *Previous;
483     struct acpi_gpe_block_info      *Next;
484     struct acpi_gpe_xrupt_info      *XruptBlock;    /* Backpointer to interrupt block */
485     ACPI_GPE_REGISTER_INFO          *RegisterInfo;  /* One per GPE register pair */
486     ACPI_GPE_EVENT_INFO             *EventInfo;     /* One for each GPE */
487     ACPI_GENERIC_ADDRESS            BlockAddress;   /* Base address of the block */
488     UINT32                          RegisterCount;  /* Number of register pairs in block */
489     UINT8                           BlockBaseNumber;/* Base GPE number for this block */
490 
491 } ACPI_GPE_BLOCK_INFO;
492 
493 /* Information about GPE interrupt handlers, one per each interrupt level used for GPEs */
494 
495 typedef struct acpi_gpe_xrupt_info
496 {
497     struct acpi_gpe_xrupt_info      *Previous;
498     struct acpi_gpe_xrupt_info      *Next;
499     ACPI_GPE_BLOCK_INFO             *GpeBlockListHead;  /* List of GPE blocks for this xrupt */
500     UINT32                          InterruptNumber;    /* System interrupt number */
501 
502 } ACPI_GPE_XRUPT_INFO;
503 
504 
505 typedef struct acpi_gpe_walk_info
506 {
507     ACPI_NAMESPACE_NODE             *GpeDevice;
508     ACPI_GPE_BLOCK_INFO             *GpeBlock;
509 
510 } ACPI_GPE_WALK_INFO;
511 
512 
513 typedef ACPI_STATUS (*ACPI_GPE_CALLBACK) (
514     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
515     ACPI_GPE_BLOCK_INFO     *GpeBlock);
516 
517 
518 /* Information about each particular fixed event */
519 
520 typedef struct acpi_fixed_event_handler
521 {
522     ACPI_EVENT_HANDLER      Handler;        /* Address of handler. */
523     void                    *Context;       /* Context to be passed to handler */
524 
525 } ACPI_FIXED_EVENT_HANDLER;
526 
527 typedef struct acpi_fixed_event_info
528 {
529     UINT8                   StatusRegisterId;
530     UINT8                   EnableRegisterId;
531     UINT16                  StatusBitMask;
532     UINT16                  EnableBitMask;
533 
534 } ACPI_FIXED_EVENT_INFO;
535 
536 /* Information used during field processing */
537 
538 typedef struct acpi_field_info
539 {
540     UINT8                   SkipField;
541     UINT8                   FieldFlag;
542     UINT32                  PkgLength;
543 
544 } ACPI_FIELD_INFO;
545 
546 
547 /*****************************************************************************
548  *
549  * Generic "state" object for stacks
550  *
551  ****************************************************************************/
552 
553 #define ACPI_CONTROL_NORMAL                  0xC0
554 #define ACPI_CONTROL_CONDITIONAL_EXECUTING   0xC1
555 #define ACPI_CONTROL_PREDICATE_EXECUTING     0xC2
556 #define ACPI_CONTROL_PREDICATE_FALSE         0xC3
557 #define ACPI_CONTROL_PREDICATE_TRUE          0xC4
558 
559 
560 #define ACPI_STATE_COMMON   /* Two 32-bit fields and a pointer */\
561     UINT8                       DataType;   /* To differentiate various internal objs */\
562     UINT8                       Flags;      \
563     UINT16                      Value;      \
564     UINT16                      State;      \
565     UINT16                      Reserved;   \
566     void                        *Next;
567 
568 typedef struct acpi_common_state
569 {
570     ACPI_STATE_COMMON
571 } ACPI_COMMON_STATE;
572 
573 
574 /*
575  * Update state - used to traverse complex objects such as packages
576  */
577 typedef struct acpi_update_state
578 {
579     ACPI_STATE_COMMON
580     union acpi_operand_object   *Object;
581 
582 } ACPI_UPDATE_STATE;
583 
584 
585 /*
586  * Pkg state - used to traverse nested package structures
587  */
588 typedef struct acpi_pkg_state
589 {
590     ACPI_STATE_COMMON
591     union acpi_operand_object   *SourceObject;
592     union acpi_operand_object   *DestObject;
593     struct acpi_walk_state      *WalkState;
594     void                        *ThisTargetObj;
595     UINT32                      NumPackages;
596     UINT16                      Index;
597 
598 } ACPI_PKG_STATE;
599 
600 
601 /*
602  * Control state - one per if/else and while constructs.
603  * Allows nesting of these constructs
604  */
605 typedef struct acpi_control_state
606 {
607     ACPI_STATE_COMMON
608     union acpi_parse_object     *PredicateOp;
609     UINT8                       *AmlPredicateStart;     /* Start of if/while predicate */
610     UINT8                       *PackageEnd;            /* End of if/while block */
611     UINT16                      Opcode;
612 
613 } ACPI_CONTROL_STATE;
614 
615 
616 /*
617  * Scope state - current scope during namespace lookups
618  */
619 typedef struct acpi_scope_state
620 {
621     ACPI_STATE_COMMON
622     ACPI_NAMESPACE_NODE         *Node;
623 
624 } ACPI_SCOPE_STATE;
625 
626 
627 typedef struct acpi_pscope_state
628 {
629     ACPI_STATE_COMMON
630     union acpi_parse_object     *Op;                    /* Current op being parsed */
631     UINT8                       *ArgEnd;                /* Current argument end */
632     UINT8                       *PkgEnd;                /* Current package end */
633     UINT32                      ArgList;                /* Next argument to parse */
634     UINT32                      ArgCount;               /* Number of fixed arguments */
635 
636 } ACPI_PSCOPE_STATE;
637 
638 
639 /*
640  * Thread state - one per thread across multiple walk states.  Multiple walk
641  * states are created when there are nested control methods executing.
642  */
643 typedef struct acpi_thread_state
644 {
645     ACPI_STATE_COMMON
646     struct acpi_walk_state      *WalkStateList;         /* Head of list of WalkStates for this thread */
647     union acpi_operand_object   *AcquiredMutexList;     /* List of all currently acquired mutexes */
648     UINT32                      ThreadId;               /* Running thread ID */
649     UINT8                       CurrentSyncLevel;       /* Mutex Sync (nested acquire) level */
650 
651 } ACPI_THREAD_STATE;
652 
653 
654 /*
655  * Result values - used to accumulate the results of nested
656  * AML arguments
657  */
658 typedef struct acpi_result_values
659 {
660     ACPI_STATE_COMMON
661     union acpi_operand_object   *ObjDesc [ACPI_OBJ_NUM_OPERANDS];
662     UINT8                       NumResults;
663     UINT8                       LastInsert;
664 
665 } ACPI_RESULT_VALUES;
666 
667 
668 typedef
669 ACPI_STATUS (*ACPI_PARSE_DOWNWARDS) (
670     struct acpi_walk_state      *WalkState,
671     union acpi_parse_object     **OutOp);
672 
673 typedef
674 ACPI_STATUS (*ACPI_PARSE_UPWARDS) (
675     struct acpi_walk_state      *WalkState);
676 
677 
678 /*
679  * Notify info - used to pass info to the deferred notify
680  * handler/dispatcher.
681  */
682 typedef struct acpi_notify_info
683 {
684     ACPI_STATE_COMMON
685     ACPI_NAMESPACE_NODE         *Node;
686     union acpi_operand_object   *HandlerObj;
687 
688 } ACPI_NOTIFY_INFO;
689 
690 
691 /* Generic state is union of structs above */
692 
693 typedef union acpi_generic_state
694 {
695     ACPI_COMMON_STATE           Common;
696     ACPI_CONTROL_STATE          Control;
697     ACPI_UPDATE_STATE           Update;
698     ACPI_SCOPE_STATE            Scope;
699     ACPI_PSCOPE_STATE           ParseScope;
700     ACPI_PKG_STATE              Pkg;
701     ACPI_THREAD_STATE           Thread;
702     ACPI_RESULT_VALUES          Results;
703     ACPI_NOTIFY_INFO            Notify;
704 
705 } ACPI_GENERIC_STATE;
706 
707 
708 /*****************************************************************************
709  *
710  * Interpreter typedefs and structs
711  *
712  ****************************************************************************/
713 
714 typedef
715 ACPI_STATUS (*ACPI_EXECUTE_OP) (
716     struct acpi_walk_state      *WalkState);
717 
718 
719 /*****************************************************************************
720  *
721  * Parser typedefs and structs
722  *
723  ****************************************************************************/
724 
725 /*
726  * AML opcode, name, and argument layout
727  */
728 typedef struct acpi_opcode_info
729 {
730 #if defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUG_OUTPUT)
731     char                        *Name;          /* Opcode name (disassembler/debug only) */
732 #endif
733     UINT32                      ParseArgs;      /* Grammar/Parse time arguments */
734     UINT32                      RuntimeArgs;    /* Interpret time arguments */
735     UINT32                      Flags;          /* Misc flags */
736     UINT8                       ObjectType;     /* Corresponding internal object type */
737     UINT8                       Class;          /* Opcode class */
738     UINT8                       Type;           /* Opcode type */
739 
740 } ACPI_OPCODE_INFO;
741 
742 typedef union acpi_parse_value
743 {
744     ACPI_INTEGER                Integer;        /* Integer constant (Up to 64 bits) */
745     UINT64_STRUCT               Integer64;      /* Structure overlay for 2 32-bit Dwords */
746     UINT32                      Size;           /* bytelist or field size */
747     char                        *String;        /* NULL terminated string */
748     UINT8                       *Buffer;        /* buffer or string */
749     char                        *Name;          /* NULL terminated string */
750     union acpi_parse_object     *Arg;           /* arguments and contained ops */
751 
752 } ACPI_PARSE_VALUE;
753 
754 #define ACPI_PARSE_COMMON \
755     UINT8                       DataType;       /* To differentiate various internal objs */\
756     UINT8                       Flags;          /* Type of Op */\
757     UINT16                      AmlOpcode;      /* AML opcode */\
758     UINT32                      AmlOffset;      /* Offset of declaration in AML */\
759     union acpi_parse_object     *Parent;        /* Parent op */\
760     union acpi_parse_object     *Next;          /* Next op */\
761     ACPI_DISASM_ONLY_MEMBERS (\
762     UINT8                       DisasmFlags;    /* Used during AML disassembly */\
763     UINT8                       DisasmOpcode;   /* Subtype used for disassembly */\
764     char                        AmlOpName[16])  /* Op name (debug only) */\
765                                                 /* NON-DEBUG members below: */\
766     ACPI_NAMESPACE_NODE         *Node;          /* For use by interpreter */\
767     ACPI_PARSE_VALUE            Value;          /* Value or args associated with the opcode */
768 
769 
770 #define ACPI_DASM_BUFFER        0x00
771 #define ACPI_DASM_RESOURCE      0x01
772 #define ACPI_DASM_STRING        0x02
773 #define ACPI_DASM_UNICODE       0x03
774 #define ACPI_DASM_EISAID        0x04
775 #define ACPI_DASM_MATCHOP       0x05
776 
777 /*
778  * generic operation (for example:  If, While, Store)
779  */
780 typedef struct acpi_parse_obj_common
781 {
782     ACPI_PARSE_COMMON
783 } ACPI_PARSE_OBJ_COMMON;
784 
785 
786 /*
787  * Extended Op for named ops (Scope, Method, etc.), deferred ops (Methods and OpRegions),
788  * and bytelists.
789  */
790 typedef struct acpi_parse_obj_named
791 {
792     ACPI_PARSE_COMMON
793     UINT8                       *Path;
794     UINT8                       *Data;          /* AML body or bytelist data */
795     UINT32                      Length;         /* AML length */
796     UINT32                      Name;           /* 4-byte name or zero if no name */
797 
798 } ACPI_PARSE_OBJ_NAMED;
799 
800 
801 /* The parse node is the fundamental element of the parse tree */
802 
803 #define ACPI_MAX_PARSEOP_NAME   20
804 
805 typedef struct acpi_parse_obj_asl
806 {
807     ACPI_PARSE_COMMON
808     union acpi_parse_object     *Child;
809     union acpi_parse_object     *ParentMethod;
810     char                        *Filename;
811     char                        *ExternalName;
812     char                        *Namepath;
813     char                        NameSeg[4];
814     UINT32                      ExtraValue;
815     UINT32                      Column;
816     UINT32                      LineNumber;
817     UINT32                      LogicalLineNumber;
818     UINT32                      LogicalByteOffset;
819     UINT32                      EndLine;
820     UINT32                      EndLogicalLine;
821     UINT32                      AcpiBtype;
822     UINT32                      AmlLength;
823     UINT32                      AmlSubtreeLength;
824     UINT32                      FinalAmlLength;
825     UINT32                      FinalAmlOffset;
826     UINT32                      CompileFlags;
827     UINT16                      ParseOpcode;
828     UINT8                       AmlOpcodeLength;
829     UINT8                       AmlPkgLenBytes;
830     UINT8                       Extra;
831     char                        ParseOpName[ACPI_MAX_PARSEOP_NAME];
832 
833 } ACPI_PARSE_OBJ_ASL;
834 
835 typedef union acpi_parse_object
836 {
837     ACPI_PARSE_OBJ_COMMON       Common;
838     ACPI_PARSE_OBJ_NAMED        Named;
839     ACPI_PARSE_OBJ_ASL          Asl;
840 
841 } ACPI_PARSE_OBJECT;
842 
843 
844 /*
845  * Parse state - one state per parser invocation and each control
846  * method.
847  */
848 typedef struct acpi_parse_state
849 {
850     UINT32                      AmlSize;
851     UINT8                       *AmlStart;      /* First AML byte */
852     UINT8                       *Aml;           /* Next AML byte */
853     UINT8                       *AmlEnd;        /* (last + 1) AML byte */
854     UINT8                       *PkgStart;      /* Current package begin */
855     UINT8                       *PkgEnd;        /* Current package end */
856     union acpi_parse_object     *StartOp;       /* Root of parse tree */
857     struct acpi_namespace_node  *StartNode;
858     union acpi_generic_state    *Scope;         /* Current scope */
859     union acpi_parse_object     *StartScope;
860 
861 } ACPI_PARSE_STATE;
862 
863 
864 /* Parse object flags */
865 
866 #define ACPI_PARSEOP_GENERIC                    0x01
867 #define ACPI_PARSEOP_NAMED                      0x02
868 #define ACPI_PARSEOP_DEFERRED                   0x04
869 #define ACPI_PARSEOP_BYTELIST                   0x08
870 #define ACPI_PARSEOP_IN_CACHE                   0x80
871 
872 /* Parse object DisasmFlags */
873 
874 #define ACPI_PARSEOP_IGNORE                     0x01
875 #define ACPI_PARSEOP_PARAMLIST                  0x02
876 #define ACPI_PARSEOP_EMPTY_TERMLIST             0x04
877 #define ACPI_PARSEOP_SPECIAL                    0x10
878 
879 
880 /*****************************************************************************
881  *
882  * Hardware (ACPI registers) and PNP
883  *
884  ****************************************************************************/
885 
886 #define PCI_ROOT_HID_STRING         "PNP0A03"
887 #define PCI_EXPRESS_ROOT_HID_STRING "PNP0A08"
888 
889 typedef struct acpi_bit_register_info
890 {
891     UINT8                       ParentRegister;
892     UINT8                       BitPosition;
893     UINT16                      AccessBitMask;
894 
895 } ACPI_BIT_REGISTER_INFO;
896 
897 
898 /*
899  * Register IDs
900  * These are the full ACPI registers
901  */
902 #define ACPI_REGISTER_PM1_STATUS                0x01
903 #define ACPI_REGISTER_PM1_ENABLE                0x02
904 #define ACPI_REGISTER_PM1_CONTROL               0x03
905 #define ACPI_REGISTER_PM1A_CONTROL              0x04
906 #define ACPI_REGISTER_PM1B_CONTROL              0x05
907 #define ACPI_REGISTER_PM2_CONTROL               0x06
908 #define ACPI_REGISTER_PM_TIMER                  0x07
909 #define ACPI_REGISTER_PROCESSOR_BLOCK           0x08
910 #define ACPI_REGISTER_SMI_COMMAND_BLOCK         0x09
911 
912 
913 /* Masks used to access the BitRegisters */
914 
915 #define ACPI_BITMASK_TIMER_STATUS               0x0001
916 #define ACPI_BITMASK_BUS_MASTER_STATUS          0x0010
917 #define ACPI_BITMASK_GLOBAL_LOCK_STATUS         0x0020
918 #define ACPI_BITMASK_POWER_BUTTON_STATUS        0x0100
919 #define ACPI_BITMASK_SLEEP_BUTTON_STATUS        0x0200
920 #define ACPI_BITMASK_RT_CLOCK_STATUS            0x0400
921 #define ACPI_BITMASK_PCIEXP_WAKE_STATUS         0x4000    /* ACPI 3.0 */
922 #define ACPI_BITMASK_WAKE_STATUS                0x8000
923 
924 #define ACPI_BITMASK_ALL_FIXED_STATUS           (ACPI_BITMASK_TIMER_STATUS          | \
925                                                  ACPI_BITMASK_BUS_MASTER_STATUS     | \
926                                                  ACPI_BITMASK_GLOBAL_LOCK_STATUS    | \
927                                                  ACPI_BITMASK_POWER_BUTTON_STATUS   | \
928                                                  ACPI_BITMASK_SLEEP_BUTTON_STATUS   | \
929                                                  ACPI_BITMASK_RT_CLOCK_STATUS       | \
930                                                  ACPI_BITMASK_WAKE_STATUS)
931 
932 #define ACPI_BITMASK_TIMER_ENABLE               0x0001
933 #define ACPI_BITMASK_GLOBAL_LOCK_ENABLE         0x0020
934 #define ACPI_BITMASK_POWER_BUTTON_ENABLE        0x0100
935 #define ACPI_BITMASK_SLEEP_BUTTON_ENABLE        0x0200
936 #define ACPI_BITMASK_RT_CLOCK_ENABLE            0x0400
937 #define ACPI_BITMASK_PCIEXP_WAKE_DISABLE        0x4000    /* ACPI 3.0 */
938 
939 #define ACPI_BITMASK_SCI_ENABLE                 0x0001
940 #define ACPI_BITMASK_BUS_MASTER_RLD             0x0002
941 #define ACPI_BITMASK_GLOBAL_LOCK_RELEASE        0x0004
942 #define ACPI_BITMASK_SLEEP_TYPE_X               0x1C00
943 #define ACPI_BITMASK_SLEEP_ENABLE               0x2000
944 
945 #define ACPI_BITMASK_ARB_DISABLE                0x0001
946 
947 
948 /* Raw bit position of each BitRegister */
949 
950 #define ACPI_BITPOSITION_TIMER_STATUS           0x00
951 #define ACPI_BITPOSITION_BUS_MASTER_STATUS      0x04
952 #define ACPI_BITPOSITION_GLOBAL_LOCK_STATUS     0x05
953 #define ACPI_BITPOSITION_POWER_BUTTON_STATUS    0x08
954 #define ACPI_BITPOSITION_SLEEP_BUTTON_STATUS    0x09
955 #define ACPI_BITPOSITION_RT_CLOCK_STATUS        0x0A
956 #define ACPI_BITPOSITION_PCIEXP_WAKE_STATUS     0x0E    /* ACPI 3.0 */
957 #define ACPI_BITPOSITION_WAKE_STATUS            0x0F
958 
959 #define ACPI_BITPOSITION_TIMER_ENABLE           0x00
960 #define ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE     0x05
961 #define ACPI_BITPOSITION_POWER_BUTTON_ENABLE    0x08
962 #define ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE    0x09
963 #define ACPI_BITPOSITION_RT_CLOCK_ENABLE        0x0A
964 #define ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE    0x0E    /* ACPI 3.0 */
965 
966 #define ACPI_BITPOSITION_SCI_ENABLE             0x00
967 #define ACPI_BITPOSITION_BUS_MASTER_RLD         0x01
968 #define ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE    0x02
969 #define ACPI_BITPOSITION_SLEEP_TYPE_X           0x0A
970 #define ACPI_BITPOSITION_SLEEP_ENABLE           0x0D
971 
972 #define ACPI_BITPOSITION_ARB_DISABLE            0x00
973 
974 
975 /*****************************************************************************
976  *
977  * Resource descriptors
978  *
979  ****************************************************************************/
980 
981 /* ResourceType values */
982 
983 #define ACPI_ADDRESS_TYPE_MEMORY_RANGE          0
984 #define ACPI_ADDRESS_TYPE_IO_RANGE              1
985 #define ACPI_ADDRESS_TYPE_BUS_NUMBER_RANGE      2
986 
987 /* Resource descriptor types and masks */
988 
989 #define ACPI_RESOURCE_NAME_LARGE                0x80
990 #define ACPI_RESOURCE_NAME_SMALL                0x00
991 
992 #define ACPI_RESOURCE_NAME_SMALL_MASK           0x78 /* Bits 6:3 contain the type */
993 #define ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK    0x07 /* Bits 2:0 contain the length */
994 #define ACPI_RESOURCE_NAME_LARGE_MASK           0x7F /* Bits 6:0 contain the type */
995 
996 
997 /*
998  * Small resource descriptor "names" as defined by the ACPI specification.
999  * Note: Bits 2:0 are used for the descriptor length
1000  */
1001 #define ACPI_RESOURCE_NAME_IRQ                  0x20
1002 #define ACPI_RESOURCE_NAME_DMA                  0x28
1003 #define ACPI_RESOURCE_NAME_START_DEPENDENT      0x30
1004 #define ACPI_RESOURCE_NAME_END_DEPENDENT        0x38
1005 #define ACPI_RESOURCE_NAME_IO                   0x40
1006 #define ACPI_RESOURCE_NAME_FIXED_IO             0x48
1007 #define ACPI_RESOURCE_NAME_RESERVED_S1          0x50
1008 #define ACPI_RESOURCE_NAME_RESERVED_S2          0x58
1009 #define ACPI_RESOURCE_NAME_RESERVED_S3          0x60
1010 #define ACPI_RESOURCE_NAME_RESERVED_S4          0x68
1011 #define ACPI_RESOURCE_NAME_VENDOR_SMALL         0x70
1012 #define ACPI_RESOURCE_NAME_END_TAG              0x78
1013 
1014 /*
1015  * Large resource descriptor "names" as defined by the ACPI specification.
1016  * Note: includes the Large Descriptor bit in bit[7]
1017  */
1018 #define ACPI_RESOURCE_NAME_MEMORY24             0x81
1019 #define ACPI_RESOURCE_NAME_GENERIC_REGISTER     0x82
1020 #define ACPI_RESOURCE_NAME_RESERVED_L1          0x83
1021 #define ACPI_RESOURCE_NAME_VENDOR_LARGE         0x84
1022 #define ACPI_RESOURCE_NAME_MEMORY32             0x85
1023 #define ACPI_RESOURCE_NAME_FIXED_MEMORY32       0x86
1024 #define ACPI_RESOURCE_NAME_ADDRESS32            0x87
1025 #define ACPI_RESOURCE_NAME_ADDRESS16            0x88
1026 #define ACPI_RESOURCE_NAME_EXTENDED_IRQ         0x89
1027 #define ACPI_RESOURCE_NAME_ADDRESS64            0x8A
1028 #define ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64   0x8B
1029 #define ACPI_RESOURCE_NAME_LARGE_MAX            0x8B
1030 
1031 
1032 /*****************************************************************************
1033  *
1034  * Miscellaneous
1035  *
1036  ****************************************************************************/
1037 
1038 #define ACPI_ASCII_ZERO                         0x30
1039 
1040 
1041 /*****************************************************************************
1042  *
1043  * Debugger
1044  *
1045  ****************************************************************************/
1046 
1047 typedef struct acpi_db_method_info
1048 {
1049     ACPI_HANDLE             ThreadGate;
1050     char                    *Name;
1051     char                    **Args;
1052     UINT32                  Flags;
1053     UINT32                  NumLoops;
1054     char                    Pathname[128];
1055 
1056 } ACPI_DB_METHOD_INFO;
1057 
1058 typedef struct acpi_integrity_info
1059 {
1060     UINT32              Nodes;
1061     UINT32              Objects;
1062 
1063 } ACPI_INTEGRITY_INFO;
1064 
1065 
1066 #define ACPI_DB_REDIRECTABLE_OUTPUT  0x01
1067 #define ACPI_DB_CONSOLE_OUTPUT       0x02
1068 #define ACPI_DB_DUPLICATE_OUTPUT     0x03
1069 
1070 
1071 /*****************************************************************************
1072  *
1073  * Debug
1074  *
1075  ****************************************************************************/
1076 
1077 /* Entry for a memory allocation (debug only) */
1078 
1079 #define ACPI_MEM_MALLOC                      0
1080 #define ACPI_MEM_CALLOC                      1
1081 #define ACPI_MAX_MODULE_NAME                 16
1082 
1083 #define ACPI_COMMON_DEBUG_MEM_HEADER \
1084     struct acpi_debug_mem_block *Previous; \
1085     struct acpi_debug_mem_block *Next; \
1086     UINT32                      Size; \
1087     UINT32                      Component; \
1088     UINT32                      Line; \
1089     char                        Module[ACPI_MAX_MODULE_NAME]; \
1090     UINT8                       AllocType;
1091 
1092 typedef struct acpi_debug_mem_header
1093 {
1094     ACPI_COMMON_DEBUG_MEM_HEADER
1095 
1096 } ACPI_DEBUG_MEM_HEADER;
1097 
1098 typedef struct acpi_debug_mem_block
1099 {
1100     ACPI_COMMON_DEBUG_MEM_HEADER
1101     UINT64                      UserSpace;
1102 
1103 } ACPI_DEBUG_MEM_BLOCK;
1104 
1105 
1106 #define ACPI_MEM_LIST_GLOBAL            0
1107 #define ACPI_MEM_LIST_NSNODE            1
1108 #define ACPI_MEM_LIST_MAX               1
1109 #define ACPI_NUM_MEM_LISTS              2
1110 
1111 
1112 typedef struct acpi_memory_list
1113 {
1114     char                        *ListName;
1115     void                        *ListHead;
1116     UINT16                      ObjectSize;
1117     UINT16                      MaxDepth;
1118     UINT16                      CurrentDepth;
1119     UINT16                      LinkOffset;
1120 
1121 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
1122 
1123     /* Statistics for debug memory tracking only */
1124 
1125     UINT32                      TotalAllocated;
1126     UINT32                      TotalFreed;
1127     UINT32                      CurrentTotalSize;
1128     UINT32                      Requests;
1129     UINT32                      Hits;
1130 #endif
1131 
1132 } ACPI_MEMORY_LIST;
1133 
1134 
1135 #endif /* __ACLOCAL_H__ */
1136