acpi_status acpi_ds_result_push(union acpi_operand_object * object, struct acpi_walk_state * walk_state) { union acpi_generic_state *state; acpi_status status; acpi_native_uint index; ACPI_FUNCTION_NAME(ds_result_push); if (walk_state->result_count > walk_state->result_size) { ACPI_ERROR((AE_INFO, "Result stack is full")); return (AE_AML_INTERNAL); } else if (walk_state->result_count == walk_state->result_size) { /* Extend the result stack */ status = acpi_ds_result_stack_push(walk_state); if (ACPI_FAILURE(status)) { ACPI_ERROR((AE_INFO, "Failed to extend the result stack")); return (status); } } if (!(walk_state->result_count < walk_state->result_size)) { ACPI_ERROR((AE_INFO, "No free elements in result stack")); return (AE_AML_INTERNAL); } state = walk_state->results; if (!state) { ACPI_ERROR((AE_INFO, "No result stack frame during push")); return (AE_AML_INTERNAL); } if (!object) { ACPI_ERROR((AE_INFO, "Null Object! Obj=%p State=%p Num=%X", object, walk_state, walk_state->result_count)); return (AE_BAD_PARAMETER); } /* Assign the address of object to the top free element of result stack */ index = walk_state->result_count % ACPI_RESULTS_FRAME_OBJ_NUM; state->results.obj_desc[index] = object; walk_state->result_count++; ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Obj=%p [%s] State=%p Num=%X Cur=%X\n", object, acpi_ut_get_object_type_name((union acpi_operand_object *) object), walk_state, walk_state->result_count, walk_state->current_result)); return (AE_OK); }
/**ltl * 功能: 创建walk state对象 * 参数: owner_id ->ID号 * origin -> * method_desc-> * thread -> * 返回值: * 说明: */ struct acpi_walk_state *acpi_ds_create_walk_state(acpi_owner_id owner_id, union acpi_parse_object *origin, union acpi_operand_object *method_desc, struct acpi_thread_state *thread) { struct acpi_walk_state *walk_state; acpi_status status; ACPI_FUNCTION_TRACE(ds_create_walk_state); /* 分配内存空间 */ walk_state = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_walk_state)); if (!walk_state) { return_PTR(NULL); } walk_state->descriptor_type = ACPI_DESC_TYPE_WALK; walk_state->method_desc = method_desc; walk_state->owner_id = owner_id; walk_state->origin = origin; walk_state->thread = thread; walk_state->parser_state.start_op = origin; /* Init the method args/local */ #if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY)) acpi_ds_method_data_init(walk_state); #endif /* Create an initial result stack entry */ status = acpi_ds_result_stack_push(walk_state); if (ACPI_FAILURE(status)) { ACPI_FREE(walk_state); return_PTR(NULL); } /* Put the new state at the head of the walk list */ if (thread) { acpi_ds_push_walk_state(walk_state, thread); } return_PTR(walk_state); }