ACPI_STATUS AcpiDsStoreObjectToLocal ( UINT8 Type, UINT32 Index, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status; ACPI_NAMESPACE_NODE *Node; ACPI_OPERAND_OBJECT *CurrentObjDesc; ACPI_OPERAND_OBJECT *NewObjDesc; ACPI_FUNCTION_TRACE (DsStoreObjectToLocal); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Type=%2.2X Index=%u Obj=%p\n", Type, Index, ObjDesc)); /* Parameter validation */ if (!ObjDesc) { return_ACPI_STATUS (AE_BAD_PARAMETER); } /* Get the namespace node for the arg/local */ Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } CurrentObjDesc = AcpiNsGetAttachedObject (Node); if (CurrentObjDesc == ObjDesc) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p already installed!\n", ObjDesc)); 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. */ NewObjDesc = ObjDesc; if (ObjDesc->Common.ReferenceCount > 1) { Status = AcpiUtCopyIobjectToIobject (ObjDesc, &NewObjDesc, WalkState); 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 (CurrentObjDesc) { /* * 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 RefOf (Local4): * * Store (1, Arg0) - Causes indirect store to local4 * Store (1, Local0) - Stores 1 in local0, overwriting * the reference to local4 * Store (1, DeRefof (Local0)) - Causes indirect store to local4 * * Weird, but true. */ if (Type == ACPI_REFCLASS_ARG) { /* * If we have a valid reference object that came from RefOf(), * do the indirect store */ if ((ACPI_GET_DESCRIPTOR_TYPE (CurrentObjDesc) == ACPI_DESC_TYPE_OPERAND) && (CurrentObjDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && (CurrentObjDesc->Reference.Class == ACPI_REFCLASS_REFOF)) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Arg (%p) is an ObjRef(Node), storing in node %p\n", NewObjDesc, CurrentObjDesc)); /* * 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 = AcpiExStoreObjectToNode (NewObjDesc, CurrentObjDesc->Reference.Object, WalkState, ACPI_NO_IMPLICIT_CONVERSION); /* Remove local reference if we copied the object above */ if (NewObjDesc != ObjDesc) { AcpiUtRemoveReference (NewObjDesc); } return_ACPI_STATUS (Status); } } /* Delete the existing object before storing the new one */ AcpiDsMethodDataDeleteValue (Type, Index, WalkState); } /* * Install the Obj descriptor (*NewObjDesc) into * the descriptor for the Arg or Local. * (increments the object reference count by one) */ Status = AcpiDsMethodDataSetValue (Type, Index, NewObjDesc, WalkState); /* Remove local reference if we copied the object above */ if (NewObjDesc != ObjDesc) { AcpiUtRemoveReference (NewObjDesc); } return_ACPI_STATUS (Status); }
ACPI_STATUS AcpiExStore ( ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *DestDesc, ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status = AE_OK; ACPI_OPERAND_OBJECT *RefDesc = DestDesc; ACPI_FUNCTION_TRACE_PTR (ExStore, DestDesc); /* Validate parameters */ if (!SourceDesc || !DestDesc) { ACPI_ERROR ((AE_INFO, "Null parameter")); return_ACPI_STATUS (AE_AML_NO_OPERAND); } /* DestDesc can be either a namespace node or an ACPI object */ if (ACPI_GET_DESCRIPTOR_TYPE (DestDesc) == ACPI_DESC_TYPE_NAMED) { /* * Dest is a namespace node, * Storing an object into a Named node. */ Status = AcpiExStoreObjectToNode (SourceDesc, (ACPI_NAMESPACE_NODE *) DestDesc, WalkState, ACPI_IMPLICIT_CONVERSION); return_ACPI_STATUS (Status); } /* Destination object must be a Reference or a Constant object */ switch (DestDesc->Common.Type) { case ACPI_TYPE_LOCAL_REFERENCE: break; case ACPI_TYPE_INTEGER: /* Allow stores to Constants -- a Noop as per ACPI spec */ if (DestDesc->Common.Flags & AOPOBJ_AML_CONSTANT) { return_ACPI_STATUS (AE_OK); } /*lint -fallthrough */ default: /* Destination is not a Reference object */ ACPI_ERROR ((AE_INFO, "Target is not a Reference or Constant object - %s [%p]", AcpiUtGetObjectTypeName (DestDesc), DestDesc)); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } /* * Examine the Reference class. These cases are handled: * * 1) Store to Name (Change the object associated with a name) * 2) Store to an indexed area of a Buffer or Package * 3) Store to a Method Local or Arg * 4) Store to the debug object */ switch (RefDesc->Reference.Class) { case ACPI_REFCLASS_REFOF: /* Storing an object into a Name "container" */ Status = AcpiExStoreObjectToNode (SourceDesc, RefDesc->Reference.Object, WalkState, ACPI_IMPLICIT_CONVERSION); break; case ACPI_REFCLASS_INDEX: /* Storing to an Index (pointer into a packager or buffer) */ Status = AcpiExStoreObjectToIndex (SourceDesc, RefDesc, WalkState); break; case ACPI_REFCLASS_LOCAL: case ACPI_REFCLASS_ARG: /* Store to a method local/arg */ Status = AcpiDsStoreObjectToLocal (RefDesc->Reference.Class, RefDesc->Reference.Value, SourceDesc, WalkState); break; case ACPI_REFCLASS_DEBUG: /* * Storing to the Debug object causes the value stored to be * displayed and otherwise has no effect -- see ACPI Specification */ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "**** Write to Debug Object: Object %p %s ****:\n\n", SourceDesc, AcpiUtGetObjectTypeName (SourceDesc))); ACPI_DEBUG_OBJECT (SourceDesc, 0, 0); break; default: ACPI_ERROR ((AE_INFO, "Unknown Reference Class 0x%2.2X", RefDesc->Reference.Class)); ACPI_DUMP_ENTRY (RefDesc, ACPI_LV_INFO); Status = AE_AML_INTERNAL; break; } return_ACPI_STATUS (Status); }