📄 dsopcode.c
字号:
bit_count = 32; field_flags = ACCESS_DWORD_ACC; break; /* Def_create_qWord_field */ case AML_CREATE_QWORD_FIELD_OP: /* Offset is in bytes, field is one qword */ bit_offset = 8 * offset; bit_count = 64; field_flags = ACCESS_QWORD_ACC; break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal error - unknown field creation opcode %02x\n", op->opcode)); status = AE_AML_BAD_OPCODE; goto cleanup; } /* * Setup field according to the object type */ switch (src_desc->common.type) { /* Source_buff := Term_arg=>Buffer */ case ACPI_TYPE_BUFFER: if ((bit_offset + bit_count) > (8 * (u32) src_desc->buffer.length)) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Field size %d exceeds Buffer size %d (bits)\n", bit_offset + bit_count, 8 * (u32) src_desc->buffer.length)); status = AE_AML_BUFFER_LIMIT; goto cleanup; } /* * Initialize areas of the field object that are common to all fields * For Field_flags, use LOCK_RULE = 0 (NO_LOCK), UPDATE_RULE = 0 (UPDATE_PRESERVE) */ status = acpi_ex_prep_common_field_object (obj_desc, field_flags, bit_offset, bit_count); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } obj_desc->buffer_field.buffer_obj = src_desc; /* Reference count for Src_desc inherits Obj_desc count */ src_desc->common.reference_count = (u16) (src_desc->common.reference_count + obj_desc->common.reference_count); break; /* Improper object type */ default: if ((src_desc->common.type > (u8) INTERNAL_TYPE_REFERENCE) || !acpi_ut_valid_object_type (src_desc->common.type)) /* TBD: This line MUST be a single line until Acpi_src can handle it (block deletion) */ { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Tried to create field in invalid object type %X\n", src_desc->common.type)); } else { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Tried to create field in improper object type - %s\n", acpi_ut_get_type_name (src_desc->common.type))); } status = AE_AML_OPERAND_TYPE; goto cleanup; } if (AML_CREATE_FIELD_OP == op->opcode) { /* Delete object descriptor unique to Create_field */ acpi_ut_remove_reference (cnt_desc); cnt_desc = NULL; }cleanup: /* Always delete the operands */ acpi_ut_remove_reference (off_desc); acpi_ut_remove_reference (src_desc); if (AML_CREATE_FIELD_OP == op->opcode) { acpi_ut_remove_reference (cnt_desc); } /* On failure, delete the result descriptor */ if (ACPI_FAILURE (status)) { acpi_ut_remove_reference (res_desc); /* Result descriptor */ } else { /* Now the address and length are valid for this Buffer_field */ obj_desc->buffer_field.flags |= AOPOBJ_DATA_VALID; } return_ACPI_STATUS (status);}/***************************************************************************** * * FUNCTION: Acpi_ds_eval_region_operands * * PARAMETERS: Op - A valid region Op object * * RETURN: Status * * DESCRIPTION: Get region address and length * Called from Acpi_ds_exec_end_op during Op_region parse tree walk * ****************************************************************************/acpi_statusacpi_ds_eval_region_operands ( acpi_walk_state *walk_state, acpi_parse_object *op){ acpi_status status; acpi_operand_object *obj_desc; acpi_operand_object *operand_desc; acpi_namespace_node *node; acpi_parse_object *next_op; FUNCTION_TRACE_PTR ("Ds_eval_region_operands", op); /* * This is where we evaluate the address and length fields of the Op_region declaration */ node = op->node; /* Next_op points to the op that holds the Space_iD */ next_op = op->value.arg; /* Next_op points to address op */ next_op = next_op->next; /* Acpi_evaluate/create the address and length operands */ status = acpi_ds_create_operands (walk_state, next_op); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } /* Resolve the length and address operands to numbers */ status = acpi_ex_resolve_operands (op->opcode, WALK_OPERANDS, walk_state); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, acpi_ps_get_opcode_name (op->opcode), 1, "after Acpi_ex_resolve_operands"); obj_desc = acpi_ns_get_attached_object (node); if (!obj_desc) { return_ACPI_STATUS (AE_NOT_EXIST); } /* * Get the length operand and save it * (at Top of stack) */ operand_desc = walk_state->operands[walk_state->num_operands - 1]; obj_desc->region.length = (u32) operand_desc->integer.value; acpi_ut_remove_reference (operand_desc); /* * Get the address and save it * (at top of stack - 1) */ operand_desc = walk_state->operands[walk_state->num_operands - 2]; obj_desc->region.address = (ACPI_PHYSICAL_ADDRESS) operand_desc->integer.value; acpi_ut_remove_reference (operand_desc); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Rgn_obj %p Addr %8.8X%8.8X Len %X\n", obj_desc, HIDWORD(obj_desc->region.address), LODWORD(obj_desc->region.address), obj_desc->region.length)); /* Now the address and length are valid for this opregion */ obj_desc->region.flags |= AOPOBJ_DATA_VALID; return_ACPI_STATUS (status);}/******************************************************************************* * * FUNCTION: Acpi_ds_exec_begin_control_op * * PARAMETERS: Walk_list - The list that owns the walk stack * Op - The control Op * * RETURN: Status * * DESCRIPTION: Handles all control ops encountered during control method * execution. * ******************************************************************************/acpi_statusacpi_ds_exec_begin_control_op ( acpi_walk_state *walk_state, acpi_parse_object *op){ acpi_status status = AE_OK; acpi_generic_state *control_state; PROC_NAME ("Ds_exec_begin_control_op"); ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", op, op->opcode, walk_state)); switch (op->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; } acpi_ut_push_generic_state (&walk_state->control_state, control_state); /* * Save a pointer to the predicate for multiple executions * of a loop */ walk_state->control_state->control.aml_predicate_start = walk_state->parser_state.aml - 1; /* TBD: can this be removed? */ /*Acpi_ps_pkg_length_encoding_size (GET8 (Walk_state->Parser_state->Aml));*/ 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);}/******************************************************************************* * * FUNCTION: Acpi_ds_exec_end_control_op * * PARAMETERS: Walk_list - The list that owns the walk stack * Op - The control Op * * RETURN: Status * * DESCRIPTION: Handles all control ops encountered during control method * execution. * * ******************************************************************************/acpi_statusacpi_ds_exec_end_control_op ( acpi_walk_state *walk_state, acpi_parse_object *op){ acpi_status status = AE_OK; acpi_generic_state *control_state; PROC_NAME ("Ds_exec_end_control_op"); switch (op->opcode) { case AML_IF_OP: ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", op)); /* * Save the result of the predicate in case there is an * ELSE to come */ walk_state->last_predicate = (u8) walk_state->control_state->common.value; /* * Pop the control state that was created at the start * of the IF and free it */ control_state = acpi_ut_pop_generic_state (&walk_state->control_state); acpi_ut_delete_generic_state (control_state); break; case AML_ELSE_OP: break; case AML_WHILE_OP: ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", op)); if (walk_state->control_state->common.value) { /* Predicate was true, go back and evaluate it again! */ status = AE_CTRL_PENDING; } ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] termination! Op=%p\n", op)); /* Pop this control state and free it */ control_state = acpi_ut_pop_generic_state (&walk_state->control_state); walk_state->aml_last_while = control_state->control.aml_predicate_start; acpi_ut_delete_generic_state (control_state); break; case AML_RETURN_OP: ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[RETURN_OP] Op=%p Arg=%p\n",op, op->value.arg)); /* * One optional operand -- the return value * It can be either an immediate operand or a result that * has been bubbled up the tree */ if (op->value.arg) { /* Return statement has an immediate operand */ status = acpi_ds_create_operands (walk_state, op->value.arg); if (ACPI_FAILURE (status)) { return (status); } /* * If value being returned is a Reference (such as * an arg or local), resolve it now because it may * cease to exist at the end of the method. */ status = acpi_ex_resolve_to_value (&walk_state->operands [0], walk_state); if (ACPI_FAILURE (status)) { return (status); } /* * Get the return value and save as the last result * value. This is the only place where Walk_state->Return_desc * is set to anything other than zero! */ walk_state->return_desc = walk_state->operands[0]; } else if ((walk_state->results) && (walk_state->results->results.num_results > 0)) { /* * The return value has come from a previous calculation. * * If value being returned is a Reference (such as * an arg or local), resolve it now because it may * cease to exist at the end of the method. * * Allow references created by the Index operator to return unchanged. */ if (VALID_DESCRIPTOR_TYPE (walk_state->results->results.obj_desc [0], ACPI_DESC_TYPE_INTERNAL) && ((walk_state->results->results.obj_desc [0])->common.type == INTERNAL_TYPE_REFERENCE) && ((walk_state->results->results.obj_desc [0])->reference.opcode != AML_INDEX_OP)) { status = acpi_ex_resolve_to_value (&walk_state->results->results.obj_desc [0], walk_state); if (ACPI_FAILURE (status)) { return (status); } } walk_state->return_desc = walk_state->results->results.obj_desc [0]; } else { /* No return operand */ if (walk_state->num_operands) { acpi_ut_remove_reference (walk_state->operands [0]); } walk_state->operands [0] = NULL; walk_state->num_operands = 0; walk_state->return_desc = NULL; } ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Completed RETURN_OP State=%p, Ret_val=%p\n", walk_state, walk_state->return_desc)); /* End the control method execution right now */ status = AE_CTRL_TERMINATE; break; case AML_NOOP_OP: /* Just do nothing! */ break; case AML_BREAK_POINT_OP: /* Call up to the OS service layer to handle this */ acpi_os_signal (ACPI_SIGNAL_BREAKPOINT, "Executed AML Breakpoint opcode"); /* If and when it returns, all done. */ break; case AML_BREAK_OP: ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Break to end of current package, Op=%p\n", op)); /* TBD: update behavior for ACPI 2.0 */ /* * As per the ACPI specification: * "The break operation causes the current package * execution to complete" * "Break -- Stop executing the current code package * at this point" * * Returning AE_FALSE here will cause termination of * the current package, and execution will continue one * level up, starting with the completion of the parent Op. */ status = AE_CTRL_FALSE; break; case AML_CONTINUE_OP: /* ACPI 2.0 */ status = AE_NOT_IMPLEMENTED; break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown control opcode=%X Op=%p\n", op->opcode, op)); status = AE_AML_BAD_OPCODE; break; } return (status);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -