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