1 /******************************************************************************
 
   3  * Module Name: dswstate - Dispatcher parse tree walk management routines
 
   5  *****************************************************************************/
 
   8  * Copyright (C) 2000 - 2005, R. Byron Moore
 
  11  * Redistribution and use in source and binary forms, with or without
 
  12  * modification, are permitted provided that the following conditions
 
  14  * 1. Redistributions of source code must retain the above copyright
 
  15  *    notice, this list of conditions, and the following disclaimer,
 
  16  *    without modification.
 
  17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
 
  18  *    substantially similar to the "NO WARRANTY" disclaimer below
 
  19  *    ("Disclaimer") and any redistribution must be conditioned upon
 
  20  *    including a substantially similar Disclaimer requirement for further
 
  21  *    binary redistribution.
 
  22  * 3. Neither the names of the above-listed copyright holders nor the names
 
  23  *    of any contributors may be used to endorse or promote products derived
 
  24  *    from this software without specific prior written permission.
 
  26  * Alternatively, this software may be distributed under the terms of the
 
  27  * GNU General Public License ("GPL") version 2 as published by the Free
 
  28  * Software Foundation.
 
  31  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 
  32  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 
  33  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
 
  34  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 
  35  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
  36  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 
  37  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 
  38  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 
  39  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
 
  40  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 
  41  * POSSIBILITY OF SUCH DAMAGES.
 
  45 #include <acpi/acpi.h>
 
  46 #include <acpi/acparser.h>
 
  47 #include <acpi/acdispat.h>
 
  48 #include <acpi/acnamesp.h>
 
  50 #define _COMPONENT          ACPI_DISPATCHER
 
  51          ACPI_MODULE_NAME    ("dswstate")
 
  53 /* Local prototypes */
 
  55 #ifdef ACPI_OBSOLETE_FUNCTIONS
 
  57 acpi_ds_result_insert (
 
  60         struct acpi_walk_state          *walk_state);
 
  63 acpi_ds_obj_stack_delete_all (
 
  64         struct acpi_walk_state          *walk_state);
 
  67 acpi_ds_obj_stack_pop_object (
 
  68         union acpi_operand_object       **object,
 
  69         struct acpi_walk_state          *walk_state);
 
  72 acpi_ds_obj_stack_get_value (
 
  74         struct acpi_walk_state          *walk_state);
 
  77 #ifdef ACPI_FUTURE_USAGE
 
  79 /*******************************************************************************
 
  81  * FUNCTION:    acpi_ds_result_remove
 
  83  * PARAMETERS:  Object              - Where to return the popped object
 
  84  *              Index               - Where to extract the object
 
  85  *              walk_state          - Current Walk state
 
  89  * DESCRIPTION: Pop an object off the bottom of this walk's result stack.  In
 
  90  *              other words, this is a FIFO.
 
  92  ******************************************************************************/
 
  95 acpi_ds_result_remove (
 
  96         union acpi_operand_object       **object,
 
  98         struct acpi_walk_state          *walk_state)
 
 100         union acpi_generic_state        *state;
 
 103         ACPI_FUNCTION_NAME ("ds_result_remove");
 
 106         state = walk_state->results;
 
 108                 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result object pushed! State=%p\n",
 
 110                 return (AE_NOT_EXIST);
 
 113         if (index >= ACPI_OBJ_MAX_OPERAND) {
 
 114                 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 
 115                         "Index out of range: %X State=%p Num=%X\n",
 
 116                         index, walk_state, state->results.num_results));
 
 119         /* Check for a valid result object */
 
 121         if (!state->results.obj_desc [index]) {
 
 122                 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 
 123                         "Null operand! State=%p #Ops=%X, Index=%X\n",
 
 124                         walk_state, state->results.num_results, index));
 
 125                 return (AE_AML_NO_RETURN_VALUE);
 
 128         /* Remove the object */
 
 130         state->results.num_results--;
 
 132         *object = state->results.obj_desc [index];
 
 133         state->results.obj_desc [index] = NULL;
 
 135         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
 
 136                 "Obj=%p [%s] Index=%X State=%p Num=%X\n",
 
 137                 *object, (*object) ? acpi_ut_get_object_type_name (*object) : "NULL",
 
 138                 index, walk_state, state->results.num_results));
 
 143 #endif  /*  ACPI_FUTURE_USAGE  */
 
 145 /*******************************************************************************
 
 147  * FUNCTION:    acpi_ds_result_pop
 
 149  * PARAMETERS:  Object              - Where to return the popped object
 
 150  *              walk_state          - Current Walk state
 
 154  * DESCRIPTION: Pop an object off the bottom of this walk's result stack.  In
 
 155  *              other words, this is a FIFO.
 
 157  ******************************************************************************/
 
 161         union acpi_operand_object       **object,
 
 162         struct acpi_walk_state          *walk_state)
 
 164         acpi_native_uint                index;
 
 165         union acpi_generic_state        *state;
 
 168         ACPI_FUNCTION_NAME ("ds_result_pop");
 
 171         state = walk_state->results;
 
 176         if (!state->results.num_results) {
 
 177                 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Result stack is empty! State=%p\n",
 
 179                 return (AE_AML_NO_RETURN_VALUE);
 
 182         /* Remove top element */
 
 184         state->results.num_results--;
 
 186         for (index = ACPI_OBJ_NUM_OPERANDS; index; index--) {
 
 187                 /* Check for a valid result object */
 
 189                 if (state->results.obj_desc [index -1]) {
 
 190                         *object = state->results.obj_desc [index -1];
 
 191                         state->results.obj_desc [index -1] = NULL;
 
 193                         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
 
 194                                 "Obj=%p [%s] Index=%X State=%p Num=%X\n",
 
 196                                 (*object) ? acpi_ut_get_object_type_name (*object) : "NULL",
 
 197                                 (u32) index -1, walk_state, state->results.num_results));
 
 203         ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 
 204                 "No result objects! State=%p\n", walk_state));
 
 205         return (AE_AML_NO_RETURN_VALUE);
 
 209 /*******************************************************************************
 
 211  * FUNCTION:    acpi_ds_result_pop_from_bottom
 
 213  * PARAMETERS:  Object              - Where to return the popped object
 
 214  *              walk_state          - Current Walk state
 
 218  * DESCRIPTION: Pop an object off the bottom of this walk's result stack.  In
 
 219  *              other words, this is a FIFO.
 
 221  ******************************************************************************/
 
 224 acpi_ds_result_pop_from_bottom (
 
 225         union acpi_operand_object       **object,
 
 226         struct acpi_walk_state          *walk_state)
 
 228         acpi_native_uint                index;
 
 229         union acpi_generic_state        *state;
 
 232         ACPI_FUNCTION_NAME ("ds_result_pop_from_bottom");
 
 235         state = walk_state->results;
 
 237                 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 
 238                         "Warning: No result object pushed! State=%p\n", walk_state));
 
 239                 return (AE_NOT_EXIST);
 
 242         if (!state->results.num_results) {
 
 243                 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result objects! State=%p\n",
 
 245                 return (AE_AML_NO_RETURN_VALUE);
 
 248         /* Remove Bottom element */
 
 250         *object = state->results.obj_desc [0];
 
 252         /* Push entire stack down one element */
 
 254         for (index = 0; index < state->results.num_results; index++) {
 
 255                 state->results.obj_desc [index] = state->results.obj_desc [index + 1];
 
 258         state->results.num_results--;
 
 260         /* Check for a valid result object */
 
 263                 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 
 264                         "Null operand! State=%p #Ops=%X, Index=%X\n",
 
 265                         walk_state, state->results.num_results, (u32) index));
 
 266                 return (AE_AML_NO_RETURN_VALUE);
 
 269         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s], Results=%p State=%p\n",
 
 270                 *object, (*object) ? acpi_ut_get_object_type_name (*object) : "NULL",
 
 277 /*******************************************************************************
 
 279  * FUNCTION:    acpi_ds_result_push
 
 281  * PARAMETERS:  Object              - Where to return the popped object
 
 282  *              walk_state          - Current Walk state
 
 286  * DESCRIPTION: Push an object onto the current result stack
 
 288  ******************************************************************************/
 
 291 acpi_ds_result_push (
 
 292         union acpi_operand_object       *object,
 
 293         struct acpi_walk_state          *walk_state)
 
 295         union acpi_generic_state        *state;
 
 298         ACPI_FUNCTION_NAME ("ds_result_push");
 
 301         state = walk_state->results;
 
 303                 ACPI_REPORT_ERROR (("No result stack frame during push\n"));
 
 304                 return (AE_AML_INTERNAL);
 
 307         if (state->results.num_results == ACPI_OBJ_NUM_OPERANDS) {
 
 308                 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 
 309                         "Result stack overflow: Obj=%p State=%p Num=%X\n",
 
 310                         object, walk_state, state->results.num_results));
 
 311                 return (AE_STACK_OVERFLOW);
 
 315                 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 
 316                         "Null Object! Obj=%p State=%p Num=%X\n",
 
 317                         object, walk_state, state->results.num_results));
 
 318                 return (AE_BAD_PARAMETER);
 
 321         state->results.obj_desc [state->results.num_results] = object;
 
 322         state->results.num_results++;
 
 324         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p Num=%X Cur=%X\n",
 
 325                 object, object ? acpi_ut_get_object_type_name ((union acpi_operand_object *) object) : "NULL",
 
 326                 walk_state, state->results.num_results, walk_state->current_result));
 
 332 /*******************************************************************************
 
 334  * FUNCTION:    acpi_ds_result_stack_push
 
 336  * PARAMETERS:  walk_state          - Current Walk state
 
 340  * DESCRIPTION: Push an object onto the walk_state result stack.
 
 342  ******************************************************************************/
 
 345 acpi_ds_result_stack_push (
 
 346         struct acpi_walk_state          *walk_state)
 
 348         union acpi_generic_state        *state;
 
 350         ACPI_FUNCTION_NAME ("ds_result_stack_push");
 
 353         state = acpi_ut_create_generic_state ();
 
 355                 return (AE_NO_MEMORY);
 
 358         state->common.data_type = ACPI_DESC_TYPE_STATE_RESULT;
 
 359         acpi_ut_push_generic_state (&walk_state->results, state);
 
 361         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Results=%p State=%p\n",
 
 368 /*******************************************************************************
 
 370  * FUNCTION:    acpi_ds_result_stack_pop
 
 372  * PARAMETERS:  walk_state          - Current Walk state
 
 376  * DESCRIPTION: Pop an object off of the walk_state result stack.
 
 378  ******************************************************************************/
 
 381 acpi_ds_result_stack_pop (
 
 382         struct acpi_walk_state          *walk_state)
 
 384         union acpi_generic_state        *state;
 
 386         ACPI_FUNCTION_NAME ("ds_result_stack_pop");
 
 389         /* Check for stack underflow */
 
 391         if (walk_state->results == NULL) {
 
 392                 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Underflow - State=%p\n",
 
 394                 return (AE_AML_NO_OPERAND);
 
 397         state = acpi_ut_pop_generic_state (&walk_state->results);
 
 399         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
 
 400                 "Result=%p remaining_results=%X State=%p\n",
 
 401                 state, state->results.num_results, walk_state));
 
 403         acpi_ut_delete_generic_state (state);
 
 409 /*******************************************************************************
 
 411  * FUNCTION:    acpi_ds_obj_stack_push
 
 413  * PARAMETERS:  Object              - Object to push
 
 414  *              walk_state          - Current Walk state
 
 418  * DESCRIPTION: Push an object onto this walk's object/operand stack
 
 420  ******************************************************************************/
 
 423 acpi_ds_obj_stack_push (
 
 425         struct acpi_walk_state          *walk_state)
 
 427         ACPI_FUNCTION_NAME ("ds_obj_stack_push");
 
 430         /* Check for stack overflow */
 
 432         if (walk_state->num_operands >= ACPI_OBJ_NUM_OPERANDS) {
 
 433                 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 
 434                         "overflow! Obj=%p State=%p #Ops=%X\n",
 
 435                         object, walk_state, walk_state->num_operands));
 
 436                 return (AE_STACK_OVERFLOW);
 
 439         /* Put the object onto the stack */
 
 441         walk_state->operands [walk_state->num_operands] = object;
 
 442         walk_state->num_operands++;
 
 444         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n",
 
 445                           object, acpi_ut_get_object_type_name ((union acpi_operand_object *) object),
 
 446                           walk_state, walk_state->num_operands));
 
 452 /*******************************************************************************
 
 454  * FUNCTION:    acpi_ds_obj_stack_pop
 
 456  * PARAMETERS:  pop_count           - Number of objects/entries to pop
 
 457  *              walk_state          - Current Walk state
 
 461  * DESCRIPTION: Pop this walk's object stack.  Objects on the stack are NOT
 
 462  *              deleted by this routine.
 
 464  ******************************************************************************/
 
 467 acpi_ds_obj_stack_pop (
 
 469         struct acpi_walk_state          *walk_state)
 
 473         ACPI_FUNCTION_NAME ("ds_obj_stack_pop");
 
 476         for (i = 0; i < pop_count; i++) {
 
 477                 /* Check for stack underflow */
 
 479                 if (walk_state->num_operands == 0) {
 
 480                         ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 
 481                                 "Underflow! Count=%X State=%p #Ops=%X\n",
 
 482                                 pop_count, walk_state, walk_state->num_operands));
 
 483                         return (AE_STACK_UNDERFLOW);
 
 486                 /* Just set the stack entry to null */
 
 488                 walk_state->num_operands--;
 
 489                 walk_state->operands [walk_state->num_operands] = NULL;
 
 492         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n",
 
 493                           pop_count, walk_state, walk_state->num_operands));
 
 499 /*******************************************************************************
 
 501  * FUNCTION:    acpi_ds_obj_stack_pop_and_delete
 
 503  * PARAMETERS:  pop_count           - Number of objects/entries to pop
 
 504  *              walk_state          - Current Walk state
 
 508  * DESCRIPTION: Pop this walk's object stack and delete each object that is
 
 511  ******************************************************************************/
 
 514 acpi_ds_obj_stack_pop_and_delete (
 
 516         struct acpi_walk_state          *walk_state)
 
 519         union acpi_operand_object       *obj_desc;
 
 522         ACPI_FUNCTION_NAME ("ds_obj_stack_pop_and_delete");
 
 525         for (i = 0; i < pop_count; i++) {
 
 526                 /* Check for stack underflow */
 
 528                 if (walk_state->num_operands == 0) {
 
 529                         ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 
 530                                 "Underflow! Count=%X State=%p #Ops=%X\n",
 
 531                                 pop_count, walk_state, walk_state->num_operands));
 
 532                         return (AE_STACK_UNDERFLOW);
 
 535                 /* Pop the stack and delete an object if present in this stack entry */
 
 537                 walk_state->num_operands--;
 
 538                 obj_desc = walk_state->operands [walk_state->num_operands];
 
 540                         acpi_ut_remove_reference (walk_state->operands [walk_state->num_operands]);
 
 541                         walk_state->operands [walk_state->num_operands] = NULL;
 
 545         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n",
 
 546                           pop_count, walk_state, walk_state->num_operands));
 
 552 /*******************************************************************************
 
 554  * FUNCTION:    acpi_ds_get_current_walk_state
 
 556  * PARAMETERS:  Thread          - Get current active state for this Thread
 
 558  * RETURN:      Pointer to the current walk state
 
 560  * DESCRIPTION: Get the walk state that is at the head of the list (the "current"
 
 563  ******************************************************************************/
 
 565 struct acpi_walk_state *
 
 566 acpi_ds_get_current_walk_state (
 
 567         struct acpi_thread_state        *thread)
 
 570         ACPI_FUNCTION_NAME ("ds_get_current_walk_state");
 
 577         ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Current walk_state %p\n",
 
 578                 thread->walk_state_list));
 
 580         return (thread->walk_state_list);
 
 584 /*******************************************************************************
 
 586  * FUNCTION:    acpi_ds_push_walk_state
 
 588  * PARAMETERS:  walk_state      - State to push
 
 589  *              Thread          - Thread state object
 
 593  * DESCRIPTION: Place the Thread state at the head of the state list.
 
 595  ******************************************************************************/
 
 598 acpi_ds_push_walk_state (
 
 599         struct acpi_walk_state          *walk_state,
 
 600         struct acpi_thread_state        *thread)
 
 602         ACPI_FUNCTION_TRACE ("ds_push_walk_state");
 
 605         walk_state->next      = thread->walk_state_list;
 
 606         thread->walk_state_list = walk_state;
 
 612 /*******************************************************************************
 
 614  * FUNCTION:    acpi_ds_pop_walk_state
 
 616  * PARAMETERS:  Thread      - Current thread state
 
 618  * RETURN:      A walk_state object popped from the thread's stack
 
 620  * DESCRIPTION: Remove and return the walkstate object that is at the head of
 
 621  *              the walk stack for the given walk list.  NULL indicates that
 
 624  ******************************************************************************/
 
 626 struct acpi_walk_state *
 
 627 acpi_ds_pop_walk_state (
 
 628         struct acpi_thread_state        *thread)
 
 630         struct acpi_walk_state          *walk_state;
 
 633         ACPI_FUNCTION_TRACE ("ds_pop_walk_state");
 
 636         walk_state = thread->walk_state_list;
 
 639                 /* Next walk state becomes the current walk state */
 
 641                 thread->walk_state_list = walk_state->next;
 
 644                  * Don't clear the NEXT field, this serves as an indicator
 
 645                  * that there is a parent WALK STATE
 
 646                  * Do Not: walk_state->Next = NULL;
 
 650         return_PTR (walk_state);
 
 654 /*******************************************************************************
 
 656  * FUNCTION:    acpi_ds_create_walk_state
 
 658  * PARAMETERS:  owner_id        - ID for object creation
 
 659  *              Origin          - Starting point for this walk
 
 660  *              mth_desc        - Method object
 
 661  *              Thread          - Current thread state
 
 663  * RETURN:      Pointer to the new walk state.
 
 665  * DESCRIPTION: Allocate and initialize a new walk state.  The current walk
 
 666  *              state is set to this new state.
 
 668  ******************************************************************************/
 
 670 struct acpi_walk_state *
 
 671 acpi_ds_create_walk_state (
 
 672         acpi_owner_id                   owner_id,
 
 673         union acpi_parse_object         *origin,
 
 674         union acpi_operand_object       *mth_desc,
 
 675         struct acpi_thread_state        *thread)
 
 677         struct acpi_walk_state          *walk_state;
 
 681         ACPI_FUNCTION_TRACE ("ds_create_walk_state");
 
 684         walk_state = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_WALK);
 
 689         walk_state->data_type       = ACPI_DESC_TYPE_WALK;
 
 690         walk_state->owner_id        = owner_id;
 
 691         walk_state->origin          = origin;
 
 692         walk_state->method_desc     = mth_desc;
 
 693         walk_state->thread          = thread;
 
 695         walk_state->parser_state.start_op = origin;
 
 697         /* Init the method args/local */
 
 699 #if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY))
 
 700         acpi_ds_method_data_init (walk_state);
 
 703         /* Create an initial result stack entry */
 
 705         status = acpi_ds_result_stack_push (walk_state);
 
 706         if (ACPI_FAILURE (status)) {
 
 707                 acpi_ut_release_to_cache (ACPI_MEM_LIST_WALK, walk_state);
 
 711         /* Put the new state at the head of the walk list */
 
 714                 acpi_ds_push_walk_state (walk_state, thread);
 
 717         return_PTR (walk_state);
 
 721 /*******************************************************************************
 
 723  * FUNCTION:    acpi_ds_init_aml_walk
 
 725  * PARAMETERS:  walk_state      - New state to be initialized
 
 726  *              Op              - Current parse op
 
 727  *              method_node     - Control method NS node, if any
 
 728  *              aml_start       - Start of AML
 
 729  *              aml_length      - Length of AML
 
 730  *              Info            - Method info block (params, etc.)
 
 731  *              pass_number     - 1, 2, or 3
 
 735  * DESCRIPTION: Initialize a walk state for a pass 1 or 2 parse tree walk
 
 737  ******************************************************************************/
 
 740 acpi_ds_init_aml_walk (
 
 741         struct acpi_walk_state          *walk_state,
 
 742         union acpi_parse_object         *op,
 
 743         struct acpi_namespace_node      *method_node,
 
 746         struct acpi_parameter_info      *info,
 
 750         struct acpi_parse_state         *parser_state = &walk_state->parser_state;
 
 751         union acpi_parse_object         *extra_op;
 
 754         ACPI_FUNCTION_TRACE ("ds_init_aml_walk");
 
 757         walk_state->parser_state.aml    =
 
 758         walk_state->parser_state.aml_start = aml_start;
 
 759         walk_state->parser_state.aml_end =
 
 760         walk_state->parser_state.pkg_end = aml_start + aml_length;
 
 762         /* The next_op of the next_walk will be the beginning of the method */
 
 764         walk_state->next_op = NULL;
 
 767                 if (info->parameter_type == ACPI_PARAM_GPE) {
 
 768                         walk_state->gpe_event_info = ACPI_CAST_PTR (struct acpi_gpe_event_info,
 
 772                         walk_state->params          = info->parameters;
 
 773                         walk_state->caller_return_desc = &info->return_object;
 
 777         status = acpi_ps_init_scope (&walk_state->parser_state, op);
 
 778         if (ACPI_FAILURE (status)) {
 
 779                 return_ACPI_STATUS (status);
 
 783                 walk_state->parser_state.start_node = method_node;
 
 784                 walk_state->walk_type            = ACPI_WALK_METHOD;
 
 785                 walk_state->method_node          = method_node;
 
 786                 walk_state->method_desc          = acpi_ns_get_attached_object (method_node);
 
 788                 /* Push start scope on scope stack and make it current  */
 
 790                 status = acpi_ds_scope_stack_push (method_node, ACPI_TYPE_METHOD, walk_state);
 
 791                 if (ACPI_FAILURE (status)) {
 
 792                         return_ACPI_STATUS (status);
 
 795                 /* Init the method arguments */
 
 797                 status = acpi_ds_method_data_init_args (walk_state->params,
 
 798                                  ACPI_METHOD_NUM_ARGS, walk_state);
 
 799                 if (ACPI_FAILURE (status)) {
 
 800                         return_ACPI_STATUS (status);
 
 805                  * Setup the current scope.
 
 806                  * Find a Named Op that has a namespace node associated with it.
 
 807                  * search upwards from this Op.  Current scope is the first
 
 808                  * Op with a namespace node.
 
 810                 extra_op = parser_state->start_op;
 
 811                 while (extra_op && !extra_op->common.node) {
 
 812                         extra_op = extra_op->common.parent;
 
 816                         parser_state->start_node = NULL;
 
 819                         parser_state->start_node = extra_op->common.node;
 
 822                 if (parser_state->start_node) {
 
 823                         /* Push start scope on scope stack and make it current  */
 
 825                         status = acpi_ds_scope_stack_push (parser_state->start_node,
 
 826                                           parser_state->start_node->type, walk_state);
 
 827                         if (ACPI_FAILURE (status)) {
 
 828                                 return_ACPI_STATUS (status);
 
 833         status = acpi_ds_init_callbacks (walk_state, pass_number);
 
 834         return_ACPI_STATUS (status);
 
 838 /*******************************************************************************
 
 840  * FUNCTION:    acpi_ds_delete_walk_state
 
 842  * PARAMETERS:  walk_state      - State to delete
 
 846  * DESCRIPTION: Delete a walk state including all internal data structures
 
 848  ******************************************************************************/
 
 851 acpi_ds_delete_walk_state (
 
 852         struct acpi_walk_state          *walk_state)
 
 854         union acpi_generic_state        *state;
 
 857         ACPI_FUNCTION_TRACE_PTR ("ds_delete_walk_state", walk_state);
 
 864         if (walk_state->data_type != ACPI_DESC_TYPE_WALK) {
 
 865                 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p is not a valid walk state\n",
 
 870         if (walk_state->parser_state.scope) {
 
 871                 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p walk still has a scope list\n",
 
 875         /* Always must free any linked control states */
 
 877         while (walk_state->control_state) {
 
 878                 state = walk_state->control_state;
 
 879                 walk_state->control_state = state->common.next;
 
 881                 acpi_ut_delete_generic_state (state);
 
 884         /* Always must free any linked parse states */
 
 886         while (walk_state->scope_info) {
 
 887                 state = walk_state->scope_info;
 
 888                 walk_state->scope_info = state->common.next;
 
 890                 acpi_ut_delete_generic_state (state);
 
 893         /* Always must free any stacked result states */
 
 895         while (walk_state->results) {
 
 896                 state = walk_state->results;
 
 897                 walk_state->results = state->common.next;
 
 899                 acpi_ut_delete_generic_state (state);
 
 902         acpi_ut_release_to_cache (ACPI_MEM_LIST_WALK, walk_state);
 
 907 #ifdef ACPI_ENABLE_OBJECT_CACHE
 
 908 /******************************************************************************
 
 910  * FUNCTION:    acpi_ds_delete_walk_state_cache
 
 916  * DESCRIPTION: Purge the global state object cache.  Used during subsystem
 
 919  ******************************************************************************/
 
 922 acpi_ds_delete_walk_state_cache (
 
 925         ACPI_FUNCTION_TRACE ("ds_delete_walk_state_cache");
 
 928         acpi_ut_delete_generic_cache (ACPI_MEM_LIST_WALK);
 
 934 #ifdef ACPI_OBSOLETE_FUNCTIONS
 
 935 /*******************************************************************************
 
 937  * FUNCTION:    acpi_ds_result_insert
 
 939  * PARAMETERS:  Object              - Object to push
 
 940  *              Index               - Where to insert the object
 
 941  *              walk_state          - Current Walk state
 
 945  * DESCRIPTION: Insert an object onto this walk's result stack
 
 947  ******************************************************************************/
 
 950 acpi_ds_result_insert (
 
 953         struct acpi_walk_state          *walk_state)
 
 955         union acpi_generic_state        *state;
 
 958         ACPI_FUNCTION_NAME ("ds_result_insert");
 
 961         state = walk_state->results;
 
 963                 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result object pushed! State=%p\n",
 
 965                 return (AE_NOT_EXIST);
 
 968         if (index >= ACPI_OBJ_NUM_OPERANDS) {
 
 969                 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 
 970                         "Index out of range: %X Obj=%p State=%p Num=%X\n",
 
 971                         index, object, walk_state, state->results.num_results));
 
 972                 return (AE_BAD_PARAMETER);
 
 976                 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 
 977                         "Null Object! Index=%X Obj=%p State=%p Num=%X\n",
 
 978                         index, object, walk_state, state->results.num_results));
 
 979                 return (AE_BAD_PARAMETER);
 
 982         state->results.obj_desc [index] = object;
 
 983         state->results.num_results++;
 
 985         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
 
 986                 "Obj=%p [%s] State=%p Num=%X Cur=%X\n",
 
 987                 object, object ? acpi_ut_get_object_type_name ((union acpi_operand_object *) object) : "NULL",
 
 988                 walk_state, state->results.num_results, walk_state->current_result));
 
 994 /*******************************************************************************
 
 996  * FUNCTION:    acpi_ds_obj_stack_delete_all
 
 998  * PARAMETERS:  walk_state          - Current Walk state
 
1002  * DESCRIPTION: Clear the object stack by deleting all objects that are on it.
 
1003  *              Should be used with great care, if at all!
 
1005  ******************************************************************************/
 
1008 acpi_ds_obj_stack_delete_all (
 
1009         struct acpi_walk_state          *walk_state)
 
1014         ACPI_FUNCTION_TRACE_PTR ("ds_obj_stack_delete_all", walk_state);
 
1017         /* The stack size is configurable, but fixed */
 
1019         for (i = 0; i < ACPI_OBJ_NUM_OPERANDS; i++) {
 
1020                 if (walk_state->operands[i]) {
 
1021                         acpi_ut_remove_reference (walk_state->operands[i]);
 
1022                         walk_state->operands[i] = NULL;
 
1026         return_ACPI_STATUS (AE_OK);
 
1030 /*******************************************************************************
 
1032  * FUNCTION:    acpi_ds_obj_stack_pop_object
 
1034  * PARAMETERS:  Object              - Where to return the popped object
 
1035  *              walk_state          - Current Walk state
 
1039  * DESCRIPTION: Pop this walk's object stack.  Objects on the stack are NOT
 
1040  *              deleted by this routine.
 
1042  ******************************************************************************/
 
1045 acpi_ds_obj_stack_pop_object (
 
1046         union acpi_operand_object       **object,
 
1047         struct acpi_walk_state          *walk_state)
 
1049         ACPI_FUNCTION_NAME ("ds_obj_stack_pop_object");
 
1052         /* Check for stack underflow */
 
1054         if (walk_state->num_operands == 0) {
 
1055                 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 
1056                         "Missing operand/stack empty! State=%p #Ops=%X\n",
 
1057                         walk_state, walk_state->num_operands));
 
1059                 return (AE_AML_NO_OPERAND);
 
1064         walk_state->num_operands--;
 
1066         /* Check for a valid operand */
 
1068         if (!walk_state->operands [walk_state->num_operands]) {
 
1069                 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
 
1070                         "Null operand! State=%p #Ops=%X\n",
 
1071                         walk_state, walk_state->num_operands));
 
1073                 return (AE_AML_NO_OPERAND);
 
1076         /* Get operand and set stack entry to null */
 
1078         *object = walk_state->operands [walk_state->num_operands];
 
1079         walk_state->operands [walk_state->num_operands] = NULL;
 
1081         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n",
 
1082                           *object, acpi_ut_get_object_type_name (*object),
 
1083                           walk_state, walk_state->num_operands));
 
1089 /*******************************************************************************
 
1091  * FUNCTION:    acpi_ds_obj_stack_get_value
 
1093  * PARAMETERS:  Index               - Stack index whose value is desired.  Based
 
1094  *                                    on the top of the stack (index=0 == top)
 
1095  *              walk_state          - Current Walk state
 
1097  * RETURN:      Pointer to the requested operand
 
1099  * DESCRIPTION: Retrieve an object from this walk's operand stack.  Index must
 
1100  *              be within the range of the current stack pointer.
 
1102  ******************************************************************************/
 
1105 acpi_ds_obj_stack_get_value (
 
1107         struct acpi_walk_state          *walk_state)
 
1110         ACPI_FUNCTION_TRACE_PTR ("ds_obj_stack_get_value", walk_state);
 
1113         /* Can't do it if the stack is empty */
 
1115         if (walk_state->num_operands == 0) {
 
1119         /* or if the index is past the top of the stack */
 
1121         if (index > (walk_state->num_operands - (u32) 1)) {
 
1125         return_PTR (walk_state->operands[(acpi_native_uint)(walk_state->num_operands - 1) -