acparser.h revision 306536
1170754Sdelphij/******************************************************************************
2170754Sdelphij *
3170754Sdelphij * Module Name: acparser.h - AML Parser subcomponent prototypes and defines
4170754Sdelphij *
5170754Sdelphij *****************************************************************************/
6170754Sdelphij
7170754Sdelphij/*
8170754Sdelphij * Copyright (C) 2000 - 2016, Intel Corp.
9170754Sdelphij * All rights reserved.
10170754Sdelphij *
11170754Sdelphij * Redistribution and use in source and binary forms, with or without
12170754Sdelphij * modification, are permitted provided that the following conditions
13170754Sdelphij * are met:
14170754Sdelphij * 1. Redistributions of source code must retain the above copyright
15170754Sdelphij *    notice, this list of conditions, and the following disclaimer,
16170754Sdelphij *    without modification.
17170754Sdelphij * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18170754Sdelphij *    substantially similar to the "NO WARRANTY" disclaimer below
19170754Sdelphij *    ("Disclaimer") and any redistribution must be conditioned upon
20170754Sdelphij *    including a substantially similar Disclaimer requirement for further
21170754Sdelphij *    binary redistribution.
22170754Sdelphij * 3. Neither the names of the above-listed copyright holders nor the names
23170754Sdelphij *    of any contributors may be used to endorse or promote products derived
24170754Sdelphij *    from this software without specific prior written permission.
25170754Sdelphij *
26170754Sdelphij * Alternatively, this software may be distributed under the terms of the
27170754Sdelphij * GNU General Public License ("GPL") version 2 as published by the Free
28170754Sdelphij * Software Foundation.
29170754Sdelphij *
30170754Sdelphij * NO WARRANTY
31170754Sdelphij * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32170754Sdelphij * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33170754Sdelphij * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34170754Sdelphij * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35170754Sdelphij * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36170754Sdelphij * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37170754Sdelphij * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38170754Sdelphij * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39170754Sdelphij * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40170754Sdelphij * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41170754Sdelphij * POSSIBILITY OF SUCH DAMAGES.
42170754Sdelphij */
43170754Sdelphij
44170754Sdelphij#ifndef __ACPARSER_H__
45170754Sdelphij#define __ACPARSER_H__
46170754Sdelphij
47170754Sdelphij
48170754Sdelphij#define OP_HAS_RETURN_VALUE             1
49170754Sdelphij
50170754Sdelphij/* Variable number of arguments. This field must be 32 bits */
51170754Sdelphij
52170754Sdelphij#define ACPI_VAR_ARGS                   ACPI_UINT32_MAX
53170754Sdelphij
54170754Sdelphij
55170754Sdelphij#define ACPI_PARSE_DELETE_TREE          0x0001
56170754Sdelphij#define ACPI_PARSE_NO_TREE_DELETE       0x0000
57170754Sdelphij#define ACPI_PARSE_TREE_MASK            0x0001
58170754Sdelphij
59170754Sdelphij#define ACPI_PARSE_LOAD_PASS1           0x0010
60170754Sdelphij#define ACPI_PARSE_LOAD_PASS2           0x0020
61170754Sdelphij#define ACPI_PARSE_EXECUTE              0x0030
62170754Sdelphij#define ACPI_PARSE_MODE_MASK            0x0030
63170754Sdelphij
64170754Sdelphij#define ACPI_PARSE_DEFERRED_OP          0x0100
65170754Sdelphij#define ACPI_PARSE_DISASSEMBLE          0x0200
66170754Sdelphij
67170754Sdelphij#define ACPI_PARSE_MODULE_LEVEL         0x0400
68170754Sdelphij
69170754Sdelphij/******************************************************************************
70170754Sdelphij *
71170754Sdelphij * Parser interfaces
72170754Sdelphij *
73170754Sdelphij *****************************************************************************/
74170754Sdelphij
75170754Sdelphijextern const UINT8      AcpiGbl_ShortOpIndex[];
76170754Sdelphijextern const UINT8      AcpiGbl_LongOpIndex[];
77170754Sdelphij
78170754Sdelphij
79170754Sdelphij/*
80170754Sdelphij * psxface - Parser external interfaces
81170754Sdelphij */
82170754SdelphijACPI_STATUS
83170754SdelphijAcpiPsExecuteMethod (
84170754Sdelphij    ACPI_EVALUATE_INFO      *Info);
85170754Sdelphij
86170754Sdelphij
87170754Sdelphij/*
88170754Sdelphij * psargs - Parse AML opcode arguments
89170754Sdelphij */
90170754SdelphijUINT8 *
91170754SdelphijAcpiPsGetNextPackageEnd (
92170754Sdelphij    ACPI_PARSE_STATE        *ParserState);
93170754Sdelphij
94170754Sdelphijchar *
95170754SdelphijAcpiPsGetNextNamestring (
96170754Sdelphij    ACPI_PARSE_STATE        *ParserState);
97170754Sdelphij
98170754Sdelphijvoid
99170754SdelphijAcpiPsGetNextSimpleArg (
100170754Sdelphij    ACPI_PARSE_STATE        *ParserState,
101170754Sdelphij    UINT32                  ArgType,
102170754Sdelphij    ACPI_PARSE_OBJECT       *Arg);
103170754Sdelphij
104170754SdelphijACPI_STATUS
105170754SdelphijAcpiPsGetNextNamepath (
106170754Sdelphij    ACPI_WALK_STATE         *WalkState,
107170754Sdelphij    ACPI_PARSE_STATE        *ParserState,
108170754Sdelphij    ACPI_PARSE_OBJECT       *Arg,
109170754Sdelphij    BOOLEAN                 PossibleMethodCall);
110170754Sdelphij
111170754Sdelphij/* Values for BOOLEAN above */
112170754Sdelphij
113170754Sdelphij#define ACPI_NOT_METHOD_CALL            FALSE
114170754Sdelphij#define ACPI_POSSIBLE_METHOD_CALL       TRUE
115170754Sdelphij
116170754SdelphijACPI_STATUS
117170754SdelphijAcpiPsGetNextArg (
118170754Sdelphij    ACPI_WALK_STATE         *WalkState,
119170754Sdelphij    ACPI_PARSE_STATE        *ParserState,
120170754Sdelphij    UINT32                  ArgType,
121170754Sdelphij    ACPI_PARSE_OBJECT       **ReturnArg);
122170754Sdelphij
123170754Sdelphij
124170754Sdelphij/*
125170754Sdelphij * psfind
126170754Sdelphij */
127170754SdelphijACPI_PARSE_OBJECT *
128170754SdelphijAcpiPsFindName (
129170754Sdelphij    ACPI_PARSE_OBJECT       *Scope,
130170754Sdelphij    UINT32                  Name,
131170754Sdelphij    UINT32                  Opcode);
132170754Sdelphij
133170754SdelphijACPI_PARSE_OBJECT*
134170754SdelphijAcpiPsGetParent (
135170754Sdelphij    ACPI_PARSE_OBJECT       *Op);
136170754Sdelphij
137170754Sdelphij
138170754Sdelphij/*
139170754Sdelphij * psobject - support for parse object processing
140170754Sdelphij */
141170754SdelphijACPI_STATUS
142170754SdelphijAcpiPsBuildNamedOp (
143170754Sdelphij    ACPI_WALK_STATE         *WalkState,
144170754Sdelphij    UINT8                   *AmlOpStart,
145170754Sdelphij    ACPI_PARSE_OBJECT       *UnnamedOp,
146170754Sdelphij    ACPI_PARSE_OBJECT       **Op);
147170754Sdelphij
148170754SdelphijACPI_STATUS
149170754SdelphijAcpiPsCreateOp (
150170754Sdelphij    ACPI_WALK_STATE         *WalkState,
151170754Sdelphij    UINT8                   *AmlOpStart,
152170754Sdelphij    ACPI_PARSE_OBJECT       **NewOp);
153170754Sdelphij
154170754SdelphijACPI_STATUS
155170754SdelphijAcpiPsCompleteOp (
156170754Sdelphij    ACPI_WALK_STATE         *WalkState,
157170754Sdelphij    ACPI_PARSE_OBJECT       **Op,
158170754Sdelphij    ACPI_STATUS             Status);
159170754Sdelphij
160170754SdelphijACPI_STATUS
161170754SdelphijAcpiPsCompleteFinalOp (
162170754Sdelphij    ACPI_WALK_STATE         *WalkState,
163170754Sdelphij    ACPI_PARSE_OBJECT       *Op,
164170754Sdelphij    ACPI_STATUS             Status);
165170754Sdelphij
166170754Sdelphij
167170754Sdelphij/*
168170754Sdelphij * psopinfo - AML Opcode information
169170754Sdelphij */
170170754Sdelphijconst ACPI_OPCODE_INFO *
171170754SdelphijAcpiPsGetOpcodeInfo (
172170754Sdelphij    UINT16                  Opcode);
173170754Sdelphij
174170754Sdelphijconst char *
175170754SdelphijAcpiPsGetOpcodeName (
176170754Sdelphij    UINT16                  Opcode);
177170754Sdelphij
178170754SdelphijUINT8
179170754SdelphijAcpiPsGetArgumentCount (
180170754Sdelphij    UINT32                  OpType);
181170754Sdelphij
182170754Sdelphij
183170754Sdelphij/*
184170754Sdelphij * psparse - top level parsing routines
185170754Sdelphij */
186170754SdelphijACPI_STATUS
187170754SdelphijAcpiPsParseAml (
188170754Sdelphij    ACPI_WALK_STATE         *WalkState);
189170754Sdelphij
190170754SdelphijUINT32
191170754SdelphijAcpiPsGetOpcodeSize (
192170754Sdelphij    UINT32                  Opcode);
193170754Sdelphij
194170754SdelphijUINT16
195170754SdelphijAcpiPsPeekOpcode (
196170754Sdelphij    ACPI_PARSE_STATE        *state);
197170754Sdelphij
198170754SdelphijACPI_STATUS
199170754SdelphijAcpiPsCompleteThisOp (
200170754Sdelphij    ACPI_WALK_STATE         *WalkState,
201170754Sdelphij    ACPI_PARSE_OBJECT       *Op);
202170754Sdelphij
203170754SdelphijACPI_STATUS
204170754SdelphijAcpiPsNextParseState (
205170754Sdelphij    ACPI_WALK_STATE         *WalkState,
206170754Sdelphij    ACPI_PARSE_OBJECT       *Op,
207170754Sdelphij    ACPI_STATUS             CallbackStatus);
208170754Sdelphij
209170754Sdelphij
210170754Sdelphij/*
211170754Sdelphij * psloop - main parse loop
212170754Sdelphij */
213170754SdelphijACPI_STATUS
214170754SdelphijAcpiPsParseLoop (
215170754Sdelphij    ACPI_WALK_STATE         *WalkState);
216170754Sdelphij
217170754Sdelphij
218170754Sdelphij/*
219170754Sdelphij * psscope - Scope stack management routines
220170754Sdelphij */
221170754SdelphijACPI_STATUS
222170754SdelphijAcpiPsInitScope (
223170754Sdelphij    ACPI_PARSE_STATE        *ParserState,
224170754Sdelphij    ACPI_PARSE_OBJECT       *Root);
225170754Sdelphij
226170754SdelphijACPI_PARSE_OBJECT *
227170754SdelphijAcpiPsGetParentScope (
228170754Sdelphij    ACPI_PARSE_STATE        *state);
229170754Sdelphij
230170754SdelphijBOOLEAN
231170754SdelphijAcpiPsHasCompletedScope (
232170754Sdelphij    ACPI_PARSE_STATE        *ParserState);
233170754Sdelphij
234170754Sdelphijvoid
235170754SdelphijAcpiPsPopScope (
236170754Sdelphij    ACPI_PARSE_STATE        *ParserState,
237170754Sdelphij    ACPI_PARSE_OBJECT       **Op,
238170754Sdelphij    UINT32                  *ArgList,
239170754Sdelphij    UINT32                  *ArgCount);
240170754Sdelphij
241170754SdelphijACPI_STATUS
242170754SdelphijAcpiPsPushScope (
243170754Sdelphij    ACPI_PARSE_STATE        *ParserState,
244170754Sdelphij    ACPI_PARSE_OBJECT       *Op,
245170754Sdelphij    UINT32                  RemainingArgs,
246170754Sdelphij    UINT32                  ArgCount);
247170754Sdelphij
248170754Sdelphijvoid
249170754SdelphijAcpiPsCleanupScope (
250170754Sdelphij    ACPI_PARSE_STATE        *state);
251170754Sdelphij
252170754Sdelphij
253170754Sdelphij/*
254170754Sdelphij * pstree - parse tree manipulation routines
255170754Sdelphij */
256170754Sdelphijvoid
257170754SdelphijAcpiPsAppendArg(
258170754Sdelphij    ACPI_PARSE_OBJECT       *op,
259170754Sdelphij    ACPI_PARSE_OBJECT       *arg);
260170754Sdelphij
261170754SdelphijACPI_PARSE_OBJECT*
262170754SdelphijAcpiPsFind (
263170754Sdelphij    ACPI_PARSE_OBJECT       *Scope,
264170754Sdelphij    char                    *Path,
265170754Sdelphij    UINT16                  Opcode,
266170754Sdelphij    UINT32                  Create);
267170754Sdelphij
268170754SdelphijACPI_PARSE_OBJECT *
269170754SdelphijAcpiPsGetArg(
270170754Sdelphij    ACPI_PARSE_OBJECT       *op,
271170754Sdelphij    UINT32                   argn);
272170754Sdelphij
273170754SdelphijACPI_PARSE_OBJECT *
274170754SdelphijAcpiPsGetDepthNext (
275170754Sdelphij    ACPI_PARSE_OBJECT       *Origin,
276170754Sdelphij    ACPI_PARSE_OBJECT       *Op);
277170754Sdelphij
278170754Sdelphij
279170754Sdelphij/*
280170754Sdelphij * pswalk - parse tree walk routines
281170754Sdelphij */
282170754SdelphijACPI_STATUS
283170754SdelphijAcpiPsWalkParsedAml (
284170754Sdelphij    ACPI_PARSE_OBJECT       *StartOp,
285170754Sdelphij    ACPI_PARSE_OBJECT       *EndOp,
286170754Sdelphij    ACPI_OPERAND_OBJECT     *MthDesc,
287170754Sdelphij    ACPI_NAMESPACE_NODE     *StartNode,
288170754Sdelphij    ACPI_OPERAND_OBJECT     **Params,
289170754Sdelphij    ACPI_OPERAND_OBJECT     **CallerReturnDesc,
290170754Sdelphij    ACPI_OWNER_ID           OwnerId,
291170754Sdelphij    ACPI_PARSE_DOWNWARDS    DescendingCallback,
292170754Sdelphij    ACPI_PARSE_UPWARDS      AscendingCallback);
293170754Sdelphij
294170754SdelphijACPI_STATUS
295170754SdelphijAcpiPsGetNextWalkOp (
296170754Sdelphij    ACPI_WALK_STATE         *WalkState,
297170754Sdelphij    ACPI_PARSE_OBJECT       *Op,
298170754Sdelphij    ACPI_PARSE_UPWARDS      AscendingCallback);
299170754Sdelphij
300170754SdelphijACPI_STATUS
301170754SdelphijAcpiPsDeleteCompletedOp (
302170754Sdelphij    ACPI_WALK_STATE         *WalkState);
303170754Sdelphij
304170754Sdelphijvoid
305170754SdelphijAcpiPsDeleteParseTree (
306170754Sdelphij    ACPI_PARSE_OBJECT       *root);
307170754Sdelphij
308170754Sdelphij
309170754Sdelphij/*
310170754Sdelphij * psutils - parser utilities
311170754Sdelphij */
312170754SdelphijACPI_PARSE_OBJECT *
313170754SdelphijAcpiPsCreateScopeOp (
314170754Sdelphij    UINT8                   *Aml);
315170754Sdelphij
316170754Sdelphijvoid
317170754SdelphijAcpiPsInitOp (
318170754Sdelphij    ACPI_PARSE_OBJECT       *op,
319170754Sdelphij    UINT16                  opcode);
320170754Sdelphij
321170754SdelphijACPI_PARSE_OBJECT *
322170754SdelphijAcpiPsAllocOp (
323170754Sdelphij    UINT16                  Opcode,
324170754Sdelphij    UINT8                   *Aml);
325170754Sdelphij
326170754Sdelphijvoid
327170754SdelphijAcpiPsFreeOp (
328170754Sdelphij    ACPI_PARSE_OBJECT       *Op);
329170754Sdelphij
330170754SdelphijBOOLEAN
331170754SdelphijAcpiPsIsLeadingChar (
332170754Sdelphij    UINT32                  c);
333170754Sdelphij
334170754SdelphijUINT32
335170754SdelphijAcpiPsGetName(
336170754Sdelphij    ACPI_PARSE_OBJECT       *op);
337170754Sdelphij
338170754Sdelphijvoid
339170754SdelphijAcpiPsSetName(
340170754Sdelphij    ACPI_PARSE_OBJECT       *op,
341170754Sdelphij    UINT32                  name);
342170754Sdelphij
343170754Sdelphij
344170754Sdelphij/*
345170754Sdelphij * psdump - display parser tree
346170754Sdelphij */
347170754SdelphijUINT32
348170754SdelphijAcpiPsSprintPath (
349170754Sdelphij    char                    *BufferStart,
350170754Sdelphij    UINT32                  BufferSize,
351170754Sdelphij    ACPI_PARSE_OBJECT       *Op);
352170754Sdelphij
353170754SdelphijUINT32
354170754SdelphijAcpiPsSprintOp (
355170754Sdelphij    char                    *BufferStart,
356170754Sdelphij    UINT32                  BufferSize,
357170754Sdelphij    ACPI_PARSE_OBJECT       *Op);
358170754Sdelphij
359170754Sdelphijvoid
360170754SdelphijAcpiPsShow (
361170754Sdelphij    ACPI_PARSE_OBJECT       *op);
362170754Sdelphij
363170754Sdelphij
364170754Sdelphij#endif /* __ACPARSER_H__ */
365170754Sdelphij