2005-04-17 06:20:36 +08:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Module Name: dswstate - Dispatcher parse tree walk management routines
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/*
|
2006-01-14 05:22:00 +08:00
|
|
|
* Copyright (C) 2000 - 2006, R. Byron Moore
|
2005-04-17 06:20:36 +08: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/acparser.h>
|
|
|
|
#include <acpi/acdispat.h>
|
|
|
|
#include <acpi/acnamesp.h>
|
|
|
|
|
|
|
|
#define _COMPONENT ACPI_DISPATCHER
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_MODULE_NAME("dswstate")
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-04-19 10:49:35 +08:00
|
|
|
/* Local prototypes */
|
|
|
|
#ifdef ACPI_OBSOLETE_FUNCTIONS
|
2005-04-17 06:20:36 +08:00
|
|
|
acpi_status
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ds_result_insert(void *object,
|
|
|
|
u32 index, struct acpi_walk_state *walk_state);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_status acpi_ds_obj_stack_delete_all(struct acpi_walk_state *walk_state);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-04-19 10:49:35 +08:00
|
|
|
acpi_status
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ds_obj_stack_pop_object(union acpi_operand_object **object,
|
|
|
|
struct acpi_walk_state *walk_state);
|
|
|
|
|
|
|
|
void *acpi_ds_obj_stack_get_value(u32 index,
|
|
|
|
struct acpi_walk_state *walk_state);
|
2005-04-19 10:49:35 +08:00
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-04-19 10:49:35 +08:00
|
|
|
#ifdef ACPI_FUTURE_USAGE
|
2005-04-17 06:20:36 +08:00
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ds_result_remove
|
|
|
|
*
|
|
|
|
* PARAMETERS: Object - Where to return the popped object
|
|
|
|
* Index - Where to extract the object
|
|
|
|
* walk_state - Current Walk state
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Pop an object off the bottom of this walk's result stack. In
|
|
|
|
* other words, this is a FIFO.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
acpi_status
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ds_result_remove(union acpi_operand_object **object,
|
|
|
|
u32 index, struct acpi_walk_state *walk_state)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-08-05 12:44:28 +08:00
|
|
|
union acpi_generic_state *state;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_FUNCTION_NAME("ds_result_remove");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
state = walk_state->results;
|
|
|
|
if (!state) {
|
2006-01-28 05:43:00 +08:00
|
|
|
ACPI_ERROR((AE_INFO, "No result object pushed! State=%p",
|
|
|
|
walk_state));
|
2005-04-17 06:20:36 +08:00
|
|
|
return (AE_NOT_EXIST);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (index >= ACPI_OBJ_MAX_OPERAND) {
|
2006-01-28 05:43:00 +08:00
|
|
|
ACPI_ERROR((AE_INFO,
|
|
|
|
"Index out of range: %X State=%p Num=%X",
|
|
|
|
index, walk_state, state->results.num_results));
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Check for a valid result object */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
if (!state->results.obj_desc[index]) {
|
2006-01-28 05:43:00 +08:00
|
|
|
ACPI_ERROR((AE_INFO,
|
|
|
|
"Null operand! State=%p #Ops=%X, Index=%X",
|
|
|
|
walk_state, state->results.num_results, index));
|
2005-04-17 06:20:36 +08:00
|
|
|
return (AE_AML_NO_RETURN_VALUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Remove the object */
|
|
|
|
|
|
|
|
state->results.num_results--;
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
*object = state->results.obj_desc[index];
|
|
|
|
state->results.obj_desc[index] = NULL;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
|
|
|
|
"Obj=%p [%s] Index=%X State=%p Num=%X\n",
|
|
|
|
*object,
|
|
|
|
(*object) ? acpi_ut_get_object_type_name(*object) :
|
|
|
|
"NULL", index, walk_state,
|
|
|
|
state->results.num_results));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return (AE_OK);
|
|
|
|
}
|
2005-08-05 12:44:28 +08:00
|
|
|
#endif /* ACPI_FUTURE_USAGE */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ds_result_pop
|
|
|
|
*
|
|
|
|
* PARAMETERS: Object - Where to return the popped object
|
|
|
|
* walk_state - Current Walk state
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Pop an object off the bottom of this walk's result stack. In
|
|
|
|
* other words, this is a FIFO.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
acpi_status
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ds_result_pop(union acpi_operand_object ** object,
|
|
|
|
struct acpi_walk_state * walk_state)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_native_uint index;
|
|
|
|
union acpi_generic_state *state;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_FUNCTION_NAME("ds_result_pop");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
state = walk_state->results;
|
|
|
|
if (!state) {
|
|
|
|
return (AE_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!state->results.num_results) {
|
2006-01-28 05:43:00 +08:00
|
|
|
ACPI_ERROR((AE_INFO, "Result stack is empty! State=%p",
|
|
|
|
walk_state));
|
2005-04-17 06:20:36 +08:00
|
|
|
return (AE_AML_NO_RETURN_VALUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Remove top element */
|
|
|
|
|
|
|
|
state->results.num_results--;
|
|
|
|
|
|
|
|
for (index = ACPI_OBJ_NUM_OPERANDS; index; index--) {
|
2006-10-02 12:00:00 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Check for a valid result object */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
if (state->results.obj_desc[index - 1]) {
|
|
|
|
*object = state->results.obj_desc[index - 1];
|
|
|
|
state->results.obj_desc[index - 1] = NULL;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
|
|
|
|
"Obj=%p [%s] Index=%X State=%p Num=%X\n",
|
|
|
|
*object,
|
|
|
|
(*object) ?
|
|
|
|
acpi_ut_get_object_type_name(*object)
|
|
|
|
: "NULL", (u32) index - 1, walk_state,
|
|
|
|
state->results.num_results));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return (AE_OK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-28 05:43:00 +08:00
|
|
|
ACPI_ERROR((AE_INFO, "No result objects! State=%p", walk_state));
|
2005-04-17 06:20:36 +08:00
|
|
|
return (AE_AML_NO_RETURN_VALUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ds_result_pop_from_bottom
|
|
|
|
*
|
|
|
|
* PARAMETERS: Object - Where to return the popped object
|
|
|
|
* walk_state - Current Walk state
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Pop an object off the bottom of this walk's result stack. In
|
|
|
|
* other words, this is a FIFO.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
acpi_status
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ds_result_pop_from_bottom(union acpi_operand_object ** object,
|
|
|
|
struct acpi_walk_state * walk_state)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_native_uint index;
|
|
|
|
union acpi_generic_state *state;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_FUNCTION_NAME("ds_result_pop_from_bottom");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
state = walk_state->results;
|
|
|
|
if (!state) {
|
2006-01-28 05:43:00 +08:00
|
|
|
ACPI_ERROR((AE_INFO,
|
|
|
|
"No result object pushed! State=%p", walk_state));
|
2005-04-17 06:20:36 +08:00
|
|
|
return (AE_NOT_EXIST);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!state->results.num_results) {
|
2006-01-28 05:43:00 +08:00
|
|
|
ACPI_ERROR((AE_INFO, "No result objects! State=%p",
|
|
|
|
walk_state));
|
2005-04-17 06:20:36 +08:00
|
|
|
return (AE_AML_NO_RETURN_VALUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Remove Bottom element */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
*object = state->results.obj_desc[0];
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Push entire stack down one element */
|
|
|
|
|
|
|
|
for (index = 0; index < state->results.num_results; index++) {
|
2005-08-05 12:44:28 +08:00
|
|
|
state->results.obj_desc[index] =
|
|
|
|
state->results.obj_desc[index + 1];
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
state->results.num_results--;
|
|
|
|
|
|
|
|
/* Check for a valid result object */
|
|
|
|
|
|
|
|
if (!*object) {
|
2006-01-28 05:43:00 +08:00
|
|
|
ACPI_ERROR((AE_INFO,
|
|
|
|
"Null operand! State=%p #Ops=%X Index=%X",
|
|
|
|
walk_state, state->results.num_results,
|
|
|
|
(u32) index));
|
2005-04-17 06:20:36 +08:00
|
|
|
return (AE_AML_NO_RETURN_VALUE);
|
|
|
|
}
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Obj=%p [%s] Results=%p State=%p\n",
|
|
|
|
*object,
|
|
|
|
(*object) ? acpi_ut_get_object_type_name(*object) :
|
|
|
|
"NULL", state, walk_state));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return (AE_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ds_result_push
|
|
|
|
*
|
|
|
|
* PARAMETERS: Object - Where to return the popped object
|
|
|
|
* walk_state - Current Walk state
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Push an object onto the current result stack
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
acpi_status
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ds_result_push(union acpi_operand_object * object,
|
|
|
|
struct acpi_walk_state * walk_state)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-08-05 12:44:28 +08:00
|
|
|
union acpi_generic_state *state;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_FUNCTION_NAME("ds_result_push");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
state = walk_state->results;
|
|
|
|
if (!state) {
|
2006-01-28 05:43:00 +08:00
|
|
|
ACPI_ERROR((AE_INFO, "No result stack frame during push"));
|
2005-04-17 06:20:36 +08:00
|
|
|
return (AE_AML_INTERNAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (state->results.num_results == ACPI_OBJ_NUM_OPERANDS) {
|
2006-01-28 05:43:00 +08:00
|
|
|
ACPI_ERROR((AE_INFO,
|
|
|
|
"Result stack overflow: Obj=%p State=%p Num=%X",
|
|
|
|
object, walk_state, state->results.num_results));
|
2005-04-17 06:20:36 +08:00
|
|
|
return (AE_STACK_OVERFLOW);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!object) {
|
2006-01-28 05:43:00 +08:00
|
|
|
ACPI_ERROR((AE_INFO,
|
|
|
|
"Null Object! Obj=%p State=%p Num=%X",
|
|
|
|
object, walk_state, state->results.num_results));
|
2005-04-17 06:20:36 +08:00
|
|
|
return (AE_BAD_PARAMETER);
|
|
|
|
}
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
state->results.obj_desc[state->results.num_results] = object;
|
2005-04-17 06:20:36 +08:00
|
|
|
state->results.num_results++;
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Obj=%p [%s] State=%p Num=%X Cur=%X\n",
|
|
|
|
object,
|
|
|
|
object ?
|
|
|
|
acpi_ut_get_object_type_name((union
|
|
|
|
acpi_operand_object *)
|
|
|
|
object) : "NULL",
|
|
|
|
walk_state, state->results.num_results,
|
|
|
|
walk_state->current_result));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return (AE_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ds_result_stack_push
|
|
|
|
*
|
|
|
|
* PARAMETERS: walk_state - Current Walk state
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Push an object onto the walk_state result stack.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_status acpi_ds_result_stack_push(struct acpi_walk_state * walk_state)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-08-05 12:44:28 +08:00
|
|
|
union acpi_generic_state *state;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_FUNCTION_NAME("ds_result_stack_push");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
state = acpi_ut_create_generic_state();
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!state) {
|
|
|
|
return (AE_NO_MEMORY);
|
|
|
|
}
|
|
|
|
|
2006-03-18 05:44:00 +08:00
|
|
|
state->common.descriptor_type = ACPI_DESC_TYPE_STATE_RESULT;
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ut_push_generic_state(&walk_state->results, state);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Results=%p State=%p\n",
|
|
|
|
state, walk_state));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return (AE_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ds_result_stack_pop
|
|
|
|
*
|
|
|
|
* PARAMETERS: walk_state - Current Walk state
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Pop an object off of the walk_state result stack.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_status acpi_ds_result_stack_pop(struct acpi_walk_state * walk_state)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-08-05 12:44:28 +08:00
|
|
|
union acpi_generic_state *state;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_FUNCTION_NAME("ds_result_stack_pop");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Check for stack underflow */
|
|
|
|
|
|
|
|
if (walk_state->results == NULL) {
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Underflow - State=%p\n",
|
|
|
|
walk_state));
|
2005-04-17 06:20:36 +08:00
|
|
|
return (AE_AML_NO_OPERAND);
|
|
|
|
}
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
state = acpi_ut_pop_generic_state(&walk_state->results);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
|
|
|
|
"Result=%p remaining_results=%X State=%p\n",
|
|
|
|
state, state->results.num_results, walk_state));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ut_delete_generic_state(state);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return (AE_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ds_obj_stack_push
|
|
|
|
*
|
|
|
|
* PARAMETERS: Object - Object to push
|
|
|
|
* walk_state - Current Walk state
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Push an object onto this walk's object/operand stack
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
acpi_status
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ds_obj_stack_push(void *object, struct acpi_walk_state * walk_state)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_FUNCTION_NAME("ds_obj_stack_push");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Check for stack overflow */
|
|
|
|
|
|
|
|
if (walk_state->num_operands >= ACPI_OBJ_NUM_OPERANDS) {
|
2006-01-28 05:43:00 +08:00
|
|
|
ACPI_ERROR((AE_INFO,
|
|
|
|
"Object stack overflow! Obj=%p State=%p #Ops=%X",
|
|
|
|
object, walk_state, walk_state->num_operands));
|
2005-04-17 06:20:36 +08:00
|
|
|
return (AE_STACK_OVERFLOW);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Put the object onto the stack */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
walk_state->operands[walk_state->num_operands] = object;
|
2005-04-17 06:20:36 +08:00
|
|
|
walk_state->num_operands++;
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n",
|
|
|
|
object,
|
|
|
|
acpi_ut_get_object_type_name((union
|
|
|
|
acpi_operand_object *)
|
|
|
|
object), walk_state,
|
|
|
|
walk_state->num_operands));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return (AE_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ds_obj_stack_pop
|
|
|
|
*
|
|
|
|
* PARAMETERS: pop_count - Number of objects/entries to pop
|
|
|
|
* walk_state - Current Walk state
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT
|
|
|
|
* deleted by this routine.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
acpi_status
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ds_obj_stack_pop(u32 pop_count, struct acpi_walk_state * walk_state)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-08-05 12:44:28 +08:00
|
|
|
u32 i;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_FUNCTION_NAME("ds_obj_stack_pop");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
for (i = 0; i < pop_count; i++) {
|
2006-10-02 12:00:00 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Check for stack underflow */
|
|
|
|
|
|
|
|
if (walk_state->num_operands == 0) {
|
2006-01-28 05:43:00 +08:00
|
|
|
ACPI_ERROR((AE_INFO,
|
|
|
|
"Object stack underflow! Count=%X State=%p #Ops=%X",
|
|
|
|
pop_count, walk_state,
|
|
|
|
walk_state->num_operands));
|
2005-04-17 06:20:36 +08:00
|
|
|
return (AE_STACK_UNDERFLOW);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Just set the stack entry to null */
|
|
|
|
|
|
|
|
walk_state->num_operands--;
|
2005-08-05 12:44:28 +08:00
|
|
|
walk_state->operands[walk_state->num_operands] = NULL;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n",
|
2005-04-17 06:20:36 +08:00
|
|
|
pop_count, walk_state, walk_state->num_operands));
|
|
|
|
|
|
|
|
return (AE_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ds_obj_stack_pop_and_delete
|
|
|
|
*
|
|
|
|
* PARAMETERS: pop_count - Number of objects/entries to pop
|
|
|
|
* walk_state - Current Walk state
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Pop this walk's object stack and delete each object that is
|
|
|
|
* popped off.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
acpi_status
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ds_obj_stack_pop_and_delete(u32 pop_count,
|
|
|
|
struct acpi_walk_state * walk_state)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-08-05 12:44:28 +08:00
|
|
|
u32 i;
|
|
|
|
union acpi_operand_object *obj_desc;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_FUNCTION_NAME("ds_obj_stack_pop_and_delete");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
for (i = 0; i < pop_count; i++) {
|
2006-10-02 12:00:00 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Check for stack underflow */
|
|
|
|
|
|
|
|
if (walk_state->num_operands == 0) {
|
2006-01-28 05:43:00 +08:00
|
|
|
ACPI_ERROR((AE_INFO,
|
|
|
|
"Object stack underflow! Count=%X State=%p #Ops=%X",
|
|
|
|
pop_count, walk_state,
|
|
|
|
walk_state->num_operands));
|
2005-04-17 06:20:36 +08:00
|
|
|
return (AE_STACK_UNDERFLOW);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Pop the stack and delete an object if present in this stack entry */
|
|
|
|
|
|
|
|
walk_state->num_operands--;
|
2005-08-05 12:44:28 +08:00
|
|
|
obj_desc = walk_state->operands[walk_state->num_operands];
|
2005-04-17 06:20:36 +08:00
|
|
|
if (obj_desc) {
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ut_remove_reference(walk_state->
|
|
|
|
operands[walk_state->
|
|
|
|
num_operands]);
|
|
|
|
walk_state->operands[walk_state->num_operands] = NULL;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n",
|
2005-04-17 06:20:36 +08:00
|
|
|
pop_count, walk_state, walk_state->num_operands));
|
|
|
|
|
|
|
|
return (AE_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ds_get_current_walk_state
|
|
|
|
*
|
|
|
|
* PARAMETERS: Thread - Get current active state for this Thread
|
|
|
|
*
|
|
|
|
* RETURN: Pointer to the current walk state
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Get the walk state that is at the head of the list (the "current"
|
|
|
|
* walk state.)
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
struct acpi_walk_state *acpi_ds_get_current_walk_state(struct acpi_thread_state
|
|
|
|
*thread)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_FUNCTION_NAME("ds_get_current_walk_state");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (!thread) {
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "Current walk_state %p\n",
|
|
|
|
thread->walk_state_list));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return (thread->walk_state_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ds_push_walk_state
|
|
|
|
*
|
|
|
|
* PARAMETERS: walk_state - State to push
|
2005-04-19 10:49:35 +08:00
|
|
|
* Thread - Thread state object
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* RETURN: None
|
|
|
|
*
|
2005-04-19 10:49:35 +08:00
|
|
|
* DESCRIPTION: Place the Thread state at the head of the state list.
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
void
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ds_push_walk_state(struct acpi_walk_state *walk_state,
|
|
|
|
struct acpi_thread_state *thread)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_FUNCTION_TRACE("ds_push_walk_state");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
walk_state->next = thread->walk_state_list;
|
2005-04-17 06:20:36 +08:00
|
|
|
thread->walk_state_list = walk_state;
|
|
|
|
|
|
|
|
return_VOID;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ds_pop_walk_state
|
|
|
|
*
|
2005-04-19 10:49:35 +08:00
|
|
|
* PARAMETERS: Thread - Current thread state
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
2005-04-19 10:49:35 +08:00
|
|
|
* RETURN: A walk_state object popped from the thread's stack
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* DESCRIPTION: Remove and return the walkstate object that is at the head of
|
|
|
|
* the walk stack for the given walk list. NULL indicates that
|
|
|
|
* the list is empty.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
struct acpi_walk_state *acpi_ds_pop_walk_state(struct acpi_thread_state *thread)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-08-05 12:44:28 +08:00
|
|
|
struct acpi_walk_state *walk_state;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_FUNCTION_TRACE("ds_pop_walk_state");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
walk_state = thread->walk_state_list;
|
|
|
|
|
|
|
|
if (walk_state) {
|
2006-10-02 12:00:00 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Next walk state becomes the current walk state */
|
|
|
|
|
|
|
|
thread->walk_state_list = walk_state->next;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Don't clear the NEXT field, this serves as an indicator
|
|
|
|
* that there is a parent WALK STATE
|
2005-04-19 10:49:35 +08:00
|
|
|
* Do Not: walk_state->Next = NULL;
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
return_PTR(walk_state);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ds_create_walk_state
|
|
|
|
*
|
2005-04-19 10:49:35 +08:00
|
|
|
* PARAMETERS: owner_id - ID for object creation
|
|
|
|
* Origin - Starting point for this walk
|
2006-03-18 05:44:00 +08:00
|
|
|
* method_desc - Method object
|
2005-04-17 06:20:36 +08:00
|
|
|
* Thread - Current thread state
|
|
|
|
*
|
|
|
|
* RETURN: Pointer to the new walk state.
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Allocate and initialize a new walk state. The current walk
|
|
|
|
* state is set to this new state.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
struct acpi_walk_state *acpi_ds_create_walk_state(acpi_owner_id owner_id,
|
|
|
|
union acpi_parse_object
|
|
|
|
*origin,
|
|
|
|
union acpi_operand_object
|
2006-03-18 05:44:00 +08:00
|
|
|
*method_desc,
|
2005-08-05 12:44:28 +08:00
|
|
|
struct acpi_thread_state
|
|
|
|
*thread)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-08-05 12:44:28 +08:00
|
|
|
struct acpi_walk_state *walk_state;
|
|
|
|
acpi_status status;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_FUNCTION_TRACE("ds_create_walk_state");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-10-03 12:00:00 +08:00
|
|
|
walk_state = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_walk_state));
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!walk_state) {
|
2005-08-05 12:44:28 +08:00
|
|
|
return_PTR(NULL);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2006-03-18 05:44:00 +08:00
|
|
|
walk_state->descriptor_type = ACPI_DESC_TYPE_WALK;
|
|
|
|
walk_state->method_desc = method_desc;
|
2005-08-05 12:44:28 +08:00
|
|
|
walk_state->owner_id = owner_id;
|
|
|
|
walk_state->origin = origin;
|
|
|
|
walk_state->thread = thread;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
walk_state->parser_state.start_op = origin;
|
|
|
|
|
|
|
|
/* Init the method args/local */
|
|
|
|
|
|
|
|
#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY))
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ds_method_data_init(walk_state);
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Create an initial result stack entry */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
status = acpi_ds_result_stack_push(walk_state);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
2006-10-03 12:00:00 +08:00
|
|
|
ACPI_FREE(walk_state);
|
2005-08-05 12:44:28 +08:00
|
|
|
return_PTR(NULL);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Put the new state at the head of the walk list */
|
|
|
|
|
|
|
|
if (thread) {
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ds_push_walk_state(walk_state, thread);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
return_PTR(walk_state);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ds_init_aml_walk
|
|
|
|
*
|
|
|
|
* PARAMETERS: walk_state - New state to be initialized
|
|
|
|
* Op - Current parse op
|
|
|
|
* method_node - Control method NS node, if any
|
|
|
|
* aml_start - Start of AML
|
|
|
|
* aml_length - Length of AML
|
2005-04-19 10:49:35 +08:00
|
|
|
* Info - Method info block (params, etc.)
|
2005-04-17 06:20:36 +08:00
|
|
|
* pass_number - 1, 2, or 3
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Initialize a walk state for a pass 1 or 2 parse tree walk
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
acpi_status
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ds_init_aml_walk(struct acpi_walk_state *walk_state,
|
|
|
|
union acpi_parse_object *op,
|
|
|
|
struct acpi_namespace_node *method_node,
|
|
|
|
u8 * aml_start,
|
|
|
|
u32 aml_length,
|
|
|
|
struct acpi_parameter_info *info, u8 pass_number)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_status status;
|
|
|
|
struct acpi_parse_state *parser_state = &walk_state->parser_state;
|
|
|
|
union acpi_parse_object *extra_op;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_FUNCTION_TRACE("ds_init_aml_walk");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
walk_state->parser_state.aml =
|
|
|
|
walk_state->parser_state.aml_start = aml_start;
|
2005-04-17 06:20:36 +08:00
|
|
|
walk_state->parser_state.aml_end =
|
2005-08-05 12:44:28 +08:00
|
|
|
walk_state->parser_state.pkg_end = aml_start + aml_length;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* The next_op of the next_walk will be the beginning of the method */
|
|
|
|
|
2005-04-19 10:49:35 +08:00
|
|
|
walk_state->next_op = NULL;
|
2005-07-30 06:15:00 +08:00
|
|
|
walk_state->pass_number = pass_number;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (info) {
|
|
|
|
if (info->parameter_type == ACPI_PARAM_GPE) {
|
2005-08-05 12:44:28 +08:00
|
|
|
walk_state->gpe_event_info =
|
|
|
|
ACPI_CAST_PTR(struct acpi_gpe_event_info,
|
|
|
|
info->parameters);
|
|
|
|
} else {
|
|
|
|
walk_state->params = info->parameters;
|
2005-04-19 10:49:35 +08:00
|
|
|
walk_state->caller_return_desc = &info->return_object;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
status = acpi_ps_init_scope(&walk_state->parser_state, op);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (method_node) {
|
|
|
|
walk_state->parser_state.start_node = method_node;
|
2005-08-05 12:44:28 +08:00
|
|
|
walk_state->walk_type = ACPI_WALK_METHOD;
|
|
|
|
walk_state->method_node = method_node;
|
|
|
|
walk_state->method_desc =
|
|
|
|
acpi_ns_get_attached_object(method_node);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Push start scope on scope stack and make it current */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
status =
|
|
|
|
acpi_ds_scope_stack_push(method_node, ACPI_TYPE_METHOD,
|
|
|
|
walk_state);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Init the method arguments */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
status = acpi_ds_method_data_init_args(walk_state->params,
|
|
|
|
ACPI_METHOD_NUM_ARGS,
|
|
|
|
walk_state);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2005-08-05 12:44:28 +08:00
|
|
|
} else {
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Setup the current scope.
|
|
|
|
* Find a Named Op that has a namespace node associated with it.
|
|
|
|
* search upwards from this Op. Current scope is the first
|
|
|
|
* Op with a namespace node.
|
|
|
|
*/
|
|
|
|
extra_op = parser_state->start_op;
|
|
|
|
while (extra_op && !extra_op->common.node) {
|
|
|
|
extra_op = extra_op->common.parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!extra_op) {
|
|
|
|
parser_state->start_node = NULL;
|
2005-08-05 12:44:28 +08:00
|
|
|
} else {
|
2005-04-17 06:20:36 +08:00
|
|
|
parser_state->start_node = extra_op->common.node;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parser_state->start_node) {
|
2006-10-02 12:00:00 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Push start scope on scope stack and make it current */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
status =
|
|
|
|
acpi_ds_scope_stack_push(parser_state->start_node,
|
|
|
|
parser_state->start_node->
|
|
|
|
type, walk_state);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
status = acpi_ds_init_callbacks(walk_state, pass_number);
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ds_delete_walk_state
|
|
|
|
*
|
|
|
|
* PARAMETERS: walk_state - State to delete
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Delete a walk state including all internal data structures
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
void acpi_ds_delete_walk_state(struct acpi_walk_state *walk_state)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-08-05 12:44:28 +08:00
|
|
|
union acpi_generic_state *state;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_FUNCTION_TRACE_PTR("ds_delete_walk_state", walk_state);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (!walk_state) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-03-18 05:44:00 +08:00
|
|
|
if (walk_state->descriptor_type != ACPI_DESC_TYPE_WALK) {
|
2006-01-28 05:43:00 +08:00
|
|
|
ACPI_ERROR((AE_INFO, "%p is not a valid walk state",
|
|
|
|
walk_state));
|
2005-04-17 06:20:36 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (walk_state->parser_state.scope) {
|
2006-01-28 05:43:00 +08:00
|
|
|
ACPI_ERROR((AE_INFO, "%p walk still has a scope list",
|
|
|
|
walk_state));
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Always must free any linked control states */
|
|
|
|
|
|
|
|
while (walk_state->control_state) {
|
|
|
|
state = walk_state->control_state;
|
|
|
|
walk_state->control_state = state->common.next;
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ut_delete_generic_state(state);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Always must free any linked parse states */
|
|
|
|
|
|
|
|
while (walk_state->scope_info) {
|
|
|
|
state = walk_state->scope_info;
|
|
|
|
walk_state->scope_info = state->common.next;
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ut_delete_generic_state(state);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Always must free any stacked result states */
|
|
|
|
|
|
|
|
while (walk_state->results) {
|
|
|
|
state = walk_state->results;
|
|
|
|
walk_state->results = state->common.next;
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ut_delete_generic_state(state);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2006-10-03 12:00:00 +08:00
|
|
|
ACPI_FREE(walk_state);
|
2005-04-17 06:20:36 +08:00
|
|
|
return_VOID;
|
|
|
|
}
|
|
|
|
|
2005-04-19 10:49:35 +08:00
|
|
|
#ifdef ACPI_OBSOLETE_FUNCTIONS
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ds_result_insert
|
|
|
|
*
|
|
|
|
* PARAMETERS: Object - Object to push
|
|
|
|
* Index - Where to insert the object
|
|
|
|
* walk_state - Current Walk state
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Insert an object onto this walk's result stack
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
acpi_status
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ds_result_insert(void *object,
|
|
|
|
u32 index, struct acpi_walk_state *walk_state)
|
2005-04-19 10:49:35 +08:00
|
|
|
{
|
2005-08-05 12:44:28 +08:00
|
|
|
union acpi_generic_state *state;
|
2005-04-19 10:49:35 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_FUNCTION_NAME("ds_result_insert");
|
2005-04-19 10:49:35 +08:00
|
|
|
|
|
|
|
state = walk_state->results;
|
|
|
|
if (!state) {
|
2006-01-28 05:43:00 +08:00
|
|
|
ACPI_ERROR((AE_INFO, "No result object pushed! State=%p",
|
|
|
|
walk_state));
|
2005-04-19 10:49:35 +08:00
|
|
|
return (AE_NOT_EXIST);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (index >= ACPI_OBJ_NUM_OPERANDS) {
|
2006-01-28 05:43:00 +08:00
|
|
|
ACPI_ERROR((AE_INFO,
|
|
|
|
"Index out of range: %X Obj=%p State=%p Num=%X",
|
|
|
|
index, object, walk_state,
|
|
|
|
state->results.num_results));
|
2005-04-19 10:49:35 +08:00
|
|
|
return (AE_BAD_PARAMETER);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!object) {
|
2006-01-28 05:43:00 +08:00
|
|
|
ACPI_ERROR((AE_INFO,
|
|
|
|
"Null Object! Index=%X Obj=%p State=%p Num=%X",
|
|
|
|
index, object, walk_state,
|
|
|
|
state->results.num_results));
|
2005-04-19 10:49:35 +08:00
|
|
|
return (AE_BAD_PARAMETER);
|
|
|
|
}
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
state->results.obj_desc[index] = object;
|
2005-04-19 10:49:35 +08:00
|
|
|
state->results.num_results++;
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
|
|
|
|
"Obj=%p [%s] State=%p Num=%X Cur=%X\n",
|
|
|
|
object,
|
|
|
|
object ?
|
|
|
|
acpi_ut_get_object_type_name((union
|
|
|
|
acpi_operand_object *)
|
|
|
|
object) : "NULL",
|
|
|
|
walk_state, state->results.num_results,
|
|
|
|
walk_state->current_result));
|
2005-04-19 10:49:35 +08:00
|
|
|
|
|
|
|
return (AE_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ds_obj_stack_delete_all
|
|
|
|
*
|
|
|
|
* PARAMETERS: walk_state - Current Walk state
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Clear the object stack by deleting all objects that are on it.
|
|
|
|
* Should be used with great care, if at all!
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_status acpi_ds_obj_stack_delete_all(struct acpi_walk_state * walk_state)
|
2005-04-19 10:49:35 +08:00
|
|
|
{
|
2005-08-05 12:44:28 +08:00
|
|
|
u32 i;
|
2005-04-19 10:49:35 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_FUNCTION_TRACE_PTR("ds_obj_stack_delete_all", walk_state);
|
2005-04-19 10:49:35 +08:00
|
|
|
|
|
|
|
/* The stack size is configurable, but fixed */
|
|
|
|
|
|
|
|
for (i = 0; i < ACPI_OBJ_NUM_OPERANDS; i++) {
|
|
|
|
if (walk_state->operands[i]) {
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ut_remove_reference(walk_state->operands[i]);
|
2005-04-19 10:49:35 +08:00
|
|
|
walk_state->operands[i] = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
return_ACPI_STATUS(AE_OK);
|
2005-04-19 10:49:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ds_obj_stack_pop_object
|
|
|
|
*
|
|
|
|
* PARAMETERS: Object - Where to return the popped object
|
|
|
|
* walk_state - Current Walk state
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT
|
|
|
|
* deleted by this routine.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
acpi_status
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ds_obj_stack_pop_object(union acpi_operand_object **object,
|
|
|
|
struct acpi_walk_state *walk_state)
|
2005-04-19 10:49:35 +08:00
|
|
|
{
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_FUNCTION_NAME("ds_obj_stack_pop_object");
|
2005-04-19 10:49:35 +08:00
|
|
|
|
|
|
|
/* Check for stack underflow */
|
|
|
|
|
|
|
|
if (walk_state->num_operands == 0) {
|
2006-01-28 05:43:00 +08:00
|
|
|
ACPI_ERROR((AE_INFO,
|
|
|
|
"Missing operand/stack empty! State=%p #Ops=%X",
|
|
|
|
walk_state, walk_state->num_operands));
|
2005-04-19 10:49:35 +08:00
|
|
|
*object = NULL;
|
|
|
|
return (AE_AML_NO_OPERAND);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Pop the stack */
|
|
|
|
|
|
|
|
walk_state->num_operands--;
|
|
|
|
|
|
|
|
/* Check for a valid operand */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
if (!walk_state->operands[walk_state->num_operands]) {
|
2006-01-28 05:43:00 +08:00
|
|
|
ACPI_ERROR((AE_INFO,
|
|
|
|
"Null operand! State=%p #Ops=%X",
|
|
|
|
walk_state, walk_state->num_operands));
|
2005-04-19 10:49:35 +08:00
|
|
|
*object = NULL;
|
|
|
|
return (AE_AML_NO_OPERAND);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get operand and set stack entry to null */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
*object = walk_state->operands[walk_state->num_operands];
|
|
|
|
walk_state->operands[walk_state->num_operands] = NULL;
|
2005-04-19 10:49:35 +08:00
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n",
|
|
|
|
*object, acpi_ut_get_object_type_name(*object),
|
2005-04-19 10:49:35 +08:00
|
|
|
walk_state, walk_state->num_operands));
|
|
|
|
|
|
|
|
return (AE_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ds_obj_stack_get_value
|
|
|
|
*
|
|
|
|
* PARAMETERS: Index - Stack index whose value is desired. Based
|
|
|
|
* on the top of the stack (index=0 == top)
|
|
|
|
* walk_state - Current Walk state
|
|
|
|
*
|
|
|
|
* RETURN: Pointer to the requested operand
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Retrieve an object from this walk's operand stack. Index must
|
|
|
|
* be within the range of the current stack pointer.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
void *acpi_ds_obj_stack_get_value(u32 index, struct acpi_walk_state *walk_state)
|
2005-04-19 10:49:35 +08:00
|
|
|
{
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_FUNCTION_TRACE_PTR("ds_obj_stack_get_value", walk_state);
|
2005-04-19 10:49:35 +08:00
|
|
|
|
|
|
|
/* Can't do it if the stack is empty */
|
|
|
|
|
|
|
|
if (walk_state->num_operands == 0) {
|
2005-08-05 12:44:28 +08:00
|
|
|
return_PTR(NULL);
|
2005-04-19 10:49:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* or if the index is past the top of the stack */
|
|
|
|
|
|
|
|
if (index > (walk_state->num_operands - (u32) 1)) {
|
2005-08-05 12:44:28 +08:00
|
|
|
return_PTR(NULL);
|
2005-04-19 10:49:35 +08:00
|
|
|
}
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
return_PTR(walk_state->
|
|
|
|
operands[(acpi_native_uint) (walk_state->num_operands - 1) -
|
|
|
|
index]);
|
2005-04-19 10:49:35 +08:00
|
|
|
}
|
|
|
|
#endif
|