psobject.c revision 7b1019a6d29ccb7999dc76cba3dde1c627e8e609
/******************************************************************************
*
* Module Name: psobject - Support for parse objects
*
*****************************************************************************/
/*
* Copyright (C) 2000 - 2016, Intel Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*/
#include "acpi.h"
#include "accommon.h"
#include "acparser.h"
#include "amlcode.h"
#define _COMPONENT ACPI_PARSER
ACPI_MODULE_NAME ("psobject")
/* Local prototypes */
static ACPI_STATUS
/*******************************************************************************
*
* FUNCTION: AcpiPsGetAmlOpcode
*
* PARAMETERS: WalkState - Current state
*
* RETURN: Status
*
* DESCRIPTION: Extract the next AML opcode from the input stream.
*
******************************************************************************/
static ACPI_STATUS
{
/*
* First cut to determine what we have found:
* 1) A valid AML opcode
* 2) A name string
*/
{
case AML_CLASS_ASCII:
case AML_CLASS_PREFIX:
/*
* Starts with a valid prefix or ASCII char, this is a name
* string. Convert the bare name string to a namepath.
*/
break;
case AML_CLASS_UNKNOWN:
/* The opcode is unrecognized. Complain and skip unknown opcodes */
{
"Unknown opcode 0x%.2X at table offset 0x%.4X, ignoring",
#ifdef ACPI_ASL_COMPILER
/*
* This is executed for the disassembler only. Output goes
* to the disassembled ASL output file.
*/
"/*\nError: Unknown opcode 0x%.2X at table offset 0x%.4X, context:\n",
/* Dump the context surrounding the invalid opcode */
48, DB_BYTE_DISPLAY,
AcpiOsPrintf (" */\n");
#endif
}
/* Increment past one-byte or two-byte opcode */
{
}
default:
/* Found opcode info, this is a normal opcode */
break;
}
}
/*******************************************************************************
*
* FUNCTION: AcpiPsBuildNamedOp
*
* PARAMETERS: WalkState - Current state
* AmlOpStart - Begin of named Op in AML
* UnnamedOp - Early Op (not a named Op)
* Op - Returned Op
*
* RETURN: Status
*
* DESCRIPTION: Parse a named Op
*
******************************************************************************/
{
/*
* Get and append arguments until we find the node that contains
* the name (the type ARGP_NAME).
*/
{
if (ACPI_FAILURE (Status))
{
}
}
/*
* Make sure that we found a NAME and didn't run out of arguments
*/
{
}
/* We know that this arg is a name, move to next arg */
/*
* Find the object. This will either insert the object into
* the namespace or simply look it up
*/
if (ACPI_FAILURE (Status))
{
if (Status != AE_CTRL_TERMINATE)
{
}
}
if (!*Op)
{
}
if (ACPI_FAILURE (Status))
{
if (Status == AE_CTRL_PENDING)
{
}
}
{
/*
* Defer final parsing of an OperationRegion body, because we don't
* have enough info in the first pass to parse it correctly (i.e.,
* there may be method calls within the TermArg elements of the body.)
*
* However, we must continue parsing because the opregion is not a
* standalone package -- we don't know where the end is at this point.
*
* (Length is unknown until parse of the body complete)
*/
}
}
/*******************************************************************************
*
* FUNCTION: AcpiPsCreateOp
*
* PARAMETERS: WalkState - Current state
* AmlOpStart - Op start in AML
* NewOp - Returned Op
*
* RETURN: Status
*
* DESCRIPTION: Get Op from AML
*
******************************************************************************/
{
const ACPI_OPCODE_INFO *OpInfo;
if (Status == AE_CTRL_PARSE_CONTINUE)
{
}
/* Create Op structure and append to parent's argument list */
if (!Op)
{
}
{
AcpiPsFreeOp (Op);
if (ACPI_FAILURE (Status))
{
}
}
/* Not a named opcode, just allocate Op and append to parent */
{
/*
* Backup to beginning of CreateXXXfield declaration
* BodyLength is unknown until we parse the body
*/
}
{
/*
* Backup to beginning of BankField declaration
* BodyLength is unknown until we parse the body
*/
}
if (ParentScope)
{
{
{
}
}
{
}
}
{
/*
* Find the object. This will either insert the object into
* the namespace or simply look it up
*/
if (Status == AE_CTRL_PENDING)
{
}
}
}
/*******************************************************************************
*
* FUNCTION: AcpiPsCompleteOp
*
* PARAMETERS: WalkState - Current state
* Op - Returned Op
* Status - Parse status before complete Op
*
* RETURN: Status
*
* DESCRIPTION: Complete Op
*
******************************************************************************/
{
/*
* Finished one argument of the containing scope
*/
/* Close this Op (will result in parse subtree deletion) */
if (ACPI_FAILURE (Status2))
{
}
switch (Status)
{
case AE_OK:
break;
case AE_CTRL_TRANSFER:
/* We are about to transfer to a called method */
case AE_CTRL_END:
if (*Op)
{
if (ACPI_FAILURE (Status2))
{
}
}
break;
case AE_CTRL_BREAK:
case AE_CTRL_CONTINUE:
/* Pop off scopes until we find the While */
{
}
/* Close this iteration of the While loop */
if (ACPI_FAILURE (Status2))
{
}
break;
case AE_CTRL_TERMINATE:
/* Clean up */
do
{
if (*Op)
{
if (ACPI_FAILURE (Status2))
{
}
}
} while (*Op);
default: /* All other non-AE_OK status */
do
{
if (*Op)
{
if (ACPI_FAILURE (Status2))
{
}
}
} while (*Op);
#if 0
/*
* TBD: Cleanup parse ops on error
*/
{
}
#endif
}
/* This scope complete? */
{
}
else
{
}
}
/*******************************************************************************
*
* FUNCTION: AcpiPsCompleteFinalOp
*
* PARAMETERS: WalkState - Current state
* Op - Current Op
* Status - Current parse status before complete last
* Op
*
* RETURN: Status
*
* DESCRIPTION: Complete last Op.
*
******************************************************************************/
{
/*
* Complete the last Op (if not completed), and clear the scope stack.
* It is easily possible to end an AML "package" with an unbounded number
* of open scopes (such as when several ASL blocks are closed with
* sequential closing braces). We want to terminate each one cleanly.
*/
do
{
if (Op)
{
{
if (Status == AE_CTRL_PENDING)
{
if (ACPI_FAILURE (Status))
{
}
}
if (Status == AE_CTRL_TERMINATE)
{
/* Clean up */
do
{
if (Op)
{
if (ACPI_FAILURE (Status2))
{
}
}
} while (Op);
}
else if (ACPI_FAILURE (Status))
{
/* First error is most important */
}
}
if (ACPI_FAILURE (Status2))
{
}
}
} while (Op);
}