ACPI_STATUS AcpiDsMethodDataInitArgs ( ACPI_OPERAND_OBJECT **Params, UINT32 MaxParamCount, ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status; UINT32 Mindex; UINT32 Pindex; FUNCTION_TRACE_PTR ("DsMethodDataInitArgs", Params); if (!Params) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "No param list passed to method\n")); return_ACPI_STATUS (AE_OK); } /* Copy passed parameters into the new method stack frame */ for (Pindex = Mindex = 0; (Mindex < MTH_NUM_ARGS) && (Pindex < MaxParamCount); Mindex++) { if (Params[Pindex]) { /* * A valid parameter. * Set the current method argument to the * Params[Pindex++] argument object descriptor */ Status = AcpiDsStoreObjectToLocal (AML_ARG_OP, Mindex, Params[Pindex], WalkState); if (ACPI_FAILURE (Status)) { break; } Pindex++; } else { break; } } ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%d args passed to method\n", Pindex)); return_ACPI_STATUS (AE_OK); }
void AcpiDbSetMethodData ( char *TypeArg, char *IndexArg, char *ValueArg) { char Type; UINT32 Index; UINT32 Value; ACPI_WALK_STATE *WalkState; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_STATUS Status; ACPI_NAMESPACE_NODE *Node; /* Validate TypeArg */ AcpiUtStrupr (TypeArg); Type = TypeArg[0]; if ((Type != 'L') && (Type != 'A') && (Type != 'N')) { AcpiOsPrintf ("Invalid SET operand: %s\n", TypeArg); return; } Value = ACPI_STRTOUL (ValueArg, NULL, 16); if (Type == 'N') { Node = AcpiDbConvertToNode (IndexArg); if (Node->Type != ACPI_TYPE_INTEGER) { AcpiOsPrintf ("Can only set Integer nodes\n"); return; } ObjDesc = Node->Object; ObjDesc->Integer.Value = Value; return; } /* Get the index and value */ Index = ACPI_STRTOUL (IndexArg, NULL, 16); WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); if (!WalkState) { AcpiOsPrintf ("There is no method currently executing\n"); return; } /* Create and initialize the new object */ ObjDesc = AcpiUtCreateIntegerObject ((UINT64) Value); if (!ObjDesc) { AcpiOsPrintf ("Could not create an internal object\n"); return; } /* Store the new object into the target */ switch (Type) { case 'A': /* Set a method argument */ if (Index > ACPI_METHOD_MAX_ARG) { AcpiOsPrintf ("Arg%u - Invalid argument name\n", Index); goto Cleanup; } Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_ARG, Index, ObjDesc, WalkState); if (ACPI_FAILURE (Status)) { goto Cleanup; } ObjDesc = WalkState->Arguments[Index].Object; AcpiOsPrintf ("Arg%u: ", Index); AcpiDmDisplayInternalObject (ObjDesc, WalkState); break; case 'L': /* Set a method local */ if (Index > ACPI_METHOD_MAX_LOCAL) { AcpiOsPrintf ("Local%u - Invalid local variable name\n", Index); goto Cleanup; } Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_LOCAL, Index, ObjDesc, WalkState); if (ACPI_FAILURE (Status)) { goto Cleanup; } ObjDesc = WalkState->LocalVariables[Index].Object; AcpiOsPrintf ("Local%u: ", Index); AcpiDmDisplayInternalObject (ObjDesc, WalkState); break; default: break; } Cleanup: AcpiUtRemoveReference (ObjDesc); }
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); }