/*******************************************************************************
*
* Module Name: nseval - Object evaluation, includes control method execution
*
******************************************************************************/
/*
* 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 "acinterp.h"
#include "acnamesp.h"
ACPI_MODULE_NAME ("nseval")
/* Local prototypes */
static void
/*******************************************************************************
*
* FUNCTION: AcpiNsEvaluate
*
* PARAMETERS: Info - Evaluation info block, contains these fields
* and more:
* RelativePath - Name of method to execute, If NULL, the
* Node is the object to execute
* Parameters - List of parameters to pass to the method,
* terminated by NULL. Params itself may be
* NULL if no parameters are being passed.
* ParameterType - Type of Parameter list
* ReturnObject - Where to put method's return value (if
* any). If NULL, no value is returned.
* Flags - ACPI_IGNORE_RETURN_VALUE to delete return
*
* RETURN: Status
*
* DESCRIPTION: Execute a control method or return the current value of an
* ACPI namespace object.
*
* MUTEX: Locks interpreter
*
******************************************************************************/
{
if (!Info)
{
}
{
/*
* Get the actual namespace node for the target object if we
* need to. Handles these cases:
*
* 1) Null node, valid pathname from root (absolute path)
* 2) Node and valid pathname (path relative to Node)
* 3) Node, Null pathname
*/
if (ACPI_FAILURE (Status))
{
}
}
/*
* For a method alias, we must grab the actual method node so that
* proper scoping context will be established before execution.
*/
{
}
/* Complete the info block initialization */
/* Get info if we have a predefined name (_HID, etc.) */
/* Get the full pathname to the object, for use in warning messages */
if (!Info->FullPathname)
{
}
/* Count the number of arguments being passed in */
Info->ParamCount = 0;
if (Info->Parameters)
{
{
Info->ParamCount++;
}
/* Warn on impossible argument count */
{
"Excess arguments (%u) - using only %u",
}
}
/*
* For predefined names: Check that the declared argument count
* matches the ACPI spec -- otherwise this is a BIOS error.
*/
Info->Predefined);
/*
* For all names: Check that the incoming argument count for
*/
/* For predefined names: Typecheck all incoming arguments */
/*
* Three major evaluation cases:
*
* 1) Object types that cannot be evaluated by definition
* 2) The object is a control method -- execute it
* 3) The object is not a method -- just return it's current value
*/
{
case ACPI_TYPE_DEVICE:
case ACPI_TYPE_EVENT:
case ACPI_TYPE_MUTEX:
case ACPI_TYPE_REGION:
case ACPI_TYPE_THERMAL:
case ACPI_TYPE_LOCAL_SCOPE:
/*
* 1) Disallow evaluation of certain object types. For these,
* object evaluation is undefined and not supported.
*/
"%s: Evaluation of object type [%s] is not supported",
goto Cleanup;
case ACPI_TYPE_METHOD:
/*
* 2) Object is a control method - execute it
*/
/* Verify that there is a method object associated with this node */
{
Info->FullPathname));
goto Cleanup;
}
"**** Execute method [%s] at AML address %p length %X\n",
/*
* Any namespace deletion must acquire both the namespace and
* interpreter locks to ensure that no thread is using the portion of
* the namespace that is being deleted.
*
* Execute the method via the interpreter. The interpreter is locked
* here before calling into the AML parser
*/
break;
default:
/*
* 3) All other non-method objects -- get the current object value
*/
/*
* Some objects require additional resolution steps (e.g., the Node
* may be a field that must be read, etc.) -- we can't just grab
* the object out of the node.
*
* Use ResolveNodeToValue() to get the associated value.
*
* NOTE: we can get away with passing in NULL for a walk state because
* the Node is guaranteed to not be a reference to either a method
* local or a method argument (because this interface is never called
* from a running method.)
*
* Even though we do not directly invoke the interpreter for object
* resolution, we must lock it because we could access an OpRegion.
* The OpRegion access code assumes that the interpreter is locked.
*/
/* TBD: ResolveNodeToValue has a strange interface, fix */
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
break;
}
/*
* For predefined names, check the return value against the ACPI
* specification. Some incorrect return value types are repaired.
*/
/* Check if there is a return value that must be dealt with */
if (Status == AE_CTRL_RETURN_VALUE)
{
/* If caller does not want the return value, delete it */
{
}
/* Map AE_CTRL_RETURN_VALUE to AE_OK, we are done with it */
}
"*** Completed evaluation of object %s ***\n",
Info->RelativePathname));
/*
* Namespace was unlocked by the handling AcpiNs* function, so we
* just free the pathname and return
*/
}
/*******************************************************************************
*
* FUNCTION: AcpiNsExecModuleCodeList
*
* PARAMETERS: None
*
* RETURN: None. Exceptions during method execution are ignored, since
* we cannot abort a table load.
*
* DESCRIPTION: Execute all elements of the global module-level code list.
* Each element is executed as a single control method.
*
******************************************************************************/
void
void)
{
/* Exit now if the list is empty */
if (!Next)
{
}
/* Allocate the evaluation information block */
if (!Info)
{
}
/* Walk the list, executing each "method" */
while (Next)
{
/* Clear the link field and execute the method */
MethodCount++;
/* Delete the (temporary) method object */
}
ACPI_INFO ((
"Executed %u blocks of module-level executable AML code",
MethodCount));
}
/*******************************************************************************
*
* FUNCTION: AcpiNsExecModuleCode
*
* PARAMETERS: MethodObj - Object container for the module-level code
* Info - Info block for method evaluation
*
* RETURN: None. Exceptions during method execution are ignored, since
* we cannot abort a table load.
*
* DESCRIPTION: Execute a control method containing a block of module-level
* executable AML code. The control method is temporarily
* installed to the root node, then evaluated.
*
******************************************************************************/
static void
{
/*
* Get the parent node. We cheat by using the NextObject field
* of the method object descriptor.
*/
/*
* Get the region handler and save it in the method object. We may need
* this if an operation region declaration causes a _REG method to be run.
*
* We can't do this in AcpiPsLinkModuleCode because
* AcpiGbl_RootNode->Object is NULL at PASS1.
*/
{
}
/* Must clear NextObject (AcpiNsAttachObject needs the field) */
/* Initialize the evaluation information block */
/*
* Get the currently attached parent object. Add a reference,
* because the ref count will be decreased when the method object
* is installed to the parent node.
*/
if (ParentObj)
{
}
/* Install the method (module-level code) in the parent node */
if (ACPI_FAILURE (Status))
{
goto Exit;
}
/* Execute the parent node as a control method */
"Executed module-level code at %p\n",
/* Delete a possible implicit return value (in slack mode) */
if (Info->ReturnObject)
{
}
/* Detach the temporary method object */
/* Restore the original parent object */
if (ParentObj)
{
}
else
{
}
Exit:
if (ParentObj)
{
}
}