/******************************************************************************
*
* Module Name: dsobject - Dispatcher object management routines
*
*****************************************************************************/
/*
* 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"
#include "acdispat.h"
#include "acnamesp.h"
#include "acinterp.h"
ACPI_MODULE_NAME ("dsobject")
/* Local prototypes */
static ACPI_STATUS
#ifndef ACPI_NO_METHOD_EXECUTION
/*******************************************************************************
*
* FUNCTION: AcpiDsBuildInternalObject
*
* PARAMETERS: WalkState - Current walk state
* Op - Parser object to be translated
* ObjDescPtr - Where the ACPI internal object is returned
*
* RETURN: Status
*
* DESCRIPTION: Translate a parser Op object to the equivalent namespace object
* Simple objects are any objects other than a package object!
*
******************************************************************************/
static ACPI_STATUS
{
*ObjDescPtr = NULL;
{
/*
* This is a named object reference. If this name was
* previously looked up in the namespace, it was stored in this op.
* Otherwise, go ahead and look it up now
*/
{
if (ACPI_FAILURE (Status))
{
/* Check if we are resolving a named reference within a package */
{
/*
* We didn't find the target and we are populating elements
* of a package - ignore if slack enabled. Some ASL code
* contains dangling invalid references in packages and
* expects that no exception will be issued. Leave the
* element as a null element. It cannot be used, but it
* can be overwritten by subsequent ASL code - this is
* typically the case.
*/
"Ignoring unresolved reference in package [%4.4s]\n",
}
else
{
}
}
}
/* Special object resolution for elements of a package */
{
/*
* Attempt to resolve the node to a value before we insert it into
* the package. If this is a reference to a common data type,
* resolve it immediately. According to the ACPI spec, package
* elements can only be "data objects" or method references.
* Attempt to resolve to an Integer, Buffer, String or Package.
* If cannot, return the named reference (for things like Devices,
* Methods, etc.) Buffer Fields and Fields will resolve to simple
*
* NOTE: References to things like Devices, Methods, Mutexes, etc.
* will remain as named references. This behavior is not described
* in the ACPI spec, but it appears to be an oversight.
*/
if (ACPI_FAILURE (Status))
{
}
/*
* Special handling for Alias objects. We need to setup the type
* and the Op->Common.Node to point to the Alias target. Note,
* Alias has at most one level of indirection internally.
*/
if (Type == ACPI_TYPE_LOCAL_ALIAS)
{
}
switch (Type)
{
/*
* For these types, we need the actual node, not the subobject.
* However, the subobject did not get an extra reference count above.
*
* TBD: should ExResolveNodeToValue be changed to fix this?
*/
case ACPI_TYPE_DEVICE:
case ACPI_TYPE_THERMAL:
/*lint -fallthrough */
/*
* For these types, we need the actual node, not the subobject.
* The subobject got an extra reference count in ExResolveNodeToValue.
*/
case ACPI_TYPE_MUTEX:
case ACPI_TYPE_METHOD:
case ACPI_TYPE_POWER:
case ACPI_TYPE_PROCESSOR:
case ACPI_TYPE_EVENT:
case ACPI_TYPE_REGION:
/* We will create a reference object for these types below */
break;
default:
/*
* All other types - the node was resolved to an actual
* object, we are done.
*/
goto Exit;
}
}
}
/* Create and init a new internal ACPI object */
if (!ObjDesc)
{
}
if (ACPI_FAILURE (Status))
{
}
Exit:
*ObjDescPtr = ObjDesc;
}
/*******************************************************************************
*
* FUNCTION: AcpiDsBuildInternalBufferObj
*
* PARAMETERS: WalkState - Current walk state
* Op - Parser object to be translated
* BufferLength - Length of the buffer
* ObjDescPtr - Where the ACPI internal object is returned
*
* RETURN: Status
*
* DESCRIPTION: Translate a parser Op package object to the equivalent
* namespace object
*
******************************************************************************/
{
/*
* If we are evaluating a Named buffer object "Name (xxxx, Buffer)".
* The buffer object already exists (from the NS node), otherwise it must
* be created.
*/
ObjDesc = *ObjDescPtr;
if (!ObjDesc)
{
/* Create a new buffer object */
*ObjDescPtr = ObjDesc;
if (!ObjDesc)
{
}
}
/*
* Second arg is the buffer data (optional) ByteList can be either
* individual bytes or a string initializer. In either case, a
* ByteList appears in the AML.
*/
if (ByteList)
{
{
"Expecting bytelist, found AML opcode 0x%X in op %p",
return (AE_TYPE);
}
}
/*
* The buffer length (number of bytes) will be the larger of:
* 1) The specified buffer length and
* 2) The length of the initializer byte list
*/
if (ByteListLength > BufferLength)
{
}
/* Allocate the buffer */
{
"Buffer defined with zero length in AML, creating\n"));
}
else
{
{
}
/* Initialize buffer from the ByteList (if present) */
if (ByteList)
{
}
}
}
/*******************************************************************************
*
* FUNCTION: AcpiDsBuildInternalPackageObj
*
* PARAMETERS: WalkState - Current walk state
* Op - Parser object to be translated
* ElementCount - Number of elements in the package - this is
* the NumElements argument to Package()
* ObjDescPtr - Where the ACPI internal object is returned
*
* RETURN: Status
*
* DESCRIPTION: Translate a parser Op package object to the equivalent
* namespace object
*
* NOTE: The number of elements in the package will be always be the NumElements
* count, regardless of the number of elements in the package list. If
* NumElements is smaller, only that many package list elements are used.
* if NumElements is larger, the Package object is padded out with
* objects of type Uninitialized (as per ACPI spec.)
*
* Even though the ASL compilers do not allow NumElements to be smaller
* than the Package list length (for the fixed length package opcode), some
* BIOS code modifies the AML on the fly to adjust the NumElements, and
* this code compensates for that. This also provides compatibility with
* other AML interpreters.
*
******************************************************************************/
{
UINT32 i;
/* Find the parent of a possibly nested package */
{
}
/*
* If we are evaluating a Named package object "Name (xxxx, Package)",
* the package object already exists, otherwise it must be created.
*/
ObjDesc = *ObjDescPtr;
if (!ObjDesc)
{
*ObjDescPtr = ObjDesc;
if (!ObjDesc)
{
}
}
/*
* Allocate the element array (array of pointers to the individual
* objects) based on the NumElements parameter. Add an extra pointer slot
* so that the list is always null terminated.
*/
{
}
/*
* Initialize the elements of the package, up to the NumElements count.
* Package is automatically padded with uninitialized (NULL) elements
* if NumElements is greater than the package list length. Likewise,
* Package is truncated if NumElements is less than the list length.
*/
for (i = 0; Arg && (i < ElementCount); i++)
{
{
{
/*
* A method reference "looks" to the parser to be a method
* invocation, so we special case it here
*/
}
else
{
/* This package element is already built, just get it */
}
}
else
{
}
if (*ObjDescPtr)
{
/* Existing package, get existing reference count */
if (ReferenceCount > 1)
{
/* Make new element ref count match original ref count */
{
}
}
}
}
/* Check for match between NumElements and actual length of PackageList */
if (Arg)
{
/*
* NumElements was exhausted, but there are remaining elements in the
* PackageList. Truncate the package to NumElements.
*
* Note: technically, this is an error, from ACPI spec: "It is an error
* for NumElements to be less than the number of elements in the
* PackageList". However, we just print a message and
* no exception is returned. This provides Windows compatibility. Some
* BIOSs will alter the NumElements on the fly, creating this type
* of ill-formed package object.
*/
while (Arg)
{
/*
* We must delete any package elements that were created earlier
* and are not going to be used because of the package truncation.
*/
{
}
/* Find out how many elements there really are */
i++;
}
ACPI_INFO ((
"Actual Package length (%u) is larger than "
"NumElements field (%u), truncated",
i, ElementCount));
}
else if (i < ElementCount)
{
/*
* Arg list (elements) was exhausted, but we did not reach NumElements count.
* Note: this is not an error, the package is padded out with NULLs.
*/
"Package List length (%u) smaller than NumElements "
"count (%u), padded with null elements\n",
i, ElementCount));
}
}
/*******************************************************************************
*
* FUNCTION: AcpiDsCreateNode
*
* PARAMETERS: WalkState - Current walk state
* Node - NS Node to be initialized
* Op - Parser object to be translated
*
* RETURN: Status
*
* DESCRIPTION: Create the object to be associated with a namespace node
*
******************************************************************************/
{
/*
* Because of the execution pass through the non-control-method
* parts of the table, we can arrive here twice. Only init
* the named object node the first time through
*/
if (AcpiNsGetAttachedObject (Node))
{
}
{
/* No arguments, there is nothing to do */
}
/* Build an internal object for the argument(s) */
if (ACPI_FAILURE (Status))
{
}
/* Re-type the object according to its argument */
/* Attach obj to node */
/* Remove local reference to the object */
}
#endif /* ACPI_NO_METHOD_EXECUTION */
/*******************************************************************************
*
* FUNCTION: AcpiDsInitObjectFromOp
*
* PARAMETERS: WalkState - Current walk state
* Op - Parser op used to init the internal object
* Opcode - AML opcode associated with the object
* RetObjDesc - Namespace object to be initialized
*
* RETURN: Status
*
* DESCRIPTION: Initialize a namespace object from a parser Op and its
* associated arguments. The namespace object is a more compact
* representation of the Op and its arguments.
*
******************************************************************************/
{
ObjDesc = *RetObjDesc;
{
/* Unknown opcode */
}
/* Perform per-object initialization */
{
case ACPI_TYPE_BUFFER:
/*
* Defer evaluation of Buffer TermArg operand
*/
break;
case ACPI_TYPE_PACKAGE:
/*
* Defer evaluation of Package TermArg operand
*/
break;
case ACPI_TYPE_INTEGER:
{
case AML_TYPE_CONSTANT:
/*
* Resolve AML Constants here - AND ONLY HERE!
* All constants are integers.
* We mark the integer with a flag that indicates that it started
* life as a constant -- so that stores to constants will perform
* as expected (noop). ZeroOp is used as a placeholder for optional
* target operands.
*/
switch (Opcode)
{
case AML_ZERO_OP:
break;
case AML_ONE_OP:
break;
case AML_ONES_OP:
/* Truncate value if we are executing from a 32-bit ACPI table */
#ifndef ACPI_NO_METHOD_EXECUTION
(void) AcpiExTruncateFor32bitTable (ObjDesc);
#endif
break;
case AML_REVISION_OP:
break;
default:
"Unknown constant opcode 0x%X", Opcode));
break;
}
break;
case AML_TYPE_LITERAL:
#ifndef ACPI_NO_METHOD_EXECUTION
{
/* Warn if we found a 64-bit constant in a 32-bit table */
"Truncated 64-bit constant found in 32-bit table: %8.8X%8.8X => %8.8X",
}
#endif
break;
default:
break;
}
break;
case ACPI_TYPE_STRING:
/*
* The string is contained in the ACPI table, don't ever try
* to delete it
*/
break;
case ACPI_TYPE_METHOD:
break;
{
case AML_TYPE_LOCAL_VARIABLE:
/* Local ID (0-7) is (AML opcode - base AML_LOCAL_OP) */
#ifndef ACPI_NO_METHOD_EXECUTION
#endif
break;
case AML_TYPE_METHOD_ARGUMENT:
/* Arg ID (0-6) is (AML opcode - base AML_ARG_OP) */
#ifndef ACPI_NO_METHOD_EXECUTION
#endif
break;
default: /* Object name or Debug object */
{
case AML_INT_NAMEPATH_OP:
/* Node was saved in Op */
break;
case AML_DEBUG_OP:
break;
default:
"Unimplemented reference type for AML opcode: 0x%4.4X", Opcode));
}
break;
}
break;
default:
break;
}
}