static acpi_status acpi_ds_result_stack_push(struct acpi_walk_state *walk_state) { union acpi_generic_state *state; ACPI_FUNCTION_NAME(ds_result_stack_push); /* Check for stack overflow */ if (((u32) walk_state->result_size + ACPI_RESULTS_FRAME_OBJ_NUM) > ACPI_RESULTS_OBJ_NUM_MAX) { ACPI_ERROR((AE_INFO, "Result stack overflow: State=%p Num=%X", walk_state, walk_state->result_size)); return (AE_STACK_OVERFLOW); } state = acpi_ut_create_generic_state(); if (!state) { return (AE_NO_MEMORY); } state->common.descriptor_type = ACPI_DESC_TYPE_STATE_RESULT; acpi_ut_push_generic_state(&walk_state->results, state); /* Increase the length of the result stack by the length of frame */ walk_state->result_size += ACPI_RESULTS_FRAME_OBJ_NUM; ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Results=%p State=%p\n", state, walk_state)); return (AE_OK); }
acpi_status acpi_ut_create_update_state_and_push ( union acpi_operand_object *object, u16 action, union acpi_generic_state **state_list) { union acpi_generic_state *state; ACPI_FUNCTION_ENTRY (); /* Ignore null objects; these are expected */ if (!object) { return (AE_OK); } state = acpi_ut_create_update_state (object, action); if (!state) { return (AE_NO_MEMORY); } acpi_ut_push_generic_state (state_list, state); return (AE_OK); }
acpi_status acpi_ds_scope_stack_push ( acpi_namespace_node *node, acpi_object_type8 type, acpi_walk_state *walk_state) { acpi_generic_state *scope_info; FUNCTION_TRACE ("Ds_scope_stack_push"); if (!node) { /* Invalid scope */ REPORT_ERROR (("Ds_scope_stack_push: null scope passed\n")); return_ACPI_STATUS (AE_BAD_PARAMETER); } /* Make sure object type is valid */ if (!acpi_ex_validate_object_type (type)) { REPORT_WARNING (("Ds_scope_stack_push: type code out of range\n")); } /* Allocate a new scope object */ scope_info = acpi_ut_create_generic_state (); if (!scope_info) { return_ACPI_STATUS (AE_NO_MEMORY); } /* Init new scope object */ scope_info->common.data_type = ACPI_DESC_TYPE_STATE_WSCOPE; scope_info->scope.node = node; scope_info->common.value = (u16) type; /* Push new scope object onto stack */ acpi_ut_push_generic_state (&walk_state->scope_info, scope_info); return_ACPI_STATUS (AE_OK); }
acpi_status acpi_ds_result_stack_push(struct acpi_walk_state * walk_state) { union acpi_generic_state *state; ACPI_FUNCTION_NAME(ds_result_stack_push); state = acpi_ut_create_generic_state(); if (!state) { return (AE_NO_MEMORY); } state->common.descriptor_type = ACPI_DESC_TYPE_STATE_RESULT; acpi_ut_push_generic_state(&walk_state->results, state); ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Results=%p State=%p\n", state, walk_state)); return (AE_OK); }
/******************************************************************************* * * FUNCTION: acpi_ut_create_pkg_state_and_push * * PARAMETERS: Object - Object to be added to the new state * Action - Increment/Decrement * state_list - List the state will be added to * * RETURN: Status * * DESCRIPTION: Create a new state and push it * ******************************************************************************/ acpi_status acpi_ut_create_pkg_state_and_push(void *internal_object, void *external_object, u16 index, union acpi_generic_state **state_list) { union acpi_generic_state *state; ACPI_FUNCTION_ENTRY(); state = acpi_ut_create_pkg_state(internal_object, external_object, index); if (!state) { return (AE_NO_MEMORY); } acpi_ut_push_generic_state(state_list, state); return (AE_OK); }
acpi_status acpi_ps_push_scope ( struct acpi_parse_state *parser_state, union acpi_parse_object *op, u32 remaining_args, u32 arg_count) { union acpi_generic_state *scope; ACPI_FUNCTION_TRACE_PTR ("ps_push_scope", op); scope = acpi_ut_create_generic_state (); if (!scope) { return_ACPI_STATUS (AE_NO_MEMORY); } scope->common.data_type = ACPI_DESC_TYPE_STATE_PSCOPE; scope->parse_scope.op = op; scope->parse_scope.arg_list = remaining_args; scope->parse_scope.arg_count = arg_count; scope->parse_scope.pkg_end = parser_state->pkg_end; /* Push onto scope stack */ acpi_ut_push_generic_state (&parser_state->scope, scope); if (arg_count == ACPI_VAR_ARGS) { /* multiple arguments */ scope->parse_scope.arg_end = parser_state->pkg_end; } else { /* single argument */ scope->parse_scope.arg_end = ACPI_TO_POINTER (ACPI_MAX_PTR); } return_ACPI_STATUS (AE_OK); }
acpi_status acpi_ds_scope_stack_push(struct acpi_namespace_node *node, acpi_object_type type, struct acpi_walk_state *walk_state) { union acpi_generic_state *scope_info; union acpi_generic_state *old_scope_info; ACPI_FUNCTION_TRACE(ds_scope_stack_push); if (!node) { /* Invalid scope */ ACPI_ERROR((AE_INFO, "Null scope parameter")); return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Make sure object type is valid */ if (!acpi_ut_valid_object_type(type)) { ACPI_WARNING((AE_INFO, "Invalid object type: 0x%X", type)); } /* Allocate a new scope object */ scope_info = acpi_ut_create_generic_state(); if (!scope_info) { return_ACPI_STATUS(AE_NO_MEMORY); } /* Init new scope object */ scope_info->common.descriptor_type = ACPI_DESC_TYPE_STATE_WSCOPE; scope_info->scope.node = node; scope_info->common.value = (u16) type; walk_state->scope_depth++; ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%.2d] Pushed scope ", (u32) walk_state->scope_depth)); old_scope_info = walk_state->scope_info; if (old_scope_info) { ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC, "[%4.4s] (%s)", acpi_ut_get_node_name(old_scope_info-> scope.node), acpi_ut_get_type_name(old_scope_info-> common.value))); } else { ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC, "[\\___] (%s)", "ROOT")); } ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC, ", New scope -> [%4.4s] (%s)\n", acpi_ut_get_node_name(scope_info->scope.node), acpi_ut_get_type_name(scope_info->common.value))); /* Push new scope object onto stack */ acpi_ut_push_generic_state(&walk_state->scope_info, scope_info); return_ACPI_STATUS(AE_OK); }
acpi_status acpi_ut_walk_package_tree(union acpi_operand_object *source_object, void *target_object, acpi_pkg_callback walk_callback, void *context) { acpi_status status = AE_OK; union acpi_generic_state *state_list = NULL; union acpi_generic_state *state; union acpi_operand_object *this_source_obj; u32 this_index; ACPI_FUNCTION_TRACE(ut_walk_package_tree); state = acpi_ut_create_pkg_state(source_object, target_object, 0); if (!state) { return_ACPI_STATUS(AE_NO_MEMORY); } while (state) { /* Get one element of the package */ this_index = state->pkg.index; this_source_obj = state->pkg.source_object->package.elements[this_index]; state->pkg.this_target_obj = &state->pkg.source_object->package.elements[this_index]; /* * Check for: * 1) An uninitialized package element. It is completely * legal to declare a package and leave it uninitialized * 2) Not an internal object - can be a namespace node instead * 3) Any type other than a package. Packages are handled in else * case below. */ if ((!this_source_obj) || (ACPI_GET_DESCRIPTOR_TYPE(this_source_obj) != ACPI_DESC_TYPE_OPERAND) || (this_source_obj->common.type != ACPI_TYPE_PACKAGE)) { status = walk_callback(ACPI_COPY_TYPE_SIMPLE, this_source_obj, state, context); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } state->pkg.index++; while (state->pkg.index >= state->pkg.source_object->package.count) { /* * We've handled all of the objects at this level, This means * that we have just completed a package. That package may * have contained one or more packages itself. * * Delete this state and pop the previous state (package). */ acpi_ut_delete_generic_state(state); state = acpi_ut_pop_generic_state(&state_list); /* Finished when there are no more states */ if (!state) { /* * We have handled all of the objects in the top level * package just add the length of the package objects * and exit */ return_ACPI_STATUS(AE_OK); } /* * Go back up a level and move the index past the just * completed package object. */ state->pkg.index++; } } else { /* This is a subobject of type package */ status = walk_callback(ACPI_COPY_TYPE_PACKAGE, this_source_obj, state, context); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } /* * Push the current state and create a new one * The callback above returned a new target package object. */ acpi_ut_push_generic_state(&state_list, state); state = acpi_ut_create_pkg_state(this_source_obj, state->pkg.this_target_obj, 0); if (!state) { /* Free any stacked Update State objects */ while (state_list) { state = acpi_ut_pop_generic_state (&state_list); acpi_ut_delete_generic_state(state); } return_ACPI_STATUS(AE_NO_MEMORY); } } } /* We should never get here */ ACPI_ERROR((AE_INFO, "State list did not terminate correctly")); return_ACPI_STATUS(AE_AML_INTERNAL); }
acpi_status acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state, union acpi_parse_object *op) { acpi_status status = AE_OK; union acpi_generic_state *control_state; ACPI_FUNCTION_NAME(ds_exec_begin_control_op); ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", op, op->common.aml_opcode, walk_state)); switch (op->common.aml_opcode) { case AML_IF_OP: case AML_WHILE_OP: /* * IF/WHILE: Create a new control state to manage these * constructs. We need to manage these as a stack, in order * to handle nesting. */ control_state = acpi_ut_create_control_state(); if (!control_state) { status = AE_NO_MEMORY; break; } /* * Save a pointer to the predicate for multiple executions * of a loop */ control_state->control.aml_predicate_start = walk_state->parser_state.aml - 1; control_state->control.package_end = walk_state->parser_state.pkg_end; control_state->control.opcode = op->common.aml_opcode; /* Push the control state on this walk's control stack */ acpi_ut_push_generic_state(&walk_state->control_state, control_state); break; case AML_ELSE_OP: /* Predicate is in the state object */ /* If predicate is true, the IF was executed, ignore ELSE part */ if (walk_state->last_predicate) { status = AE_CTRL_TRUE; } break; case AML_RETURN_OP: break; default: break; } return (status); }
acpi_status acpi_ut_walk_package_tree ( acpi_operand_object *source_object, void *target_object, ACPI_PKG_CALLBACK walk_callback, void *context) { acpi_status status = AE_OK; acpi_generic_state *state_list = NULL; acpi_generic_state *state; u32 this_index; acpi_operand_object *this_source_obj; FUNCTION_TRACE ("Ut_walk_package_tree"); state = acpi_ut_create_pkg_state (source_object, target_object, 0); if (!state) { return_ACPI_STATUS (AE_NO_MEMORY); } while (state) { this_index = state->pkg.index; this_source_obj = (acpi_operand_object *) state->pkg.source_object->package.elements[this_index]; /* * Check for * 1) An uninitialized package element. It is completely * legal to declare a package and leave it uninitialized * 2) Not an internal object - can be a namespace node instead * 3) Any type other than a package. Packages are handled in else * case below. */ if ((!this_source_obj) || (!VALID_DESCRIPTOR_TYPE ( this_source_obj, ACPI_DESC_TYPE_INTERNAL)) || (!IS_THIS_OBJECT_TYPE ( this_source_obj, ACPI_TYPE_PACKAGE))) { status = walk_callback (ACPI_COPY_TYPE_SIMPLE, this_source_obj, state, context); if (ACPI_FAILURE (status)) { /* TBD: must delete package created up to this point */ return_ACPI_STATUS (status); } state->pkg.index++; while (state->pkg.index >= state->pkg.source_object->package.count) { /* * We've handled all of the objects at this level, This means * that we have just completed a package. That package may * have contained one or more packages itself. * * Delete this state and pop the previous state (package). */ acpi_ut_delete_generic_state (state); state = acpi_ut_pop_generic_state (&state_list); /* Finished when there are no more states */ if (!state) { /* * We have handled all of the objects in the top level * package just add the length of the package objects * and exit */ return_ACPI_STATUS (AE_OK); } /* * Go back up a level and move the index past the just * completed package object. */ state->pkg.index++; } } else { /* This is a sub-object of type package */ status = walk_callback (ACPI_COPY_TYPE_PACKAGE, this_source_obj, state, context); if (ACPI_FAILURE (status)) { /* TBD: must delete package created up to this point */ return_ACPI_STATUS (status); } /* * The callback above returned a new target package object. */ /* * Push the current state and create a new one */ acpi_ut_push_generic_state (&state_list, state); state = acpi_ut_create_pkg_state (this_source_obj, state->pkg.this_target_obj, 0); if (!state) { /* TBD: must delete package created up to this point */ return_ACPI_STATUS (AE_NO_MEMORY); } } } /* We should never get here */ return (AE_AML_INTERNAL); }