xref: /titanic_44/usr/src/uts/intel/sys/acpi/acparser.h (revision f4c46b1eda9212fd32ba197043d52239ef5c0a7f)
1 /******************************************************************************
2  *
3  * Module Name: acparser.h - AML Parser subcomponent prototypes and defines
4  *
5  *****************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2011, 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 
45 #ifndef __ACPARSER_H__
46 #define __ACPARSER_H__
47 
48 
49 #define OP_HAS_RETURN_VALUE             1
50 
51 /* Variable number of arguments. This field must be 32 bits */
52 
53 #define ACPI_VAR_ARGS                   ACPI_UINT32_MAX
54 
55 
56 #define ACPI_PARSE_DELETE_TREE          0x0001
57 #define ACPI_PARSE_NO_TREE_DELETE       0x0000
58 #define ACPI_PARSE_TREE_MASK            0x0001
59 
60 #define ACPI_PARSE_LOAD_PASS1           0x0010
61 #define ACPI_PARSE_LOAD_PASS2           0x0020
62 #define ACPI_PARSE_EXECUTE              0x0030
63 #define ACPI_PARSE_MODE_MASK            0x0030
64 
65 #define ACPI_PARSE_DEFERRED_OP          0x0100
66 #define ACPI_PARSE_DISASSEMBLE          0x0200
67 
68 #define ACPI_PARSE_MODULE_LEVEL         0x0400
69 
70 /******************************************************************************
71  *
72  * Parser interfaces
73  *
74  *****************************************************************************/
75 
76 
77 /*
78  * psxface - Parser external interfaces
79  */
80 ACPI_STATUS
81 AcpiPsExecuteMethod (
82     ACPI_EVALUATE_INFO      *Info);
83 
84 
85 /*
86  * psargs - Parse AML opcode arguments
87  */
88 UINT8 *
89 AcpiPsGetNextPackageEnd (
90     ACPI_PARSE_STATE        *ParserState);
91 
92 char *
93 AcpiPsGetNextNamestring (
94     ACPI_PARSE_STATE        *ParserState);
95 
96 void
97 AcpiPsGetNextSimpleArg (
98     ACPI_PARSE_STATE        *ParserState,
99     UINT32                  ArgType,
100     ACPI_PARSE_OBJECT       *Arg);
101 
102 ACPI_STATUS
103 AcpiPsGetNextNamepath (
104     ACPI_WALK_STATE         *WalkState,
105     ACPI_PARSE_STATE        *ParserState,
106     ACPI_PARSE_OBJECT       *Arg,
107     BOOLEAN                 MethodCall);
108 
109 ACPI_STATUS
110 AcpiPsGetNextArg (
111     ACPI_WALK_STATE         *WalkState,
112     ACPI_PARSE_STATE        *ParserState,
113     UINT32                  ArgType,
114     ACPI_PARSE_OBJECT       **ReturnArg);
115 
116 
117 /*
118  * psfind
119  */
120 ACPI_PARSE_OBJECT *
121 AcpiPsFindName (
122     ACPI_PARSE_OBJECT       *Scope,
123     UINT32                  Name,
124     UINT32                  Opcode);
125 
126 ACPI_PARSE_OBJECT*
127 AcpiPsGetParent (
128     ACPI_PARSE_OBJECT       *Op);
129 
130 
131 /*
132  * psopcode - AML Opcode information
133  */
134 const ACPI_OPCODE_INFO *
135 AcpiPsGetOpcodeInfo (
136     UINT16                  Opcode);
137 
138 char *
139 AcpiPsGetOpcodeName (
140     UINT16                  Opcode);
141 
142 UINT8
143 AcpiPsGetArgumentCount (
144     UINT32                  OpType);
145 
146 
147 /*
148  * psparse - top level parsing routines
149  */
150 ACPI_STATUS
151 AcpiPsParseAml (
152     ACPI_WALK_STATE         *WalkState);
153 
154 UINT32
155 AcpiPsGetOpcodeSize (
156     UINT32                  Opcode);
157 
158 UINT16
159 AcpiPsPeekOpcode (
160     ACPI_PARSE_STATE        *state);
161 
162 ACPI_STATUS
163 AcpiPsCompleteThisOp (
164     ACPI_WALK_STATE         *WalkState,
165     ACPI_PARSE_OBJECT       *Op);
166 
167 ACPI_STATUS
168 AcpiPsNextParseState (
169     ACPI_WALK_STATE         *WalkState,
170     ACPI_PARSE_OBJECT       *Op,
171     ACPI_STATUS             CallbackStatus);
172 
173 
174 /*
175  * psloop - main parse loop
176  */
177 ACPI_STATUS
178 AcpiPsParseLoop (
179     ACPI_WALK_STATE         *WalkState);
180 
181 
182 /*
183  * psscope - Scope stack management routines
184  */
185 ACPI_STATUS
186 AcpiPsInitScope (
187     ACPI_PARSE_STATE        *ParserState,
188     ACPI_PARSE_OBJECT       *Root);
189 
190 ACPI_PARSE_OBJECT *
191 AcpiPsGetParentScope (
192     ACPI_PARSE_STATE        *state);
193 
194 BOOLEAN
195 AcpiPsHasCompletedScope (
196     ACPI_PARSE_STATE        *ParserState);
197 
198 void
199 AcpiPsPopScope (
200     ACPI_PARSE_STATE        *ParserState,
201     ACPI_PARSE_OBJECT       **Op,
202     UINT32                  *ArgList,
203     UINT32                  *ArgCount);
204 
205 ACPI_STATUS
206 AcpiPsPushScope (
207     ACPI_PARSE_STATE        *ParserState,
208     ACPI_PARSE_OBJECT       *Op,
209     UINT32                  RemainingArgs,
210     UINT32                  ArgCount);
211 
212 void
213 AcpiPsCleanupScope (
214     ACPI_PARSE_STATE        *state);
215 
216 
217 /*
218  * pstree - parse tree manipulation routines
219  */
220 void
221 AcpiPsAppendArg(
222     ACPI_PARSE_OBJECT       *op,
223     ACPI_PARSE_OBJECT       *arg);
224 
225 ACPI_PARSE_OBJECT*
226 AcpiPsFind (
227     ACPI_PARSE_OBJECT       *Scope,
228     char                    *Path,
229     UINT16                  Opcode,
230     UINT32                  Create);
231 
232 ACPI_PARSE_OBJECT *
233 AcpiPsGetArg(
234     ACPI_PARSE_OBJECT       *op,
235     UINT32                   argn);
236 
237 ACPI_PARSE_OBJECT *
238 AcpiPsGetDepthNext (
239     ACPI_PARSE_OBJECT       *Origin,
240     ACPI_PARSE_OBJECT       *Op);
241 
242 
243 /*
244  * pswalk - parse tree walk routines
245  */
246 ACPI_STATUS
247 AcpiPsWalkParsedAml (
248     ACPI_PARSE_OBJECT       *StartOp,
249     ACPI_PARSE_OBJECT       *EndOp,
250     ACPI_OPERAND_OBJECT     *MthDesc,
251     ACPI_NAMESPACE_NODE     *StartNode,
252     ACPI_OPERAND_OBJECT     **Params,
253     ACPI_OPERAND_OBJECT     **CallerReturnDesc,
254     ACPI_OWNER_ID           OwnerId,
255     ACPI_PARSE_DOWNWARDS    DescendingCallback,
256     ACPI_PARSE_UPWARDS      AscendingCallback);
257 
258 ACPI_STATUS
259 AcpiPsGetNextWalkOp (
260     ACPI_WALK_STATE         *WalkState,
261     ACPI_PARSE_OBJECT       *Op,
262     ACPI_PARSE_UPWARDS      AscendingCallback);
263 
264 ACPI_STATUS
265 AcpiPsDeleteCompletedOp (
266     ACPI_WALK_STATE         *WalkState);
267 
268 void
269 AcpiPsDeleteParseTree (
270     ACPI_PARSE_OBJECT       *root);
271 
272 
273 /*
274  * psutils - parser utilities
275  */
276 ACPI_PARSE_OBJECT *
277 AcpiPsCreateScopeOp (
278     void);
279 
280 void
281 AcpiPsInitOp (
282     ACPI_PARSE_OBJECT       *op,
283     UINT16                  opcode);
284 
285 ACPI_PARSE_OBJECT *
286 AcpiPsAllocOp (
287     UINT16                  opcode);
288 
289 void
290 AcpiPsFreeOp (
291     ACPI_PARSE_OBJECT       *Op);
292 
293 BOOLEAN
294 AcpiPsIsLeadingChar (
295     UINT32                  c);
296 
297 BOOLEAN
298 AcpiPsIsPrefixChar (
299     UINT32                  c);
300 
301 UINT32
302 AcpiPsGetName(
303     ACPI_PARSE_OBJECT       *op);
304 
305 void
306 AcpiPsSetName(
307     ACPI_PARSE_OBJECT       *op,
308     UINT32                  name);
309 
310 
311 /*
312  * psdump - display parser tree
313  */
314 UINT32
315 AcpiPsSprintPath (
316     char                    *BufferStart,
317     UINT32                  BufferSize,
318     ACPI_PARSE_OBJECT       *Op);
319 
320 UINT32
321 AcpiPsSprintOp (
322     char                    *BufferStart,
323     UINT32                  BufferSize,
324     ACPI_PARSE_OBJECT       *Op);
325 
326 void
327 AcpiPsShow (
328     ACPI_PARSE_OBJECT       *op);
329 
330 
331 #endif /* __ACPARSER_H__ */
332