]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/contrib/dev/acpica/aclocal.h
Vendor import of the Intel ACPI CA 20010816 update.
[FreeBSD/FreeBSD.git] / sys / contrib / dev / acpica / aclocal.h
1 /******************************************************************************
2  *
3  * Name: aclocal.h - Internal data types used across the ACPI subsystem
4  *       $Revision: 127 $
5  *
6  *****************************************************************************/
7
8 /******************************************************************************
9  *
10  * 1. Copyright Notice
11  *
12  * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
13  * All rights reserved.
14  *
15  * 2. License
16  *
17  * 2.1. This is your license from Intel Corp. under its intellectual property
18  * rights.  You may have additional license terms from the party that provided
19  * you this software, covering your right to use that party's intellectual
20  * property rights.
21  *
22  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23  * copy of the source code appearing in this file ("Covered Code") an
24  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25  * base code distributed originally by Intel ("Original Intel Code") to copy,
26  * make derivatives, distribute, use and display any portion of the Covered
27  * Code in any form, with the right to sublicense such rights; and
28  *
29  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30  * license (with the right to sublicense), under only those claims of Intel
31  * patents that are infringed by the Original Intel Code, to make, use, sell,
32  * offer to sell, and import the Covered Code and derivative works thereof
33  * solely to the minimum extent necessary to exercise the above copyright
34  * license, and in no event shall the patent license extend to any additions
35  * to or modifications of the Original Intel Code.  No other license or right
36  * is granted directly or by implication, estoppel or otherwise;
37  *
38  * The above copyright and patent license is granted only if the following
39  * conditions are met:
40  *
41  * 3. Conditions
42  *
43  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44  * Redistribution of source code of any substantial portion of the Covered
45  * Code or modification with rights to further distribute source must include
46  * the above Copyright Notice, the above License, this list of Conditions,
47  * and the following Disclaimer and Export Compliance provision.  In addition,
48  * Licensee must cause all Covered Code to which Licensee contributes to
49  * contain a file documenting the changes Licensee made to create that Covered
50  * Code and the date of any change.  Licensee must include in that file the
51  * documentation of any changes made by any predecessor Licensee.  Licensee
52  * must include a prominent statement that the modification is derived,
53  * directly or indirectly, from Original Intel Code.
54  *
55  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56  * Redistribution of source code of any substantial portion of the Covered
57  * Code or modification without rights to further distribute source must
58  * include the following Disclaimer and Export Compliance provision in the
59  * documentation and/or other materials provided with distribution.  In
60  * addition, Licensee may not authorize further sublicense of source of any
61  * portion of the Covered Code, and must include terms to the effect that the
62  * license from Licensee to its licensee is limited to the intellectual
63  * property embodied in the software Licensee provides to its licensee, and
64  * not to intellectual property embodied in modifications its licensee may
65  * make.
66  *
67  * 3.3. Redistribution of Executable. Redistribution in executable form of any
68  * substantial portion of the Covered Code or modification must reproduce the
69  * above Copyright Notice, and the following Disclaimer and Export Compliance
70  * provision in the documentation and/or other materials provided with the
71  * distribution.
72  *
73  * 3.4. Intel retains all right, title, and interest in and to the Original
74  * Intel Code.
75  *
76  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77  * Intel shall be used in advertising or otherwise to promote the sale, use or
78  * other dealings in products derived from or relating to the Covered Code
79  * without prior written authorization from Intel.
80  *
81  * 4. Disclaimer and Export Compliance
82  *
83  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
86  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
87  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
88  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89  * PARTICULAR PURPOSE.
90  *
91  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
97  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98  * LIMITED REMEDY.
99  *
100  * 4.3. Licensee shall not export, either directly or indirectly, any of this
101  * software or system incorporating such software without first obtaining any
102  * required license or other approval from the U. S. Department of Commerce or
103  * any other agency or department of the United States Government.  In the
104  * event Licensee exports any such software from the United States or
105  * re-exports any such software from a foreign destination, Licensee shall
106  * ensure that the distribution and export/re-export of the software is in
107  * compliance with all laws, regulations, orders, or other restrictions of the
108  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109  * any of its subsidiaries will export/re-export any technical data, process,
110  * software, or service, directly or indirectly, to any country for which the
111  * United States government or any agency thereof requires an export license,
112  * other governmental approval, or letter of assurance, without first obtaining
113  * such license, approval or letter.
114  *
115  *****************************************************************************/
116
117 #ifndef __ACLOCAL_H__
118 #define __ACLOCAL_H__
119
120
121 #define WAIT_FOREVER                    ((UINT32) -1)
122
123 typedef void*                           ACPI_MUTEX;
124 typedef UINT32                          ACPI_MUTEX_HANDLE;
125
126
127
128 #define ACPI_MEMORY_MODE                0x01
129 #define ACPI_LOGICAL_ADDRESSING         0x00
130 #define ACPI_PHYSICAL_ADDRESSING        0x01
131
132 /* Object descriptor types */
133
134 #define ACPI_CACHED_OBJECT              0x11    /* ORed in when object is cached */
135 #define ACPI_DESC_TYPE_STATE            0x22
136 #define ACPI_DESC_TYPE_WALK             0x44
137 #define ACPI_DESC_TYPE_PARSER           0x66
138 #define ACPI_DESC_TYPE_INTERNAL         0x88
139 #define ACPI_DESC_TYPE_NAMED            0xAA
140
141
142 /*****************************************************************************
143  *
144  * Mutex typedefs and structs
145  *
146  ****************************************************************************/
147
148
149 /*
150  * Predefined handles for the mutex objects used within the subsystem
151  * All mutex objects are automatically created by AcpiUtMutexInitialize.
152  *
153  * The acquire/release ordering protocol is implied via this list.  Mutexes
154  * with a lower value must be acquired before mutexes with a higher value.
155  *
156  * NOTE: any changes here must be reflected in the AcpiGbl_MutexNames table also!
157  */
158
159 #define ACPI_MTX_EXECUTE                0
160 #define ACPI_MTX_INTERPRETER            1
161 #define ACPI_MTX_PARSER                 2
162 #define ACPI_MTX_DISPATCHER             3
163 #define ACPI_MTX_TABLES                 4
164 #define ACPI_MTX_OP_REGIONS             5
165 #define ACPI_MTX_NAMESPACE              6
166 #define ACPI_MTX_EVENTS                 7
167 #define ACPI_MTX_HARDWARE               8
168 #define ACPI_MTX_CACHES                 9
169 #define ACPI_MTX_MEMORY                 10
170 #define ACPI_MTX_DEBUG_CMD_COMPLETE     11
171 #define ACPI_MTX_DEBUG_CMD_READY        12
172
173 #define MAX_MTX                         12
174 #define NUM_MTX                         MAX_MTX+1
175
176
177 #if defined(ACPI_DEBUG) || defined(ENABLE_DEBUGGER)
178 #ifdef DEFINE_ACPI_GLOBALS
179
180 /* Names for the mutexes used in the subsystem */
181
182 static NATIVE_CHAR          *AcpiGbl_MutexNames[] =
183 {
184     "ACPI_MTX_Execute",
185     "ACPI_MTX_Interpreter",
186     "ACPI_MTX_Parser",
187     "ACPI_MTX_Dispatcher",
188     "ACPI_MTX_Tables",
189     "ACPI_MTX_OpRegions",
190     "ACPI_MTX_Namespace",
191     "ACPI_MTX_Events",
192     "ACPI_MTX_Hardware",
193     "ACPI_MTX_Caches",
194     "ACPI_MTX_Memory",
195     "ACPI_MTX_DebugCmdComplete",
196     "ACPI_MTX_DebugCmdReady",
197 };
198
199 #endif
200 #endif
201
202
203 /* Table for the global mutexes */
204
205 typedef struct AcpiMutexInfo
206 {
207     ACPI_MUTEX                  Mutex;
208     UINT32                      UseCount;
209     UINT32                      OwnerId;
210
211 } ACPI_MUTEX_INFO;
212
213 /* This owner ID means that the mutex is not in use (unlocked) */
214
215 #define ACPI_MUTEX_NOT_ACQUIRED         (UINT32) (-1)
216
217
218 /* Lock flag parameter for various interfaces */
219
220 #define ACPI_MTX_DO_NOT_LOCK            0
221 #define ACPI_MTX_LOCK                   1
222
223
224 typedef UINT16                          ACPI_OWNER_ID;
225 #define OWNER_TYPE_TABLE                0x0
226 #define OWNER_TYPE_METHOD               0x1
227 #define FIRST_METHOD_ID                 0x0000
228 #define FIRST_TABLE_ID                  0x8000
229
230 /* TBD: [Restructure] get rid of the need for this! */
231
232 #define TABLE_ID_DSDT                   (ACPI_OWNER_ID) 0x8000
233
234
235 /* Field access granularities */
236
237 #define ACPI_FIELD_BYTE_GRANULARITY     1
238 #define ACPI_FIELD_WORD_GRANULARITY     2
239 #define ACPI_FIELD_DWORD_GRANULARITY    4
240 #define ACPI_FIELD_QWORD_GRANULARITY    8
241
242 /*****************************************************************************
243  *
244  * Namespace typedefs and structs
245  *
246  ****************************************************************************/
247
248
249 /* Operational modes of the AML interpreter/scanner */
250
251 typedef enum
252 {
253     IMODE_LOAD_PASS1                = 0x01,
254     IMODE_LOAD_PASS2                = 0x02,
255     IMODE_EXECUTE                   = 0x0E
256
257 } OPERATING_MODE;
258
259
260 /*
261  * The Node describes a named object that appears in the AML
262  * An AcpiNode is used to store Nodes.
263  *
264  * DataType is used to differentiate between internal descriptors, and MUST
265  * be the first byte in this structure.
266  */
267
268 typedef struct acpi_node
269 {
270     UINT8                   DataType;
271     UINT8                   Type;           /* Type associated with this name */
272     UINT16                  OwnerId;
273     UINT32                  Name;           /* ACPI Name, always 4 chars per ACPI spec */
274
275
276     void                    *Object;        /* Pointer to attached ACPI object (optional) */
277     struct acpi_node        *Child;         /* first child */
278     struct acpi_node        *Peer;          /* Next peer*/
279     UINT16                  ReferenceCount; /* Current count of references and children */
280     UINT8                   Flags;
281
282 } ACPI_NAMESPACE_NODE;
283
284
285 #define ENTRY_NOT_FOUND             NULL
286
287
288 /* Node flags */
289
290 #define ANOBJ_AML_ATTACHMENT            0x01
291 #define ANOBJ_END_OF_PEER_LIST          0x02
292 #define ANOBJ_DATA_WIDTH_32             0x04     /* Parent table is 64-bits */
293 #define ANOBJ_METHOD_ARG                0x08
294 #define ANOBJ_METHOD_LOCAL              0x10
295 #define ANOBJ_METHOD_NO_RETVAL          0x20
296 #define ANOBJ_METHOD_SOME_NO_RETVAL     0x40
297
298 #define ANOBJ_IS_BIT_OFFSET             0x80
299
300
301 /*
302  * ACPI Table Descriptor.  One per ACPI table
303  */
304 typedef struct AcpiTableDesc
305 {
306     struct AcpiTableDesc    *Prev;
307     struct AcpiTableDesc    *Next;
308     struct AcpiTableDesc    *InstalledDesc;
309     ACPI_TABLE_HEADER       *Pointer;
310     void                    *BasePointer;
311     UINT8                   *AmlPointer;
312     UINT64                  PhysicalAddress;
313     UINT32                  AmlLength;
314     UINT32                  Length;
315     UINT32                  Count;
316     ACPI_OWNER_ID           TableId;
317     UINT8                   Type;
318     UINT8                   Allocation;
319     BOOLEAN                 LoadedIntoNamespace;
320
321 } ACPI_TABLE_DESC;
322
323
324 typedef struct
325 {
326     NATIVE_CHAR             *SearchFor;
327     ACPI_HANDLE             *List;
328     UINT32                  *Count;
329
330 } FIND_CONTEXT;
331
332
333 typedef struct
334 {
335     ACPI_NAMESPACE_NODE     *Node;
336 } NS_SEARCH_DATA;
337
338
339 /*
340  * Predefined Namespace items
341  */
342 typedef struct
343 {
344     NATIVE_CHAR             *Name;
345     ACPI_OBJECT_TYPE8       Type;
346     NATIVE_CHAR             *Val;
347
348 } PREDEFINED_NAMES;
349
350
351 /* Object types used during package copies */
352
353
354 #define ACPI_COPY_TYPE_SIMPLE           0
355 #define ACPI_COPY_TYPE_PACKAGE          1
356
357 /* Info structure used to convert external<->internal namestrings */
358
359 typedef struct acpi_namestring_info
360 {
361     NATIVE_CHAR             *ExternalName;
362     NATIVE_CHAR             *NextExternalChar;
363     NATIVE_CHAR             *InternalName;
364     UINT32                  Length;
365     UINT32                  NumSegments;
366     UINT32                  NumCarats;
367     BOOLEAN                 FullyQualified;
368
369 } ACPI_NAMESTRING_INFO;
370
371
372 /*****************************************************************************
373  *
374  * Event typedefs and structs
375  *
376  ****************************************************************************/
377
378
379 /* Status bits. */
380
381 #define ACPI_STATUS_PMTIMER             0x0001
382 #define ACPI_STATUS_BUSMASTER           0x0010
383 #define ACPI_STATUS_GLOBAL              0x0020
384 #define ACPI_STATUS_POWER_BUTTON        0x0100
385 #define ACPI_STATUS_SLEEP_BUTTON        0x0200
386 #define ACPI_STATUS_RTC_ALARM           0x0400
387
388 /* Enable bits. */
389
390 #define ACPI_ENABLE_PMTIMER             0x0001
391 #define ACPI_ENABLE_GLOBAL              0x0020
392 #define ACPI_ENABLE_POWER_BUTTON        0x0100
393 #define ACPI_ENABLE_SLEEP_BUTTON        0x0200
394 #define ACPI_ENABLE_RTC_ALARM           0x0400
395
396
397 /*
398  * Entry in the AddressSpace (AKA Operation Region) table
399  */
400
401 typedef struct
402 {
403     ACPI_ADR_SPACE_HANDLER  Handler;
404     void                    *Context;
405
406 } ACPI_ADR_SPACE_INFO;
407
408
409 /* Values and addresses of the GPE registers (both banks) */
410
411 typedef struct
412 {
413     UINT8                   Status;         /* Current value of status reg */
414     UINT8                   Enable;         /* Current value of enable reg */
415     UINT16                  StatusAddr;     /* Address of status reg */
416     UINT16                  EnableAddr;     /* Address of enable reg */
417     UINT8                   GpeBase;        /* Base GPE number */
418
419 } ACPI_GPE_REGISTERS;
420
421
422 #define ACPI_GPE_LEVEL_TRIGGERED        1
423 #define ACPI_GPE_EDGE_TRIGGERED         2
424
425
426 /* Information about each particular GPE level */
427
428 typedef struct
429 {
430     UINT8                   Type;           /* Level or Edge */
431
432     ACPI_HANDLE             MethodHandle;   /* Method handle for direct (fast) execution */
433     ACPI_GPE_HANDLER        Handler;        /* Address of handler, if any */
434     void                    *Context;       /* Context to be passed to handler */
435
436 } ACPI_GPE_LEVEL_INFO;
437
438
439 /* Information about each particular fixed event */
440
441 typedef struct
442 {
443     ACPI_EVENT_HANDLER      Handler;        /* Address of handler. */
444     void                    *Context;       /* Context to be passed to handler */
445
446 } ACPI_FIXED_EVENT_INFO;
447
448
449 /* Information used during field processing */
450
451 typedef struct
452 {
453     UINT8                   SkipField;
454     UINT8                   FieldFlag;
455     UINT32                  PkgLength;
456
457 } ACPI_FIELD_INFO;
458
459
460 /*****************************************************************************
461  *
462  * Generic "state" object for stacks
463  *
464  ****************************************************************************/
465
466
467 #define CONTROL_NORMAL                  0xC0
468 #define CONTROL_CONDITIONAL_EXECUTING   0xC1
469 #define CONTROL_PREDICATE_EXECUTING     0xC2
470 #define CONTROL_PREDICATE_FALSE         0xC3
471 #define CONTROL_PREDICATE_TRUE          0xC4
472
473
474 /* Forward declarations */
475 struct acpi_walk_state;
476 struct acpi_walk_list;
477 struct acpi_parse_obj;
478 struct acpi_obj_mutex;
479
480
481 #define ACPI_STATE_COMMON                  /* Two 32-bit fields and a pointer */\
482     UINT8                   DataType;           /* To differentiate various internal objs */\
483     UINT8                   Flags; \
484     UINT16                  Value; \
485     UINT16                  State; \
486     UINT16                  AcpiEval;  \
487     void                    *Next; \
488
489 typedef struct acpi_common_state
490 {
491     ACPI_STATE_COMMON
492 } ACPI_COMMON_STATE;
493
494
495 /*
496  * Update state - used to traverse complex objects such as packages
497  */
498 typedef struct acpi_update_state
499 {
500     ACPI_STATE_COMMON
501     union acpi_operand_obj  *Object;
502
503 } ACPI_UPDATE_STATE;
504
505
506 /*
507  * Pkg state - used to traverse nested package structures
508  */
509 typedef struct acpi_pkg_state
510 {
511     ACPI_STATE_COMMON
512     union acpi_operand_obj  *SourceObject;
513     union acpi_operand_obj  *DestObject;
514     struct acpi_walk_state  *WalkState;
515     void                    *ThisTargetObj;
516     UINT32                  NumPackages;
517     UINT16                  Index;
518
519 } ACPI_PKG_STATE;
520
521
522 /*
523  * Control state - one per if/else and while constructs.
524  * Allows nesting of these constructs
525  */
526 typedef struct acpi_control_state
527 {
528     ACPI_STATE_COMMON
529     struct acpi_parse_obj   *PredicateOp;
530     UINT8                   *AmlPredicateStart;   /* Start of if/while predicate */
531
532 } ACPI_CONTROL_STATE;
533
534
535 /*
536  * Scope state - current scope during namespace lookups
537  */
538 typedef struct acpi_scope_state
539 {
540     ACPI_STATE_COMMON
541     ACPI_NAMESPACE_NODE     *Node;
542
543 } ACPI_SCOPE_STATE;
544
545
546 typedef struct acpi_pscope_state
547 {
548     ACPI_STATE_COMMON
549     struct acpi_parse_obj   *Op;            /* current op being parsed */
550     UINT8                   *ArgEnd;        /* current argument end */
551     UINT8                   *PkgEnd;        /* current package end */
552     UINT32                  ArgList;        /* next argument to parse */
553     UINT32                  ArgCount;       /* Number of fixed arguments */
554
555 } ACPI_PSCOPE_STATE;
556
557
558 /*
559  * Result values - used to accumulate the results of nested
560  * AML arguments
561  */
562 typedef struct acpi_result_values
563 {
564     ACPI_STATE_COMMON
565     union acpi_operand_obj  *ObjDesc [OBJ_NUM_OPERANDS];
566     UINT8                   NumResults;
567     UINT8                   LastInsert;
568
569 } ACPI_RESULT_VALUES;
570
571
572 /*
573  * Notify info - used to pass info to the deferred notify
574  * handler/dispatcher.
575  */
576 typedef struct acpi_notify_info
577 {
578     ACPI_STATE_COMMON
579     ACPI_NAMESPACE_NODE     *Node;
580     union acpi_operand_obj  *HandlerObj;
581
582 } ACPI_NOTIFY_INFO;
583
584
585 /* Generic state is union of structs above */
586
587 typedef union acpi_gen_state
588 {
589     ACPI_COMMON_STATE       Common;
590     ACPI_CONTROL_STATE      Control;
591     ACPI_UPDATE_STATE       Update;
592     ACPI_SCOPE_STATE        Scope;
593     ACPI_PSCOPE_STATE       ParseScope;
594     ACPI_PKG_STATE          Pkg;
595     ACPI_RESULT_VALUES      Results;
596     ACPI_NOTIFY_INFO        Notify;
597
598 } ACPI_GENERIC_STATE;
599
600
601 typedef
602 ACPI_STATUS (*ACPI_PARSE_DOWNWARDS) (
603     UINT16                  Opcode,
604     struct acpi_parse_obj   *Op,
605     struct acpi_walk_state  *WalkState,
606     struct acpi_parse_obj   **OutOp);
607
608 typedef
609 ACPI_STATUS (*ACPI_PARSE_UPWARDS) (
610     struct acpi_walk_state  *WalkState,
611     struct acpi_parse_obj   *Op);
612
613
614 /*****************************************************************************
615  *
616  * Parser typedefs and structs
617  *
618  ****************************************************************************/
619
620 #define ACPI_OP_CLASS_MASK              0x1F
621 #define ACPI_OP_ARGS_MASK               0x20
622 #define ACPI_OP_TYPE_MASK               0xC0
623
624 #define ACPI_OP_TYPE_OPCODE             0x00
625 #define ACPI_OP_TYPE_ASCII              0x40
626 #define ACPI_OP_TYPE_PREFIX             0x80
627 #define ACPI_OP_TYPE_UNKNOWN            0xC0
628
629 #define ACPI_GET_OP_CLASS(a)            ((a)->Flags & ACPI_OP_CLASS_MASK)
630 #define ACPI_GET_OP_ARGS(a)             ((a)->Flags & ACPI_OP_ARGS_MASK)
631 #define ACPI_GET_OP_TYPE(a)             ((a)->Flags & ACPI_OP_TYPE_MASK)
632
633
634 /*
635  * AML opcode, name, and argument layout
636  */
637 typedef struct acpi_opcode_info
638 {
639     UINT8                   Flags;          /* Opcode type, HasArgs flag */
640     UINT32                  ParseArgs;      /* Grammar/Parse time arguments */
641     UINT32                  RuntimeArgs;    /* Interpret time arguments */
642
643 #ifdef _OPCODE_NAMES
644     NATIVE_CHAR             *Name;          /* op name (debug only) */
645 #endif
646
647 } ACPI_OPCODE_INFO;
648
649
650 typedef union acpi_parse_val
651 {
652     ACPI_INTEGER            Integer;        /* integer constant (Up to 64 bits) */
653     UINT64_STRUCT           Integer64;      /* Structure overlay for 2 32-bit Dwords */
654     UINT32                  Integer32;      /* integer constant, 32 bits only */
655     UINT16                  Integer16;      /* integer constant, 16 bits only */
656     UINT8                   Integer8;       /* integer constant, 8 bits only */
657     UINT32                  Size;           /* bytelist or field size */
658     NATIVE_CHAR             *String;        /* NULL terminated string */
659     UINT8                   *Buffer;        /* buffer or string */
660     NATIVE_CHAR             *Name;          /* NULL terminated string */
661     struct acpi_parse_obj   *Arg;           /* arguments and contained ops */
662
663 } ACPI_PARSE_VALUE;
664
665
666 #define ACPI_PARSE_COMMON \
667     UINT8                   DataType;       /* To differentiate various internal objs */\
668     UINT8                   Flags;          /* Type of Op */\
669     UINT16                  Opcode;         /* AML opcode */\
670     UINT32                  AmlOffset;      /* offset of declaration in AML */\
671     struct acpi_parse_obj   *Parent;        /* parent op */\
672     struct acpi_parse_obj   *Next;          /* next op */\
673     DEBUG_ONLY_MEMBERS (\
674     NATIVE_CHAR             OpName[16])     /* op name (debug only) */\
675                                             /* NON-DEBUG members below: */\
676     ACPI_NAMESPACE_NODE     *Node;          /* for use by interpreter */\
677     ACPI_PARSE_VALUE        Value;          /* Value or args associated with the opcode */\
678
679
680 /*
681  * generic operation (eg. If, While, Store)
682  */
683 typedef struct acpi_parse_obj
684 {
685     ACPI_PARSE_COMMON
686 } ACPI_PARSE_OBJECT;
687
688
689 /*
690  * Extended Op for named ops (Scope, Method, etc.), deferred ops (Methods and OpRegions),
691  * and bytelists.
692  */
693 typedef struct acpi_parse2_obj
694 {
695     ACPI_PARSE_COMMON
696     UINT8                   *Data;          /* AML body or bytelist data */
697     UINT32                  Length;         /* AML length */
698     UINT32                  Name;           /* 4-byte name or zero if no name */
699
700 } ACPI_PARSE2_OBJECT;
701
702
703 /*
704  * Parse state - one state per parser invocation and each control
705  * method.
706  */
707
708 typedef struct acpi_parse_state
709 {
710     UINT8                   *AmlStart;      /* first AML byte */
711     UINT8                   *Aml;           /* next AML byte */
712     UINT8                   *AmlEnd;        /* (last + 1) AML byte */
713     UINT8                   *PkgStart;      /* current package begin */
714     UINT8                   *PkgEnd;        /* current package end */
715     ACPI_PARSE_OBJECT       *StartOp;       /* root of parse tree */
716     struct acpi_node        *StartNode;
717     ACPI_GENERIC_STATE      *Scope;         /* current scope */
718     struct acpi_parse_state *Next;
719
720 } ACPI_PARSE_STATE;
721
722
723 /*****************************************************************************
724  *
725  * Hardware and PNP
726  *
727  ****************************************************************************/
728
729
730 /* PCI */
731 #define PCI_ROOT_HID_STRING             "PNP0A03"
732
733 /*
734  * The #define's and enum below establish an abstract way of identifying what
735  * register block and register is to be accessed.  Do not change any of the
736  * values as they are used in switch statements and offset calculations.
737  */
738
739 #define REGISTER_BLOCK_MASK             0xFF00  /* Register Block Id    */
740 #define BIT_IN_REGISTER_MASK            0x00FF  /* Bit Id in the Register Block Id    */
741 #define BYTE_IN_REGISTER_MASK           0x00FF  /* Register Offset in the Register Block    */
742
743 #define REGISTER_BLOCK_ID(RegId)        (RegId & REGISTER_BLOCK_MASK)
744 #define REGISTER_BIT_ID(RegId)          (RegId & BIT_IN_REGISTER_MASK)
745 #define REGISTER_OFFSET(RegId)          (RegId & BYTE_IN_REGISTER_MASK)
746
747 /*
748  * Access Rule
749  *  To access a Register Bit:
750  *  -> Use Bit Name (= Register Block Id | Bit Id) defined in the enum.
751  *
752  *  To access a Register:
753  *  -> Use Register Id (= Register Block Id | Register Offset)
754  */
755
756
757 /*
758  * Register Block Id
759  */
760 #define PM1_STS                         0x0100
761 #define PM1_EN                          0x0200
762 #define PM1_CONTROL                     0x0300
763 #define PM1A_CONTROL                    0x0400
764 #define PM1B_CONTROL                    0x0500
765 #define PM2_CONTROL                     0x0600
766 #define PM_TIMER                        0x0700
767 #define PROCESSOR_BLOCK                 0x0800
768 #define GPE0_STS_BLOCK                  0x0900
769 #define GPE0_EN_BLOCK                   0x0A00
770 #define GPE1_STS_BLOCK                  0x0B00
771 #define GPE1_EN_BLOCK                   0x0C00
772 #define SMI_CMD_BLOCK                   0x0D00
773
774 /*
775  * Address space bitmasks for mmio or io spaces
776  */
777
778 #define SMI_CMD_ADDRESS_SPACE           0x01
779 #define PM1_BLK_ADDRESS_SPACE           0x02
780 #define PM2_CNT_BLK_ADDRESS_SPACE       0x04
781 #define PM_TMR_BLK_ADDRESS_SPACE        0x08
782 #define GPE0_BLK_ADDRESS_SPACE          0x10
783 #define GPE1_BLK_ADDRESS_SPACE          0x20
784
785 /*
786  * Control bit definitions
787  */
788 #define TMR_STS                         (PM1_STS | 0x01)
789 #define BM_STS                          (PM1_STS | 0x02)
790 #define GBL_STS                         (PM1_STS | 0x03)
791 #define PWRBTN_STS                      (PM1_STS | 0x04)
792 #define SLPBTN_STS                      (PM1_STS | 0x05)
793 #define RTC_STS                         (PM1_STS | 0x06)
794 #define WAK_STS                         (PM1_STS | 0x07)
795
796 #define TMR_EN                          (PM1_EN | 0x01)
797                                         /* no BM_EN */
798 #define GBL_EN                          (PM1_EN | 0x03)
799 #define PWRBTN_EN                       (PM1_EN | 0x04)
800 #define SLPBTN_EN                       (PM1_EN | 0x05)
801 #define RTC_EN                          (PM1_EN | 0x06)
802 #define WAK_EN                          (PM1_EN | 0x07)
803
804 #define SCI_EN                          (PM1_CONTROL | 0x01)
805 #define BM_RLD                          (PM1_CONTROL | 0x02)
806 #define GBL_RLS                         (PM1_CONTROL | 0x03)
807 #define SLP_TYPE_A                      (PM1_CONTROL | 0x04)
808 #define SLP_TYPE_B                      (PM1_CONTROL | 0x05)
809 #define SLP_EN                          (PM1_CONTROL | 0x06)
810
811 #define ARB_DIS                         (PM2_CONTROL | 0x01)
812
813 #define TMR_VAL                         (PM_TIMER | 0x01)
814
815 #define GPE0_STS                        (GPE0_STS_BLOCK | 0x01)
816 #define GPE0_EN                         (GPE0_EN_BLOCK  | 0x01)
817
818 #define GPE1_STS                        (GPE1_STS_BLOCK | 0x01)
819 #define GPE1_EN                         (GPE1_EN_BLOCK  | 0x01)
820
821
822 #define TMR_STS_MASK                    0x0001
823 #define BM_STS_MASK                     0x0010
824 #define GBL_STS_MASK                    0x0020
825 #define PWRBTN_STS_MASK                 0x0100
826 #define SLPBTN_STS_MASK                 0x0200
827 #define RTC_STS_MASK                    0x0400
828 #define WAK_STS_MASK                    0x8000
829
830 #define ALL_FIXED_STS_BITS              (TMR_STS_MASK   | BM_STS_MASK  | GBL_STS_MASK \
831                                         | PWRBTN_STS_MASK | SLPBTN_STS_MASK \
832                                         | RTC_STS_MASK | WAK_STS_MASK)
833
834 #define TMR_EN_MASK                     0x0001
835 #define GBL_EN_MASK                     0x0020
836 #define PWRBTN_EN_MASK                  0x0100
837 #define SLPBTN_EN_MASK                  0x0200
838 #define RTC_EN_MASK                     0x0400
839
840 #define SCI_EN_MASK                     0x0001
841 #define BM_RLD_MASK                     0x0002
842 #define GBL_RLS_MASK                    0x0004
843 #define SLP_TYPE_X_MASK                 0x1C00
844 #define SLP_EN_MASK                     0x2000
845
846 #define ARB_DIS_MASK                    0x0001
847 #define TMR_VAL_MASK                    0xFFFFFFFF
848
849 #define GPE0_STS_MASK
850 #define GPE0_EN_MASK
851
852 #define GPE1_STS_MASK
853 #define GPE1_EN_MASK
854
855
856 #define ACPI_READ                       1
857 #define ACPI_WRITE                      2
858
859
860 /*****************************************************************************
861  *
862  * Resource descriptors
863  *
864  ****************************************************************************/
865
866
867 /* ResourceType values */
868
869 #define RESOURCE_TYPE_MEMORY_RANGE              0
870 #define RESOURCE_TYPE_IO_RANGE                  1
871 #define RESOURCE_TYPE_BUS_NUMBER_RANGE          2
872
873 /* Resource descriptor types and masks */
874
875 #define RESOURCE_DESC_TYPE_LARGE                0x80
876 #define RESOURCE_DESC_TYPE_SMALL                0x00
877
878 #define RESOURCE_DESC_TYPE_MASK                 0x80
879 #define RESOURCE_DESC_SMALL_MASK                0x78        /* Only bits 6:3 contain the type */
880
881
882 /*
883  * Small resource descriptor types
884  * Note: The 3 length bits (2:0) must be zero
885  */
886 #define RESOURCE_DESC_IRQ_FORMAT                0x20
887 #define RESOURCE_DESC_DMA_FORMAT                0x28
888 #define RESOURCE_DESC_START_DEPENDENT           0x30
889 #define RESOURCE_DESC_END_DEPENDENT             0x38
890 #define RESOURCE_DESC_IO_PORT                   0x40
891 #define RESOURCE_DESC_FIXED_IO_PORT             0x48
892 #define RESOURCE_DESC_SMALL_VENDOR              0x70
893 #define RESOURCE_DESC_END_TAG                   0x78
894
895 /*
896  * Large resource descriptor types
897  */
898
899 #define RESOURCE_DESC_MEMORY_24                 0x81
900 #define RESOURCE_DESC_GENERAL_REGISTER          0x82
901 #define RESOURCE_DESC_LARGE_VENDOR              0x84
902 #define RESOURCE_DESC_MEMORY_32                 0x85
903 #define RESOURCE_DESC_FIXED_MEMORY_32           0x86
904 #define RESOURCE_DESC_DWORD_ADDRESS_SPACE       0x87
905 #define RESOURCE_DESC_WORD_ADDRESS_SPACE        0x88
906 #define RESOURCE_DESC_EXTENDED_XRUPT            0x89
907 #define RESOURCE_DESC_QWORD_ADDRESS_SPACE       0x8A
908
909
910 /* String version of device HIDs and UIDs */
911
912 #define ACPI_DEVICE_ID_LENGTH                   0x09
913
914 typedef struct
915 {
916     char            Buffer[ACPI_DEVICE_ID_LENGTH];
917
918 } ACPI_DEVICE_ID;
919
920
921
922 /*****************************************************************************
923  *
924  * Miscellaneous
925  *
926  ****************************************************************************/
927
928 #define ASCII_ZERO                      0x30
929
930 /*****************************************************************************
931  *
932  * Debugger
933  *
934  ****************************************************************************/
935
936 typedef struct dbmethodinfo
937 {
938     ACPI_HANDLE             ThreadGate;
939     NATIVE_CHAR             *Name;
940     NATIVE_CHAR             **Args;
941     UINT32                  Flags;
942     UINT32                  NumLoops;
943     NATIVE_CHAR             Pathname[128];
944
945 } DB_METHOD_INFO;
946
947
948
949 /*****************************************************************************
950  *
951  * Debug
952  *
953  ****************************************************************************/
954
955
956 /* Entry for a memory allocation (debug only) */
957
958
959 #define MEM_MALLOC                      0
960 #define MEM_CALLOC                      1
961 #define MAX_MODULE_NAME                 16
962
963 #define ACPI_COMMON_DEBUG_MEM_HEADER \
964     struct AcpiDebugMemBlock    *Previous; \
965     struct AcpiDebugMemBlock    *Next; \
966     UINT32                      Size; \
967     UINT32                      Component; \
968     UINT32                      Line; \
969     NATIVE_CHAR                 Module[MAX_MODULE_NAME]; \
970     UINT8                       AllocType;
971
972
973 typedef struct
974 {
975     ACPI_COMMON_DEBUG_MEM_HEADER
976
977 } ACPI_DEBUG_MEM_HEADER;
978
979 typedef struct AcpiDebugMemBlock
980 {
981     ACPI_COMMON_DEBUG_MEM_HEADER
982     UINT64                      UserSpace;
983
984 } ACPI_DEBUG_MEM_BLOCK;
985
986
987
988 #define ACPI_MEM_LIST_GLOBAL            0
989 #define ACPI_MEM_LIST_NSNODE            1
990
991 #define ACPI_MEM_LIST_FIRST_CACHE_LIST  2
992 #define ACPI_MEM_LIST_STATE             2
993 #define ACPI_MEM_LIST_PSNODE            3
994 #define ACPI_MEM_LIST_PSNODE_EXT        4
995 #define ACPI_MEM_LIST_OPERAND           5
996 #define ACPI_MEM_LIST_WALK              6
997 #define ACPI_MEM_LIST_MAX               6
998 #define ACPI_NUM_MEM_LISTS              7
999
1000
1001 typedef struct
1002 {
1003     void                        *ListHead;
1004     UINT16                      LinkOffset;
1005     UINT16                      MaxCacheDepth;
1006     UINT16                      CacheDepth;
1007     UINT16                      ObjectSize;
1008
1009 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
1010
1011     /* Statistics for debug memory tracking only */
1012
1013     UINT32                      TotalAllocated;
1014     UINT32                      TotalFreed;
1015     UINT32                      CurrentTotalSize;
1016     UINT32                      CacheRequests;
1017     UINT32                      CacheHits;
1018     char                        *ListName;
1019 #endif
1020
1021 } ACPI_MEMORY_LIST;
1022
1023
1024
1025 #endif /* __ACLOCAL_H__ */