2005-04-16 16:20:36 -06:00
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* Module Name: dsmthdat - control method arguments and local variables
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
/*
|
2006-01-13 14:22:00 -07:00
|
|
|
* Copyright (C) 2000 - 2006, R. Byron Moore
|
2005-04-16 16:20:36 -06:00
|
|
|
* 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/acpi.h>
|
|
|
|
#include <acpi/acdispat.h>
|
|
|
|
#include <acpi/amlcode.h>
|
|
|
|
#include <acpi/acnamesp.h>
|
|
|
|
#include <acpi/acinterp.h>
|
|
|
|
|
|
|
|
#define _COMPONENT ACPI_DISPATCHER
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_MODULE_NAME("dsmthdat")
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2005-04-18 20:49:35 -06:00
|
|
|
/* Local prototypes */
|
|
|
|
static void
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_ds_method_data_delete_value(u16 opcode,
|
|
|
|
u32 index, struct acpi_walk_state *walk_state);
|
2005-04-18 20:49:35 -06:00
|
|
|
|
|
|
|
static acpi_status
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_ds_method_data_set_value(u16 opcode,
|
|
|
|
u32 index,
|
|
|
|
union acpi_operand_object *object,
|
|
|
|
struct acpi_walk_state *walk_state);
|
2005-04-18 20:49:35 -06:00
|
|
|
|
|
|
|
#ifdef ACPI_OBSOLETE_FUNCTIONS
|
|
|
|
acpi_object_type
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_ds_method_data_get_type(u16 opcode,
|
|
|
|
u32 index, struct acpi_walk_state *walk_state);
|
2005-04-18 20:49:35 -06:00
|
|
|
#endif
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ds_method_data_init
|
|
|
|
*
|
|
|
|
* PARAMETERS: walk_state - Current walk state object
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Initialize the data structures that hold the method's arguments
|
2005-04-18 20:49:35 -06:00
|
|
|
* and locals. The data struct is an array of namespace nodes for
|
|
|
|
* each - this allows ref_of and de_ref_of to work properly for these
|
2005-04-16 16:20:36 -06:00
|
|
|
* special data types.
|
|
|
|
*
|
|
|
|
* NOTES: walk_state fields are initialized to zero by the
|
2006-10-02 22:00:00 -06:00
|
|
|
* ACPI_ALLOCATE_ZEROED().
|
2005-04-16 16:20:36 -06:00
|
|
|
*
|
|
|
|
* A pseudo-Namespace Node is assigned to each argument and local
|
|
|
|
* so that ref_of() can return a pointer to the Node.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
void acpi_ds_method_data_init(struct acpi_walk_state *walk_state)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-08-04 22:44:28 -06:00
|
|
|
u32 i;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_FUNCTION_TRACE("ds_method_data_init");
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* Init the method arguments */
|
|
|
|
|
|
|
|
for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++) {
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_MOVE_32_TO_32(&walk_state->arguments[i].name,
|
2005-04-16 16:20:36 -06:00
|
|
|
NAMEOF_ARG_NTE);
|
|
|
|
walk_state->arguments[i].name.integer |= (i << 24);
|
2005-08-04 22:44:28 -06:00
|
|
|
walk_state->arguments[i].descriptor = ACPI_DESC_TYPE_NAMED;
|
|
|
|
walk_state->arguments[i].type = ACPI_TYPE_ANY;
|
|
|
|
walk_state->arguments[i].flags = ANOBJ_END_OF_PEER_LIST |
|
|
|
|
ANOBJ_METHOD_ARG;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Init the method locals */
|
|
|
|
|
|
|
|
for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++) {
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_MOVE_32_TO_32(&walk_state->local_variables[i].name,
|
2005-04-16 16:20:36 -06:00
|
|
|
NAMEOF_LOCAL_NTE);
|
|
|
|
|
|
|
|
walk_state->local_variables[i].name.integer |= (i << 24);
|
2005-08-04 22:44:28 -06:00
|
|
|
walk_state->local_variables[i].descriptor =
|
|
|
|
ACPI_DESC_TYPE_NAMED;
|
|
|
|
walk_state->local_variables[i].type = ACPI_TYPE_ANY;
|
|
|
|
walk_state->local_variables[i].flags = ANOBJ_END_OF_PEER_LIST |
|
|
|
|
ANOBJ_METHOD_LOCAL;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return_VOID;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ds_method_data_delete_all
|
|
|
|
*
|
|
|
|
* PARAMETERS: walk_state - Current walk state object
|
|
|
|
*
|
|
|
|
* RETURN: None
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Delete method locals and arguments. Arguments are only
|
|
|
|
* deleted if this method was called from another method.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
void acpi_ds_method_data_delete_all(struct acpi_walk_state *walk_state)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-08-04 22:44:28 -06:00
|
|
|
u32 index;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_FUNCTION_TRACE("ds_method_data_delete_all");
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* Detach the locals */
|
|
|
|
|
|
|
|
for (index = 0; index < ACPI_METHOD_NUM_LOCALS; index++) {
|
|
|
|
if (walk_state->local_variables[index].object) {
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Deleting Local%d=%p\n",
|
|
|
|
index,
|
|
|
|
walk_state->local_variables[index].
|
|
|
|
object));
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* Detach object (if present) and remove a reference */
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_ns_detach_object(&walk_state->
|
|
|
|
local_variables[index]);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Detach the arguments */
|
|
|
|
|
|
|
|
for (index = 0; index < ACPI_METHOD_NUM_ARGS; index++) {
|
|
|
|
if (walk_state->arguments[index].object) {
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Deleting Arg%d=%p\n",
|
|
|
|
index,
|
|
|
|
walk_state->arguments[index].object));
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* Detach object (if present) and remove a reference */
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_ns_detach_object(&walk_state->arguments[index]);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return_VOID;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ds_method_data_init_args
|
|
|
|
*
|
|
|
|
* PARAMETERS: *Params - Pointer to a parameter list for the method
|
|
|
|
* max_param_count - The arg count for this method
|
|
|
|
* walk_state - Current walk state object
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Initialize arguments for a method. The parameter list is a list
|
|
|
|
* of ACPI operand objects, either null terminated or whose length
|
|
|
|
* is defined by max_param_count.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
acpi_status
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_ds_method_data_init_args(union acpi_operand_object **params,
|
|
|
|
u32 max_param_count,
|
|
|
|
struct acpi_walk_state *walk_state)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_status status;
|
|
|
|
u32 index = 0;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_FUNCTION_TRACE_PTR("ds_method_data_init_args", params);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
if (!params) {
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
|
|
|
|
"No param list passed to method\n"));
|
|
|
|
return_ACPI_STATUS(AE_OK);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
2005-04-18 20:49:35 -06:00
|
|
|
/* Copy passed parameters into the new method stack frame */
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2005-04-18 20:49:35 -06:00
|
|
|
while ((index < ACPI_METHOD_NUM_ARGS) &&
|
2005-08-04 22:44:28 -06:00
|
|
|
(index < max_param_count) && params[index]) {
|
2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* A valid parameter.
|
|
|
|
* Store the argument in the method/walk descriptor.
|
|
|
|
* Do not copy the arg in order to implement call by reference
|
|
|
|
*/
|
2005-08-04 22:44:28 -06:00
|
|
|
status = acpi_ds_method_data_set_value(AML_ARG_OP, index,
|
|
|
|
params[index],
|
|
|
|
walk_state);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%d args passed to method\n", index));
|
|
|
|
return_ACPI_STATUS(AE_OK);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ds_method_data_get_node
|
|
|
|
*
|
|
|
|
* PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
|
2005-04-18 20:49:35 -06:00
|
|
|
* Index - Which Local or Arg whose type to get
|
2005-04-16 16:20:36 -06:00
|
|
|
* walk_state - Current walk state object
|
2005-04-18 20:49:35 -06:00
|
|
|
* Node - Where the node is returned.
|
2005-04-16 16:20:36 -06:00
|
|
|
*
|
2005-04-18 20:49:35 -06:00
|
|
|
* RETURN: Status and node
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Get the Node associated with a local or arg.
|
2005-04-16 16:20:36 -06:00
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
acpi_status
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_ds_method_data_get_node(u16 opcode,
|
|
|
|
u32 index,
|
|
|
|
struct acpi_walk_state *walk_state,
|
|
|
|
struct acpi_namespace_node **node)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_FUNCTION_TRACE("ds_method_data_get_node");
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Method Locals and Arguments are supported
|
|
|
|
*/
|
|
|
|
switch (opcode) {
|
|
|
|
case AML_LOCAL_OP:
|
|
|
|
|
|
|
|
if (index > ACPI_METHOD_MAX_LOCAL) {
|
2006-01-27 14:43:00 -07:00
|
|
|
ACPI_ERROR((AE_INFO,
|
|
|
|
"Local index %d is invalid (max %d)",
|
|
|
|
index, ACPI_METHOD_MAX_LOCAL));
|
2005-08-04 22:44:28 -06:00
|
|
|
return_ACPI_STATUS(AE_AML_INVALID_INDEX);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Return a pointer to the pseudo-node */
|
|
|
|
|
|
|
|
*node = &walk_state->local_variables[index];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AML_ARG_OP:
|
|
|
|
|
|
|
|
if (index > ACPI_METHOD_MAX_ARG) {
|
2006-01-27 14:43:00 -07:00
|
|
|
ACPI_ERROR((AE_INFO,
|
|
|
|
"Arg index %d is invalid (max %d)",
|
|
|
|
index, ACPI_METHOD_MAX_ARG));
|
2005-08-04 22:44:28 -06:00
|
|
|
return_ACPI_STATUS(AE_AML_INVALID_INDEX);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Return a pointer to the pseudo-node */
|
|
|
|
|
|
|
|
*node = &walk_state->arguments[index];
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2006-01-27 14:43:00 -07:00
|
|
|
ACPI_ERROR((AE_INFO, "Opcode %d is invalid", opcode));
|
2005-08-04 22:44:28 -06:00
|
|
|
return_ACPI_STATUS(AE_AML_BAD_OPCODE);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
return_ACPI_STATUS(AE_OK);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ds_method_data_set_value
|
|
|
|
*
|
|
|
|
* PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
|
2005-04-18 20:49:35 -06:00
|
|
|
* Index - Which Local or Arg to get
|
2005-04-16 16:20:36 -06:00
|
|
|
* Object - Object to be inserted into the stack entry
|
|
|
|
* walk_state - Current walk state object
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Insert an object onto the method stack at entry Opcode:Index.
|
|
|
|
* Note: There is no "implicit conversion" for locals.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-04-18 20:49:35 -06:00
|
|
|
static acpi_status
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_ds_method_data_set_value(u16 opcode,
|
|
|
|
u32 index,
|
|
|
|
union acpi_operand_object *object,
|
|
|
|
struct acpi_walk_state *walk_state)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_status status;
|
|
|
|
struct acpi_namespace_node *node;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_FUNCTION_TRACE("ds_method_data_set_value");
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
|
|
|
|
"new_obj %p Opcode %X, Refs=%d [%s]\n", object,
|
|
|
|
opcode, object->common.reference_count,
|
|
|
|
acpi_ut_get_type_name(object->common.type)));
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* Get the namespace node for the arg/local */
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Increment ref count so object can't be deleted while installed.
|
|
|
|
* NOTE: We do not copy the object in order to preserve the call by
|
|
|
|
* reference semantics of ACPI Control Method invocation.
|
|
|
|
* (See ACPI specification 2.0_c)
|
|
|
|
*/
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_ut_add_reference(object);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* Install the object */
|
|
|
|
|
|
|
|
node->object = object;
|
2005-08-04 22:44:28 -06:00
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ds_method_data_get_value
|
|
|
|
*
|
|
|
|
* PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
|
|
|
|
* Index - which local_var or argument to get
|
|
|
|
* walk_state - Current walk state object
|
2005-04-18 20:49:35 -06:00
|
|
|
* dest_desc - Where Arg or Local value is returned
|
2005-04-16 16:20:36 -06:00
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
2005-04-18 20:49:35 -06:00
|
|
|
* DESCRIPTION: Retrieve value of selected Arg or Local for this method
|
2005-04-16 16:20:36 -06:00
|
|
|
* Used only in acpi_ex_resolve_to_value().
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
acpi_status
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_ds_method_data_get_value(u16 opcode,
|
|
|
|
u32 index,
|
|
|
|
struct acpi_walk_state *walk_state,
|
|
|
|
union acpi_operand_object **dest_desc)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_status status;
|
|
|
|
struct acpi_namespace_node *node;
|
|
|
|
union acpi_operand_object *object;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_FUNCTION_TRACE("ds_method_data_get_value");
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* Validate the object descriptor */
|
|
|
|
|
|
|
|
if (!dest_desc) {
|
2006-01-27 14:43:00 -07:00
|
|
|
ACPI_ERROR((AE_INFO, "Null object descriptor pointer"));
|
2005-08-04 22:44:28 -06:00
|
|
|
return_ACPI_STATUS(AE_BAD_PARAMETER);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the namespace node for the arg/local */
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the object from the node */
|
|
|
|
|
|
|
|
object = node->object;
|
|
|
|
|
|
|
|
/* Examine the returned object, it must be valid. */
|
|
|
|
|
|
|
|
if (!object) {
|
|
|
|
/*
|
|
|
|
* Index points to uninitialized object.
|
|
|
|
* This means that either 1) The expected argument was
|
|
|
|
* not passed to the method, or 2) A local variable
|
|
|
|
* was referenced by the method (via the ASL)
|
|
|
|
* before it was initialized. Either case is an error.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* If slack enabled, init the local_x/arg_x to an Integer of value zero */
|
|
|
|
|
|
|
|
if (acpi_gbl_enable_interpreter_slack) {
|
2005-08-04 22:44:28 -06:00
|
|
|
object =
|
|
|
|
acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
|
2005-04-16 16:20:36 -06:00
|
|
|
if (!object) {
|
2005-08-04 22:44:28 -06:00
|
|
|
return_ACPI_STATUS(AE_NO_MEMORY);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
object->integer.value = 0;
|
|
|
|
node->object = object;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Otherwise, return the error */
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
else
|
|
|
|
switch (opcode) {
|
|
|
|
case AML_ARG_OP:
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2006-01-27 14:43:00 -07:00
|
|
|
ACPI_ERROR((AE_INFO,
|
|
|
|
"Uninitialized Arg[%d] at node %p",
|
|
|
|
index, node));
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
return_ACPI_STATUS(AE_AML_UNINITIALIZED_ARG);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
case AML_LOCAL_OP:
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2006-01-27 14:43:00 -07:00
|
|
|
ACPI_ERROR((AE_INFO,
|
|
|
|
"Uninitialized Local[%d] at node %p",
|
|
|
|
index, node));
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
return_ACPI_STATUS(AE_AML_UNINITIALIZED_LOCAL);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
default:
|
2006-01-27 14:43:00 -07:00
|
|
|
ACPI_ERROR((AE_INFO,
|
|
|
|
"Not a Arg/Local opcode: %X",
|
|
|
|
opcode));
|
2005-08-04 22:44:28 -06:00
|
|
|
return_ACPI_STATUS(AE_AML_INTERNAL);
|
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The Index points to an initialized and valid object.
|
|
|
|
* Return an additional reference to the object
|
|
|
|
*/
|
|
|
|
*dest_desc = object;
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_ut_add_reference(object);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
return_ACPI_STATUS(AE_OK);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ds_method_data_delete_value
|
|
|
|
*
|
|
|
|
* PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
|
|
|
|
* Index - which local_var or argument to delete
|
|
|
|
* walk_state - Current walk state object
|
|
|
|
*
|
|
|
|
* RETURN: None
|
|
|
|
*
|
2005-04-18 20:49:35 -06:00
|
|
|
* DESCRIPTION: Delete the entry at Opcode:Index. Inserts
|
2005-04-16 16:20:36 -06:00
|
|
|
* a null into the stack slot after the object is deleted.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-04-18 20:49:35 -06:00
|
|
|
static void
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_ds_method_data_delete_value(u16 opcode,
|
|
|
|
u32 index, struct acpi_walk_state *walk_state)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_status status;
|
|
|
|
struct acpi_namespace_node *node;
|
|
|
|
union acpi_operand_object *object;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_FUNCTION_TRACE("ds_method_data_delete_value");
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* Get the namespace node for the arg/local */
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
2005-04-16 16:20:36 -06:00
|
|
|
return_VOID;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the associated object */
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
object = acpi_ns_get_attached_object(node);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Undefine the Arg or Local by setting its descriptor
|
|
|
|
* pointer to NULL. Locals/Args can contain both
|
|
|
|
* ACPI_OPERAND_OBJECTS and ACPI_NAMESPACE_NODEs
|
|
|
|
*/
|
|
|
|
node->object = NULL;
|
|
|
|
|
|
|
|
if ((object) &&
|
2005-08-04 22:44:28 -06:00
|
|
|
(ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_OPERAND)) {
|
2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* There is a valid object.
|
|
|
|
* Decrement the reference count by one to balance the
|
|
|
|
* increment when the object was stored.
|
|
|
|
*/
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_ut_remove_reference(object);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return_VOID;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ds_store_object_to_local
|
|
|
|
*
|
|
|
|
* PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
|
2005-04-18 20:49:35 -06:00
|
|
|
* Index - Which Local or Arg to set
|
2005-04-16 16:20:36 -06:00
|
|
|
* obj_desc - Value to be stored
|
|
|
|
* walk_state - Current walk state
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Store a value in an Arg or Local. The obj_desc is installed
|
|
|
|
* as the new value for the Arg or Local and the reference count
|
|
|
|
* for obj_desc is incremented.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
acpi_status
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_ds_store_object_to_local(u16 opcode,
|
|
|
|
u32 index,
|
|
|
|
union acpi_operand_object *obj_desc,
|
|
|
|
struct acpi_walk_state *walk_state)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_status status;
|
|
|
|
struct acpi_namespace_node *node;
|
|
|
|
union acpi_operand_object *current_obj_desc;
|
|
|
|
union acpi_operand_object *new_obj_desc;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_FUNCTION_TRACE("ds_store_object_to_local");
|
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Opcode=%X Index=%d Obj=%p\n",
|
|
|
|
opcode, index, obj_desc));
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* Parameter validation */
|
|
|
|
|
|
|
|
if (!obj_desc) {
|
2005-08-04 22:44:28 -06:00
|
|
|
return_ACPI_STATUS(AE_BAD_PARAMETER);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the namespace node for the arg/local */
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
current_obj_desc = acpi_ns_get_attached_object(node);
|
2005-04-16 16:20:36 -06:00
|
|
|
if (current_obj_desc == obj_desc) {
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Obj=%p already installed!\n",
|
|
|
|
obj_desc));
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the reference count on the object is more than one, we must
|
|
|
|
* take a copy of the object before we store. A reference count
|
|
|
|
* of exactly 1 means that the object was just created during the
|
|
|
|
* evaluation of an expression, and we can safely use it since it
|
|
|
|
* is not used anywhere else.
|
|
|
|
*/
|
|
|
|
new_obj_desc = obj_desc;
|
|
|
|
if (obj_desc->common.reference_count > 1) {
|
2005-08-04 22:44:28 -06:00
|
|
|
status =
|
|
|
|
acpi_ut_copy_iobject_to_iobject(obj_desc, &new_obj_desc,
|
|
|
|
walk_state);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If there is an object already in this slot, we either
|
|
|
|
* have to delete it, or if this is an argument and there
|
|
|
|
* is an object reference stored there, we have to do
|
|
|
|
* an indirect store!
|
|
|
|
*/
|
|
|
|
if (current_obj_desc) {
|
|
|
|
/*
|
|
|
|
* Check for an indirect store if an argument
|
|
|
|
* contains an object reference (stored as an Node).
|
|
|
|
* We don't allow this automatic dereferencing for
|
|
|
|
* locals, since a store to a local should overwrite
|
|
|
|
* anything there, including an object reference.
|
|
|
|
*
|
|
|
|
* If both Arg0 and Local0 contain ref_of (Local4):
|
|
|
|
*
|
|
|
|
* Store (1, Arg0) - Causes indirect store to local4
|
|
|
|
* Store (1, Local0) - Stores 1 in local0, overwriting
|
|
|
|
* the reference to local4
|
|
|
|
* Store (1, de_refof (Local0)) - Causes indirect store to local4
|
|
|
|
*
|
|
|
|
* Weird, but true.
|
|
|
|
*/
|
|
|
|
if (opcode == AML_ARG_OP) {
|
|
|
|
/*
|
2005-04-18 20:49:35 -06:00
|
|
|
* If we have a valid reference object that came from ref_of(),
|
|
|
|
* do the indirect store
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
2005-08-04 22:44:28 -06:00
|
|
|
if ((ACPI_GET_DESCRIPTOR_TYPE(current_obj_desc) ==
|
|
|
|
ACPI_DESC_TYPE_OPERAND)
|
|
|
|
&& (current_obj_desc->common.type ==
|
|
|
|
ACPI_TYPE_LOCAL_REFERENCE)
|
|
|
|
&& (current_obj_desc->reference.opcode ==
|
|
|
|
AML_REF_OF_OP)) {
|
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
|
|
|
|
"Arg (%p) is an obj_ref(Node), storing in node %p\n",
|
|
|
|
new_obj_desc,
|
|
|
|
current_obj_desc));
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Store this object to the Node (perform the indirect store)
|
|
|
|
* NOTE: No implicit conversion is performed, as per the ACPI
|
|
|
|
* specification rules on storing to Locals/Args.
|
|
|
|
*/
|
2005-08-04 22:44:28 -06:00
|
|
|
status =
|
|
|
|
acpi_ex_store_object_to_node(new_obj_desc,
|
|
|
|
current_obj_desc->
|
|
|
|
reference.
|
|
|
|
object,
|
|
|
|
walk_state,
|
|
|
|
ACPI_NO_IMPLICIT_CONVERSION);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* Remove local reference if we copied the object above */
|
|
|
|
|
|
|
|
if (new_obj_desc != obj_desc) {
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_ut_remove_reference(new_obj_desc);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
2005-08-04 22:44:28 -06:00
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Delete the existing object
|
|
|
|
* before storing the new one
|
|
|
|
*/
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_ds_method_data_delete_value(opcode, index, walk_state);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Install the Obj descriptor (*new_obj_desc) into
|
|
|
|
* the descriptor for the Arg or Local.
|
|
|
|
* (increments the object reference count by one)
|
|
|
|
*/
|
2005-08-04 22:44:28 -06:00
|
|
|
status =
|
|
|
|
acpi_ds_method_data_set_value(opcode, index, new_obj_desc,
|
|
|
|
walk_state);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* Remove local reference if we copied the object above */
|
|
|
|
|
|
|
|
if (new_obj_desc != obj_desc) {
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_ut_remove_reference(new_obj_desc);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
2005-04-18 20:49:35 -06:00
|
|
|
#ifdef ACPI_OBSOLETE_FUNCTIONS
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ds_method_data_get_type
|
|
|
|
*
|
|
|
|
* PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
|
|
|
|
* Index - Which Local or Arg whose type to get
|
|
|
|
* walk_state - Current walk state object
|
|
|
|
*
|
|
|
|
* RETURN: Data type of current value of the selected Arg or Local
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Get the type of the object stored in the Local or Arg
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
acpi_object_type
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_ds_method_data_get_type(u16 opcode,
|
|
|
|
u32 index, struct acpi_walk_state *walk_state)
|
2005-04-18 20:49:35 -06:00
|
|
|
{
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_status status;
|
|
|
|
struct acpi_namespace_node *node;
|
|
|
|
union acpi_operand_object *object;
|
2005-04-18 20:49:35 -06:00
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_FUNCTION_TRACE("ds_method_data_get_type");
|
2005-04-18 20:49:35 -06:00
|
|
|
|
|
|
|
/* Get the namespace node for the arg/local */
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_VALUE((ACPI_TYPE_NOT_FOUND));
|
2005-04-18 20:49:35 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the object */
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
object = acpi_ns_get_attached_object(node);
|
2005-04-18 20:49:35 -06:00
|
|
|
if (!object) {
|
2006-10-01 22:00:00 -06:00
|
|
|
|
2005-04-18 20:49:35 -06:00
|
|
|
/* Uninitialized local/arg, return TYPE_ANY */
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
return_VALUE(ACPI_TYPE_ANY);
|
2005-04-18 20:49:35 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the object type */
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
return_VALUE(ACPI_GET_OBJECT_TYPE(object));
|
2005-04-18 20:49:35 -06:00
|
|
|
}
|
|
|
|
#endif
|