kernel: Sync ACPICA with Intel's version 20140214.
[dragonfly.git] / sys / contrib / dev / acpica / source / include / acstruct.h
1 /******************************************************************************
2  *
3  * Name: acstruct.h - Internal structs
4  *
5  *****************************************************************************/
6
7 /*
8  * Copyright (C) 2000 - 2014, 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 __ACSTRUCT_H__
45 #define __ACSTRUCT_H__
46
47
48 #pragma pack(push) /* Set default struct packing */
49
50 /* acpisrc:StructDefs -- for acpisrc conversion */
51
52 /*****************************************************************************
53  *
54  * Tree walking typedefs and structs
55  *
56  ****************************************************************************/
57
58
59 /*
60  * Walk state - current state of a parse tree walk. Used for both a leisurely
61  * stroll through the tree (for whatever reason), and for control method
62  * execution.
63  */
64 #define ACPI_NEXT_OP_DOWNWARD       1
65 #define ACPI_NEXT_OP_UPWARD         2
66
67 /*
68  * Groups of definitions for WalkType used for different implementations of
69  * walkers (never simultaneously) - flags for interpreter:
70  */
71 #define ACPI_WALK_NON_METHOD        0
72 #define ACPI_WALK_METHOD            0x01
73 #define ACPI_WALK_METHOD_RESTART    0x02
74
75 /* Flags for iASL compiler only */
76
77 #define ACPI_WALK_CONST_REQUIRED    0x10
78 #define ACPI_WALK_CONST_OPTIONAL    0x20
79
80
81 typedef struct acpi_walk_state
82 {
83     struct acpi_walk_state          *Next;              /* Next WalkState in list */
84     UINT8                           DescriptorType;     /* To differentiate various internal objs */
85     UINT8                           WalkType;
86     UINT16                          Opcode;             /* Current AML opcode */
87     UINT8                           NextOpInfo;         /* Info about NextOp */
88     UINT8                           NumOperands;        /* Stack pointer for Operands[] array */
89     UINT8                           OperandIndex;       /* Index into operand stack, to be used by AcpiDsObjStackPush */
90     ACPI_OWNER_ID                   OwnerId;            /* Owner of objects created during the walk */
91     BOOLEAN                         LastPredicate;      /* Result of last predicate */
92     UINT8                           CurrentResult;
93     UINT8                           ReturnUsed;
94     UINT8                           ScopeDepth;
95     UINT8                           PassNumber;         /* Parse pass during table load */
96     UINT8                           ResultSize;         /* Total elements for the result stack */
97     UINT8                           ResultCount;        /* Current number of occupied elements of result stack */
98     UINT32                          AmlOffset;
99     UINT32                          ArgTypes;
100     UINT32                          MethodBreakpoint;   /* For single stepping */
101     UINT32                          UserBreakpoint;     /* User AML breakpoint */
102     UINT32                          ParseFlags;
103
104     ACPI_PARSE_STATE                ParserState;        /* Current state of parser */
105     UINT32                          PrevArgTypes;
106     UINT32                          ArgCount;           /* push for fixed or var args */
107
108     struct acpi_namespace_node      Arguments[ACPI_METHOD_NUM_ARGS];        /* Control method arguments */
109     struct acpi_namespace_node      LocalVariables[ACPI_METHOD_NUM_LOCALS]; /* Control method locals */
110     union acpi_operand_object       *Operands[ACPI_OBJ_NUM_OPERANDS + 1];   /* Operands passed to the interpreter (+1 for NULL terminator) */
111     union acpi_operand_object       **Params;
112
113     UINT8                           *AmlLastWhile;
114     union acpi_operand_object       **CallerReturnDesc;
115     ACPI_GENERIC_STATE              *ControlState;      /* List of control states (nested IFs) */
116     struct acpi_namespace_node      *DeferredNode;      /* Used when executing deferred opcodes */
117     union acpi_operand_object       *ImplicitReturnObj;
118     struct acpi_namespace_node      *MethodCallNode;    /* Called method Node*/
119     ACPI_PARSE_OBJECT               *MethodCallOp;      /* MethodCall Op if running a method */
120     union acpi_operand_object       *MethodDesc;        /* Method descriptor if running a method */
121     struct acpi_namespace_node      *MethodNode;        /* Method node if running a method. */
122     ACPI_PARSE_OBJECT               *Op;                /* Current parser op */
123     const ACPI_OPCODE_INFO          *OpInfo;            /* Info on current opcode */
124     ACPI_PARSE_OBJECT               *Origin;            /* Start of walk [Obsolete] */
125     union acpi_operand_object       *ResultObj;
126     ACPI_GENERIC_STATE              *Results;           /* Stack of accumulated results */
127     union acpi_operand_object       *ReturnDesc;        /* Return object, if any */
128     ACPI_GENERIC_STATE              *ScopeInfo;         /* Stack of nested scopes */
129     ACPI_PARSE_OBJECT               *PrevOp;            /* Last op that was processed */
130     ACPI_PARSE_OBJECT               *NextOp;            /* next op to be processed */
131     ACPI_THREAD_STATE               *Thread;
132     ACPI_PARSE_DOWNWARDS            DescendingCallback;
133     ACPI_PARSE_UPWARDS              AscendingCallback;
134
135 } ACPI_WALK_STATE;
136
137
138 /* Info used by AcpiNsInitializeObjects and AcpiDsInitializeObjects */
139
140 typedef struct acpi_init_walk_info
141 {
142     UINT32                          TableIndex;
143     UINT32                          ObjectCount;
144     UINT32                          MethodCount;
145     UINT32                          SerialMethodCount;
146     UINT32                          NonSerialMethodCount;
147     UINT32                          SerializedMethodCount;
148     UINT32                          DeviceCount;
149     UINT32                          OpRegionCount;
150     UINT32                          FieldCount;
151     UINT32                          BufferCount;
152     UINT32                          PackageCount;
153     UINT32                          OpRegionInit;
154     UINT32                          FieldInit;
155     UINT32                          BufferInit;
156     UINT32                          PackageInit;
157     ACPI_OWNER_ID                   OwnerId;
158
159 } ACPI_INIT_WALK_INFO;
160
161
162 typedef struct acpi_get_devices_info
163 {
164     ACPI_WALK_CALLBACK              UserFunction;
165     void                            *Context;
166     char                            *Hid;
167
168 } ACPI_GET_DEVICES_INFO;
169
170
171 typedef union acpi_aml_operands
172 {
173     ACPI_OPERAND_OBJECT             *Operands[7];
174
175     struct
176     {
177         ACPI_OBJECT_INTEGER             *Type;
178         ACPI_OBJECT_INTEGER             *Code;
179         ACPI_OBJECT_INTEGER             *Argument;
180
181     } Fatal;
182
183     struct
184     {
185         ACPI_OPERAND_OBJECT             *Source;
186         ACPI_OBJECT_INTEGER             *Index;
187         ACPI_OPERAND_OBJECT             *Target;
188
189     } Index;
190
191     struct
192     {
193         ACPI_OPERAND_OBJECT             *Source;
194         ACPI_OBJECT_INTEGER             *Index;
195         ACPI_OBJECT_INTEGER             *Length;
196         ACPI_OPERAND_OBJECT             *Target;
197
198     } Mid;
199
200 } ACPI_AML_OPERANDS;
201
202
203 /*
204  * Structure used to pass object evaluation information and parameters.
205  * Purpose is to reduce CPU stack use.
206  */
207 typedef struct acpi_evaluate_info
208 {
209     /* The first 3 elements are passed by the caller to AcpiNsEvaluate */
210
211     ACPI_NAMESPACE_NODE             *PrefixNode;        /* Input: starting node */
212     char                            *RelativePathname;  /* Input: path relative to PrefixNode */
213     ACPI_OPERAND_OBJECT             **Parameters;       /* Input: argument list */
214
215     ACPI_NAMESPACE_NODE             *Node;              /* Resolved node (PrefixNode:RelativePathname) */
216     ACPI_OPERAND_OBJECT             *ObjDesc;           /* Object attached to the resolved node */
217     char                            *FullPathname;      /* Full pathname of the resolved node */
218
219     const ACPI_PREDEFINED_INFO      *Predefined;        /* Used if Node is a predefined name */
220     ACPI_OPERAND_OBJECT             *ReturnObject;      /* Object returned from the evaluation */
221     union acpi_operand_object       *ParentPackage;     /* Used if return object is a Package */
222
223     UINT32                          ReturnFlags;        /* Used for return value analysis */
224     UINT32                          ReturnBtype;        /* Bitmapped type of the returned object */
225     UINT16                          ParamCount;         /* Count of the input argument list */
226     UINT8                           PassNumber;         /* Parser pass number */
227     UINT8                           ReturnObjectType;   /* Object type of the returned object */
228     UINT8                           NodeFlags;          /* Same as Node->Flags */
229     UINT8                           Flags;              /* General flags */
230
231 } ACPI_EVALUATE_INFO;
232
233 /* Values for Flags above */
234
235 #define ACPI_IGNORE_RETURN_VALUE    1
236
237 /* Defines for ReturnFlags field above */
238
239 #define ACPI_OBJECT_REPAIRED        1
240 #define ACPI_OBJECT_WRAPPED         2
241
242
243 /* Info used by AcpiNsInitializeDevices */
244
245 typedef struct acpi_device_walk_info
246 {
247     ACPI_TABLE_DESC                 *TableDesc;
248     ACPI_EVALUATE_INFO              *EvaluateInfo;
249     UINT32                          DeviceCount;
250     UINT32                          Num_STA;
251     UINT32                          Num_INI;
252
253 } ACPI_DEVICE_WALK_INFO;
254
255
256 /* TBD: [Restructure] Merge with struct above */
257
258 typedef struct acpi_walk_info
259 {
260     UINT32                          DebugLevel;
261     UINT32                          Count;
262     ACPI_OWNER_ID                   OwnerId;
263     UINT8                           DisplayType;
264
265 } ACPI_WALK_INFO;
266
267 /* Display Types */
268
269 #define ACPI_DISPLAY_SUMMARY        (UINT8) 0
270 #define ACPI_DISPLAY_OBJECTS        (UINT8) 1
271 #define ACPI_DISPLAY_MASK           (UINT8) 1
272
273 #define ACPI_DISPLAY_SHORT          (UINT8) 2
274
275
276 #pragma pack(pop) /* Restore original struct packing */
277
278 #endif