acpi_object_type acpi_ds_method_data_get_type(u16 opcode, u32 index, struct acpi_walk_state *walk_state) { acpi_status status; struct acpi_namespace_node *node; union acpi_operand_object *object; ACPI_FUNCTION_TRACE(ds_method_data_get_type); /* Get the namespace node for the arg/local */ status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node); if (ACPI_FAILURE(status)) { return_VALUE((ACPI_TYPE_NOT_FOUND)); } /* Get the object */ object = acpi_ns_get_attached_object(node); if (!object) { /* Uninitialized local/arg, return TYPE_ANY */ return_VALUE(ACPI_TYPE_ANY); } /* Get the object type */ return_VALUE(ACPI_GET_OBJECT_TYPE(object)); }
acpi_status acpi_ex_get_object_reference ( acpi_operand_object *obj_desc, acpi_operand_object **return_desc, acpi_walk_state *walk_state) { acpi_status status = AE_OK; FUNCTION_TRACE_PTR ("Ex_get_object_reference", obj_desc); if (VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_INTERNAL)) { if (obj_desc->common.type != INTERNAL_TYPE_REFERENCE) { *return_desc = NULL; status = AE_TYPE; goto cleanup; } /* * Not a Name -- an indirect name pointer would have * been converted to a direct name pointer in Acpi_ex_resolve_operands */ switch (obj_desc->reference.opcode) { case AML_LOCAL_OP: case AML_ARG_OP: *return_desc = (void *) acpi_ds_method_data_get_node (obj_desc->reference.opcode, obj_desc->reference.offset, walk_state); break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(Internal) Unknown Ref subtype %02x\n", obj_desc->reference.opcode)); *return_desc = NULL; status = AE_AML_INTERNAL; goto cleanup; } } else if (VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_NAMED)) { /* Must be a named object; Just return the Node */ *return_desc = obj_desc; } else { *return_desc = NULL; status = AE_TYPE; } cleanup: ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p Ref=%p\n", obj_desc, *return_desc)); return_ACPI_STATUS (status); }
void acpi_ds_method_data_delete_value ( u16 opcode, u32 index, struct acpi_walk_state *walk_state) { acpi_status status; struct acpi_namespace_node *node; union acpi_operand_object *object; ACPI_FUNCTION_TRACE ("ds_method_data_delete_value"); /* Get the namespace node for the arg/local */ status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node); if (ACPI_FAILURE (status)) { return_VOID; } /* Get the associated object */ object = acpi_ns_get_attached_object (node); /* * Undefine the Arg or Local by setting its descriptor * pointer to NULL. Locals/Args can contain both * ACPI_OPERAND_OBJECTS and ACPI_NAMESPACE_NODEs */ node->object = NULL; if ((object) && (ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_OPERAND)) { /* * There is a valid object. * Decrement the reference count by one to balance the * increment when the object was stored. */ acpi_ut_remove_reference (object); } return_VOID; }
acpi_status acpi_ds_method_data_set_value ( u16 opcode, u32 index, union acpi_operand_object *object, struct acpi_walk_state *walk_state) { acpi_status status; struct acpi_namespace_node *node; ACPI_FUNCTION_TRACE ("ds_method_data_set_value"); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "new_obj %p Opcode %X, Refs=%d [%s]\n", object, opcode, object->common.reference_count, acpi_ut_get_type_name (object->common.type))); /* Get the namespace node for the arg/local */ status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } /* * Increment ref count so object can't be deleted while installed. * NOTE: We do not copy the object in order to preserve the call by * reference semantics of ACPI Control Method invocation. * (See ACPI specification 2.0_c) */ acpi_ut_add_reference (object); /* Install the object */ node->object = object; return_ACPI_STATUS (status); }
acpi_status acpi_ds_store_object_to_local(u16 opcode, u32 index, union acpi_operand_object *obj_desc, struct acpi_walk_state *walk_state) { acpi_status status; struct acpi_namespace_node *node; union acpi_operand_object *current_obj_desc; union acpi_operand_object *new_obj_desc; ACPI_FUNCTION_TRACE(ds_store_object_to_local); ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Opcode=%X Index=%d Obj=%p\n", opcode, index, obj_desc)); /* Parameter validation */ if (!obj_desc) { return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Get the namespace node for the arg/local */ status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } current_obj_desc = acpi_ns_get_attached_object(node); if (current_obj_desc == obj_desc) { ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Obj=%p already installed!\n", obj_desc)); return_ACPI_STATUS(status); } /* * If the reference count on the object is more than one, we must * take a copy of the object before we store. A reference count * of exactly 1 means that the object was just created during the * evaluation of an expression, and we can safely use it since it * is not used anywhere else. */ new_obj_desc = obj_desc; if (obj_desc->common.reference_count > 1) { status = acpi_ut_copy_iobject_to_iobject(obj_desc, &new_obj_desc, walk_state); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } } /* * If there is an object already in this slot, we either * have to delete it, or if this is an argument and there * is an object reference stored there, we have to do * an indirect store! */ if (current_obj_desc) { /* * Check for an indirect store if an argument * contains an object reference (stored as an Node). * We don't allow this automatic dereferencing for * locals, since a store to a local should overwrite * anything there, including an object reference. * * If both Arg0 and Local0 contain ref_of (Local4): * * Store (1, Arg0) - Causes indirect store to local4 * Store (1, Local0) - Stores 1 in local0, overwriting * the reference to local4 * Store (1, de_refof (Local0)) - Causes indirect store to local4 * * Weird, but true. */ if (opcode == AML_ARG_OP) { /* * If we have a valid reference object that came from ref_of(), * do the indirect store */ if ((ACPI_GET_DESCRIPTOR_TYPE(current_obj_desc) == ACPI_DESC_TYPE_OPERAND) && (current_obj_desc->common.type == ACPI_TYPE_LOCAL_REFERENCE) && (current_obj_desc->reference.opcode == AML_REF_OF_OP)) { ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Arg (%p) is an ObjRef(Node), storing in node %p\n", new_obj_desc, current_obj_desc)); /* * Store this object to the Node (perform the indirect store) * NOTE: No implicit conversion is performed, as per the ACPI * specification rules on storing to Locals/Args. */ status = acpi_ex_store_object_to_node(new_obj_desc, current_obj_desc-> reference. object, walk_state, ACPI_NO_IMPLICIT_CONVERSION); /* Remove local reference if we copied the object above */ if (new_obj_desc != obj_desc) { acpi_ut_remove_reference(new_obj_desc); } return_ACPI_STATUS(status); } } /* * Delete the existing object * before storing the new one */ acpi_ds_method_data_delete_value(opcode, index, walk_state); } /* * Install the Obj descriptor (*new_obj_desc) into * the descriptor for the Arg or Local. * (increments the object reference count by one) */ status = acpi_ds_method_data_set_value(opcode, index, new_obj_desc, walk_state); /* Remove local reference if we copied the object above */ if (new_obj_desc != obj_desc) { acpi_ut_remove_reference(new_obj_desc); } return_ACPI_STATUS(status); }
acpi_status acpi_ds_method_data_get_value(u16 opcode, u32 index, struct acpi_walk_state *walk_state, union acpi_operand_object **dest_desc) { acpi_status status; struct acpi_namespace_node *node; union acpi_operand_object *object; ACPI_FUNCTION_TRACE(ds_method_data_get_value); /* Validate the object descriptor */ if (!dest_desc) { ACPI_ERROR((AE_INFO, "Null object descriptor pointer")); return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Get the namespace node for the arg/local */ status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } /* Get the object from the node */ object = node->object; /* Examine the returned object, it must be valid. */ if (!object) { /* * Index points to uninitialized object. * This means that either 1) The expected argument was * not passed to the method, or 2) A local variable * was referenced by the method (via the ASL) * before it was initialized. Either case is an error. */ /* If slack enabled, init the local_x/arg_x to an Integer of value zero */ if (acpi_gbl_enable_interpreter_slack) { object = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); if (!object) { return_ACPI_STATUS(AE_NO_MEMORY); } object->integer.value = 0; node->object = object; } /* Otherwise, return the error */ else switch (opcode) { case AML_ARG_OP: ACPI_ERROR((AE_INFO, "Uninitialized Arg[%d] at node %p", index, node)); return_ACPI_STATUS(AE_AML_UNINITIALIZED_ARG); case AML_LOCAL_OP: ACPI_ERROR((AE_INFO, "Uninitialized Local[%d] at node %p", index, node)); return_ACPI_STATUS(AE_AML_UNINITIALIZED_LOCAL); default: ACPI_ERROR((AE_INFO, "Not a Arg/Local opcode: %X", opcode)); return_ACPI_STATUS(AE_AML_INTERNAL); } } /* * The Index points to an initialized and valid object. * Return an additional reference to the object */ *dest_desc = object; acpi_ut_add_reference(object); return_ACPI_STATUS(AE_OK); }