/******************************************************************************
*
* Module Name: exoparg2 - AML execution - opcodes with 2 arguments
*
*****************************************************************************/
/*
* 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 "acevents.h"
#include "amlcode.h"
ACPI_MODULE_NAME ("exoparg2")
/*!
* Naming convention for AML interpreter execution routines.
*
* The routines that begin execution of AML opcodes are named with a common
* convention based upon the number of arguments, the number of target operands,
* and whether or not a value is returned:
*
* AcpiExOpcode_xA_yT_zR
*
* Where:
*
* xA - ARGUMENTS: The number of arguments (input operands) that are
* required for this opcode type (1 through 6 args).
* yT - TARGETS: The number of targets (output operands) that are required
* for this opcode type (0, 1, or 2 targets).
* zR - RETURN VALUE: Indicates whether this opcode type returns a value
* as the function return (0 or 1).
*
* The AcpiExOpcode* functions are called via the Dispatcher component with
* fully resolved operands.
!*/
/*******************************************************************************
*
* FUNCTION: AcpiExOpcode_2A_0T_0R
*
* PARAMETERS: WalkState - Current walk state
*
* RETURN: Status
*
* DESCRIPTION: Execute opcode with two arguments, no target, and no return
* value.
*
* ALLOCATION: Deletes both operands
*
******************************************************************************/
{
/* Examine the opcode */
{
case AML_NOTIFY_OP: /* Notify (NotifyObject, NotifyValue) */
/* The first operand is a namespace node */
/* Second value is the notify value */
/* Are notifies allowed on this object? */
if (!AcpiEvIsNotifyObject (Node))
{
"Unexpected notify object type [%s]",
break;
}
/*
* Dispatch the notify to the appropriate handler
* NOTE: the request is queued for execution after this method
* completes. The notify handlers are NOT invoked synchronously
* from this thread -- because handlers may in turn run other
* control methods.
*/
break;
default:
}
}
/*******************************************************************************
*
* FUNCTION: AcpiExOpcode_2A_2T_1R
*
* PARAMETERS: WalkState - Current walk state
*
* RETURN: Status
*
* DESCRIPTION: Execute a dyadic operator (2 operands) with 2 output targets
* and one implicit return value.
*
******************************************************************************/
{
/* Execute the opcode */
{
case AML_DIVIDE_OP:
/* Divide (Dividend, Divisor, RemainderResult QuotientResult) */
if (!ReturnDesc1)
{
goto Cleanup;
}
if (!ReturnDesc2)
{
goto Cleanup;
}
/* Quotient to ReturnDesc1, remainder to ReturnDesc2 */
Status = AcpiUtDivide (
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
break;
default:
goto Cleanup;
}
/* Store the results to the target reference operands */
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
/*
* Since the remainder is not returned indirectly, remove a reference to
* it. Only the quotient is returned indirectly.
*/
if (ACPI_FAILURE (Status))
{
/* Delete the return object */
}
/* Save return object (the remainder) on success */
else
{
}
}
/*******************************************************************************
*
* FUNCTION: AcpiExOpcode_2A_1T_1R
*
* PARAMETERS: WalkState - Current walk state
*
* RETURN: Status
*
* DESCRIPTION: Execute opcode with two arguments, one target, and a return
* value.
*
******************************************************************************/
{
/* Execute the opcode */
{
/* All simple math opcodes (add, etc.) */
if (!ReturnDesc)
{
goto Cleanup;
}
goto StoreResultToTarget;
}
{
case AML_MOD_OP: /* Mod (Dividend, Divisor, RemainderResult (ACPI 2.0) */
if (!ReturnDesc)
{
goto Cleanup;
}
/* ReturnDesc will contain the remainder */
Status = AcpiUtDivide (
NULL,
break;
case AML_CONCAT_OP: /* Concatenate (Data1, Data2, Result) */
break;
case AML_TO_STRING_OP: /* ToString (Buffer, Length, Result) (ACPI 2.0) */
/*
* Input object is guaranteed to be a buffer at this point (it may have
* been converted.) Copy the raw buffer data to a new object of
* type String.
*/
/*
* Get the length of the new string. It is the smallest of:
* 1) Length of the input buffer
* 2) Max length as specified in the ToString operator
* 3) Length of input buffer up to a zero byte (null terminator)
*
* NOTE: A length of zero is ok, and will create a zero-length, null
* terminated string.
*/
{
Length++;
}
/* Allocate a new string object */
if (!ReturnDesc)
{
goto Cleanup;
}
/*
* Copy the raw buffer data with no transform.
* (NULL terminated already)
*/
break;
case AML_CONCAT_RES_OP:
/* ConcatenateResTemplate (Buffer, Buffer, Result) (ACPI 2.0) */
break;
case AML_INDEX_OP: /* Index (Source Index Result) */
/* Create the internal return object */
if (!ReturnDesc)
{
goto Cleanup;
}
/* Initialize the Index reference object */
/*
* At this point, the Source operand is a String, Buffer, or Package.
* Verify that the index is within range.
*/
{
case ACPI_TYPE_STRING:
{
}
break;
case ACPI_TYPE_BUFFER:
{
}
break;
case ACPI_TYPE_PACKAGE:
{
}
break;
default:
goto Cleanup;
}
/* Failure means that the Index was beyond the end of the object */
if (ACPI_FAILURE (Status))
{
"Index (0x%X%8.8X) is beyond end of object (length 0x%X)",
goto Cleanup;
}
/*
* Save the target object and add a reference to it for the life
* of the index
*/
AcpiUtAddReference (Operand[0]);
/* Store the reference to the Target */
/* Return the reference */
goto Cleanup;
default:
break;
}
if (ACPI_SUCCESS (Status))
{
/*
* Store the result of the operation (which is now in ReturnDesc) into
* the Target descriptor.
*/
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
{
}
}
/* Delete return object on error */
if (ACPI_FAILURE (Status))
{
}
}
/*******************************************************************************
*
* FUNCTION: AcpiExOpcode_2A_0T_1R
*
* PARAMETERS: WalkState - Current walk state
*
* RETURN: Status
*
* DESCRIPTION: Execute opcode with 2 arguments, no target, and a return value
*
******************************************************************************/
{
/* Create the internal return object */
if (!ReturnDesc)
{
goto Cleanup;
}
/* Execute the Opcode */
{
/* LogicalOp (Operand0, Operand1) */
goto StoreLogicalResult;
}
{
/* LogicalOp (Operand0, Operand1) */
goto StoreLogicalResult;
}
{
case AML_ACQUIRE_OP: /* Acquire (MutexObject, Timeout) */
{
}
break;
case AML_WAIT_OP: /* Wait (EventObject, Timeout) */
{
}
break;
default:
goto Cleanup;
}
/*
* Set return value to according to LogicalResult. logical TRUE (all ones)
* Default is FALSE (zero)
*/
if (LogicalResult)
{
}
/* Delete return object on error */
if (ACPI_FAILURE (Status))
{
}
/* Save return object on success */
else
{
}
}