acparser.h revision 193267
119304Speter/******************************************************************************
219304Speter *
319304Speter * Module Name: acparser.h - AML Parser subcomponent prototypes and defines
419304Speter *
519304Speter *****************************************************************************/
619304Speter
719304Speter/******************************************************************************
819304Speter *
919304Speter * 1. Copyright Notice
1019304Speter *
1119304Speter * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
1219304Speter * All rights reserved.
13254225Speter *
1419304Speter * 2. License
1519304Speter *
1619304Speter * 2.1. This is your license from Intel Corp. under its intellectual property
1719304Speter * rights.  You may have additional license terms from the party that provided
1819304Speter * you this software, covering your right to use that party's intellectual
1919304Speter * property rights.
2019304Speter *
2119304Speter * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
2219304Speter * copy of the source code appearing in this file ("Covered Code") an
2319304Speter * irrevocable, perpetual, worldwide license under Intel's copyrights in the
2419304Speter * base code distributed originally by Intel ("Original Intel Code") to copy,
2519304Speter * make derivatives, distribute, use and display any portion of the Covered
2619304Speter * Code in any form, with the right to sublicense such rights; and
2719304Speter *
28281373Sbapt * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29281373Sbapt * license (with the right to sublicense), under only those claims of Intel
3019304Speter * patents that are infringed by the Original Intel Code, to make, use, sell,
3119304Speter * offer to sell, and import the Covered Code and derivative works thereof
3219304Speter * solely to the minimum extent necessary to exercise the above copyright
3319304Speter * license, and in no event shall the patent license extend to any additions
3419304Speter * to or modifications of the Original Intel Code.  No other license or right
35281373Sbapt * is granted directly or by implication, estoppel or otherwise;
3619304Speter *
3719304Speter * The above copyright and patent license is granted only if the following
38254225Speter * conditions are met:
3919304Speter *
4019304Speter * 3. Conditions
4119304Speter *
4219304Speter * 3.1. Redistribution of Source with Rights to Further Distribute Source.
4319304Speter * Redistribution of source code of any substantial portion of the Covered
4419304Speter * Code or modification with rights to further distribute source must include
4519304Speter * the above Copyright Notice, the above License, this list of Conditions,
4619304Speter * and the following Disclaimer and Export Compliance provision.  In addition,
4719304Speter * Licensee must cause all Covered Code to which Licensee contributes to
4819304Speter * contain a file documenting the changes Licensee made to create that Covered
4919304Speter * Code and the date of any change.  Licensee must include in that file the
5019304Speter * documentation of any changes made by any predecessor Licensee.  Licensee
5119304Speter * must include a prominent statement that the modification is derived,
5219304Speter * directly or indirectly, from Original Intel Code.
5319304Speter *
5419304Speter * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
5519304Speter * Redistribution of source code of any substantial portion of the Covered
5619304Speter * Code or modification without rights to further distribute source must
5719304Speter * include the following Disclaimer and Export Compliance provision in the
5819304Speter * documentation and/or other materials provided with distribution.  In
5919304Speter * addition, Licensee may not authorize further sublicense of source of any
6019304Speter * portion of the Covered Code, and must include terms to the effect that the
6119304Speter * license from Licensee to its licensee is limited to the intellectual
6219304Speter * property embodied in the software Licensee provides to its licensee, and
6319304Speter * not to intellectual property embodied in modifications its licensee may
64281373Sbapt * make.
6519304Speter *
6619304Speter * 3.3. Redistribution of Executable. Redistribution in executable form of any
67254225Speter * substantial portion of the Covered Code or modification must reproduce the
6819304Speter * above Copyright Notice, and the following Disclaimer and Export Compliance
6919304Speter * provision in the documentation and/or other materials provided with the
7019304Speter * distribution.
7119304Speter *
7219304Speter * 3.4. Intel retains all right, title, and interest in and to the Original
7319304Speter * Intel Code.
7419304Speter *
7519304Speter * 3.5. Neither the name Intel nor any other trademark owned or controlled by
7619304Speter * Intel shall be used in advertising or otherwise to promote the sale, use or
7719304Speter * other dealings in products derived from or relating to the Covered Code
7819304Speter * without prior written authorization from Intel.
7919304Speter *
8019304Speter * 4. Disclaimer and Export Compliance
8119304Speter *
8219304Speter * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
8319304Speter * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
8419304Speter * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
8519304Speter * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
8619304Speter * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
8719304Speter * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
8819304Speter * PARTICULAR PURPOSE.
8919304Speter *
9019304Speter * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
9119304Speter * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
9219304Speter * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
9319304Speter * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
9419304Speter * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
9519304Speter * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
9619304Speter * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
9719304Speter * LIMITED REMEDY.
9819304Speter *
9919304Speter * 4.3. Licensee shall not export, either directly or indirectly, any of this
10019304Speter * software or system incorporating such software without first obtaining any
10119304Speter * required license or other approval from the U. S. Department of Commerce or
10219304Speter * any other agency or department of the United States Government.  In the
103281373Sbapt * event Licensee exports any such software from the United States or
10419304Speter * re-exports any such software from a foreign destination, Licensee shall
10519304Speter * ensure that the distribution and export/re-export of the software is in
106254225Speter * compliance with all laws, regulations, orders, or other restrictions of the
10719304Speter * U.S. Export Administration Regulations. Licensee agrees that neither it nor
10819304Speter * any of its subsidiaries will export/re-export any technical data, process,
10919304Speter * software, or service, directly or indirectly, to any country for which the
11019304Speter * United States government or any agency thereof requires an export license,
11119304Speter * other governmental approval, or letter of assurance, without first obtaining
11219304Speter * such license, approval or letter.
11319304Speter *
11419304Speter *****************************************************************************/
11519304Speter
11619304Speter
11719304Speter#ifndef __ACPARSER_H__
11819304Speter#define __ACPARSER_H__
11919304Speter
12019304Speter
12119304Speter#define OP_HAS_RETURN_VALUE             1
12219304Speter
12319304Speter/* Variable number of arguments. This field must be 32 bits */
12419304Speter
12519304Speter#define ACPI_VAR_ARGS                   ACPI_UINT32_MAX
12619304Speter
12719304Speter
12819304Speter#define ACPI_PARSE_DELETE_TREE          0x0001
12919304Speter#define ACPI_PARSE_NO_TREE_DELETE       0x0000
13019304Speter#define ACPI_PARSE_TREE_MASK            0x0001
13119304Speter
13219304Speter#define ACPI_PARSE_LOAD_PASS1           0x0010
13319304Speter#define ACPI_PARSE_LOAD_PASS2           0x0020
134281373Sbapt#define ACPI_PARSE_EXECUTE              0x0030
13519304Speter#define ACPI_PARSE_MODE_MASK            0x0030
13619304Speter
137254225Speter#define ACPI_PARSE_DEFERRED_OP          0x0100
13819304Speter#define ACPI_PARSE_DISASSEMBLE          0x0200
13919304Speter
14019304Speter
141254225Speter/******************************************************************************
142254225Speter *
143254225Speter * Parser interfaces
14419304Speter *
14519304Speter *****************************************************************************/
14619304Speter
14719304Speter
14819304Speter/*
14919304Speter * psxface - Parser external interfaces
15019304Speter */
15119304SpeterACPI_STATUS
15219304SpeterAcpiPsExecuteMethod (
15319304Speter    ACPI_EVALUATE_INFO      *Info);
15419304Speter
15519304Speter
15619304Speter/*
15719304Speter * psargs - Parse AML opcode arguments
15819304Speter */
15919304SpeterUINT8 *
16019304SpeterAcpiPsGetNextPackageEnd (
16119304Speter    ACPI_PARSE_STATE        *ParserState);
16219304Speter
16319304Speterchar *
16419304SpeterAcpiPsGetNextNamestring (
16519304Speter    ACPI_PARSE_STATE        *ParserState);
16619304Speter
16719304Spetervoid
16819304SpeterAcpiPsGetNextSimpleArg (
16919304Speter    ACPI_PARSE_STATE        *ParserState,
17019304Speter    UINT32                  ArgType,
17119304Speter    ACPI_PARSE_OBJECT       *Arg);
17219304Speter
17319304SpeterACPI_STATUS
17419304SpeterAcpiPsGetNextNamepath (
17519304Speter    ACPI_WALK_STATE         *WalkState,
17619304Speter    ACPI_PARSE_STATE        *ParserState,
17719304Speter    ACPI_PARSE_OBJECT       *Arg,
17819304Speter    BOOLEAN                 MethodCall);
17919304Speter
18019304SpeterACPI_STATUS
18119304SpeterAcpiPsGetNextArg (
18219304Speter    ACPI_WALK_STATE         *WalkState,
18319304Speter    ACPI_PARSE_STATE        *ParserState,
18419304Speter    UINT32                  ArgType,
18519304Speter    ACPI_PARSE_OBJECT       **ReturnArg);
18619304Speter
18719304Speter
18819304Speter/*
18919304Speter * psfind
19019304Speter */
191281373SbaptACPI_PARSE_OBJECT *
19219304SpeterAcpiPsFindName (
19319304Speter    ACPI_PARSE_OBJECT       *Scope,
194254225Speter    UINT32                  Name,
19519304Speter    UINT32                  Opcode);
19619304Speter
19719304SpeterACPI_PARSE_OBJECT*
19819304SpeterAcpiPsGetParent (
19919304Speter    ACPI_PARSE_OBJECT       *Op);
20019304Speter
20119304Speter
20219304Speter/*
20319304Speter * psopcode - AML Opcode information
20419304Speter */
20519304Speterconst ACPI_OPCODE_INFO *
20619304SpeterAcpiPsGetOpcodeInfo (
20719304Speter    UINT16                  Opcode);
20819304Speter
20919304Speterchar *
21019304SpeterAcpiPsGetOpcodeName (
21119304Speter    UINT16                  Opcode);
21219304Speter
21319304SpeterUINT8
21419304SpeterAcpiPsGetArgumentCount (
21519304Speter    UINT32                  OpType);
216281373Sbapt
21719304Speter
21819304Speter/*
219254225Speter * psparse - top level parsing routines
22019304Speter */
22119304SpeterACPI_STATUS
22219304SpeterAcpiPsParseAml (
223254225Speter    ACPI_WALK_STATE         *WalkState);
224254225Speter
225254225SpeterUINT32
22619304SpeterAcpiPsGetOpcodeSize (
22719304Speter    UINT32                  Opcode);
22819304Speter
22919304SpeterUINT16
23019304SpeterAcpiPsPeekOpcode (
23119304Speter    ACPI_PARSE_STATE        *state);
23219304Speter
23319304SpeterACPI_STATUS
23419304SpeterAcpiPsCompleteThisOp (
23519304Speter    ACPI_WALK_STATE         *WalkState,
23619304Speter    ACPI_PARSE_OBJECT       *Op);
23719304Speter
23819304SpeterACPI_STATUS
23919304SpeterAcpiPsNextParseState (
24019304Speter    ACPI_WALK_STATE         *WalkState,
24119304Speter    ACPI_PARSE_OBJECT       *Op,
24219304Speter    ACPI_STATUS             CallbackStatus);
24319304Speter
24419304Speter
24519304Speter/*
24619304Speter * psloop - main parse loop
24719304Speter */
24819304SpeterACPI_STATUS
24919304SpeterAcpiPsParseLoop (
25019304Speter    ACPI_WALK_STATE         *WalkState);
25119304Speter
25219304Speter
25319304Speter/*
25419304Speter * psscope - Scope stack management routines
25519304Speter */
25619304SpeterACPI_STATUS
25719304SpeterAcpiPsInitScope (
25819304Speter    ACPI_PARSE_STATE        *ParserState,
25919304Speter    ACPI_PARSE_OBJECT       *Root);
26019304Speter
26119304SpeterACPI_PARSE_OBJECT *
26219304SpeterAcpiPsGetParentScope (
26319304Speter    ACPI_PARSE_STATE        *state);
26419304Speter
26519304SpeterBOOLEAN
26619304SpeterAcpiPsHasCompletedScope (
26719304Speter    ACPI_PARSE_STATE        *ParserState);
26819304Speter
26919304Spetervoid
27019304SpeterAcpiPsPopScope (
27119304Speter    ACPI_PARSE_STATE        *ParserState,
27219304Speter    ACPI_PARSE_OBJECT       **Op,
273254225Speter    UINT32                  *ArgList,
27419304Speter    UINT32                  *ArgCount);
27519304Speter
27619304SpeterACPI_STATUS
27719304SpeterAcpiPsPushScope (
27819304Speter    ACPI_PARSE_STATE        *ParserState,
279254225Speter    ACPI_PARSE_OBJECT       *Op,
28019304Speter    UINT32                  RemainingArgs,
28119304Speter    UINT32                  ArgCount);
28219304Speter
283void
284AcpiPsCleanupScope (
285    ACPI_PARSE_STATE        *state);
286
287
288/*
289 * pstree - parse tree manipulation routines
290 */
291void
292AcpiPsAppendArg(
293    ACPI_PARSE_OBJECT       *op,
294    ACPI_PARSE_OBJECT       *arg);
295
296ACPI_PARSE_OBJECT*
297AcpiPsFind (
298    ACPI_PARSE_OBJECT       *Scope,
299    char                    *Path,
300    UINT16                  Opcode,
301    UINT32                  Create);
302
303ACPI_PARSE_OBJECT *
304AcpiPsGetArg(
305    ACPI_PARSE_OBJECT       *op,
306    UINT32                   argn);
307
308ACPI_PARSE_OBJECT *
309AcpiPsGetDepthNext (
310    ACPI_PARSE_OBJECT       *Origin,
311    ACPI_PARSE_OBJECT       *Op);
312
313
314/*
315 * pswalk - parse tree walk routines
316 */
317ACPI_STATUS
318AcpiPsWalkParsedAml (
319    ACPI_PARSE_OBJECT       *StartOp,
320    ACPI_PARSE_OBJECT       *EndOp,
321    ACPI_OPERAND_OBJECT     *MthDesc,
322    ACPI_NAMESPACE_NODE     *StartNode,
323    ACPI_OPERAND_OBJECT     **Params,
324    ACPI_OPERAND_OBJECT     **CallerReturnDesc,
325    ACPI_OWNER_ID           OwnerId,
326    ACPI_PARSE_DOWNWARDS    DescendingCallback,
327    ACPI_PARSE_UPWARDS      AscendingCallback);
328
329ACPI_STATUS
330AcpiPsGetNextWalkOp (
331    ACPI_WALK_STATE         *WalkState,
332    ACPI_PARSE_OBJECT       *Op,
333    ACPI_PARSE_UPWARDS      AscendingCallback);
334
335ACPI_STATUS
336AcpiPsDeleteCompletedOp (
337    ACPI_WALK_STATE         *WalkState);
338
339void
340AcpiPsDeleteParseTree (
341    ACPI_PARSE_OBJECT       *root);
342
343
344/*
345 * psutils - parser utilities
346 */
347ACPI_PARSE_OBJECT *
348AcpiPsCreateScopeOp (
349    void);
350
351void
352AcpiPsInitOp (
353    ACPI_PARSE_OBJECT       *op,
354    UINT16                  opcode);
355
356ACPI_PARSE_OBJECT *
357AcpiPsAllocOp (
358    UINT16                  opcode);
359
360void
361AcpiPsFreeOp (
362    ACPI_PARSE_OBJECT       *Op);
363
364BOOLEAN
365AcpiPsIsLeadingChar (
366    UINT32                  c);
367
368BOOLEAN
369AcpiPsIsPrefixChar (
370    UINT32                  c);
371
372UINT32
373AcpiPsGetName(
374    ACPI_PARSE_OBJECT       *op);
375
376void
377AcpiPsSetName(
378    ACPI_PARSE_OBJECT       *op,
379    UINT32                  name);
380
381
382/*
383 * psdump - display parser tree
384 */
385UINT32
386AcpiPsSprintPath (
387    char                    *BufferStart,
388    UINT32                  BufferSize,
389    ACPI_PARSE_OBJECT       *Op);
390
391UINT32
392AcpiPsSprintOp (
393    char                    *BufferStart,
394    UINT32                  BufferSize,
395    ACPI_PARSE_OBJECT       *Op);
396
397void
398AcpiPsShow (
399    ACPI_PARSE_OBJECT       *op);
400
401
402#endif /* __ACPARSER_H__ */
403