acparser.h revision 197104
1243730Srwatson/******************************************************************************
2243730Srwatson *
3243730Srwatson * Module Name: acparser.h - AML Parser subcomponent prototypes and defines
4243730Srwatson *
5243730Srwatson *****************************************************************************/
6243730Srwatson
7243730Srwatson/******************************************************************************
8243730Srwatson *
9243730Srwatson * 1. Copyright Notice
10243730Srwatson *
11243730Srwatson * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
12243730Srwatson * All rights reserved.
13243730Srwatson *
14243730Srwatson * 2. License
15243730Srwatson *
16243730Srwatson * 2.1. This is your license from Intel Corp. under its intellectual property
17243730Srwatson * rights.  You may have additional license terms from the party that provided
18243730Srwatson * you this software, covering your right to use that party's intellectual
19243730Srwatson * property rights.
20243730Srwatson *
21243730Srwatson * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22243730Srwatson * copy of the source code appearing in this file ("Covered Code") an
23243730Srwatson * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24243730Srwatson * base code distributed originally by Intel ("Original Intel Code") to copy,
25243730Srwatson * make derivatives, distribute, use and display any portion of the Covered
26243730Srwatson * Code in any form, with the right to sublicense such rights; and
27243730Srwatson *
28243730Srwatson * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29243730Srwatson * license (with the right to sublicense), under only those claims of Intel
30243730Srwatson * patents that are infringed by the Original Intel Code, to make, use, sell,
31243730Srwatson * offer to sell, and import the Covered Code and derivative works thereof
32243730Srwatson * solely to the minimum extent necessary to exercise the above copyright
33243730Srwatson * license, and in no event shall the patent license extend to any additions
34243730Srwatson * to or modifications of the Original Intel Code.  No other license or right
35243730Srwatson * is granted directly or by implication, estoppel or otherwise;
36243730Srwatson *
37243730Srwatson * The above copyright and patent license is granted only if the following
38243730Srwatson * conditions are met:
39243730Srwatson *
40243730Srwatson * 3. Conditions
41243730Srwatson *
42243730Srwatson * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43243730Srwatson * Redistribution of source code of any substantial portion of the Covered
44243730Srwatson * Code or modification with rights to further distribute source must include
45243730Srwatson * the above Copyright Notice, the above License, this list of Conditions,
46243730Srwatson * and the following Disclaimer and Export Compliance provision.  In addition,
47243730Srwatson * Licensee must cause all Covered Code to which Licensee contributes to
48243730Srwatson * contain a file documenting the changes Licensee made to create that Covered
49243730Srwatson * Code and the date of any change.  Licensee must include in that file the
50243730Srwatson * documentation of any changes made by any predecessor Licensee.  Licensee
51243730Srwatson * must include a prominent statement that the modification is derived,
52243730Srwatson * directly or indirectly, from Original Intel Code.
53243730Srwatson *
54243730Srwatson * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55243730Srwatson * Redistribution of source code of any substantial portion of the Covered
56243730Srwatson * Code or modification without rights to further distribute source must
57243730Srwatson * include the following Disclaimer and Export Compliance provision in the
58243730Srwatson * documentation and/or other materials provided with distribution.  In
59243730Srwatson * addition, Licensee may not authorize further sublicense of source of any
60243730Srwatson * portion of the Covered Code, and must include terms to the effect that the
61243730Srwatson * license from Licensee to its licensee is limited to the intellectual
62243730Srwatson * property embodied in the software Licensee provides to its licensee, and
63243730Srwatson * not to intellectual property embodied in modifications its licensee may
64243730Srwatson * make.
65243730Srwatson *
66243730Srwatson * 3.3. Redistribution of Executable. Redistribution in executable form of any
67243730Srwatson * substantial portion of the Covered Code or modification must reproduce the
68243730Srwatson * above Copyright Notice, and the following Disclaimer and Export Compliance
69243730Srwatson * provision in the documentation and/or other materials provided with the
70243730Srwatson * distribution.
71243730Srwatson *
72243730Srwatson * 3.4. Intel retains all right, title, and interest in and to the Original
73243730Srwatson * Intel Code.
74243730Srwatson *
75243730Srwatson * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76243730Srwatson * Intel shall be used in advertising or otherwise to promote the sale, use or
77243730Srwatson * other dealings in products derived from or relating to the Covered Code
78243730Srwatson * without prior written authorization from Intel.
79243730Srwatson *
80243730Srwatson * 4. Disclaimer and Export Compliance
81243730Srwatson *
82243730Srwatson * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83243730Srwatson * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84243730Srwatson * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
85243730Srwatson * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
86243730Srwatson * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
87243730Srwatson * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88243730Srwatson * PARTICULAR PURPOSE.
89243730Srwatson *
90243730Srwatson * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91243730Srwatson * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92243730Srwatson * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93243730Srwatson * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94243730Srwatson * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95243730Srwatson * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
96243730Srwatson * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97243730Srwatson * LIMITED REMEDY.
98243730Srwatson *
99243730Srwatson * 4.3. Licensee shall not export, either directly or indirectly, any of this
100243730Srwatson * software or system incorporating such software without first obtaining any
101243730Srwatson * required license or other approval from the U. S. Department of Commerce or
102243730Srwatson * any other agency or department of the United States Government.  In the
103243730Srwatson * event Licensee exports any such software from the United States or
104243730Srwatson * re-exports any such software from a foreign destination, Licensee shall
105243730Srwatson * ensure that the distribution and export/re-export of the software is in
106243730Srwatson * compliance with all laws, regulations, orders, or other restrictions of the
107243730Srwatson * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108243730Srwatson * any of its subsidiaries will export/re-export any technical data, process,
109243730Srwatson * software, or service, directly or indirectly, to any country for which the
110243730Srwatson * United States government or any agency thereof requires an export license,
111243730Srwatson * other governmental approval, or letter of assurance, without first obtaining
112243730Srwatson * such license, approval or letter.
113243730Srwatson *
114243730Srwatson *****************************************************************************/
115243730Srwatson
116243730Srwatson
117243730Srwatson#ifndef __ACPARSER_H__
118243730Srwatson#define __ACPARSER_H__
119243730Srwatson
120243730Srwatson
121243730Srwatson#define OP_HAS_RETURN_VALUE             1
122243730Srwatson
123243730Srwatson/* Variable number of arguments. This field must be 32 bits */
124243730Srwatson
125243730Srwatson#define ACPI_VAR_ARGS                   ACPI_UINT32_MAX
126243730Srwatson
127243730Srwatson
128243730Srwatson#define ACPI_PARSE_DELETE_TREE          0x0001
129243730Srwatson#define ACPI_PARSE_NO_TREE_DELETE       0x0000
130243730Srwatson#define ACPI_PARSE_TREE_MASK            0x0001
131243730Srwatson
132243730Srwatson#define ACPI_PARSE_LOAD_PASS1           0x0010
133243730Srwatson#define ACPI_PARSE_LOAD_PASS2           0x0020
134243730Srwatson#define ACPI_PARSE_EXECUTE              0x0030
135243730Srwatson#define ACPI_PARSE_MODE_MASK            0x0030
136243730Srwatson
137243730Srwatson#define ACPI_PARSE_DEFERRED_OP          0x0100
138243730Srwatson#define ACPI_PARSE_DISASSEMBLE          0x0200
139243730Srwatson
140243730Srwatson#define ACPI_PARSE_MODULE_LEVEL         0x0400
141243730Srwatson
142243730Srwatson/******************************************************************************
143243730Srwatson *
144243730Srwatson * Parser interfaces
145243730Srwatson *
146243730Srwatson *****************************************************************************/
147243730Srwatson
148243730Srwatson
149243730Srwatson/*
150243730Srwatson * psxface - Parser external interfaces
151243730Srwatson */
152243730SrwatsonACPI_STATUS
153243730SrwatsonAcpiPsExecuteMethod (
154243730Srwatson    ACPI_EVALUATE_INFO      *Info);
155243730Srwatson
156243730Srwatson
157243730Srwatson/*
158243730Srwatson * psargs - Parse AML opcode arguments
159243730Srwatson */
160243730SrwatsonUINT8 *
161243730SrwatsonAcpiPsGetNextPackageEnd (
162243730Srwatson    ACPI_PARSE_STATE        *ParserState);
163243730Srwatson
164243730Srwatsonchar *
165243730SrwatsonAcpiPsGetNextNamestring (
166243730Srwatson    ACPI_PARSE_STATE        *ParserState);
167243730Srwatson
168243730Srwatsonvoid
169243730SrwatsonAcpiPsGetNextSimpleArg (
170243730Srwatson    ACPI_PARSE_STATE        *ParserState,
171243730Srwatson    UINT32                  ArgType,
172243730Srwatson    ACPI_PARSE_OBJECT       *Arg);
173243730Srwatson
174243730SrwatsonACPI_STATUS
175243730SrwatsonAcpiPsGetNextNamepath (
176243730Srwatson    ACPI_WALK_STATE         *WalkState,
177243730Srwatson    ACPI_PARSE_STATE        *ParserState,
178243730Srwatson    ACPI_PARSE_OBJECT       *Arg,
179243730Srwatson    BOOLEAN                 MethodCall);
180243730Srwatson
181243730SrwatsonACPI_STATUS
182243730SrwatsonAcpiPsGetNextArg (
183243730Srwatson    ACPI_WALK_STATE         *WalkState,
184243730Srwatson    ACPI_PARSE_STATE        *ParserState,
185243730Srwatson    UINT32                  ArgType,
186243730Srwatson    ACPI_PARSE_OBJECT       **ReturnArg);
187243730Srwatson
188243730Srwatson
189243730Srwatson/*
190243730Srwatson * psfind
191243730Srwatson */
192243730SrwatsonACPI_PARSE_OBJECT *
193243730SrwatsonAcpiPsFindName (
194243730Srwatson    ACPI_PARSE_OBJECT       *Scope,
195243730Srwatson    UINT32                  Name,
196243730Srwatson    UINT32                  Opcode);
197243730Srwatson
198243730SrwatsonACPI_PARSE_OBJECT*
199243730SrwatsonAcpiPsGetParent (
200243730Srwatson    ACPI_PARSE_OBJECT       *Op);
201243730Srwatson
202243730Srwatson
203243730Srwatson/*
204243730Srwatson * psopcode - AML Opcode information
205243730Srwatson */
206243730Srwatsonconst ACPI_OPCODE_INFO *
207243730SrwatsonAcpiPsGetOpcodeInfo (
208243730Srwatson    UINT16                  Opcode);
209243730Srwatson
210243730Srwatsonchar *
211243730SrwatsonAcpiPsGetOpcodeName (
212243730Srwatson    UINT16                  Opcode);
213243730Srwatson
214243730SrwatsonUINT8
215243730SrwatsonAcpiPsGetArgumentCount (
216243730Srwatson    UINT32                  OpType);
217243730Srwatson
218243730Srwatson
219243730Srwatson/*
220243730Srwatson * psparse - top level parsing routines
221243730Srwatson */
222243730SrwatsonACPI_STATUS
223243730SrwatsonAcpiPsParseAml (
224243730Srwatson    ACPI_WALK_STATE         *WalkState);
225243730Srwatson
226243730SrwatsonUINT32
227243730SrwatsonAcpiPsGetOpcodeSize (
228243730Srwatson    UINT32                  Opcode);
229243730Srwatson
230243730SrwatsonUINT16
231243730SrwatsonAcpiPsPeekOpcode (
232243730Srwatson    ACPI_PARSE_STATE        *state);
233243730Srwatson
234243730SrwatsonACPI_STATUS
235243730SrwatsonAcpiPsCompleteThisOp (
236243730Srwatson    ACPI_WALK_STATE         *WalkState,
237243730Srwatson    ACPI_PARSE_OBJECT       *Op);
238243730Srwatson
239243730SrwatsonACPI_STATUS
240243730SrwatsonAcpiPsNextParseState (
241243730Srwatson    ACPI_WALK_STATE         *WalkState,
242243730Srwatson    ACPI_PARSE_OBJECT       *Op,
243243730Srwatson    ACPI_STATUS             CallbackStatus);
244243730Srwatson
245243730Srwatson
246243730Srwatson/*
247243730Srwatson * psloop - main parse loop
248243730Srwatson */
249243730SrwatsonACPI_STATUS
250243730SrwatsonAcpiPsParseLoop (
251243730Srwatson    ACPI_WALK_STATE         *WalkState);
252243730Srwatson
253243730Srwatson
254243730Srwatson/*
255243730Srwatson * psscope - Scope stack management routines
256243730Srwatson */
257243730SrwatsonACPI_STATUS
258243730SrwatsonAcpiPsInitScope (
259243730Srwatson    ACPI_PARSE_STATE        *ParserState,
260243730Srwatson    ACPI_PARSE_OBJECT       *Root);
261243730Srwatson
262243730SrwatsonACPI_PARSE_OBJECT *
263243730SrwatsonAcpiPsGetParentScope (
264243730Srwatson    ACPI_PARSE_STATE        *state);
265243730Srwatson
266243730SrwatsonBOOLEAN
267243730SrwatsonAcpiPsHasCompletedScope (
268243730Srwatson    ACPI_PARSE_STATE        *ParserState);
269243730Srwatson
270243730Srwatsonvoid
271243730SrwatsonAcpiPsPopScope (
272243730Srwatson    ACPI_PARSE_STATE        *ParserState,
273243730Srwatson    ACPI_PARSE_OBJECT       **Op,
274243730Srwatson    UINT32                  *ArgList,
275243730Srwatson    UINT32                  *ArgCount);
276243730Srwatson
277243730SrwatsonACPI_STATUS
278243730SrwatsonAcpiPsPushScope (
279243730Srwatson    ACPI_PARSE_STATE        *ParserState,
280243730Srwatson    ACPI_PARSE_OBJECT       *Op,
281243730Srwatson    UINT32                  RemainingArgs,
282243730Srwatson    UINT32                  ArgCount);
283243730Srwatson
284243730Srwatsonvoid
285243730SrwatsonAcpiPsCleanupScope (
286243730Srwatson    ACPI_PARSE_STATE        *state);
287243730Srwatson
288243730Srwatson
289243730Srwatson/*
290243730Srwatson * pstree - parse tree manipulation routines
291243730Srwatson */
292243730Srwatsonvoid
293243730SrwatsonAcpiPsAppendArg(
294243730Srwatson    ACPI_PARSE_OBJECT       *op,
295243730Srwatson    ACPI_PARSE_OBJECT       *arg);
296243730Srwatson
297243730SrwatsonACPI_PARSE_OBJECT*
298243730SrwatsonAcpiPsFind (
299243730Srwatson    ACPI_PARSE_OBJECT       *Scope,
300243730Srwatson    char                    *Path,
301243730Srwatson    UINT16                  Opcode,
302243730Srwatson    UINT32                  Create);
303243730Srwatson
304243730SrwatsonACPI_PARSE_OBJECT *
305243730SrwatsonAcpiPsGetArg(
306243730Srwatson    ACPI_PARSE_OBJECT       *op,
307243730Srwatson    UINT32                   argn);
308243730Srwatson
309243730SrwatsonACPI_PARSE_OBJECT *
310243730SrwatsonAcpiPsGetDepthNext (
311243730Srwatson    ACPI_PARSE_OBJECT       *Origin,
312243730Srwatson    ACPI_PARSE_OBJECT       *Op);
313243730Srwatson
314243730Srwatson
315243730Srwatson/*
316243730Srwatson * pswalk - parse tree walk routines
317243730Srwatson */
318243730SrwatsonACPI_STATUS
319243730SrwatsonAcpiPsWalkParsedAml (
320243730Srwatson    ACPI_PARSE_OBJECT       *StartOp,
321243730Srwatson    ACPI_PARSE_OBJECT       *EndOp,
322243730Srwatson    ACPI_OPERAND_OBJECT     *MthDesc,
323243730Srwatson    ACPI_NAMESPACE_NODE     *StartNode,
324243730Srwatson    ACPI_OPERAND_OBJECT     **Params,
325243730Srwatson    ACPI_OPERAND_OBJECT     **CallerReturnDesc,
326243730Srwatson    ACPI_OWNER_ID           OwnerId,
327243730Srwatson    ACPI_PARSE_DOWNWARDS    DescendingCallback,
328243730Srwatson    ACPI_PARSE_UPWARDS      AscendingCallback);
329243730Srwatson
330243730SrwatsonACPI_STATUS
331243730SrwatsonAcpiPsGetNextWalkOp (
332243730Srwatson    ACPI_WALK_STATE         *WalkState,
333243730Srwatson    ACPI_PARSE_OBJECT       *Op,
334243730Srwatson    ACPI_PARSE_UPWARDS      AscendingCallback);
335243730Srwatson
336243730SrwatsonACPI_STATUS
337243730SrwatsonAcpiPsDeleteCompletedOp (
338243730Srwatson    ACPI_WALK_STATE         *WalkState);
339243730Srwatson
340243730Srwatsonvoid
341243730SrwatsonAcpiPsDeleteParseTree (
342243730Srwatson    ACPI_PARSE_OBJECT       *root);
343243730Srwatson
344243730Srwatson
345243730Srwatson/*
346243730Srwatson * psutils - parser utilities
347243730Srwatson */
348243730SrwatsonACPI_PARSE_OBJECT *
349243730SrwatsonAcpiPsCreateScopeOp (
350243730Srwatson    void);
351243730Srwatson
352243730Srwatsonvoid
353243730SrwatsonAcpiPsInitOp (
354243730Srwatson    ACPI_PARSE_OBJECT       *op,
355243730Srwatson    UINT16                  opcode);
356243730Srwatson
357243730SrwatsonACPI_PARSE_OBJECT *
358243730SrwatsonAcpiPsAllocOp (
359243730Srwatson    UINT16                  opcode);
360243730Srwatson
361243730Srwatsonvoid
362243730SrwatsonAcpiPsFreeOp (
363243730Srwatson    ACPI_PARSE_OBJECT       *Op);
364243730Srwatson
365243730SrwatsonBOOLEAN
366243730SrwatsonAcpiPsIsLeadingChar (
367243730Srwatson    UINT32                  c);
368243730Srwatson
369243730SrwatsonBOOLEAN
370243730SrwatsonAcpiPsIsPrefixChar (
371243730Srwatson    UINT32                  c);
372243730Srwatson
373243730SrwatsonUINT32
374243730SrwatsonAcpiPsGetName(
375243730Srwatson    ACPI_PARSE_OBJECT       *op);
376243730Srwatson
377243730Srwatsonvoid
378243730SrwatsonAcpiPsSetName(
379243730Srwatson    ACPI_PARSE_OBJECT       *op,
380243730Srwatson    UINT32                  name);
381243730Srwatson
382243730Srwatson
383243730Srwatson/*
384243730Srwatson * psdump - display parser tree
385243730Srwatson */
386243730SrwatsonUINT32
387243730SrwatsonAcpiPsSprintPath (
388243730Srwatson    char                    *BufferStart,
389243730Srwatson    UINT32                  BufferSize,
390243730Srwatson    ACPI_PARSE_OBJECT       *Op);
391243730Srwatson
392243730SrwatsonUINT32
393243730SrwatsonAcpiPsSprintOp (
394243730Srwatson    char                    *BufferStart,
395243730Srwatson    UINT32                  BufferSize,
396243730Srwatson    ACPI_PARSE_OBJECT       *Op);
397243730Srwatson
398243730Srwatsonvoid
399243730SrwatsonAcpiPsShow (
400243730Srwatson    ACPI_PARSE_OBJECT       *op);
401243730Srwatson
402243730Srwatson
403243730Srwatson#endif /* __ACPARSER_H__ */
404243730Srwatson