Sync ACPICA with Intel's version 20180508 (from previously 20170831).
[dragonfly.git] / sys / contrib / dev / acpica / source / include / aclocal.h
1 /******************************************************************************
2  *
3  * Name: aclocal.h - Internal data types used across the ACPI subsystem
4  *
5  *****************************************************************************/
6
7 /******************************************************************************
8  *
9  * 1. Copyright Notice
10  *
11  * Some or all of this work - Copyright (c) 1999 - 2018, Intel Corp.
12  * All rights reserved.
13  *
14  * 2. License
15  *
16  * 2.1. This is your license from Intel Corp. under its intellectual property
17  * rights. You may have additional license terms from the party that provided
18  * you this software, covering your right to use that party's intellectual
19  * property rights.
20  *
21  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22  * copy of the source code appearing in this file ("Covered Code") an
23  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24  * base code distributed originally by Intel ("Original Intel Code") to copy,
25  * make derivatives, distribute, use and display any portion of the Covered
26  * Code in any form, with the right to sublicense such rights; and
27  *
28  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29  * license (with the right to sublicense), under only those claims of Intel
30  * patents that are infringed by the Original Intel Code, to make, use, sell,
31  * offer to sell, and import the Covered Code and derivative works thereof
32  * solely to the minimum extent necessary to exercise the above copyright
33  * license, and in no event shall the patent license extend to any additions
34  * to or modifications of the Original Intel Code. No other license or right
35  * is granted directly or by implication, estoppel or otherwise;
36  *
37  * The above copyright and patent license is granted only if the following
38  * conditions are met:
39  *
40  * 3. Conditions
41  *
42  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43  * Redistribution of source code of any substantial portion of the Covered
44  * Code or modification with rights to further distribute source must include
45  * the above Copyright Notice, the above License, this list of Conditions,
46  * and the following Disclaimer and Export Compliance provision. In addition,
47  * Licensee must cause all Covered Code to which Licensee contributes to
48  * contain a file documenting the changes Licensee made to create that Covered
49  * Code and the date of any change. Licensee must include in that file the
50  * documentation of any changes made by any predecessor Licensee. Licensee
51  * must include a prominent statement that the modification is derived,
52  * directly or indirectly, from Original Intel Code.
53  *
54  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55  * Redistribution of source code of any substantial portion of the Covered
56  * Code or modification without rights to further distribute source must
57  * include the following Disclaimer and Export Compliance provision in the
58  * documentation and/or other materials provided with distribution. In
59  * addition, Licensee may not authorize further sublicense of source of any
60  * portion of the Covered Code, and must include terms to the effect that the
61  * license from Licensee to its licensee is limited to the intellectual
62  * property embodied in the software Licensee provides to its licensee, and
63  * not to intellectual property embodied in modifications its licensee may
64  * make.
65  *
66  * 3.3. Redistribution of Executable. Redistribution in executable form of any
67  * substantial portion of the Covered Code or modification must reproduce the
68  * above Copyright Notice, and the following Disclaimer and Export Compliance
69  * provision in the documentation and/or other materials provided with the
70  * distribution.
71  *
72  * 3.4. Intel retains all right, title, and interest in and to the Original
73  * Intel Code.
74  *
75  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76  * Intel shall be used in advertising or otherwise to promote the sale, use or
77  * other dealings in products derived from or relating to the Covered Code
78  * without prior written authorization from Intel.
79  *
80  * 4. Disclaimer and Export Compliance
81  *
82  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88  * PARTICULAR PURPOSE.
89  *
90  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97  * LIMITED REMEDY.
98  *
99  * 4.3. Licensee shall not export, either directly or indirectly, any of this
100  * software or system incorporating such software without first obtaining any
101  * required license or other approval from the U. S. Department of Commerce or
102  * any other agency or department of the United States Government. In the
103  * event Licensee exports any such software from the United States or
104  * re-exports any such software from a foreign destination, Licensee shall
105  * ensure that the distribution and export/re-export of the software is in
106  * compliance with all laws, regulations, orders, or other restrictions of the
107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108  * any of its subsidiaries will export/re-export any technical data, process,
109  * software, or service, directly or indirectly, to any country for which the
110  * United States government or any agency thereof requires an export license,
111  * other governmental approval, or letter of assurance, without first obtaining
112  * such license, approval or letter.
113  *
114  *****************************************************************************
115  *
116  * Alternatively, you may choose to be licensed under the terms of the
117  * following license:
118  *
119  * Redistribution and use in source and binary forms, with or without
120  * modification, are permitted provided that the following conditions
121  * are met:
122  * 1. Redistributions of source code must retain the above copyright
123  *    notice, this list of conditions, and the following disclaimer,
124  *    without modification.
125  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126  *    substantially similar to the "NO WARRANTY" disclaimer below
127  *    ("Disclaimer") and any redistribution must be conditioned upon
128  *    including a substantially similar Disclaimer requirement for further
129  *    binary redistribution.
130  * 3. Neither the names of the above-listed copyright holders nor the names
131  *    of any contributors may be used to endorse or promote products derived
132  *    from this software without specific prior written permission.
133  *
134  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145  *
146  * Alternatively, you may choose to be licensed under the terms of the
147  * GNU General Public License ("GPL") version 2 as published by the Free
148  * Software Foundation.
149  *
150  *****************************************************************************/
151
152 #ifndef __ACLOCAL_H__
153 #define __ACLOCAL_H__
154
155
156 /* acpisrc:StructDefs -- for acpisrc conversion */
157
158 #define ACPI_SERIALIZED                 0xFF
159
160 typedef UINT32                          ACPI_MUTEX_HANDLE;
161 #define ACPI_GLOBAL_LOCK                (ACPI_SEMAPHORE) (-1)
162
163 /* Total number of aml opcodes defined */
164
165 #define AML_NUM_OPCODES                 0x83
166
167
168 /* Forward declarations */
169
170 struct acpi_walk_state;
171 struct acpi_obj_mutex;
172 union acpi_parse_object;
173
174
175 /*****************************************************************************
176  *
177  * Mutex typedefs and structs
178  *
179  ****************************************************************************/
180
181
182 /*
183  * Predefined handles for the mutex objects used within the subsystem
184  * All mutex objects are automatically created by AcpiUtMutexInitialize.
185  *
186  * The acquire/release ordering protocol is implied via this list. Mutexes
187  * with a lower value must be acquired before mutexes with a higher value.
188  *
189  * NOTE: any changes here must be reflected in the AcpiGbl_MutexNames
190  * table below also!
191  */
192 #define ACPI_MTX_INTERPRETER            0   /* AML Interpreter, main lock */
193 #define ACPI_MTX_NAMESPACE              1   /* ACPI Namespace */
194 #define ACPI_MTX_TABLES                 2   /* Data for ACPI tables */
195 #define ACPI_MTX_EVENTS                 3   /* Data for ACPI events */
196 #define ACPI_MTX_CACHES                 4   /* Internal caches, general purposes */
197 #define ACPI_MTX_MEMORY                 5   /* Debug memory tracking lists */
198
199 #define ACPI_MAX_MUTEX                  5
200 #define ACPI_NUM_MUTEX                  (ACPI_MAX_MUTEX+1)
201
202
203 /* Lock structure for reader/writer interfaces */
204
205 typedef struct acpi_rw_lock
206 {
207     ACPI_MUTEX              WriterMutex;
208     ACPI_MUTEX              ReaderMutex;
209     UINT32                  NumReaders;
210
211 } ACPI_RW_LOCK;
212
213
214 /*
215  * Predefined handles for spinlocks used within the subsystem.
216  * These spinlocks are created by AcpiUtMutexInitialize
217  */
218 #define ACPI_LOCK_GPES                  0
219 #define ACPI_LOCK_HARDWARE              1
220
221 #define ACPI_MAX_LOCK                   1
222 #define ACPI_NUM_LOCK                   (ACPI_MAX_LOCK+1)
223
224
225 /* This Thread ID means that the mutex is not in use (unlocked) */
226
227 #define ACPI_MUTEX_NOT_ACQUIRED         ((ACPI_THREAD_ID) -1)
228
229 /* This Thread ID means an invalid thread ID */
230
231 #ifdef ACPI_OS_INVALID_THREAD_ID
232 #define ACPI_INVALID_THREAD_ID          ACPI_OS_INVALID_THREAD_ID
233 #else
234 #define ACPI_INVALID_THREAD_ID          ((ACPI_THREAD_ID) 0xFFFFFFFF)
235 #endif
236
237 /* Table for the global mutexes */
238
239 typedef struct acpi_mutex_info
240 {
241     ACPI_MUTEX                      Mutex;
242     UINT32                          UseCount;
243     ACPI_THREAD_ID                  ThreadId;
244
245 } ACPI_MUTEX_INFO;
246
247
248 /* Lock flag parameter for various interfaces */
249
250 #define ACPI_MTX_DO_NOT_LOCK            0
251 #define ACPI_MTX_LOCK                   1
252
253
254 /* Field access granularities */
255
256 #define ACPI_FIELD_BYTE_GRANULARITY     1
257 #define ACPI_FIELD_WORD_GRANULARITY     2
258 #define ACPI_FIELD_DWORD_GRANULARITY    4
259 #define ACPI_FIELD_QWORD_GRANULARITY    8
260
261
262 #define ACPI_ENTRY_NOT_FOUND            NULL
263
264
265 /*****************************************************************************
266  *
267  * Namespace typedefs and structs
268  *
269  ****************************************************************************/
270
271 /* Operational modes of the AML interpreter/scanner */
272
273 typedef enum
274 {
275     ACPI_IMODE_LOAD_PASS1           = 0x01,
276     ACPI_IMODE_LOAD_PASS2           = 0x02,
277     ACPI_IMODE_EXECUTE              = 0x03
278
279 } ACPI_INTERPRETER_MODE;
280
281
282 /*
283  * The Namespace Node describes a named object that appears in the AML.
284  * DescriptorType is used to differentiate between internal descriptors.
285  *
286  * The node is optimized for both 32-bit and 64-bit platforms:
287  * 28 bytes for the 32-bit case, 48 bytes for the 64-bit case.
288  *
289  * Note: The DescriptorType and Type fields must appear in the identical
290  * position in both the ACPI_NAMESPACE_NODE and ACPI_OPERAND_OBJECT
291  * structures.
292  */
293 typedef struct acpi_namespace_node
294 {
295     union acpi_operand_object       *Object;        /* Interpreter object */
296     UINT8                           DescriptorType; /* Differentiate object descriptor types */
297     UINT8                           Type;           /* ACPI Type associated with this name */
298     UINT8                           Flags;          /* Miscellaneous flags */
299     ACPI_OWNER_ID                   OwnerId;        /* Node creator */
300     ACPI_NAME_UNION                 Name;           /* ACPI Name, always 4 chars per ACPI spec */
301     struct acpi_namespace_node      *Parent;        /* Parent node */
302     struct acpi_namespace_node      *Child;         /* First child */
303     struct acpi_namespace_node      *Peer;          /* First peer */
304     struct acpi_namespace_node      *OwnerList;     /* All nodes owned by a table or method */
305
306 /*
307  * The following fields are appended to the namespace node and
308  * are used by the ASL compiler and AML disassembler only
309  */
310 #ifdef ACPI_LARGE_NAMESPACE_NODE
311     union acpi_parse_object         *Op;
312     void                            *MethodLocals;
313     void                            *MethodArgs;
314     UINT32                          Value;
315     UINT32                          Length;
316     UINT8                           ArgCount;
317 #endif
318
319 } ACPI_NAMESPACE_NODE;
320
321
322 /* Namespace Node flags */
323
324 #define ANOBJ_RESERVED                  0x01    /* Available for use */
325 #define ANOBJ_TEMPORARY                 0x02    /* Node is create by a method and is temporary */
326 #define ANOBJ_METHOD_ARG                0x04    /* Node is a method argument */
327 #define ANOBJ_METHOD_LOCAL              0x08    /* Node is a method local */
328 #define ANOBJ_SUBTREE_HAS_INI           0x10    /* Used to optimize device initialization */
329 #define ANOBJ_EVALUATED                 0x20    /* Set on first evaluation of node */
330 #define ANOBJ_ALLOCATED_BUFFER          0x40    /* Method AML buffer is dynamic (InstallMethod) */
331
332 #define IMPLICIT_EXTERNAL               0x02    /* iASL only: This object created implicitly via External */
333 #define ANOBJ_IS_EXTERNAL               0x08    /* iASL only: This object created via External() */
334 #define ANOBJ_METHOD_NO_RETVAL          0x10    /* iASL only: Method has no return value */
335 #define ANOBJ_METHOD_SOME_NO_RETVAL     0x20    /* iASL only: Method has at least one return value */
336 #define ANOBJ_IS_REFERENCED             0x80    /* iASL only: Object was referenced */
337
338
339 /* Internal ACPI table management - master table list */
340
341 typedef struct acpi_table_list
342 {
343     ACPI_TABLE_DESC                 *Tables;            /* Table descriptor array */
344     UINT32                          CurrentTableCount;  /* Tables currently in the array */
345     UINT32                          MaxTableCount;      /* Max tables array will hold */
346     UINT8                           Flags;
347
348 } ACPI_TABLE_LIST;
349
350 /* Flags for above */
351
352 #define ACPI_ROOT_ORIGIN_UNKNOWN        (0)     /* ~ORIGIN_ALLOCATED */
353 #define ACPI_ROOT_ORIGIN_ALLOCATED      (1)
354 #define ACPI_ROOT_ALLOW_RESIZE          (2)
355
356
357 /* List to manage incoming ACPI tables */
358
359 typedef struct acpi_new_table_desc
360 {
361     ACPI_TABLE_HEADER               *Table;
362     struct acpi_new_table_desc      *Next;
363
364 } ACPI_NEW_TABLE_DESC;
365
366
367 /* Predefined table indexes */
368
369 #define ACPI_INVALID_TABLE_INDEX        (0xFFFFFFFF)
370
371
372 typedef struct acpi_find_context
373 {
374     char                            *SearchFor;
375     ACPI_HANDLE                     *List;
376     UINT32                          *Count;
377
378 } ACPI_FIND_CONTEXT;
379
380
381 typedef struct acpi_ns_search_data
382 {
383     ACPI_NAMESPACE_NODE             *Node;
384
385 } ACPI_NS_SEARCH_DATA;
386
387
388 /* Object types used during package copies */
389
390 #define ACPI_COPY_TYPE_SIMPLE           0
391 #define ACPI_COPY_TYPE_PACKAGE          1
392
393
394 /* Info structure used to convert external<->internal namestrings */
395
396 typedef struct acpi_namestring_info
397 {
398     const char                      *ExternalName;
399     const char                      *NextExternalChar;
400     char                            *InternalName;
401     UINT32                          Length;
402     UINT32                          NumSegments;
403     UINT32                          NumCarats;
404     BOOLEAN                         FullyQualified;
405
406 } ACPI_NAMESTRING_INFO;
407
408
409 /* Field creation info */
410
411 typedef struct acpi_create_field_info
412 {
413     ACPI_NAMESPACE_NODE             *RegionNode;
414     ACPI_NAMESPACE_NODE             *FieldNode;
415     ACPI_NAMESPACE_NODE             *RegisterNode;
416     ACPI_NAMESPACE_NODE             *DataRegisterNode;
417     ACPI_NAMESPACE_NODE             *ConnectionNode;
418     UINT8                           *ResourceBuffer;
419     UINT32                          BankValue;
420     UINT32                          FieldBitPosition;
421     UINT32                          FieldBitLength;
422     UINT16                          ResourceLength;
423     UINT16                          PinNumberIndex;
424     UINT8                           FieldFlags;
425     UINT8                           Attribute;
426     UINT8                           FieldType;
427     UINT8                           AccessLength;
428
429 } ACPI_CREATE_FIELD_INFO;
430
431
432 typedef
433 ACPI_STATUS (*ACPI_INTERNAL_METHOD) (
434     struct acpi_walk_state          *WalkState);
435
436
437 /*
438  * Bitmapped ACPI types. Used internally only
439  */
440 #define ACPI_BTYPE_ANY                  0x00000000
441 #define ACPI_BTYPE_INTEGER              0x00000001
442 #define ACPI_BTYPE_STRING               0x00000002
443 #define ACPI_BTYPE_BUFFER               0x00000004
444 #define ACPI_BTYPE_PACKAGE              0x00000008
445 #define ACPI_BTYPE_FIELD_UNIT           0x00000010
446 #define ACPI_BTYPE_DEVICE               0x00000020
447 #define ACPI_BTYPE_EVENT                0x00000040
448 #define ACPI_BTYPE_METHOD               0x00000080
449 #define ACPI_BTYPE_MUTEX                0x00000100
450 #define ACPI_BTYPE_REGION               0x00000200
451 #define ACPI_BTYPE_POWER                0x00000400
452 #define ACPI_BTYPE_PROCESSOR            0x00000800
453 #define ACPI_BTYPE_THERMAL              0x00001000
454 #define ACPI_BTYPE_BUFFER_FIELD         0x00002000
455 #define ACPI_BTYPE_DDB_HANDLE           0x00004000
456 #define ACPI_BTYPE_DEBUG_OBJECT         0x00008000
457 #define ACPI_BTYPE_REFERENCE_OBJECT     0x00010000 /* From Index(), RefOf(), etc (Type6Opcodes) */
458 #define ACPI_BTYPE_RESOURCE             0x00020000
459 #define ACPI_BTYPE_NAMED_REFERENCE      0x00040000 /* Generic unresolved Name or Namepath */
460
461 #define ACPI_BTYPE_COMPUTE_DATA         (ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER)
462
463 #define ACPI_BTYPE_DATA                 (ACPI_BTYPE_COMPUTE_DATA  | ACPI_BTYPE_PACKAGE)
464
465     /* Used by Copy, DeRefOf, Store, Printf, Fprintf */
466
467 #define ACPI_BTYPE_DATA_REFERENCE       (ACPI_BTYPE_DATA | ACPI_BTYPE_REFERENCE_OBJECT | ACPI_BTYPE_DDB_HANDLE)
468 #define ACPI_BTYPE_DEVICE_OBJECTS       (ACPI_BTYPE_DEVICE | ACPI_BTYPE_THERMAL | ACPI_BTYPE_PROCESSOR)
469 #define ACPI_BTYPE_OBJECTS_AND_REFS     0x0001FFFF  /* ARG or LOCAL */
470 #define ACPI_BTYPE_ALL_OBJECTS          0x0000FFFF
471
472 #pragma pack(1)
473
474 /*
475  * Information structure for ACPI predefined names.
476  * Each entry in the table contains the following items:
477  *
478  * Name                 - The ACPI reserved name
479  * ParamCount           - Number of arguments to the method
480  * ExpectedReturnBtypes - Allowed type(s) for the return value
481  */
482 typedef struct acpi_name_info
483 {
484     char                        Name[ACPI_NAME_SIZE];
485     UINT16                      ArgumentList;
486     UINT8                       ExpectedBtypes;
487
488 } ACPI_NAME_INFO;
489
490 /*
491  * Secondary information structures for ACPI predefined objects that return
492  * package objects. This structure appears as the next entry in the table
493  * after the NAME_INFO structure above.
494  *
495  * The reason for this is to minimize the size of the predefined name table.
496  */
497
498 /*
499  * Used for ACPI_PTYPE1_FIXED, ACPI_PTYPE1_VAR, ACPI_PTYPE2,
500  * ACPI_PTYPE2_MIN, ACPI_PTYPE2_PKG_COUNT, ACPI_PTYPE2_COUNT,
501  * ACPI_PTYPE2_FIX_VAR
502  */
503 typedef struct acpi_package_info
504 {
505     UINT8                       Type;
506     UINT8                       ObjectType1;
507     UINT8                       Count1;
508     UINT8                       ObjectType2;
509     UINT8                       Count2;
510     UINT16                      Reserved;
511
512 } ACPI_PACKAGE_INFO;
513
514 /* Used for ACPI_PTYPE2_FIXED */
515
516 typedef struct acpi_package_info2
517 {
518     UINT8                       Type;
519     UINT8                       Count;
520     UINT8                       ObjectType[4];
521     UINT8                       Reserved;
522
523 } ACPI_PACKAGE_INFO2;
524
525 /* Used for ACPI_PTYPE1_OPTION */
526
527 typedef struct acpi_package_info3
528 {
529     UINT8                       Type;
530     UINT8                       Count;
531     UINT8                       ObjectType[2];
532     UINT8                       TailObjectType;
533     UINT16                      Reserved;
534
535 } ACPI_PACKAGE_INFO3;
536
537 typedef struct acpi_package_info4
538 {
539     UINT8                       Type;
540     UINT8                       ObjectType1;
541     UINT8                       Count1;
542     UINT8                       SubObjectTypes;
543     UINT8                       PkgCount;
544     UINT16                      Reserved;
545
546 } ACPI_PACKAGE_INFO4;
547
548 typedef union acpi_predefined_info
549 {
550     ACPI_NAME_INFO              Info;
551     ACPI_PACKAGE_INFO           RetInfo;
552     ACPI_PACKAGE_INFO2          RetInfo2;
553     ACPI_PACKAGE_INFO3          RetInfo3;
554     ACPI_PACKAGE_INFO4          RetInfo4;
555
556 } ACPI_PREDEFINED_INFO;
557
558 /* Reset to default packing */
559
560 #pragma pack()
561
562
563 /* Return object auto-repair info */
564
565 typedef ACPI_STATUS (*ACPI_OBJECT_CONVERTER) (
566     struct acpi_namespace_node  *Scope,
567     union acpi_operand_object   *OriginalObject,
568     union acpi_operand_object   **ConvertedObject);
569
570 typedef struct acpi_simple_repair_info
571 {
572     char                        Name[ACPI_NAME_SIZE];
573     UINT32                      UnexpectedBtypes;
574     UINT32                      PackageIndex;
575     ACPI_OBJECT_CONVERTER       ObjectConverter;
576
577 } ACPI_SIMPLE_REPAIR_INFO;
578
579
580 /*
581  * Bitmapped return value types
582  * Note: the actual data types must be contiguous, a loop in nspredef.c
583  * depends on this.
584  */
585 #define ACPI_RTYPE_ANY                  0x00
586 #define ACPI_RTYPE_NONE                 0x01
587 #define ACPI_RTYPE_INTEGER              0x02
588 #define ACPI_RTYPE_STRING               0x04
589 #define ACPI_RTYPE_BUFFER               0x08
590 #define ACPI_RTYPE_PACKAGE              0x10
591 #define ACPI_RTYPE_REFERENCE            0x20
592 #define ACPI_RTYPE_ALL                  0x3F
593
594 #define ACPI_NUM_RTYPES                 5   /* Number of actual object types */
595
596
597 /* Info for running the _REG methods */
598
599 typedef struct acpi_reg_walk_info
600 {
601     ACPI_ADR_SPACE_TYPE     SpaceId;
602     UINT32                  Function;
603     UINT32                  RegRunCount;
604
605 } ACPI_REG_WALK_INFO;
606
607
608 /*****************************************************************************
609  *
610  * Event typedefs and structs
611  *
612  ****************************************************************************/
613
614 /* Dispatch info for each host-installed SCI handler */
615
616 typedef struct acpi_sci_handler_info
617 {
618     struct acpi_sci_handler_info    *Next;
619     ACPI_SCI_HANDLER                Address;        /* Address of handler */
620     void                            *Context;       /* Context to be passed to handler */
621
622 } ACPI_SCI_HANDLER_INFO;
623
624 /* Dispatch info for each GPE -- either a method or handler, cannot be both */
625
626 typedef struct acpi_gpe_handler_info
627 {
628     ACPI_GPE_HANDLER                Address;        /* Address of handler, if any */
629     void                            *Context;       /* Context to be passed to handler */
630     ACPI_NAMESPACE_NODE             *MethodNode;    /* Method node for this GPE level (saved) */
631     UINT8                           OriginalFlags;  /* Original (pre-handler) GPE info */
632     BOOLEAN                         OriginallyEnabled; /* True if GPE was originally enabled */
633
634 } ACPI_GPE_HANDLER_INFO;
635
636 /* Notify info for implicit notify, multiple device objects */
637
638 typedef struct acpi_gpe_notify_info
639 {
640     ACPI_NAMESPACE_NODE             *DeviceNode;    /* Device to be notified */
641     struct acpi_gpe_notify_info     *Next;
642
643 } ACPI_GPE_NOTIFY_INFO;
644
645 /*
646  * GPE dispatch info. At any time, the GPE can have at most one type
647  * of dispatch - Method, Handler, or Implicit Notify.
648  */
649 typedef union acpi_gpe_dispatch_info
650 {
651     ACPI_NAMESPACE_NODE             *MethodNode;    /* Method node for this GPE level */
652     ACPI_GPE_HANDLER_INFO           *Handler;       /* Installed GPE handler */
653     ACPI_GPE_NOTIFY_INFO            *NotifyList;    /* List of _PRW devices for implicit notifies */
654
655 } ACPI_GPE_DISPATCH_INFO;
656
657 /*
658  * Information about a GPE, one per each GPE in an array.
659  * NOTE: Important to keep this struct as small as possible.
660  */
661 typedef struct acpi_gpe_event_info
662 {
663     union acpi_gpe_dispatch_info    Dispatch;           /* Either Method, Handler, or NotifyList */
664     struct acpi_gpe_register_info   *RegisterInfo;      /* Backpointer to register info */
665     UINT8                           Flags;              /* Misc info about this GPE */
666     UINT8                           GpeNumber;          /* This GPE */
667     UINT8                           RuntimeCount;       /* References to a run GPE */
668     BOOLEAN                         DisableForDispatch; /* Masked during dispatching */
669
670 } ACPI_GPE_EVENT_INFO;
671
672 /* Information about a GPE register pair, one per each status/enable pair in an array */
673
674 typedef struct acpi_gpe_register_info
675 {
676     ACPI_GENERIC_ADDRESS            StatusAddress;  /* Address of status reg */
677     ACPI_GENERIC_ADDRESS            EnableAddress;  /* Address of enable reg */
678     UINT16                          BaseGpeNumber;  /* Base GPE number for this register */
679     UINT8                           EnableForWake;  /* GPEs to keep enabled when sleeping */
680     UINT8                           EnableForRun;   /* GPEs to keep enabled when running */
681     UINT8                           MaskForRun;     /* GPEs to keep masked when running */
682     UINT8                           EnableMask;     /* Current mask of enabled GPEs */
683
684 } ACPI_GPE_REGISTER_INFO;
685
686 /*
687  * Information about a GPE register block, one per each installed block --
688  * GPE0, GPE1, and one per each installed GPE Block Device.
689  */
690 typedef struct acpi_gpe_block_info
691 {
692     ACPI_NAMESPACE_NODE             *Node;
693     struct acpi_gpe_block_info      *Previous;
694     struct acpi_gpe_block_info      *Next;
695     struct acpi_gpe_xrupt_info      *XruptBlock;    /* Backpointer to interrupt block */
696     ACPI_GPE_REGISTER_INFO          *RegisterInfo;  /* One per GPE register pair */
697     ACPI_GPE_EVENT_INFO             *EventInfo;     /* One for each GPE */
698     UINT64                          Address;        /* Base address of the block */
699     UINT32                          RegisterCount;  /* Number of register pairs in block */
700     UINT16                          GpeCount;       /* Number of individual GPEs in block */
701     UINT16                          BlockBaseNumber;/* Base GPE number for this block */
702     UINT8                           SpaceId;
703     BOOLEAN                         Initialized;    /* TRUE if this block is initialized */
704
705 } ACPI_GPE_BLOCK_INFO;
706
707 /* Information about GPE interrupt handlers, one per each interrupt level used for GPEs */
708
709 typedef struct acpi_gpe_xrupt_info
710 {
711     struct acpi_gpe_xrupt_info      *Previous;
712     struct acpi_gpe_xrupt_info      *Next;
713     ACPI_GPE_BLOCK_INFO             *GpeBlockListHead;  /* List of GPE blocks for this xrupt */
714     UINT32                          InterruptNumber;    /* System interrupt number */
715
716 } ACPI_GPE_XRUPT_INFO;
717
718 typedef struct acpi_gpe_walk_info
719 {
720     ACPI_NAMESPACE_NODE             *GpeDevice;
721     ACPI_GPE_BLOCK_INFO             *GpeBlock;
722     UINT16                          Count;
723     ACPI_OWNER_ID                   OwnerId;
724     BOOLEAN                         ExecuteByOwnerId;
725
726 } ACPI_GPE_WALK_INFO;
727
728 typedef struct acpi_gpe_device_info
729 {
730     UINT32                          Index;
731     UINT32                          NextBlockBaseIndex;
732     ACPI_STATUS                     Status;
733     ACPI_NAMESPACE_NODE             *GpeDevice;
734
735 } ACPI_GPE_DEVICE_INFO;
736
737 typedef ACPI_STATUS (*ACPI_GPE_CALLBACK) (
738     ACPI_GPE_XRUPT_INFO             *GpeXruptInfo,
739     ACPI_GPE_BLOCK_INFO             *GpeBlock,
740     void                            *Context);
741
742
743 /* Information about each particular fixed event */
744
745 typedef struct acpi_fixed_event_handler
746 {
747     ACPI_EVENT_HANDLER              Handler;        /* Address of handler. */
748     void                            *Context;       /* Context to be passed to handler */
749
750 } ACPI_FIXED_EVENT_HANDLER;
751
752 typedef struct acpi_fixed_event_info
753 {
754     UINT8                           StatusRegisterId;
755     UINT8                           EnableRegisterId;
756     UINT16                          StatusBitMask;
757     UINT16                          EnableBitMask;
758
759 } ACPI_FIXED_EVENT_INFO;
760
761 /* Information used during field processing */
762
763 typedef struct acpi_field_info
764 {
765     UINT8                           SkipField;
766     UINT8                           FieldFlag;
767     UINT32                          PkgLength;
768
769 } ACPI_FIELD_INFO;
770
771
772 /*****************************************************************************
773  *
774  * Generic "state" object for stacks
775  *
776  ****************************************************************************/
777
778 #define ACPI_CONTROL_NORMAL                  0xC0
779 #define ACPI_CONTROL_CONDITIONAL_EXECUTING   0xC1
780 #define ACPI_CONTROL_PREDICATE_EXECUTING     0xC2
781 #define ACPI_CONTROL_PREDICATE_FALSE         0xC3
782 #define ACPI_CONTROL_PREDICATE_TRUE          0xC4
783
784
785 #define ACPI_STATE_COMMON \
786     void                            *Next; \
787     UINT8                           DescriptorType; /* To differentiate various internal objs */\
788     UINT8                           Flags; \
789     UINT16                          Value; \
790     UINT16                          State;
791
792     /* There are 2 bytes available here until the next natural alignment boundary */
793
794 typedef struct acpi_common_state
795 {
796     ACPI_STATE_COMMON
797 } ACPI_COMMON_STATE;
798
799
800 /*
801  * Update state - used to traverse complex objects such as packages
802  */
803 typedef struct acpi_update_state
804 {
805     ACPI_STATE_COMMON
806     union acpi_operand_object       *Object;
807
808 } ACPI_UPDATE_STATE;
809
810
811 /*
812  * Pkg state - used to traverse nested package structures
813  */
814 typedef struct acpi_pkg_state
815 {
816     ACPI_STATE_COMMON
817     UINT32                          Index;
818     union acpi_operand_object       *SourceObject;
819     union acpi_operand_object       *DestObject;
820     struct acpi_walk_state          *WalkState;
821     void                            *ThisTargetObj;
822     UINT32                          NumPackages;
823
824 } ACPI_PKG_STATE;
825
826
827 /*
828  * Control state - one per if/else and while constructs.
829  * Allows nesting of these constructs
830  */
831 typedef struct acpi_control_state
832 {
833     ACPI_STATE_COMMON
834     UINT16                          Opcode;
835     union acpi_parse_object         *PredicateOp;
836     UINT8                           *AmlPredicateStart;     /* Start of if/while predicate */
837     UINT8                           *PackageEnd;            /* End of if/while block */
838     UINT64                          LoopTimeout;            /* While() loop timeout */
839
840 } ACPI_CONTROL_STATE;
841
842
843 /*
844  * Scope state - current scope during namespace lookups
845  */
846 typedef struct acpi_scope_state
847 {
848     ACPI_STATE_COMMON
849     ACPI_NAMESPACE_NODE             *Node;
850
851 } ACPI_SCOPE_STATE;
852
853
854 typedef struct acpi_pscope_state
855 {
856     ACPI_STATE_COMMON
857     UINT32                          ArgCount;               /* Number of fixed arguments */
858     union acpi_parse_object         *Op;                    /* Current op being parsed */
859     UINT8                           *ArgEnd;                /* Current argument end */
860     UINT8                           *PkgEnd;                /* Current package end */
861     UINT32                          ArgList;                /* Next argument to parse */
862
863 } ACPI_PSCOPE_STATE;
864
865
866 /*
867  * Thread state - one per thread across multiple walk states. Multiple walk
868  * states are created when there are nested control methods executing.
869  */
870 typedef struct acpi_thread_state
871 {
872     ACPI_STATE_COMMON
873     UINT8                           CurrentSyncLevel;       /* Mutex Sync (nested acquire) level */
874     struct acpi_walk_state          *WalkStateList;         /* Head of list of WalkStates for this thread */
875     union acpi_operand_object       *AcquiredMutexList;     /* List of all currently acquired mutexes */
876     ACPI_THREAD_ID                  ThreadId;               /* Running thread ID */
877
878 } ACPI_THREAD_STATE;
879
880
881 /*
882  * Result values - used to accumulate the results of nested
883  * AML arguments
884  */
885 typedef struct acpi_result_values
886 {
887     ACPI_STATE_COMMON
888     union acpi_operand_object       *ObjDesc [ACPI_RESULTS_FRAME_OBJ_NUM];
889
890 } ACPI_RESULT_VALUES;
891
892
893 typedef
894 ACPI_STATUS (*ACPI_PARSE_DOWNWARDS) (
895     struct acpi_walk_state          *WalkState,
896     union acpi_parse_object         **OutOp);
897
898 typedef
899 ACPI_STATUS (*ACPI_PARSE_UPWARDS) (
900     struct acpi_walk_state          *WalkState);
901
902
903 /* Global handlers for AML Notifies */
904
905 typedef struct acpi_global_notify_handler
906 {
907     ACPI_NOTIFY_HANDLER             Handler;
908     void                            *Context;
909
910 } ACPI_GLOBAL_NOTIFY_HANDLER;
911
912 /*
913  * Notify info - used to pass info to the deferred notify
914  * handler/dispatcher.
915  */
916 typedef struct acpi_notify_info
917 {
918     ACPI_STATE_COMMON
919     UINT8                           HandlerListId;
920     ACPI_NAMESPACE_NODE             *Node;
921     union acpi_operand_object       *HandlerListHead;
922     ACPI_GLOBAL_NOTIFY_HANDLER      *Global;
923
924 } ACPI_NOTIFY_INFO;
925
926
927 /* Generic state is union of structs above */
928
929 typedef union acpi_generic_state
930 {
931     ACPI_COMMON_STATE               Common;
932     ACPI_CONTROL_STATE              Control;
933     ACPI_UPDATE_STATE               Update;
934     ACPI_SCOPE_STATE                Scope;
935     ACPI_PSCOPE_STATE               ParseScope;
936     ACPI_PKG_STATE                  Pkg;
937     ACPI_THREAD_STATE               Thread;
938     ACPI_RESULT_VALUES              Results;
939     ACPI_NOTIFY_INFO                Notify;
940
941 } ACPI_GENERIC_STATE;
942
943
944 /*****************************************************************************
945  *
946  * Interpreter typedefs and structs
947  *
948  ****************************************************************************/
949
950 typedef
951 ACPI_STATUS (*ACPI_EXECUTE_OP) (
952     struct acpi_walk_state          *WalkState);
953
954 /* Address Range info block */
955
956 typedef struct acpi_address_range
957 {
958     struct acpi_address_range   *Next;
959     ACPI_NAMESPACE_NODE         *RegionNode;
960     ACPI_PHYSICAL_ADDRESS       StartAddress;
961     ACPI_PHYSICAL_ADDRESS       EndAddress;
962
963 } ACPI_ADDRESS_RANGE;
964
965
966 /*****************************************************************************
967  *
968  * Parser typedefs and structs
969  *
970  ****************************************************************************/
971
972 /*
973  * AML opcode, name, and argument layout
974  */
975 typedef struct acpi_opcode_info
976 {
977 #if defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUG_OUTPUT)
978     char                            *Name;          /* Opcode name (disassembler/debug only) */
979 #endif
980     UINT32                          ParseArgs;      /* Grammar/Parse time arguments */
981     UINT32                          RuntimeArgs;    /* Interpret time arguments */
982     UINT16                          Flags;          /* Misc flags */
983     UINT8                           ObjectType;     /* Corresponding internal object type */
984     UINT8                           Class;          /* Opcode class */
985     UINT8                           Type;           /* Opcode type */
986
987 } ACPI_OPCODE_INFO;
988
989 /* Structure for Resource Tag information */
990
991 typedef struct acpi_tag_info
992 {
993     UINT32                          BitOffset;
994     UINT32                          BitLength;
995
996 } ACPI_TAG_INFO;
997
998 /* Value associated with the parse object */
999
1000 typedef union acpi_parse_value
1001 {
1002     UINT64                          Integer;        /* Integer constant (Up to 64 bits) */
1003     UINT32                          Size;           /* bytelist or field size */
1004     char                            *String;        /* NULL terminated string */
1005     UINT8                           *Buffer;        /* buffer or string */
1006     char                            *Name;          /* NULL terminated string */
1007     union acpi_parse_object         *Arg;           /* arguments and contained ops */
1008     ACPI_TAG_INFO                   Tag;            /* Resource descriptor tag info  */
1009
1010 } ACPI_PARSE_VALUE;
1011
1012
1013 #if defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUG_OUTPUT)
1014 #define ACPI_DISASM_ONLY_MEMBERS(a)     a;
1015 #else
1016 #define ACPI_DISASM_ONLY_MEMBERS(a)
1017 #endif
1018
1019 #if defined(ACPI_ASL_COMPILER)
1020 #define ACPI_CONVERTER_ONLY_MEMBERS(a)  a;
1021 #else
1022 #define ACPI_CONVERTER_ONLY_MEMBERS(a)
1023 #endif
1024
1025 #define ACPI_PARSE_COMMON \
1026     union acpi_parse_object         *Parent;            /* Parent op */\
1027     UINT8                           DescriptorType;     /* To differentiate various internal objs */\
1028     UINT8                           Flags;              /* Type of Op */\
1029     UINT16                          AmlOpcode;          /* AML opcode */\
1030     UINT8                           *Aml;               /* Address of declaration in AML */\
1031     union acpi_parse_object         *Next;              /* Next op */\
1032     ACPI_NAMESPACE_NODE             *Node;              /* For use by interpreter */\
1033     ACPI_PARSE_VALUE                Value;              /* Value or args associated with the opcode */\
1034     UINT8                           ArgListLength;      /* Number of elements in the arg list */\
1035      ACPI_DISASM_ONLY_MEMBERS (\
1036     UINT16                          DisasmFlags;        /* Used during AML disassembly */\
1037     UINT8                           DisasmOpcode;       /* Subtype used for disassembly */\
1038     char                            *OperatorSymbol;    /* Used for C-style operator name strings */\
1039     char                            AmlOpName[16])      /* Op name (debug only) */\
1040      ACPI_CONVERTER_ONLY_MEMBERS (\
1041     char                            *InlineComment;     /* Inline comment */\
1042     char                            *EndNodeComment;    /* End of node comment */\
1043     char                            *NameComment;       /* Comment associated with the first parameter of the name node */\
1044     char                            *CloseBraceComment; /* Comments that come after } on the same as } */\
1045     ACPI_COMMENT_NODE               *CommentList;       /* comments that appears before this node */\
1046     ACPI_COMMENT_NODE               *EndBlkComment;     /* comments that at the end of a block but before ) or } */\
1047     char                            *CvFilename;        /* Filename associated with this node. Used for ASL/ASL+ converter */\
1048     char                            *CvParentFilename)  /* Parent filename associated with this node. Used for ASL/ASL+ converter */
1049
1050
1051 /* categories of comments */
1052
1053 typedef enum
1054 {
1055     STANDARD_COMMENT = 1,
1056     INLINE_COMMENT,
1057     ENDNODE_COMMENT,
1058     OPENBRACE_COMMENT,
1059     CLOSE_BRACE_COMMENT,
1060     STD_DEFBLK_COMMENT,
1061     END_DEFBLK_COMMENT,
1062     FILENAME_COMMENT,
1063     PARENTFILENAME_COMMENT,
1064     ENDBLK_COMMENT,
1065     INCLUDE_COMMENT
1066
1067 } ASL_COMMENT_TYPES;
1068
1069
1070 /* Internal opcodes for DisasmOpcode field above */
1071
1072 #define ACPI_DASM_BUFFER                0x00        /* Buffer is a simple data buffer */
1073 #define ACPI_DASM_RESOURCE              0x01        /* Buffer is a Resource Descriptor */
1074 #define ACPI_DASM_STRING                0x02        /* Buffer is a ASCII string */
1075 #define ACPI_DASM_UNICODE               0x03        /* Buffer is a Unicode string */
1076 #define ACPI_DASM_PLD_METHOD            0x04        /* Buffer is a _PLD method bit-packed buffer */
1077 #define ACPI_DASM_UUID                  0x05        /* Buffer is a UUID/GUID */
1078 #define ACPI_DASM_EISAID                0x06        /* Integer is an EISAID */
1079 #define ACPI_DASM_MATCHOP               0x07        /* Parent opcode is a Match() operator */
1080 #define ACPI_DASM_LNOT_PREFIX           0x08        /* Start of a LNotEqual (etc.) pair of opcodes */
1081 #define ACPI_DASM_LNOT_SUFFIX           0x09        /* End  of a LNotEqual (etc.) pair of opcodes */
1082 #define ACPI_DASM_HID_STRING            0x0A        /* String is a _HID or _CID */
1083 #define ACPI_DASM_IGNORE_SINGLE         0x0B        /* Ignore the opcode but not it's children */
1084 #define ACPI_DASM_SWITCH                0x0C        /* While is a Switch */
1085 #define ACPI_DASM_SWITCH_PREDICATE      0x0D        /* Object is a predicate for a Switch or Case block */
1086 #define ACPI_DASM_CASE                  0x0E        /* If/Else is a Case in a Switch/Case block */
1087 #define ACPI_DASM_DEFAULT               0x0F        /* Else is a Default in a Switch/Case block */
1088
1089
1090 /*
1091  * List struct used in the -ca option
1092  */
1093 typedef struct acpi_comment_node
1094 {
1095   char                      *Comment;
1096   struct acpi_comment_node  *Next;
1097
1098 } ACPI_COMMENT_NODE;
1099
1100
1101 typedef struct acpi_comment_addr_node
1102 {
1103   UINT8                                    *Addr;
1104   struct acpi_comment_addr_node            *Next;
1105 } ACPI_COMMENT_ADDR_NODE;
1106
1107 #ifdef ACPI_APPLICATION
1108 /*
1109  * File node - used for "Include" operator file stack and
1110  * depdendency tree for the -ca option
1111  */
1112 typedef struct acpi_file_node
1113 {
1114     void                    *File;
1115     char                    *Filename;
1116     char                    *FileStart;  /* Points to AML and indicates when the AML for this particular file starts. */
1117     char                    *FileEnd;    /* Points to AML and indicates when the AML for this particular file ends. */
1118     struct acpi_file_node   *Next;
1119     struct acpi_file_node   *Parent;
1120     BOOLEAN                 IncludeWritten;
1121     ACPI_COMMENT_NODE       *IncludeComment;
1122
1123 } ACPI_FILE_NODE;
1124 #endif
1125
1126 /*
1127  * Generic operation (for example:  If, While, Store)
1128  */
1129 typedef struct acpi_parse_obj_common
1130 {
1131     ACPI_PARSE_COMMON
1132 } ACPI_PARSE_OBJ_COMMON;
1133
1134
1135 /*
1136  * Extended Op for named ops (Scope, Method, etc.), deferred ops (Methods and OpRegions),
1137  * and bytelists.
1138  */
1139 typedef struct acpi_parse_obj_named
1140 {
1141     ACPI_PARSE_COMMON
1142     char                            *Path;
1143     UINT8                           *Data;          /* AML body or bytelist data */
1144     UINT32                          Length;         /* AML length */
1145     UINT32                          Name;           /* 4-byte name or zero if no name */
1146
1147 } ACPI_PARSE_OBJ_NAMED;
1148
1149
1150 /* This version is used by the iASL compiler only */
1151
1152 #define ACPI_MAX_PARSEOP_NAME       20
1153
1154 typedef struct acpi_parse_obj_asl
1155 {
1156     ACPI_PARSE_COMMON
1157     union acpi_parse_object         *Child;
1158     union acpi_parse_object         *ParentMethod;
1159     char                            *Filename;
1160     BOOLEAN                         FileChanged;
1161     char                            *ParentFilename;
1162     char                            *ExternalName;
1163     char                            *Namepath;
1164     char                            NameSeg[4];
1165     UINT32                          ExtraValue;
1166     UINT32                          Column;
1167     UINT32                          LineNumber;
1168     UINT32                          LogicalLineNumber;
1169     UINT32                          LogicalByteOffset;
1170     UINT32                          EndLine;
1171     UINT32                          EndLogicalLine;
1172     UINT32                          AcpiBtype;
1173     UINT32                          AmlLength;
1174     UINT32                          AmlSubtreeLength;
1175     UINT32                          FinalAmlLength;
1176     UINT32                          FinalAmlOffset;
1177     UINT32                          CompileFlags;
1178     UINT16                          ParseOpcode;
1179     UINT8                           AmlOpcodeLength;
1180     UINT8                           AmlPkgLenBytes;
1181     UINT8                           Extra;
1182     char                            ParseOpName[ACPI_MAX_PARSEOP_NAME];
1183
1184 } ACPI_PARSE_OBJ_ASL;
1185
1186 typedef union acpi_parse_object
1187 {
1188     ACPI_PARSE_OBJ_COMMON           Common;
1189     ACPI_PARSE_OBJ_NAMED            Named;
1190     ACPI_PARSE_OBJ_ASL              Asl;
1191
1192 } ACPI_PARSE_OBJECT;
1193
1194 typedef struct asl_comment_state
1195 {
1196     UINT8                           CommentType;
1197     UINT32                          SpacesBefore;
1198     ACPI_PARSE_OBJECT               *LatestParseOp;
1199     ACPI_PARSE_OBJECT               *ParsingParenBraceNode;
1200     BOOLEAN                         CaptureComments;
1201
1202 } ASL_COMMENT_STATE;
1203
1204
1205 /*
1206  * Parse state - one state per parser invocation and each control
1207  * method.
1208  */
1209 typedef struct acpi_parse_state
1210 {
1211     UINT8                           *AmlStart;      /* First AML byte */
1212     UINT8                           *Aml;           /* Next AML byte */
1213     UINT8                           *AmlEnd;        /* (last + 1) AML byte */
1214     UINT8                           *PkgStart;      /* Current package begin */
1215     UINT8                           *PkgEnd;        /* Current package end */
1216     union acpi_parse_object         *StartOp;       /* Root of parse tree */
1217     struct acpi_namespace_node      *StartNode;
1218     union acpi_generic_state        *Scope;         /* Current scope */
1219     union acpi_parse_object         *StartScope;
1220     UINT32                          AmlSize;
1221
1222 } ACPI_PARSE_STATE;
1223
1224
1225 /* Parse object flags */
1226
1227 #define ACPI_PARSEOP_GENERIC                0x01
1228 #define ACPI_PARSEOP_NAMED_OBJECT           0x02
1229 #define ACPI_PARSEOP_DEFERRED               0x04
1230 #define ACPI_PARSEOP_BYTELIST               0x08
1231 #define ACPI_PARSEOP_IN_STACK               0x10
1232 #define ACPI_PARSEOP_TARGET                 0x20
1233 #define ACPI_PARSEOP_IN_CACHE               0x80
1234
1235 /* Parse object DisasmFlags */
1236
1237 #define ACPI_PARSEOP_IGNORE                 0x0001
1238 #define ACPI_PARSEOP_PARAMETER_LIST         0x0002
1239 #define ACPI_PARSEOP_EMPTY_TERMLIST         0x0004
1240 #define ACPI_PARSEOP_PREDEFINED_CHECKED     0x0008
1241 #define ACPI_PARSEOP_CLOSING_PAREN          0x0010
1242 #define ACPI_PARSEOP_COMPOUND_ASSIGNMENT    0x0020
1243 #define ACPI_PARSEOP_ASSIGNMENT             0x0040
1244 #define ACPI_PARSEOP_ELSEIF                 0x0080
1245 #define ACPI_PARSEOP_LEGACY_ASL_ONLY        0x0100
1246
1247
1248 /*****************************************************************************
1249  *
1250  * Hardware (ACPI registers) and PNP
1251  *
1252  ****************************************************************************/
1253
1254 typedef struct acpi_bit_register_info
1255 {
1256     UINT8                           ParentRegister;
1257     UINT8                           BitPosition;
1258     UINT16                          AccessBitMask;
1259
1260 } ACPI_BIT_REGISTER_INFO;
1261
1262
1263 /*
1264  * Some ACPI registers have bits that must be ignored -- meaning that they
1265  * must be preserved.
1266  */
1267 #define ACPI_PM1_STATUS_PRESERVED_BITS          0x0800  /* Bit 11 */
1268
1269 /* Write-only bits must be zeroed by software */
1270
1271 #define ACPI_PM1_CONTROL_WRITEONLY_BITS         0x2004  /* Bits 13, 2 */
1272
1273 /* For control registers, both ignored and reserved bits must be preserved */
1274
1275 /*
1276  * For PM1 control, the SCI enable bit (bit 0, SCI_EN) is defined by the
1277  * ACPI specification to be a "preserved" bit - "OSPM always preserves this
1278  * bit position", section 4.7.3.2.1. However, on some machines the OS must
1279  * write a one to this bit after resume for the machine to work properly.
1280  * To enable this, we no longer attempt to preserve this bit. No machines
1281  * are known to fail if the bit is not preserved. (May 2009)
1282  */
1283 #define ACPI_PM1_CONTROL_IGNORED_BITS           0x0200  /* Bit 9 */
1284 #define ACPI_PM1_CONTROL_RESERVED_BITS          0xC1F8  /* Bits 14-15, 3-8 */
1285 #define ACPI_PM1_CONTROL_PRESERVED_BITS \
1286          (ACPI_PM1_CONTROL_IGNORED_BITS | ACPI_PM1_CONTROL_RESERVED_BITS)
1287
1288 #define ACPI_PM2_CONTROL_PRESERVED_BITS         0xFFFFFFFE /* All except bit 0 */
1289
1290 /*
1291  * Register IDs
1292  * These are the full ACPI registers
1293  */
1294 #define ACPI_REGISTER_PM1_STATUS                0x01
1295 #define ACPI_REGISTER_PM1_ENABLE                0x02
1296 #define ACPI_REGISTER_PM1_CONTROL               0x03
1297 #define ACPI_REGISTER_PM2_CONTROL               0x04
1298 #define ACPI_REGISTER_PM_TIMER                  0x05
1299 #define ACPI_REGISTER_PROCESSOR_BLOCK           0x06
1300 #define ACPI_REGISTER_SMI_COMMAND_BLOCK         0x07
1301
1302
1303 /* Masks used to access the BitRegisters */
1304
1305 #define ACPI_BITMASK_TIMER_STATUS               0x0001
1306 #define ACPI_BITMASK_BUS_MASTER_STATUS          0x0010
1307 #define ACPI_BITMASK_GLOBAL_LOCK_STATUS         0x0020
1308 #define ACPI_BITMASK_POWER_BUTTON_STATUS        0x0100
1309 #define ACPI_BITMASK_SLEEP_BUTTON_STATUS        0x0200
1310 #define ACPI_BITMASK_RT_CLOCK_STATUS            0x0400
1311 #define ACPI_BITMASK_PCIEXP_WAKE_STATUS         0x4000    /* ACPI 3.0 */
1312 #define ACPI_BITMASK_WAKE_STATUS                0x8000
1313
1314 #define ACPI_BITMASK_ALL_FIXED_STATUS           (\
1315     ACPI_BITMASK_TIMER_STATUS          | \
1316     ACPI_BITMASK_BUS_MASTER_STATUS     | \
1317     ACPI_BITMASK_GLOBAL_LOCK_STATUS    | \
1318     ACPI_BITMASK_POWER_BUTTON_STATUS   | \
1319     ACPI_BITMASK_SLEEP_BUTTON_STATUS   | \
1320     ACPI_BITMASK_RT_CLOCK_STATUS       | \
1321     ACPI_BITMASK_PCIEXP_WAKE_STATUS    | \
1322     ACPI_BITMASK_WAKE_STATUS)
1323
1324 #define ACPI_BITMASK_TIMER_ENABLE               0x0001
1325 #define ACPI_BITMASK_GLOBAL_LOCK_ENABLE         0x0020
1326 #define ACPI_BITMASK_POWER_BUTTON_ENABLE        0x0100
1327 #define ACPI_BITMASK_SLEEP_BUTTON_ENABLE        0x0200
1328 #define ACPI_BITMASK_RT_CLOCK_ENABLE            0x0400
1329 #define ACPI_BITMASK_PCIEXP_WAKE_DISABLE        0x4000    /* ACPI 3.0 */
1330
1331 #define ACPI_BITMASK_SCI_ENABLE                 0x0001
1332 #define ACPI_BITMASK_BUS_MASTER_RLD             0x0002
1333 #define ACPI_BITMASK_GLOBAL_LOCK_RELEASE        0x0004
1334 #define ACPI_BITMASK_SLEEP_TYPE                 0x1C00
1335 #define ACPI_BITMASK_SLEEP_ENABLE               0x2000
1336
1337 #define ACPI_BITMASK_ARB_DISABLE                0x0001
1338
1339
1340 /* Raw bit position of each BitRegister */
1341
1342 #define ACPI_BITPOSITION_TIMER_STATUS           0x00
1343 #define ACPI_BITPOSITION_BUS_MASTER_STATUS      0x04
1344 #define ACPI_BITPOSITION_GLOBAL_LOCK_STATUS     0x05
1345 #define ACPI_BITPOSITION_POWER_BUTTON_STATUS    0x08
1346 #define ACPI_BITPOSITION_SLEEP_BUTTON_STATUS    0x09
1347 #define ACPI_BITPOSITION_RT_CLOCK_STATUS        0x0A
1348 #define ACPI_BITPOSITION_PCIEXP_WAKE_STATUS     0x0E    /* ACPI 3.0 */
1349 #define ACPI_BITPOSITION_WAKE_STATUS            0x0F
1350
1351 #define ACPI_BITPOSITION_TIMER_ENABLE           0x00
1352 #define ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE     0x05
1353 #define ACPI_BITPOSITION_POWER_BUTTON_ENABLE    0x08
1354 #define ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE    0x09
1355 #define ACPI_BITPOSITION_RT_CLOCK_ENABLE        0x0A
1356 #define ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE    0x0E    /* ACPI 3.0 */
1357
1358 #define ACPI_BITPOSITION_SCI_ENABLE             0x00
1359 #define ACPI_BITPOSITION_BUS_MASTER_RLD         0x01
1360 #define ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE    0x02
1361 #define ACPI_BITPOSITION_SLEEP_TYPE             0x0A
1362 #define ACPI_BITPOSITION_SLEEP_ENABLE           0x0D
1363
1364 #define ACPI_BITPOSITION_ARB_DISABLE            0x00
1365
1366
1367 /* Structs and definitions for _OSI support and I/O port validation */
1368
1369 #define ACPI_ALWAYS_ILLEGAL             0x00
1370
1371 typedef struct acpi_interface_info
1372 {
1373     char                        *Name;
1374     struct acpi_interface_info  *Next;
1375     UINT8                       Flags;
1376     UINT8                       Value;
1377
1378 } ACPI_INTERFACE_INFO;
1379
1380 #define ACPI_OSI_INVALID                0x01
1381 #define ACPI_OSI_DYNAMIC                0x02
1382 #define ACPI_OSI_FEATURE                0x04
1383 #define ACPI_OSI_DEFAULT_INVALID        0x08
1384 #define ACPI_OSI_OPTIONAL_FEATURE       (ACPI_OSI_FEATURE | ACPI_OSI_DEFAULT_INVALID | ACPI_OSI_INVALID)
1385
1386 typedef struct acpi_port_info
1387 {
1388     char                    *Name;
1389     UINT16                  Start;
1390     UINT16                  End;
1391     UINT8                   OsiDependency;
1392
1393 } ACPI_PORT_INFO;
1394
1395
1396 /*****************************************************************************
1397  *
1398  * Resource descriptors
1399  *
1400  ****************************************************************************/
1401
1402 /* ResourceType values */
1403
1404 #define ACPI_ADDRESS_TYPE_MEMORY_RANGE          0
1405 #define ACPI_ADDRESS_TYPE_IO_RANGE              1
1406 #define ACPI_ADDRESS_TYPE_BUS_NUMBER_RANGE      2
1407
1408 /* Resource descriptor types and masks */
1409
1410 #define ACPI_RESOURCE_NAME_LARGE                0x80
1411 #define ACPI_RESOURCE_NAME_SMALL                0x00
1412
1413 #define ACPI_RESOURCE_NAME_SMALL_MASK           0x78 /* Bits 6:3 contain the type */
1414 #define ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK    0x07 /* Bits 2:0 contain the length */
1415 #define ACPI_RESOURCE_NAME_LARGE_MASK           0x7F /* Bits 6:0 contain the type */
1416
1417
1418 /*
1419  * Small resource descriptor "names" as defined by the ACPI specification.
1420  * Note: Bits 2:0 are used for the descriptor length
1421  */
1422 #define ACPI_RESOURCE_NAME_IRQ                  0x20
1423 #define ACPI_RESOURCE_NAME_DMA                  0x28
1424 #define ACPI_RESOURCE_NAME_START_DEPENDENT      0x30
1425 #define ACPI_RESOURCE_NAME_END_DEPENDENT        0x38
1426 #define ACPI_RESOURCE_NAME_IO                   0x40
1427 #define ACPI_RESOURCE_NAME_FIXED_IO             0x48
1428 #define ACPI_RESOURCE_NAME_FIXED_DMA            0x50
1429 #define ACPI_RESOURCE_NAME_RESERVED_S2          0x58
1430 #define ACPI_RESOURCE_NAME_RESERVED_S3          0x60
1431 #define ACPI_RESOURCE_NAME_RESERVED_S4          0x68
1432 #define ACPI_RESOURCE_NAME_VENDOR_SMALL         0x70
1433 #define ACPI_RESOURCE_NAME_END_TAG              0x78
1434
1435 /*
1436  * Large resource descriptor "names" as defined by the ACPI specification.
1437  * Note: includes the Large Descriptor bit in bit[7]
1438  */
1439 #define ACPI_RESOURCE_NAME_MEMORY24             0x81
1440 #define ACPI_RESOURCE_NAME_GENERIC_REGISTER     0x82
1441 #define ACPI_RESOURCE_NAME_RESERVED_L1          0x83
1442 #define ACPI_RESOURCE_NAME_VENDOR_LARGE         0x84
1443 #define ACPI_RESOURCE_NAME_MEMORY32             0x85
1444 #define ACPI_RESOURCE_NAME_FIXED_MEMORY32       0x86
1445 #define ACPI_RESOURCE_NAME_ADDRESS32            0x87
1446 #define ACPI_RESOURCE_NAME_ADDRESS16            0x88
1447 #define ACPI_RESOURCE_NAME_EXTENDED_IRQ         0x89
1448 #define ACPI_RESOURCE_NAME_ADDRESS64            0x8A
1449 #define ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64   0x8B
1450 #define ACPI_RESOURCE_NAME_GPIO                 0x8C
1451 #define ACPI_RESOURCE_NAME_PIN_FUNCTION         0x8D
1452 #define ACPI_RESOURCE_NAME_SERIAL_BUS           0x8E
1453 #define ACPI_RESOURCE_NAME_PIN_CONFIG           0x8F
1454 #define ACPI_RESOURCE_NAME_PIN_GROUP            0x90
1455 #define ACPI_RESOURCE_NAME_PIN_GROUP_FUNCTION   0x91
1456 #define ACPI_RESOURCE_NAME_PIN_GROUP_CONFIG     0x92
1457 #define ACPI_RESOURCE_NAME_LARGE_MAX            0x92
1458
1459
1460 /*****************************************************************************
1461  *
1462  * Miscellaneous
1463  *
1464  ****************************************************************************/
1465
1466 #define ACPI_ASCII_ZERO                 0x30
1467
1468
1469 /*****************************************************************************
1470  *
1471  * Disassembler
1472  *
1473  ****************************************************************************/
1474
1475 typedef struct acpi_external_list
1476 {
1477     char                        *Path;
1478     char                        *InternalPath;
1479     struct acpi_external_list   *Next;
1480     UINT32                      Value;
1481     UINT16                      Length;
1482     UINT16                      Flags;
1483     UINT8                       Type;
1484
1485 } ACPI_EXTERNAL_LIST;
1486
1487 /* Values for Flags field above */
1488
1489 #define ACPI_EXT_RESOLVED_REFERENCE         0x01    /* Object was resolved during cross ref */
1490 #define ACPI_EXT_ORIGIN_FROM_FILE           0x02    /* External came from a file */
1491 #define ACPI_EXT_INTERNAL_PATH_ALLOCATED    0x04    /* Deallocate internal path on completion */
1492 #define ACPI_EXT_EXTERNAL_EMITTED           0x08    /* External() statement has been emitted */
1493 #define ACPI_EXT_ORIGIN_FROM_OPCODE         0x10    /* External came from a External() opcode */
1494 #define ACPI_EXT_CONFLICTING_DECLARATION    0x20    /* External has a conflicting declaration within AML */
1495
1496
1497 typedef struct acpi_external_file
1498 {
1499     char                        *Path;
1500     struct acpi_external_file   *Next;
1501
1502 } ACPI_EXTERNAL_FILE;
1503
1504
1505 typedef struct acpi_parse_object_list
1506 {
1507     ACPI_PARSE_OBJECT               *Op;
1508     struct acpi_parse_object_list   *Next;
1509
1510 } ACPI_PARSE_OBJECT_LIST;
1511
1512 /*****************************************************************************
1513  *
1514  * Debugger
1515  *
1516  ****************************************************************************/
1517
1518 typedef struct acpi_db_method_info
1519 {
1520     ACPI_HANDLE                     Method;
1521     ACPI_HANDLE                     MainThreadGate;
1522     ACPI_HANDLE                     ThreadCompleteGate;
1523     ACPI_HANDLE                     InfoGate;
1524     ACPI_THREAD_ID                  *Threads;
1525     UINT32                          NumThreads;
1526     UINT32                          NumCreated;
1527     UINT32                          NumCompleted;
1528
1529     char                            *Name;
1530     UINT32                          Flags;
1531     UINT32                          NumLoops;
1532     char                            Pathname[ACPI_DB_LINE_BUFFER_SIZE];
1533     char                            **Args;
1534     ACPI_OBJECT_TYPE                *Types;
1535
1536     /*
1537      * Arguments to be passed to method for the commands Threads and
1538      * Background. Note, ACPI specifies a maximum of 7 arguments (0 - 6).
1539      *
1540      * For the Threads command, the Number of threads, ID of current
1541      * thread and Index of current thread inside all them created.
1542      */
1543     char                            InitArgs;
1544 #ifdef ACPI_DEBUGGER
1545     ACPI_OBJECT_TYPE                ArgTypes[ACPI_METHOD_NUM_ARGS];
1546 #endif
1547     char                            *Arguments[ACPI_METHOD_NUM_ARGS];
1548     char                            NumThreadsStr[11];
1549     char                            IdOfThreadStr[11];
1550     char                            IndexOfThreadStr[11];
1551
1552 } ACPI_DB_METHOD_INFO;
1553
1554 typedef struct acpi_integrity_info
1555 {
1556     UINT32                          Nodes;
1557     UINT32                          Objects;
1558
1559 } ACPI_INTEGRITY_INFO;
1560
1561
1562 #define ACPI_DB_DISABLE_OUTPUT          0x00
1563 #define ACPI_DB_REDIRECTABLE_OUTPUT     0x01
1564 #define ACPI_DB_CONSOLE_OUTPUT          0x02
1565 #define ACPI_DB_DUPLICATE_OUTPUT        0x03
1566
1567
1568 typedef struct acpi_object_info
1569 {
1570     UINT32                  Types[ACPI_TOTAL_TYPES];
1571
1572 } ACPI_OBJECT_INFO;
1573
1574
1575 /*****************************************************************************
1576  *
1577  * Debug
1578  *
1579  ****************************************************************************/
1580
1581 /* Entry for a memory allocation (debug only) */
1582
1583 #define ACPI_MEM_MALLOC                 0
1584 #define ACPI_MEM_CALLOC                 1
1585 #define ACPI_MAX_MODULE_NAME            16
1586
1587 #define ACPI_COMMON_DEBUG_MEM_HEADER \
1588     struct acpi_debug_mem_block     *Previous; \
1589     struct acpi_debug_mem_block     *Next; \
1590     UINT32                          Size; \
1591     UINT32                          Component; \
1592     UINT32                          Line; \
1593     char                            Module[ACPI_MAX_MODULE_NAME]; \
1594     UINT8                           AllocType;
1595
1596 typedef struct acpi_debug_mem_header
1597 {
1598     ACPI_COMMON_DEBUG_MEM_HEADER
1599
1600 } ACPI_DEBUG_MEM_HEADER;
1601
1602 typedef struct acpi_debug_mem_block
1603 {
1604     ACPI_COMMON_DEBUG_MEM_HEADER
1605     UINT64                          UserSpace;
1606
1607 } ACPI_DEBUG_MEM_BLOCK;
1608
1609
1610 #define ACPI_MEM_LIST_GLOBAL            0
1611 #define ACPI_MEM_LIST_NSNODE            1
1612 #define ACPI_MEM_LIST_MAX               1
1613 #define ACPI_NUM_MEM_LISTS              2
1614
1615
1616 /*****************************************************************************
1617  *
1618  * Info/help support
1619  *
1620  ****************************************************************************/
1621
1622 typedef struct ah_predefined_name
1623 {
1624     char            *Name;
1625     char            *Description;
1626 #ifndef ACPI_ASL_COMPILER
1627     char            *Action;
1628 #endif
1629
1630 } AH_PREDEFINED_NAME;
1631
1632 typedef struct ah_device_id
1633 {
1634     char            *Name;
1635     char            *Description;
1636
1637 } AH_DEVICE_ID;
1638
1639 typedef struct ah_uuid
1640 {
1641     char            *Description;
1642     char            *String;
1643
1644 } AH_UUID;
1645
1646 typedef struct ah_table
1647 {
1648     char                    *Signature;
1649     char                    *Description;
1650
1651 } AH_TABLE;
1652
1653 #endif /* __ACLOCAL_H__ */