exstore.c revision 199767f8919635c4928607450d9e0abb932109ce
/******************************************************************************
*
* Module Name: exstore - AML Interpreter object store support
*
*****************************************************************************/
/*
* Copyright (C) 2000 - 2015, 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.
*/
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("exstore")
/* Local prototypes */
static ACPI_STATUS
static ACPI_STATUS
/*******************************************************************************
*
* FUNCTION: AcpiExStore
*
* PARAMETERS: *SourceDesc - Value to be stored
* *DestDesc - Where to store it. Must be an NS node
* or ACPI_OPERAND_OBJECT of type
* Reference;
* WalkState - Current walk state
*
* RETURN: Status
*
* DESCRIPTION: Store the value described by SourceDesc into the location
* described by DestDesc. Called by various interpreter
* functions to store the result of an operation into
* the destination operand -- not just simply the actual "Store"
* ASL operator.
*
******************************************************************************/
{
/* Validate parameters */
if (!SourceDesc || !DestDesc)
{
}
/* DestDesc can be either a namespace node or an ACPI object */
{
/*
* Dest is a namespace node,
* Storing an object into a Named node.
*/
}
/* Destination object must be a Reference or a Constant object */
{
break;
case ACPI_TYPE_INTEGER:
/* Allow stores to Constants -- a Noop as per ACPI spec */
{
}
/*lint -fallthrough */
default:
/* Destination is not a Reference object */
"Target is not a Reference or Constant object - %s [%p]",
}
/*
* Examine the Reference class. These cases are handled:
*
* 1) Store to Name (Change the object associated with a name)
* 2) Store to an indexed area of a Buffer or Package
* 3) Store to a Method Local or Arg
* 4) Store to the debug object
*/
{
case ACPI_REFCLASS_REFOF:
/* Storing an object into a Name "container" */
break;
case ACPI_REFCLASS_INDEX:
/* Storing to an Index (pointer into a packager or buffer) */
break;
case ACPI_REFCLASS_LOCAL:
case ACPI_REFCLASS_ARG:
break;
case ACPI_REFCLASS_DEBUG:
/*
* Storing to the Debug object causes the value stored to be
* displayed and otherwise has no effect -- see ACPI Specification
*/
"**** Write to Debug Object: Object %p %s ****:\n\n",
ACPI_DEBUG_OBJECT (SourceDesc, 0, 0);
break;
default:
break;
}
}
/*******************************************************************************
*
* FUNCTION: AcpiExStoreObjectToIndex
*
* PARAMETERS: *SourceDesc - Value to be stored
* *DestDesc - Named object to receive the value
* WalkState - Current walk state
*
* RETURN: Status
*
* DESCRIPTION: Store the object to indexed Buffer or Package element
*
******************************************************************************/
static ACPI_STATUS
{
UINT32 i;
/*
* Destination must be a reference pointer, and
* must point to either a buffer or a package
*/
{
case ACPI_TYPE_PACKAGE:
/*
* Storing to a package element. Copy the object and replace
* any existing object with the new object. No implicit
* conversion is performed.
*
* The object at *(IndexDesc->Reference.Where) is the
* element within the package that is to be modified.
* The parent package object is at IndexDesc->Reference.Object
*/
{
/* This is a DDBHandle, just add a reference to it */
}
else
{
/* Normal object, copy it */
if (ACPI_FAILURE (Status))
{
}
}
if (ObjDesc)
{
/* Decrement reference count by the ref count of the parent package */
for (i = 0;
i < ((ACPI_OPERAND_OBJECT *)
i++)
{
}
}
/* Increment ref count by the ref count of the parent package-1 */
for (i = 1;
i < ((ACPI_OPERAND_OBJECT *)
i++)
{
}
break;
case ACPI_TYPE_BUFFER_FIELD:
/*
* Store into a Buffer or String (not actually a real BufferField)
* at a location defined by an Index.
*
* The first 8-bit element of the source object is written to the
* 8-bit Buffer location defined by the Index destination object,
* according to the ACPI 2.0 specification.
*/
/*
* Make sure the target is a Buffer or String. An error should
* not happen here, since the ReferenceObject was constructed
* by the INDEX_OP code.
*/
{
}
/*
* The assignment of the individual elements will be slightly
* different for each source type.
*/
{
case ACPI_TYPE_INTEGER:
/* Use the least-significant byte of the integer */
break;
case ACPI_TYPE_BUFFER:
case ACPI_TYPE_STRING:
break;
default:
/* All other types are invalid */
}
/* Store the source value into the target buffer byte */
break;
default:
"Target is not a Package or BufferField"));
break;
}
}
/*******************************************************************************
*
* FUNCTION: AcpiExStoreObjectToNode
*
* PARAMETERS: SourceDesc - Value to be stored
* Node - Named object to receive the value
* WalkState - Current walk state
*
* RETURN: Status
*
* DESCRIPTION: Store the object to the named object.
*
* The Assignment of an object to a named object is handled here
* The value passed in will replace the current value (if any)
* with the input value.
*
* When storing into an object the data is converted to the
* target object type then stored in the object. This means
* that the target object type (for an initialized target) will
* not be changed by a store operation. A CopyObject can change
* the target type, however.
*
* storing to an ArgX -- as per the rules of the ACPI spec.
*
* Assumes parameters are already validated.
*
******************************************************************************/
{
/* Get current type of the node, and object attached to Node */
/*
* Resolve the source object to an actual value
* (If it is a reference object)
*/
if (ACPI_FAILURE (Status))
{
}
/* Do the actual store operation */
switch (TargetType)
{
case ACPI_TYPE_INTEGER:
case ACPI_TYPE_STRING:
case ACPI_TYPE_BUFFER:
/*
* The simple data types all support implicit source operand
* conversion before the store.
*/
{
/*
* However, CopyObject and Stores to ArgX do not perform
* an implicit conversion, as per the ACPI specification.
* A direct store is performed instead.
*/
break;
}
/* Store with implicit source operand conversion support */
if (ACPI_FAILURE (Status))
{
}
if (NewDesc != TargetDesc)
{
/*
* Store the new NewDesc as the new value of the Name, and set
* the Name's type to that of the value being stored in it.
* SourceDesc reference count is incremented by AttachObject.
*
* Note: This may change the type of the node if an explicit
* has been changed.
*/
}
break;
case ACPI_TYPE_BUFFER_FIELD:
/*
* For all fields, always write the source data to the target
* field. Any required implicit source operand conversion is
* performed in the function below as necessary. Note, field
* objects must retain their original type permanently.
*/
break;
default:
/*
* No conversions for all other types. Directly store a copy of
* the source object. This is the ACPI spec-defined behavior for
* the CopyObject operator.
*
* NOTE: For the Store operator, this is a departure from the
* ACPI spec, which states "If conversion is impossible, abort
* the running control method". Instead, this code implements
* "If conversion is impossible, treat the Store operation as
* a CopyObject".
*/
break;
}
}
/*******************************************************************************
*
* FUNCTION: AcpiExStoreDirectToNode
*
* PARAMETERS: SourceDesc - Value to be stored
* Node - Named object to receive the value
* WalkState - Current walk state
*
* RETURN: Status
*
* DESCRIPTION: "Store" an object directly to a node. This involves a copy
* and an attach.
*
******************************************************************************/
static ACPI_STATUS
{
"Storing [%s] (%p) directly into node [%s] (%p)"
" with no implicit conversion\n",
/* Copy the source object to a new object */
if (ACPI_FAILURE (Status))
{
}
/* Attach the new object to the node */
}