acpi_status acpi_ps_create_op(struct acpi_walk_state *walk_state, u8 *aml_op_start, union acpi_parse_object **new_op) { acpi_status status = AE_OK; union acpi_parse_object *op; union acpi_parse_object *named_op = NULL; union acpi_parse_object *parent_scope; u8 argument_count; const struct acpi_opcode_info *op_info; ACPI_FUNCTION_TRACE_PTR(ps_create_op, walk_state); status = acpi_ps_get_aml_opcode(walk_state); if (status == AE_CTRL_PARSE_CONTINUE) { return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE); } if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } /* Create Op structure and append to parent's argument list */ walk_state->op_info = acpi_ps_get_opcode_info(walk_state->opcode); op = acpi_ps_alloc_op(walk_state->opcode, aml_op_start); if (!op) { return_ACPI_STATUS(AE_NO_MEMORY); } if (walk_state->op_info->flags & AML_NAMED) { status = acpi_ps_build_named_op(walk_state, aml_op_start, op, &named_op); acpi_ps_free_op(op); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } *new_op = named_op; return_ACPI_STATUS(AE_OK); } /* Not a named opcode, just allocate Op and append to parent */ if (walk_state->op_info->flags & AML_CREATE) { /* * Backup to beginning of create_XXXfield declaration * body_length is unknown until we parse the body */ op->named.data = aml_op_start; op->named.length = 0; } if (walk_state->opcode == AML_BANK_FIELD_OP) { /* * Backup to beginning of bank_field declaration * body_length is unknown until we parse the body */ op->named.data = aml_op_start; op->named.length = 0; } parent_scope = acpi_ps_get_parent_scope(&(walk_state->parser_state)); acpi_ps_append_arg(parent_scope, op); if (parent_scope) { op_info = acpi_ps_get_opcode_info(parent_scope->common.aml_opcode); if (op_info->flags & AML_HAS_TARGET) { argument_count = acpi_ps_get_argument_count(op_info->type); if (parent_scope->common.arg_list_length > argument_count) { op->common.flags |= ACPI_PARSEOP_TARGET; } } /* * Special case for both Increment() and Decrement(), where * the lone argument is both a source and a target. */ else if ((parent_scope->common.aml_opcode == AML_INCREMENT_OP) || (parent_scope->common.aml_opcode == AML_DECREMENT_OP)) { op->common.flags |= ACPI_PARSEOP_TARGET; } } if (walk_state->descending_callback != NULL) { /* * Find the object. This will either insert the object into * the namespace or simply look it up */ walk_state->op = *new_op = op; status = walk_state->descending_callback(walk_state, &op); status = acpi_ps_next_parse_state(walk_state, op, status); if (status == AE_CTRL_PENDING) { status = AE_CTRL_PARSE_PENDING; } } return_ACPI_STATUS(status); }
acpi_status acpi_ps_create_op(struct acpi_walk_state *walk_state, u8 *aml_op_start, union acpi_parse_object **new_op) { acpi_status status = AE_OK; union acpi_parse_object *op; union acpi_parse_object *named_op = NULL; union acpi_parse_object *parent_scope; u8 argument_count; const struct acpi_opcode_info *op_info; ACPI_FUNCTION_TRACE_PTR(ps_create_op, walk_state); status = acpi_ps_get_aml_opcode(walk_state); if (status == AE_CTRL_PARSE_CONTINUE) { return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE); } if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } /* Create Op structure and append to parent's argument list */ walk_state->op_info = acpi_ps_get_opcode_info(walk_state->opcode); op = acpi_ps_alloc_op(walk_state->opcode, aml_op_start); if (!op) { return_ACPI_STATUS(AE_NO_MEMORY); } if (walk_state->op_info->flags & AML_NAMED) { status = acpi_ps_build_named_op(walk_state, aml_op_start, op, &named_op); acpi_ps_free_op(op); #ifdef ACPI_ASL_COMPILER if (acpi_gbl_disasm_flag && walk_state->opcode == AML_EXTERNAL_OP && status == AE_NOT_FOUND) { /* * If parsing of AML_EXTERNAL_OP's name path fails, then skip * past this opcode and keep parsing. This is a much better * alternative than to abort the entire disassembler. At this * point, the parser_state is at the end of the namepath of the * external declaration opcode. Setting walk_state->Aml to * walk_state->parser_state.Aml + 2 moves increments the * walk_state->Aml past the object type and the paramcount of the * external opcode. */ walk_state->aml = walk_state->parser_state.aml + 2; walk_state->parser_state.aml = walk_state->aml; return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE); } #endif if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } *new_op = named_op; return_ACPI_STATUS(AE_OK); } /* Not a named opcode, just allocate Op and append to parent */ if (walk_state->op_info->flags & AML_CREATE) { /* * Backup to beginning of create_XXXfield declaration * body_length is unknown until we parse the body */ op->named.data = aml_op_start; op->named.length = 0; } if (walk_state->opcode == AML_BANK_FIELD_OP) { /* * Backup to beginning of bank_field declaration * body_length is unknown until we parse the body */ op->named.data = aml_op_start; op->named.length = 0; } parent_scope = acpi_ps_get_parent_scope(&(walk_state->parser_state)); acpi_ps_append_arg(parent_scope, op); if (parent_scope) { op_info = acpi_ps_get_opcode_info(parent_scope->common.aml_opcode); if (op_info->flags & AML_HAS_TARGET) { argument_count = acpi_ps_get_argument_count(op_info->type); if (parent_scope->common.arg_list_length > argument_count) { op->common.flags |= ACPI_PARSEOP_TARGET; } } /* * Special case for both Increment() and Decrement(), where * the lone argument is both a source and a target. */ else if ((parent_scope->common.aml_opcode == AML_INCREMENT_OP) || (parent_scope->common.aml_opcode == AML_DECREMENT_OP)) { op->common.flags |= ACPI_PARSEOP_TARGET; } } if (walk_state->descending_callback != NULL) { /* * Find the object. This will either insert the object into * the namespace or simply look it up */ walk_state->op = *new_op = op; status = walk_state->descending_callback(walk_state, &op); status = acpi_ps_next_parse_state(walk_state, op, status); if (status == AE_CTRL_PENDING) { status = AE_CTRL_PARSE_PENDING; } } return_ACPI_STATUS(status); }