2000-10-28 05:01:06 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Module Name: psparse - Parser top level AML parse routines
|
2007-03-22 17:24:05 +00:00
|
|
|
* $Revision: 1.171 $
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* 1. Copyright Notice
|
|
|
|
*
|
2007-03-22 17:24:05 +00:00
|
|
|
* Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp.
|
2000-12-21 06:56:46 +00:00
|
|
|
* All rights reserved.
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
* 2. License
|
|
|
|
*
|
|
|
|
* 2.1. This is your license from Intel Corp. under its intellectual property
|
|
|
|
* rights. You may have additional license terms from the party that provided
|
|
|
|
* you this software, covering your right to use that party's intellectual
|
|
|
|
* property rights.
|
|
|
|
*
|
|
|
|
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
|
|
|
|
* copy of the source code appearing in this file ("Covered Code") an
|
|
|
|
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
|
|
|
|
* base code distributed originally by Intel ("Original Intel Code") to copy,
|
|
|
|
* make derivatives, distribute, use and display any portion of the Covered
|
|
|
|
* Code in any form, with the right to sublicense such rights; and
|
|
|
|
*
|
|
|
|
* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
|
|
|
|
* license (with the right to sublicense), under only those claims of Intel
|
|
|
|
* patents that are infringed by the Original Intel Code, to make, use, sell,
|
|
|
|
* offer to sell, and import the Covered Code and derivative works thereof
|
|
|
|
* solely to the minimum extent necessary to exercise the above copyright
|
|
|
|
* license, and in no event shall the patent license extend to any additions
|
|
|
|
* to or modifications of the Original Intel Code. No other license or right
|
|
|
|
* is granted directly or by implication, estoppel or otherwise;
|
|
|
|
*
|
|
|
|
* The above copyright and patent license is granted only if the following
|
|
|
|
* conditions are met:
|
|
|
|
*
|
|
|
|
* 3. Conditions
|
|
|
|
*
|
|
|
|
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
|
|
|
|
* Redistribution of source code of any substantial portion of the Covered
|
|
|
|
* Code or modification with rights to further distribute source must include
|
|
|
|
* the above Copyright Notice, the above License, this list of Conditions,
|
|
|
|
* and the following Disclaimer and Export Compliance provision. In addition,
|
|
|
|
* Licensee must cause all Covered Code to which Licensee contributes to
|
|
|
|
* contain a file documenting the changes Licensee made to create that Covered
|
|
|
|
* Code and the date of any change. Licensee must include in that file the
|
|
|
|
* documentation of any changes made by any predecessor Licensee. Licensee
|
|
|
|
* must include a prominent statement that the modification is derived,
|
|
|
|
* directly or indirectly, from Original Intel Code.
|
|
|
|
*
|
|
|
|
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
|
|
|
|
* Redistribution of source code of any substantial portion of the Covered
|
|
|
|
* Code or modification without rights to further distribute source must
|
|
|
|
* include the following Disclaimer and Export Compliance provision in the
|
|
|
|
* documentation and/or other materials provided with distribution. In
|
|
|
|
* addition, Licensee may not authorize further sublicense of source of any
|
|
|
|
* portion of the Covered Code, and must include terms to the effect that the
|
|
|
|
* license from Licensee to its licensee is limited to the intellectual
|
|
|
|
* property embodied in the software Licensee provides to its licensee, and
|
|
|
|
* not to intellectual property embodied in modifications its licensee may
|
|
|
|
* make.
|
|
|
|
*
|
|
|
|
* 3.3. Redistribution of Executable. Redistribution in executable form of any
|
|
|
|
* substantial portion of the Covered Code or modification must reproduce the
|
|
|
|
* above Copyright Notice, and the following Disclaimer and Export Compliance
|
|
|
|
* provision in the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
*
|
|
|
|
* 3.4. Intel retains all right, title, and interest in and to the Original
|
|
|
|
* Intel Code.
|
|
|
|
*
|
|
|
|
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
|
|
|
|
* Intel shall be used in advertising or otherwise to promote the sale, use or
|
|
|
|
* other dealings in products derived from or relating to the Covered Code
|
|
|
|
* without prior written authorization from Intel.
|
|
|
|
*
|
|
|
|
* 4. Disclaimer and Export Compliance
|
|
|
|
*
|
|
|
|
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
|
|
|
|
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
|
|
|
|
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
|
|
|
|
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
|
|
|
|
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
|
|
|
|
* PARTICULAR PURPOSE.
|
|
|
|
*
|
|
|
|
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
|
|
|
|
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
|
|
|
|
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
|
|
|
|
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
|
|
|
|
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
|
|
|
|
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
|
|
|
|
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
|
|
|
|
* LIMITED REMEDY.
|
|
|
|
*
|
|
|
|
* 4.3. Licensee shall not export, either directly or indirectly, any of this
|
|
|
|
* software or system incorporating such software without first obtaining any
|
|
|
|
* required license or other approval from the U. S. Department of Commerce or
|
|
|
|
* any other agency or department of the United States Government. In the
|
|
|
|
* event Licensee exports any such software from the United States or
|
|
|
|
* re-exports any such software from a foreign destination, Licensee shall
|
|
|
|
* ensure that the distribution and export/re-export of the software is in
|
|
|
|
* compliance with all laws, regulations, orders, or other restrictions of the
|
|
|
|
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
|
|
|
|
* any of its subsidiaries will export/re-export any technical data, process,
|
|
|
|
* software, or service, directly or indirectly, to any country for which the
|
|
|
|
* United States government or any agency thereof requires an export license,
|
|
|
|
* other governmental approval, or letter of assurance, without first obtaining
|
|
|
|
* such license, approval or letter.
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Parse the AML and build an operation tree as most interpreters,
|
|
|
|
* like Perl, do. Parsing is done by hand rather than with a YACC
|
|
|
|
* generated parser to tightly constrain stack and dynamic memory
|
|
|
|
* usage. At the same time, parsing is kept flexible and the code
|
|
|
|
* fairly compact by parsing based on a list of AML opcode
|
2000-12-01 09:36:25 +00:00
|
|
|
* templates in AmlOpInfo[]
|
2000-10-28 05:01:06 +00:00
|
|
|
*/
|
|
|
|
|
2005-10-24 04:31:06 +00:00
|
|
|
#include <contrib/dev/acpica/acpi.h>
|
|
|
|
#include <contrib/dev/acpica/acparser.h>
|
|
|
|
#include <contrib/dev/acpica/acdispat.h>
|
|
|
|
#include <contrib/dev/acpica/amlcode.h>
|
|
|
|
#include <contrib/dev/acpica/acnamesp.h>
|
|
|
|
#include <contrib/dev/acpica/acinterp.h>
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
#define _COMPONENT ACPI_PARSER
|
2002-02-23 05:10:40 +00:00
|
|
|
ACPI_MODULE_NAME ("psparse")
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
2001-09-07 01:22:25 +00:00
|
|
|
* FUNCTION: AcpiPsGetOpcodeSize
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2001-09-07 01:22:25 +00:00
|
|
|
* PARAMETERS: Opcode - An AML opcode
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2001-09-07 01:22:25 +00:00
|
|
|
* RETURN: Size of the opcode, in bytes (1 or 2)
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2001-09-07 01:22:25 +00:00
|
|
|
* DESCRIPTION: Get the size of the current opcode.
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2001-11-28 04:29:40 +00:00
|
|
|
UINT32
|
2000-10-28 05:01:06 +00:00
|
|
|
AcpiPsGetOpcodeSize (
|
|
|
|
UINT32 Opcode)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* Extended (2-byte) opcode if > 255 */
|
|
|
|
|
|
|
|
if (Opcode > 0x00FF)
|
|
|
|
{
|
|
|
|
return (2);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Otherwise, just a single byte opcode */
|
|
|
|
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: AcpiPsPeekOpcode
|
|
|
|
*
|
|
|
|
* PARAMETERS: ParserState - A parser state object
|
|
|
|
*
|
2005-11-01 22:11:18 +00:00
|
|
|
* RETURN: Next AML opcode
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
* DESCRIPTION: Get next AML opcode (without incrementing AML pointer)
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
UINT16
|
|
|
|
AcpiPsPeekOpcode (
|
|
|
|
ACPI_PARSE_STATE *ParserState)
|
|
|
|
{
|
|
|
|
UINT8 *Aml;
|
|
|
|
UINT16 Opcode;
|
|
|
|
|
|
|
|
|
|
|
|
Aml = ParserState->Aml;
|
2002-02-23 05:10:40 +00:00
|
|
|
Opcode = (UINT16) ACPI_GET8 (Aml);
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2005-11-01 22:11:18 +00:00
|
|
|
if (Opcode == AML_EXTENDED_OP_PREFIX)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2005-11-01 22:11:18 +00:00
|
|
|
/* Extended opcode, get the second opcode byte */
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-11-28 04:29:40 +00:00
|
|
|
Aml++;
|
2002-02-23 05:10:40 +00:00
|
|
|
Opcode = (UINT16) ((Opcode << 8) | ACPI_GET8 (Aml));
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return (Opcode);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: AcpiPsCompleteThisOp
|
|
|
|
*
|
|
|
|
* PARAMETERS: WalkState - Current State
|
|
|
|
* Op - Op to complete
|
|
|
|
*
|
2005-11-01 22:11:18 +00:00
|
|
|
* RETURN: Status
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
* DESCRIPTION: Perform any cleanup at the completion of an Op.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-11-01 22:11:18 +00:00
|
|
|
ACPI_STATUS
|
2000-10-28 05:01:06 +00:00
|
|
|
AcpiPsCompleteThisOp (
|
|
|
|
ACPI_WALK_STATE *WalkState,
|
|
|
|
ACPI_PARSE_OBJECT *Op)
|
|
|
|
{
|
|
|
|
ACPI_PARSE_OBJECT *Prev;
|
|
|
|
ACPI_PARSE_OBJECT *Next;
|
2001-09-07 01:22:25 +00:00
|
|
|
const ACPI_OPCODE_INFO *ParentInfo;
|
2000-10-28 05:01:06 +00:00
|
|
|
ACPI_PARSE_OBJECT *ReplacementOp = NULL;
|
|
|
|
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_FUNCTION_TRACE_PTR (PsCompleteThisOp, Op);
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
/* Check for null Op, can happen if AML code is corrupt */
|
|
|
|
|
|
|
|
if (!Op)
|
|
|
|
{
|
2005-11-01 22:11:18 +00:00
|
|
|
return_ACPI_STATUS (AE_OK); /* OK for now */
|
2002-02-23 05:10:40 +00:00
|
|
|
}
|
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
/* Delete this op and the subtree below it if asked to */
|
|
|
|
|
2004-12-01 23:14:10 +00:00
|
|
|
if (((WalkState->ParseFlags & ACPI_PARSE_TREE_MASK) != ACPI_PARSE_DELETE_TREE) ||
|
|
|
|
(WalkState->OpInfo->Class == AML_CLASS_ARGUMENT))
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2005-11-01 22:11:18 +00:00
|
|
|
return_ACPI_STATUS (AE_OK);
|
2004-12-01 23:14:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Make sure that we only delete this subtree */
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2004-12-01 23:14:10 +00:00
|
|
|
if (Op->Common.Parent)
|
|
|
|
{
|
2005-11-01 22:11:18 +00:00
|
|
|
Prev = Op->Common.Parent->Common.Value.Arg;
|
|
|
|
if (!Prev)
|
|
|
|
{
|
|
|
|
/* Nothing more to do */
|
|
|
|
|
|
|
|
goto Cleanup;
|
|
|
|
}
|
|
|
|
|
2004-12-01 23:14:10 +00:00
|
|
|
/*
|
|
|
|
* Check if we need to replace the operator and its subtree
|
|
|
|
* with a return value op (placeholder op)
|
|
|
|
*/
|
2005-11-01 22:11:18 +00:00
|
|
|
ParentInfo = AcpiPsGetOpcodeInfo (Op->Common.Parent->Common.AmlOpcode);
|
2004-12-01 23:14:10 +00:00
|
|
|
|
|
|
|
switch (ParentInfo->Class)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2004-12-01 23:14:10 +00:00
|
|
|
case AML_CLASS_CONTROL:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AML_CLASS_CREATE:
|
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
/*
|
2004-12-01 23:14:10 +00:00
|
|
|
* These opcodes contain TermArg operands. The current
|
|
|
|
* op must be replaced by a placeholder return op
|
2000-10-28 05:01:06 +00:00
|
|
|
*/
|
2004-12-01 23:14:10 +00:00
|
|
|
ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP);
|
|
|
|
if (!ReplacementOp)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2005-11-01 22:11:18 +00:00
|
|
|
goto AllocateError;
|
2004-12-01 23:14:10 +00:00
|
|
|
}
|
|
|
|
break;
|
2000-12-08 09:20:40 +00:00
|
|
|
|
2004-12-01 23:14:10 +00:00
|
|
|
case AML_CLASS_NAMED_OBJECT:
|
2000-12-21 06:56:46 +00:00
|
|
|
|
2004-12-01 23:14:10 +00:00
|
|
|
/*
|
|
|
|
* These opcodes contain TermArg operands. The current
|
|
|
|
* op must be replaced by a placeholder return op
|
|
|
|
*/
|
|
|
|
if ((Op->Common.Parent->Common.AmlOpcode == AML_REGION_OP) ||
|
|
|
|
(Op->Common.Parent->Common.AmlOpcode == AML_DATA_REGION_OP) ||
|
|
|
|
(Op->Common.Parent->Common.AmlOpcode == AML_BUFFER_OP) ||
|
|
|
|
(Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
|
|
|
|
(Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP))
|
|
|
|
{
|
2001-11-28 04:29:40 +00:00
|
|
|
ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP);
|
|
|
|
if (!ReplacementOp)
|
|
|
|
{
|
2005-11-01 22:11:18 +00:00
|
|
|
goto AllocateError;
|
2001-11-28 04:29:40 +00:00
|
|
|
}
|
2004-12-01 23:14:10 +00:00
|
|
|
}
|
2005-11-01 22:11:18 +00:00
|
|
|
else if ((Op->Common.Parent->Common.AmlOpcode == AML_NAME_OP) &&
|
|
|
|
(WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS2))
|
2004-12-01 23:14:10 +00:00
|
|
|
{
|
|
|
|
if ((Op->Common.AmlOpcode == AML_BUFFER_OP) ||
|
|
|
|
(Op->Common.AmlOpcode == AML_PACKAGE_OP) ||
|
|
|
|
(Op->Common.AmlOpcode == AML_VAR_PACKAGE_OP))
|
2000-12-08 09:20:40 +00:00
|
|
|
{
|
2004-12-01 23:14:10 +00:00
|
|
|
ReplacementOp = AcpiPsAllocOp (Op->Common.AmlOpcode);
|
2000-12-08 09:20:40 +00:00
|
|
|
if (!ReplacementOp)
|
|
|
|
{
|
2005-11-01 22:11:18 +00:00
|
|
|
goto AllocateError;
|
2000-12-08 09:20:40 +00:00
|
|
|
}
|
2004-12-01 23:14:10 +00:00
|
|
|
|
|
|
|
ReplacementOp->Named.Data = Op->Named.Data;
|
|
|
|
ReplacementOp->Named.Length = Op->Named.Length;
|
2000-12-08 09:20:40 +00:00
|
|
|
}
|
2004-12-01 23:14:10 +00:00
|
|
|
}
|
|
|
|
break;
|
2002-06-30 17:50:46 +00:00
|
|
|
|
2004-12-01 23:14:10 +00:00
|
|
|
default:
|
2005-11-01 22:11:18 +00:00
|
|
|
|
2004-12-01 23:14:10 +00:00
|
|
|
ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP);
|
|
|
|
if (!ReplacementOp)
|
|
|
|
{
|
2005-11-01 22:11:18 +00:00
|
|
|
goto AllocateError;
|
2004-12-01 23:14:10 +00:00
|
|
|
}
|
|
|
|
}
|
2002-06-30 17:50:46 +00:00
|
|
|
|
2004-12-01 23:14:10 +00:00
|
|
|
/* We must unlink this op from the parent tree */
|
2002-06-30 17:50:46 +00:00
|
|
|
|
2004-12-01 23:14:10 +00:00
|
|
|
if (Prev == Op)
|
|
|
|
{
|
|
|
|
/* This op is the first in the list */
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2004-12-01 23:14:10 +00:00
|
|
|
if (ReplacementOp)
|
|
|
|
{
|
|
|
|
ReplacementOp->Common.Parent = Op->Common.Parent;
|
|
|
|
ReplacementOp->Common.Value.Arg = NULL;
|
|
|
|
ReplacementOp->Common.Node = Op->Common.Node;
|
|
|
|
Op->Common.Parent->Common.Value.Arg = ReplacementOp;
|
|
|
|
ReplacementOp->Common.Next = Op->Common.Next;
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
2004-12-01 23:14:10 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
Op->Common.Parent->Common.Value.Arg = Op->Common.Next;
|
|
|
|
}
|
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2004-12-01 23:14:10 +00:00
|
|
|
/* Search the parent list */
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2004-12-01 23:14:10 +00:00
|
|
|
else while (Prev)
|
|
|
|
{
|
|
|
|
/* Traverse all siblings in the parent's argument list */
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2004-12-01 23:14:10 +00:00
|
|
|
Next = Prev->Common.Next;
|
|
|
|
if (Next == Op)
|
|
|
|
{
|
2000-10-28 05:01:06 +00:00
|
|
|
if (ReplacementOp)
|
|
|
|
{
|
2004-12-01 23:14:10 +00:00
|
|
|
ReplacementOp->Common.Parent = Op->Common.Parent;
|
|
|
|
ReplacementOp->Common.Value.Arg = NULL;
|
|
|
|
ReplacementOp->Common.Node = Op->Common.Node;
|
|
|
|
Prev->Common.Next = ReplacementOp;
|
|
|
|
ReplacementOp->Common.Next = Op->Common.Next;
|
|
|
|
Next = NULL;
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-12-01 23:14:10 +00:00
|
|
|
Prev->Common.Next = Op->Common.Next;
|
|
|
|
Next = NULL;
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
}
|
2004-12-01 23:14:10 +00:00
|
|
|
Prev = Next;
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
2004-12-01 23:14:10 +00:00
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
2004-12-01 23:14:10 +00:00
|
|
|
Cleanup:
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2005-11-01 22:11:18 +00:00
|
|
|
/* Now we can actually delete the subtree rooted at Op */
|
|
|
|
|
|
|
|
AcpiPsDeleteParseTree (Op);
|
|
|
|
return_ACPI_STATUS (AE_OK);
|
|
|
|
|
|
|
|
|
|
|
|
AllocateError:
|
|
|
|
|
|
|
|
/* Always delete the subtree, even on error */
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2004-12-01 23:14:10 +00:00
|
|
|
AcpiPsDeleteParseTree (Op);
|
2005-11-01 22:11:18 +00:00
|
|
|
return_ACPI_STATUS (AE_NO_MEMORY);
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: AcpiPsNextParseState
|
|
|
|
*
|
2005-11-01 22:11:18 +00:00
|
|
|
* PARAMETERS: WalkState - Current state
|
|
|
|
* Op - Current parse op
|
|
|
|
* CallbackStatus - Status from previous operation
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2002-06-30 17:50:46 +00:00
|
|
|
* RETURN: Status
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2002-06-30 17:50:46 +00:00
|
|
|
* DESCRIPTION: Update the parser state based upon the return exception from
|
|
|
|
* the parser callback.
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2001-11-28 04:29:40 +00:00
|
|
|
ACPI_STATUS
|
2000-10-28 05:01:06 +00:00
|
|
|
AcpiPsNextParseState (
|
|
|
|
ACPI_WALK_STATE *WalkState,
|
|
|
|
ACPI_PARSE_OBJECT *Op,
|
|
|
|
ACPI_STATUS CallbackStatus)
|
|
|
|
{
|
2001-10-04 23:12:13 +00:00
|
|
|
ACPI_PARSE_STATE *ParserState = &WalkState->ParserState;
|
2000-10-28 05:01:06 +00:00
|
|
|
ACPI_STATUS Status = AE_CTRL_PENDING;
|
|
|
|
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_FUNCTION_TRACE_PTR (PsNextParseState, Op);
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
switch (CallbackStatus)
|
|
|
|
{
|
|
|
|
case AE_CTRL_TERMINATE:
|
|
|
|
/*
|
|
|
|
* A control method was terminated via a RETURN statement.
|
|
|
|
* The walk of this method is complete.
|
|
|
|
*/
|
|
|
|
ParserState->Aml = ParserState->AmlEnd;
|
|
|
|
Status = AE_CTRL_TERMINATE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
case AE_CTRL_BREAK:
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
ParserState->Aml = WalkState->AmlLastWhile;
|
|
|
|
WalkState->ControlState->Common.Value = FALSE;
|
|
|
|
Status = AE_CTRL_BREAK;
|
|
|
|
break;
|
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
case AE_CTRL_CONTINUE:
|
2002-02-23 05:10:40 +00:00
|
|
|
|
|
|
|
ParserState->Aml = WalkState->AmlLastWhile;
|
|
|
|
Status = AE_CTRL_CONTINUE;
|
|
|
|
break;
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
case AE_CTRL_PENDING:
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
ParserState->Aml = WalkState->AmlLastWhile;
|
|
|
|
break;
|
|
|
|
|
2002-08-29 01:51:24 +00:00
|
|
|
#if 0
|
|
|
|
case AE_CTRL_SKIP:
|
|
|
|
|
|
|
|
ParserState->Aml = ParserState->Scope->ParseScope.PkgEnd;
|
|
|
|
Status = AE_OK;
|
|
|
|
break;
|
|
|
|
#endif
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
case AE_CTRL_TRUE:
|
2001-09-07 01:22:25 +00:00
|
|
|
/*
|
|
|
|
* Predicate of an IF was true, and we are at the matching ELSE.
|
|
|
|
* Just close out this package
|
|
|
|
*/
|
2002-02-23 05:10:40 +00:00
|
|
|
ParserState->Aml = AcpiPsGetNextPackageEnd (ParserState);
|
2007-03-22 17:24:05 +00:00
|
|
|
Status = AE_CTRL_PENDING;
|
2000-10-28 05:01:06 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case AE_CTRL_FALSE:
|
|
|
|
/*
|
|
|
|
* Either an IF/WHILE Predicate was false or we encountered a BREAK
|
|
|
|
* opcode. In both cases, we do not execute the rest of the
|
|
|
|
* package; We simply close out the parent (finishing the walk of
|
|
|
|
* this branch of the tree) and continue execution at the parent
|
|
|
|
* level.
|
|
|
|
*/
|
|
|
|
ParserState->Aml = ParserState->Scope->ParseScope.PkgEnd;
|
|
|
|
|
|
|
|
/* In the case of a BREAK, just force a predicate (if any) to FALSE */
|
|
|
|
|
|
|
|
WalkState->ControlState->Common.Value = FALSE;
|
|
|
|
Status = AE_CTRL_END;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case AE_CTRL_TRANSFER:
|
|
|
|
|
2005-11-01 22:11:18 +00:00
|
|
|
/* A method call (invocation) -- transfer control */
|
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
Status = AE_CTRL_TRANSFER;
|
|
|
|
WalkState->PrevOp = Op;
|
|
|
|
WalkState->MethodCallOp = Op;
|
2002-07-09 17:51:31 +00:00
|
|
|
WalkState->MethodCallNode = (Op->Common.Value.Arg)->Common.Node;
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
/* Will return value (if any) be used by the caller? */
|
|
|
|
|
|
|
|
WalkState->ReturnUsed = AcpiDsIsResultUsed (Op, WalkState);
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
2005-11-01 22:11:18 +00:00
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
Status = CallbackStatus;
|
|
|
|
if ((CallbackStatus & AE_CODE_MASK) == AE_CODE_CONTROL)
|
|
|
|
{
|
|
|
|
Status = AE_OK;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: AcpiPsParseAml
|
|
|
|
*
|
2005-11-01 22:11:18 +00:00
|
|
|
* PARAMETERS: WalkState - Current state
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2001-09-07 01:22:25 +00:00
|
|
|
*
|
2000-10-28 05:01:06 +00:00
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Parse raw AML and return a tree of ops
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
ACPI_STATUS
|
|
|
|
AcpiPsParseAml (
|
2001-10-04 23:12:13 +00:00
|
|
|
ACPI_WALK_STATE *WalkState)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
|
|
|
ACPI_STATUS Status;
|
2001-11-28 04:29:40 +00:00
|
|
|
ACPI_THREAD_STATE *Thread;
|
|
|
|
ACPI_THREAD_STATE *PrevWalkList = AcpiGbl_CurrentWalkList;
|
2001-10-04 23:12:13 +00:00
|
|
|
ACPI_WALK_STATE *PreviousWalkState;
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_FUNCTION_TRACE (PsParseAml);
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2005-11-01 22:11:18 +00:00
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
|
|
|
|
"Entered with WalkState=%p Aml=%p size=%X\n",
|
|
|
|
WalkState, WalkState->ParserState.Aml,
|
|
|
|
WalkState->ParserState.AmlSize));
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
2001-11-28 04:29:40 +00:00
|
|
|
/* Create and initialize a new thread state */
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-11-28 04:29:40 +00:00
|
|
|
Thread = AcpiUtCreateThreadState ();
|
|
|
|
if (!Thread)
|
|
|
|
{
|
2007-03-22 17:24:05 +00:00
|
|
|
AcpiDsDeleteWalkState (WalkState);
|
2001-11-28 04:29:40 +00:00
|
|
|
return_ACPI_STATUS (AE_NO_MEMORY);
|
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-11-28 04:29:40 +00:00
|
|
|
WalkState->Thread = Thread;
|
2007-03-22 17:24:05 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If executing a method, the starting SyncLevel is this method's
|
|
|
|
* SyncLevel
|
|
|
|
*/
|
|
|
|
if (WalkState->MethodDesc)
|
|
|
|
{
|
|
|
|
WalkState->Thread->CurrentSyncLevel = WalkState->MethodDesc->Method.SyncLevel;
|
|
|
|
}
|
|
|
|
|
2001-11-28 04:29:40 +00:00
|
|
|
AcpiDsPushWalkState (WalkState, Thread);
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
/*
|
|
|
|
* This global allows the AML debugger to get a handle to the currently
|
|
|
|
* executing control method.
|
2000-10-28 05:01:06 +00:00
|
|
|
*/
|
2001-11-28 04:29:40 +00:00
|
|
|
AcpiGbl_CurrentWalkList = Thread;
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Execute the walk loop as long as there is a valid Walk State. This
|
|
|
|
* handles nested control method invocations without recursion.
|
|
|
|
*/
|
2001-08-26 22:28:18 +00:00
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "State=%p\n", WalkState));
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-09-07 01:22:25 +00:00
|
|
|
Status = AE_OK;
|
2000-10-28 05:01:06 +00:00
|
|
|
while (WalkState)
|
|
|
|
{
|
|
|
|
if (ACPI_SUCCESS (Status))
|
|
|
|
{
|
2001-10-04 23:12:13 +00:00
|
|
|
/*
|
|
|
|
* The ParseLoop executes AML until the method terminates
|
|
|
|
* or calls another method.
|
|
|
|
*/
|
2000-10-28 05:01:06 +00:00
|
|
|
Status = AcpiPsParseLoop (WalkState);
|
|
|
|
}
|
|
|
|
|
2001-09-07 01:22:25 +00:00
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
|
2003-04-29 18:39:29 +00:00
|
|
|
"Completed one call to walk loop, %s State=%p\n",
|
2002-11-27 18:07:48 +00:00
|
|
|
AcpiFormatException (Status), WalkState));
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
if (Status == AE_CTRL_TRANSFER)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* A method call was detected.
|
|
|
|
* Transfer control to the called control method
|
|
|
|
*/
|
2001-11-28 04:29:40 +00:00
|
|
|
Status = AcpiDsCallControlMethod (Thread, WalkState, NULL);
|
2007-03-22 17:24:05 +00:00
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
|
|
|
Status = AcpiDsMethodError (Status, WalkState);
|
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If the transfer to the new method method call worked, a new walk
|
|
|
|
* state was created -- get it
|
|
|
|
*/
|
2001-11-28 04:29:40 +00:00
|
|
|
WalkState = AcpiDsGetCurrentWalkState (Thread);
|
2000-10-28 05:01:06 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (Status == AE_CTRL_TERMINATE)
|
|
|
|
{
|
|
|
|
Status = AE_OK;
|
|
|
|
}
|
2004-12-01 23:14:10 +00:00
|
|
|
else if ((Status != AE_OK) && (WalkState->MethodDesc))
|
2002-11-27 18:07:48 +00:00
|
|
|
{
|
2007-03-22 17:24:05 +00:00
|
|
|
/* Either the method parse or actual execution failed */
|
2004-03-18 17:42:14 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_ERROR_METHOD ("Method parse/execution failed",
|
|
|
|
WalkState->MethodNode, NULL, Status);
|
2005-11-01 22:11:18 +00:00
|
|
|
|
2004-03-18 17:42:14 +00:00
|
|
|
/* Check for possible multi-thread reentrancy problem */
|
|
|
|
|
|
|
|
if ((Status == AE_ALREADY_EXISTS) &&
|
2007-03-22 17:24:05 +00:00
|
|
|
(!WalkState->MethodDesc->Method.Mutex))
|
2004-03-18 17:42:14 +00:00
|
|
|
{
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_INFO ((AE_INFO, "Marking method %4.4s as Serialized",
|
|
|
|
WalkState->MethodNode->Name.Ascii));
|
|
|
|
|
2004-03-18 17:42:14 +00:00
|
|
|
/*
|
2007-03-22 17:24:05 +00:00
|
|
|
* Method tried to create an object twice. The probable cause is
|
|
|
|
* that the method cannot handle reentrancy.
|
|
|
|
*
|
|
|
|
* The method is marked NotSerialized, but it tried to create
|
2005-11-01 22:11:18 +00:00
|
|
|
* a named object, causing the second thread entrance to fail.
|
2007-03-22 17:24:05 +00:00
|
|
|
* Workaround this problem by marking the method permanently
|
2005-11-01 22:11:18 +00:00
|
|
|
* as Serialized.
|
2004-03-18 17:42:14 +00:00
|
|
|
*/
|
|
|
|
WalkState->MethodDesc->Method.MethodFlags |= AML_METHOD_SERIALIZED;
|
2007-03-22 17:24:05 +00:00
|
|
|
WalkState->MethodDesc->Method.SyncLevel = 0;
|
2004-03-18 17:42:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
/* We are done with this walk, move on to the parent if any */
|
|
|
|
|
2001-11-28 04:29:40 +00:00
|
|
|
WalkState = AcpiDsPopWalkState (Thread);
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
/* Reset the current scope to the beginning of scope stack */
|
|
|
|
|
|
|
|
AcpiDsScopeStackClear (WalkState);
|
|
|
|
|
|
|
|
/*
|
2007-03-22 17:24:05 +00:00
|
|
|
* If we just returned from the execution of a control method or if we
|
|
|
|
* encountered an error during the method parse phase, there's lots of
|
|
|
|
* cleanup to do
|
2000-10-28 05:01:06 +00:00
|
|
|
*/
|
2007-03-22 17:24:05 +00:00
|
|
|
if (((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) ||
|
|
|
|
(ACPI_FAILURE (Status)))
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2007-03-22 17:24:05 +00:00
|
|
|
AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState);
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2001-09-07 01:22:25 +00:00
|
|
|
/* Delete this walk state and all linked control states */
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-10-04 23:12:13 +00:00
|
|
|
AcpiPsCleanupScope (&WalkState->ParserState);
|
|
|
|
PreviousWalkState = WalkState;
|
|
|
|
|
2005-11-01 22:11:18 +00:00
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
|
|
|
|
"ReturnValue=%p, ImplicitValue=%p State=%p\n",
|
|
|
|
WalkState->ReturnDesc, WalkState->ImplicitReturnObj, WalkState));
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-09-07 01:22:25 +00:00
|
|
|
/* Check if we have restarted a preempted walk */
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-11-28 04:29:40 +00:00
|
|
|
WalkState = AcpiDsGetCurrentWalkState (Thread);
|
2001-10-04 23:12:13 +00:00
|
|
|
if (WalkState)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2001-10-04 23:12:13 +00:00
|
|
|
if (ACPI_SUCCESS (Status))
|
|
|
|
{
|
|
|
|
/*
|
2002-02-23 05:10:40 +00:00
|
|
|
* There is another walk state, restart it.
|
|
|
|
* If the method return value is not used by the parent,
|
2001-10-04 23:12:13 +00:00
|
|
|
* The object is deleted
|
|
|
|
*/
|
2005-11-01 22:11:18 +00:00
|
|
|
if (!PreviousWalkState->ReturnDesc)
|
|
|
|
{
|
|
|
|
Status = AcpiDsRestartControlMethod (WalkState,
|
|
|
|
PreviousWalkState->ImplicitReturnObj);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* We have a valid return value, delete any implicit
|
|
|
|
* return value.
|
|
|
|
*/
|
|
|
|
AcpiDsClearImplicitReturn (PreviousWalkState);
|
|
|
|
|
|
|
|
Status = AcpiDsRestartControlMethod (WalkState,
|
|
|
|
PreviousWalkState->ReturnDesc);
|
|
|
|
}
|
2002-07-09 17:51:31 +00:00
|
|
|
if (ACPI_SUCCESS (Status))
|
|
|
|
{
|
|
|
|
WalkState->WalkType |= ACPI_WALK_METHOD_RESTART;
|
|
|
|
}
|
2002-02-23 05:10:40 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* On error, delete any return object */
|
|
|
|
|
|
|
|
AcpiUtRemoveReference (PreviousWalkState->ReturnDesc);
|
2001-10-04 23:12:13 +00:00
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Just completed a 1st-level method, save the final internal return
|
|
|
|
* value (if any)
|
|
|
|
*/
|
2001-10-04 23:12:13 +00:00
|
|
|
else if (PreviousWalkState->CallerReturnDesc)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2005-11-01 22:11:18 +00:00
|
|
|
if (PreviousWalkState->ImplicitReturnObj)
|
|
|
|
{
|
|
|
|
*(PreviousWalkState->CallerReturnDesc) =
|
|
|
|
PreviousWalkState->ImplicitReturnObj;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* NULL if no return value */
|
|
|
|
|
|
|
|
*(PreviousWalkState->CallerReturnDesc) =
|
|
|
|
PreviousWalkState->ReturnDesc;
|
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
2005-11-01 22:11:18 +00:00
|
|
|
else
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2005-11-01 22:11:18 +00:00
|
|
|
if (PreviousWalkState->ReturnDesc)
|
|
|
|
{
|
|
|
|
/* Caller doesn't want it, must delete it */
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2005-11-01 22:11:18 +00:00
|
|
|
AcpiUtRemoveReference (PreviousWalkState->ReturnDesc);
|
|
|
|
}
|
|
|
|
if (PreviousWalkState->ImplicitReturnObj)
|
|
|
|
{
|
|
|
|
/* Caller doesn't want it, must delete it */
|
|
|
|
|
|
|
|
AcpiUtRemoveReference (PreviousWalkState->ImplicitReturnObj);
|
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
2001-10-04 23:12:13 +00:00
|
|
|
|
|
|
|
AcpiDsDeleteWalkState (PreviousWalkState);
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Normal exit */
|
|
|
|
|
2001-11-28 04:29:40 +00:00
|
|
|
AcpiExReleaseAllMutexes (Thread);
|
2002-07-09 17:51:31 +00:00
|
|
|
AcpiUtDeleteGenericState (ACPI_CAST_PTR (ACPI_GENERIC_STATE, Thread));
|
2000-10-28 05:01:06 +00:00
|
|
|
AcpiGbl_CurrentWalkList = PrevWalkList;
|
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
|
|
|
|
|
|
|
|