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