void acpi_ns_delete_node(struct acpi_namespace_node *node) { union acpi_operand_object *obj_desc; ACPI_FUNCTION_NAME(ns_delete_node); acpi_ns_detach_object(node); obj_desc = node->object; if (obj_desc && (obj_desc->common.type == ACPI_TYPE_LOCAL_DATA)) { if (obj_desc->data.handler) { obj_desc->data.handler(node, obj_desc->data.pointer); } acpi_ut_remove_reference(obj_desc); } (void)acpi_os_release_object(acpi_gbl_namespace_cache, node); ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_freed++); ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "Node %p, Remaining %X\n", node, acpi_gbl_current_node_count)); }
void acpi_ns_terminate (void) { union acpi_operand_object *obj_desc; ACPI_FUNCTION_TRACE ("ns_terminate"); /* * 1) Free the entire namespace -- all nodes and objects * * Delete all object descriptors attached to namepsace nodes */ acpi_ns_delete_namespace_subtree (acpi_gbl_root_node); /* Detach any objects attached to the root */ obj_desc = acpi_ns_get_attached_object (acpi_gbl_root_node); if (obj_desc) { acpi_ns_detach_object (acpi_gbl_root_node); } ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Namespace freed\n")); /* * 2) Now we can delete the ACPI tables */ acpi_tb_delete_all_tables (); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n")); return_VOID; }
void acpi_ns_delete_node(struct acpi_namespace_node *node) { union acpi_operand_object *obj_desc; ACPI_FUNCTION_NAME(ns_delete_node); /* Detach an object if there is one */ acpi_ns_detach_object(node); /* * Delete an attached data object if present (an object that was created * and attached via acpi_attach_data). Note: After any normal object is * detached above, the only possible remaining object is a data object. */ obj_desc = node->object; if (obj_desc && (obj_desc->common.type == ACPI_TYPE_LOCAL_DATA)) { /* Invoke the attached data deletion handler if present */ if (obj_desc->data.handler) { obj_desc->data.handler(node, obj_desc->data.pointer); } acpi_ut_remove_reference(obj_desc); } /* Now we can delete the node */ (void)acpi_os_release_object(acpi_gbl_namespace_cache, node); ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_freed++); ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "Node %p, Remaining %X\n", node, acpi_gbl_current_node_count)); }
void acpi_ns_delete_node ( struct acpi_namespace_node *node) { struct acpi_namespace_node *parent_node; struct acpi_namespace_node *prev_node; struct acpi_namespace_node *next_node; ACPI_FUNCTION_TRACE_PTR ("ns_delete_node", node); parent_node = acpi_ns_get_parent_node (node); prev_node = NULL; next_node = parent_node->child; /* Find the node that is the previous peer in the parent's child list */ while (next_node != node) { prev_node = next_node; next_node = prev_node->peer; } if (prev_node) { /* Node is not first child, unlink it */ prev_node->peer = next_node->peer; if (next_node->flags & ANOBJ_END_OF_PEER_LIST) { prev_node->flags |= ANOBJ_END_OF_PEER_LIST; } } else { /* Node is first child (has no previous peer) */ if (next_node->flags & ANOBJ_END_OF_PEER_LIST) { /* No peers at all */ parent_node->child = NULL; } else { /* Link peer list to parent */ parent_node->child = next_node->peer; } } ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].total_freed++); /* * Detach an object if there is one then delete the node */ acpi_ns_detach_object (node); ACPI_MEM_FREE (node); return_VOID; }
void acpi_ds_method_data_delete_all(struct acpi_walk_state *walk_state) { u32 index; ACPI_FUNCTION_TRACE(ds_method_data_delete_all); /* Detach the locals */ for (index = 0; index < ACPI_METHOD_NUM_LOCALS; index++) { if (walk_state->local_variables[index].object) { ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Deleting Local%d=%p\n", index, walk_state->local_variables[index]. object)); /* Detach object (if present) and remove a reference */ acpi_ns_detach_object(&walk_state-> local_variables[index]); } } /* Detach the arguments */ for (index = 0; index < ACPI_METHOD_NUM_ARGS; index++) { if (walk_state->arguments[index].object) { ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Deleting Arg%d=%p\n", index, walk_state->arguments[index].object)); /* Detach object (if present) and remove a reference */ acpi_ns_detach_object(&walk_state->arguments[index]); } } return_VOID; }
void acpi_ns_delete_namespace_subtree(struct acpi_namespace_node *parent_node) { struct acpi_namespace_node *child_node = NULL; u32 level = 1; ACPI_FUNCTION_TRACE(ns_delete_namespace_subtree); if (!parent_node) { return_VOID; } while (level > 0) { child_node = acpi_ns_get_next_node(parent_node, child_node); if (child_node) { acpi_ns_detach_object(child_node); if (child_node->child) { level++; parent_node = child_node; child_node = NULL; } } else { level--; acpi_ns_delete_children(parent_node); child_node = parent_node; parent_node = acpi_ns_get_parent_node(parent_node); } } return_VOID; }
void acpi_ns_delete_node(struct acpi_namespace_node *node) { union acpi_operand_object *obj_desc; union acpi_operand_object *next_desc; ACPI_FUNCTION_NAME(ns_delete_node); if (!node) { return_VOID; } /* Detach an object if there is one */ acpi_ns_detach_object(node); /* * Delete an attached data object list if present (objects that were * attached via acpi_attach_data). Note: After any normal object is * detached above, the only possible remaining object(s) are data * objects, in a linked list. */ obj_desc = node->object; while (obj_desc && (obj_desc->common.type == ACPI_TYPE_LOCAL_DATA)) { /* Invoke the attached data deletion handler if present */ if (obj_desc->data.handler) { obj_desc->data.handler(node, obj_desc->data.pointer); } next_desc = obj_desc->common.next_object; acpi_ut_remove_reference(obj_desc); obj_desc = next_desc; } /* Special case for the statically allocated root node */ if (node == acpi_gbl_root_node) { return; } /* Now we can delete the node */ (void)acpi_os_release_object(acpi_gbl_namespace_cache, node); ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_freed++); ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "Node %p, Remaining %X\n", node, acpi_gbl_current_node_count)); }
void acpi_ns_terminate (void) { acpi_operand_object *obj_desc; acpi_namespace_node *this_node; FUNCTION_TRACE ("Ns_terminate"); this_node = acpi_gbl_root_node; /* * 1) Free the entire namespace -- all objects, tables, and stacks * * Delete all objects linked to the root * (additional table descriptors) */ acpi_ns_delete_namespace_subtree (this_node); /* Detach any object(s) attached to the root */ obj_desc = acpi_ns_get_attached_object (this_node); if (obj_desc) { acpi_ns_detach_object (this_node); acpi_ut_remove_reference (obj_desc); } acpi_ns_delete_children (this_node); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Namespace freed\n")); /* * 2) Now we can delete the ACPI tables */ acpi_tb_delete_acpi_tables (); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n")); return_VOID; }
/******************************************************************************* * * FUNCTION: acpi_ns_attach_object * * PARAMETERS: node - Parent Node * object - Object to be attached * type - Type of object, or ACPI_TYPE_ANY if not * known * * RETURN: Status * * DESCRIPTION: Record the given object as the value associated with the * name whose acpi_handle is passed. If Object is NULL * and Type is ACPI_TYPE_ANY, set the name as having no value. * Note: Future may require that the Node->Flags field be passed * as a parameter. * * MUTEX: Assumes namespace is locked * ******************************************************************************/ acpi_status acpi_ns_attach_object(struct acpi_namespace_node *node, union acpi_operand_object *object, acpi_object_type type) { union acpi_operand_object *obj_desc; union acpi_operand_object *last_obj_desc; acpi_object_type object_type = ACPI_TYPE_ANY; ACPI_FUNCTION_TRACE(ns_attach_object); /* * Parameter validation */ if (!node) { /* Invalid handle */ ACPI_ERROR((AE_INFO, "Null NamedObj handle")); return_ACPI_STATUS(AE_BAD_PARAMETER); } if (!object && (ACPI_TYPE_ANY != type)) { /* Null object */ ACPI_ERROR((AE_INFO, "Null object, but type not ACPI_TYPE_ANY")); return_ACPI_STATUS(AE_BAD_PARAMETER); } if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) { /* Not a name handle */ ACPI_ERROR((AE_INFO, "Invalid handle %p [%s]", node, acpi_ut_get_descriptor_name(node))); return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Check if this object is already attached */ if (node->object == object) { ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Obj %p already installed in NameObj %p\n", object, node)); return_ACPI_STATUS(AE_OK); } /* If null object, we will just install it */ if (!object) { obj_desc = NULL; object_type = ACPI_TYPE_ANY; } /* * If the source object is a namespace Node with an attached object, * we will use that (attached) object */ else if ((ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED) && ((struct acpi_namespace_node *)object)->object) { /* * Value passed is a name handle and that name has a * non-null value. Use that name's value and type. */ obj_desc = ((struct acpi_namespace_node *)object)->object; object_type = ((struct acpi_namespace_node *)object)->type; } /* * Otherwise, we will use the parameter object, but we must type * it first */ else { obj_desc = (union acpi_operand_object *)object; /* Use the given type */ object_type = type; } ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Installing %p into Node %p [%4.4s]\n", obj_desc, node, acpi_ut_get_node_name(node))); /* Detach an existing attached object if present */ if (node->object) { acpi_ns_detach_object(node); } if (obj_desc) { /* * Must increment the new value's reference count * (if it is an internal object) */ acpi_ut_add_reference(obj_desc); /* * Handle objects with multiple descriptors - walk * to the end of the descriptor list */ last_obj_desc = obj_desc; while (last_obj_desc->common.next_object) { last_obj_desc = last_obj_desc->common.next_object; } /* Install the object at the front of the object list */ last_obj_desc->common.next_object = node->object; } node->type = (u8) object_type; node->object = obj_desc; return_ACPI_STATUS(AE_OK); }
void acpi_ns_delete_namespace_by_owner(acpi_owner_id owner_id) { struct acpi_namespace_node *child_node; struct acpi_namespace_node *deletion_node; struct acpi_namespace_node *parent_node; u32 level; acpi_status status; ACPI_FUNCTION_TRACE_U32(ns_delete_namespace_by_owner, owner_id); if (owner_id == 0) { return_VOID; } status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); if (ACPI_FAILURE(status)) { return_VOID; } deletion_node = NULL; parent_node = acpi_gbl_root_node; child_node = NULL; level = 1; while (level > 0) { child_node = acpi_ns_get_next_node(parent_node, child_node); if (deletion_node) { acpi_ns_delete_children(deletion_node); acpi_ns_remove_node(deletion_node); deletion_node = NULL; } if (child_node) { if (child_node->owner_id == owner_id) { acpi_ns_detach_object(child_node); } if (child_node->child) { level++; parent_node = child_node; child_node = NULL; } else if (child_node->owner_id == owner_id) { deletion_node = child_node; } } else { level--; if (level != 0) { if (parent_node->owner_id == owner_id) { deletion_node = parent_node; } } child_node = parent_node; parent_node = acpi_ns_get_parent_node(parent_node); } } (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); return_VOID; }
void acpi_ns_delete_namespace_by_owner(acpi_owner_id owner_id) { struct acpi_namespace_node *child_node; struct acpi_namespace_node *deletion_node; struct acpi_namespace_node *parent_node; u32 level; acpi_status status; ACPI_FUNCTION_TRACE_U32(ns_delete_namespace_by_owner, owner_id); if (owner_id == 0) { return_VOID; } /* Lock namespace for possible update */ status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); if (ACPI_FAILURE(status)) { return_VOID; } deletion_node = NULL; parent_node = acpi_gbl_root_node; child_node = NULL; level = 1; /* * Traverse the tree of nodes until we bubble back up * to where we started. */ while (level > 0) { /* * Get the next child of this parent node. When child_node is NULL, * the first child of the parent is returned */ child_node = acpi_ns_get_next_node(parent_node, child_node); if (deletion_node) { acpi_ns_delete_children(deletion_node); acpi_ns_remove_node(deletion_node); deletion_node = NULL; } if (child_node) { if (child_node->owner_id == owner_id) { /* Found a matching child node - detach any attached object */ acpi_ns_detach_object(child_node); } /* Check if this node has any children */ if (child_node->child) { /* * There is at least one child of this node, * visit the node */ level++; parent_node = child_node; child_node = NULL; } else if (child_node->owner_id == owner_id) { deletion_node = child_node; } } else { /* * No more children of this parent node. * Move up to the grandparent. */ level--; if (level != 0) { if (parent_node->owner_id == owner_id) { deletion_node = parent_node; } } /* New "last child" is this parent node */ child_node = parent_node; /* Move up the tree to the grandparent */ parent_node = acpi_ns_get_parent_node(parent_node); } } (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); return_VOID; }
void acpi_ns_delete_children(struct acpi_namespace_node *parent_node) { struct acpi_namespace_node *child_node; struct acpi_namespace_node *next_node; u8 flags; ACPI_FUNCTION_TRACE_PTR(ns_delete_children, parent_node); if (!parent_node) { return_VOID; } /* If no children, all done! */ child_node = parent_node->child; if (!child_node) { return_VOID; } /* * Deallocate all children at this level */ do { /* Get the things we need */ next_node = child_node->peer; flags = child_node->flags; /* Grandchildren should have all been deleted already */ if (child_node->child) { ACPI_ERROR((AE_INFO, "Found a grandchild! P=%p C=%p", parent_node, child_node)); } /* Now we can free this child object */ ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_freed++); ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "Object %p, Remaining %X\n", child_node, acpi_gbl_current_node_count)); /* * Detach an object if there is one, then free the child node */ acpi_ns_detach_object(child_node); /* Now we can delete the node */ (void)acpi_os_release_object(acpi_gbl_namespace_cache, child_node); /* And move on to the next child in the list */ child_node = next_node; } while (!(flags & ANOBJ_END_OF_PEER_LIST)); /* Clear the parent's child pointer */ parent_node->child = NULL; return_VOID; }
ACPI_STATUS acpi_ds_method_data_set_value ( u32 type, u32 index, ACPI_OPERAND_OBJECT *src_desc, ACPI_WALK_STATE *walk_state) { ACPI_STATUS status; ACPI_OPERAND_OBJECT **entry; /* Parameter validation */ if (!src_desc) { return (AE_BAD_PARAMETER); } /* Get a pointer to the requested method stack entry */ status = acpi_ds_method_data_get_entry (type, index, walk_state, &entry); if (ACPI_FAILURE (status)) { goto cleanup; } if (*entry == src_desc) { goto cleanup; } /* * 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 (*entry) { /* * 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 ((type == MTH_TYPE_ARG) && (VALID_DESCRIPTOR_TYPE (*entry, ACPI_DESC_TYPE_NAMED))) { /* Detach an existing object from the Node */ acpi_ns_detach_object ((ACPI_NAMESPACE_NODE *) *entry); /* * Store this object into the Node * (do the indirect store) */ status = acpi_ns_attach_object ((ACPI_NAMESPACE_NODE *) *entry, src_desc, src_desc->common.type); return (status); } /* * Otherwise, just delete the existing object * before storing the new one */ acpi_ds_method_data_delete_value (type, index, walk_state); } /* * Install the Obj_stack descriptor (*Src_desc) into * the descriptor for the Arg or Local. * Install the new object in the stack entry * (increments the object reference count by one) */ status = acpi_ds_method_data_set_entry (type, index, src_desc, walk_state); if (ACPI_FAILURE (status)) { goto cleanup; } /* Normal exit */ return (AE_OK); /* Error exit */ cleanup: return (status); }
void acpi_ns_delete_namespace_by_owner ( u16 owner_id) { struct acpi_namespace_node *child_node; struct acpi_namespace_node *deletion_node; u32 level; struct acpi_namespace_node *parent_node; ACPI_FUNCTION_TRACE_U32 ("ns_delete_namespace_by_owner", owner_id); parent_node = acpi_gbl_root_node; child_node = NULL; deletion_node = NULL; level = 1; /* * Traverse the tree of nodes until we bubble back up * to where we started. */ while (level > 0) { /* * Get the next child of this parent node. When child_node is NULL, * the first child of the parent is returned */ child_node = acpi_ns_get_next_node (ACPI_TYPE_ANY, parent_node, child_node); if (deletion_node) { acpi_ns_remove_reference (deletion_node); deletion_node = NULL; } if (child_node) { if (child_node->owner_id == owner_id) { /* Found a matching child node - detach any attached object */ acpi_ns_detach_object (child_node); } /* Check if this node has any children */ if (acpi_ns_get_next_node (ACPI_TYPE_ANY, child_node, NULL)) { /* * There is at least one child of this node, * visit the node */ level++; parent_node = child_node; child_node = NULL; } else if (child_node->owner_id == owner_id) { deletion_node = child_node; } } else { /* * No more children of this parent node. * Move up to the grandparent. */ level--; if (level != 0) { if (parent_node->owner_id == owner_id) { deletion_node = parent_node; } } /* New "last child" is this parent node */ child_node = parent_node; /* Move up the tree to the grandparent */ parent_node = acpi_ns_get_parent_node (parent_node); } } return_VOID; }
void acpi_ns_delete_children ( struct acpi_namespace_node *parent_node) { struct acpi_namespace_node *child_node; struct acpi_namespace_node *next_node; struct acpi_namespace_node *node; u8 flags; ACPI_FUNCTION_TRACE_PTR ("ns_delete_children", parent_node); if (!parent_node) { return_VOID; } /* If no children, all done! */ child_node = parent_node->child; if (!child_node) { return_VOID; } /* * Deallocate all children at this level */ do { /* Get the things we need */ next_node = child_node->peer; flags = child_node->flags; /* Grandchildren should have all been deleted already */ if (child_node->child) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Found a grandchild! P=%p C=%p\n", parent_node, child_node)); } /* Now we can free this child object */ ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].total_freed++); ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Object %p, Remaining %X\n", child_node, acpi_gbl_current_node_count)); /* * Detach an object if there is one, then free the child node */ acpi_ns_detach_object (child_node); /* * Decrement the reference count(s) of all parents up to * the root! (counts were incremented when the node was created) */ node = child_node; while ((node = acpi_ns_get_parent_node (node)) != NULL) { node->reference_count--; } /* There should be only one reference remaining on this node */ if (child_node->reference_count != 1) { ACPI_REPORT_WARNING (("Existing references (%d) on node being deleted (%p)\n", child_node->reference_count, child_node)); } /* Now we can delete the node */ ACPI_MEM_FREE (child_node); /* And move on to the next child in the list */ child_node = next_node; } while (!(flags & ANOBJ_END_OF_PEER_LIST)); /* Clear the parent's child pointer */ parent_node->child = NULL; return_VOID; }
void acpi_ns_delete_namespace_subtree(struct acpi_namespace_node *parent_node) { struct acpi_namespace_node *child_node = NULL; u32 level = 1; ACPI_FUNCTION_TRACE(ns_delete_namespace_subtree); if (!parent_node) { return_VOID; } /* * Traverse the tree of objects until we bubble back up * to where we started. */ while (level > 0) { /* Get the next node in this scope (NULL if none) */ child_node = acpi_ns_get_next_node(parent_node, child_node); if (child_node) { /* Found a child node - detach any attached object */ acpi_ns_detach_object(child_node); /* Check if this node has any children */ if (child_node->child) { /* * There is at least one child of this node, * visit the node */ level++; parent_node = child_node; child_node = NULL; } } else { /* * No more children of this parent node. * Move up to the grandparent. */ level--; /* * Now delete all of the children of this parent * all at the same time. */ acpi_ns_delete_children(parent_node); /* New "last child" is this parent node */ child_node = parent_node; /* Move up the tree to the grandparent */ parent_node = acpi_ns_get_parent_node(parent_node); } } return_VOID; }
acpi_status acpi_ns_attach_object(struct acpi_namespace_node *node, union acpi_operand_object *object, acpi_object_type type) { union acpi_operand_object *obj_desc; union acpi_operand_object *last_obj_desc; acpi_object_type object_type = ACPI_TYPE_ANY; ACPI_FUNCTION_TRACE(ns_attach_object); if (!node) { ACPI_ERROR((AE_INFO, "Null NamedObj handle")); return_ACPI_STATUS(AE_BAD_PARAMETER); } if (!object && (ACPI_TYPE_ANY != type)) { ACPI_ERROR((AE_INFO, "Null object, but type not ACPI_TYPE_ANY")); return_ACPI_STATUS(AE_BAD_PARAMETER); } if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) { ACPI_ERROR((AE_INFO, "Invalid handle %p [%s]", node, acpi_ut_get_descriptor_name(node))); return_ACPI_STATUS(AE_BAD_PARAMETER); } if (node->object == object) { ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Obj %p already installed in NameObj %p\n", object, node)); return_ACPI_STATUS(AE_OK); } if (!object) { obj_desc = NULL; object_type = ACPI_TYPE_ANY; } else if ((ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED) && ((struct acpi_namespace_node *)object)->object) { obj_desc = ((struct acpi_namespace_node *)object)->object; object_type = ((struct acpi_namespace_node *)object)->type; } else { obj_desc = (union acpi_operand_object *)object; object_type = type; } ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Installing %p into Node %p [%4.4s]\n", obj_desc, node, acpi_ut_get_node_name(node))); if (node->object) { acpi_ns_detach_object(node); } if (obj_desc) { acpi_ut_add_reference(obj_desc); last_obj_desc = obj_desc; while (last_obj_desc->common.next_object) { last_obj_desc = last_obj_desc->common.next_object; } last_obj_desc->common.next_object = node->object; } node->type = (u8) object_type; node->object = obj_desc; return_ACPI_STATUS(AE_OK); }
acpi_status acpi_ds_store_object_to_local ( u16 opcode, u32 index, acpi_operand_object *src_desc, acpi_walk_state *walk_state) { acpi_status status; acpi_operand_object **entry; FUNCTION_TRACE ("Ds_method_data_set_value"); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode=%d Idx=%d Obj=%p\n", opcode, index, src_desc)); /* Parameter validation */ if (!src_desc) { return_ACPI_STATUS (AE_BAD_PARAMETER); } /* Get a pointer to the requested method stack entry */ status = acpi_ds_method_data_get_entry (opcode, index, walk_state, &entry); if (ACPI_FAILURE (status)) { goto cleanup; } if (*entry == src_desc) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p already installed!\n", src_desc)); goto cleanup; } /* * 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 (*entry) { /* * 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) && (VALID_DESCRIPTOR_TYPE (*entry, ACPI_DESC_TYPE_NAMED))) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Arg (%p) is an Obj_ref(Node), storing in %p\n", src_desc, *entry)); /* Detach an existing object from the Node */ acpi_ns_detach_object ((acpi_namespace_node *) *entry); /* * Store this object into the Node * (do the indirect store) */ status = acpi_ns_attach_object ((acpi_namespace_node *) *entry, src_desc, src_desc->common.type); return_ACPI_STATUS (status); } #ifdef ACPI_ENABLE_IMPLICIT_CONVERSION /* * Perform "Implicit conversion" of the new object to the type of the * existing object */ status = acpi_ex_convert_to_target_type ((*entry)->common.type, &src_desc, walk_state); if (ACPI_FAILURE (status)) { goto cleanup; } #endif /* * Delete the existing object * before storing the new one */ acpi_ds_method_data_delete_value (opcode, index, walk_state); } /* * Install the Obj_stack descriptor (*Src_desc) into * the descriptor for the Arg or Local. * Install the new object in the stack entry * (increments the object reference count by one) */ status = acpi_ds_method_data_set_entry (opcode, index, src_desc, walk_state); if (ACPI_FAILURE (status)) { goto cleanup; } /* Normal exit */ return_ACPI_STATUS (AE_OK); /* Error exit */ cleanup: return_ACPI_STATUS (status); }