{
ACPI_STATUSStatus = AE_OK;
ACPI_OPERAND_OBJECT *ObjDesc;
ACPI_OPERAND_OBJECT *NewDesc;
UINT8Value = 0;
UINT32 i;
ACPI_FUNCTION_TRACE (ExStoreObjectToIndex);
/* * Destination must be a reference pointer, and * must point to either a buffer or a package */switch (IndexDesc->Reference.TargetType)
{
caseACPI_TYPE_PACKAGE:
/* * Storing to a package element. Copy the object and replace * any existing object with the new object. No implicit * conversion is performed. * * The object at *(IndexDesc->Reference.Where) is the * element within the package that is to be modified. * The parent package object is at IndexDesc->Reference.Object */
ObjDesc = *(IndexDesc->Reference.Where);
if (SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE &&
SourceDesc->Reference.Class == ACPI_REFCLASS_TABLE)
{
/* This is a DDBHandle, just add a reference to it */AcpiUtAddReference (SourceDesc);
NewDesc = SourceDesc;
}
else
{
/* Normal object, copy it */
Status = AcpiUtCopyIobjectToIobject (SourceDesc, &NewDesc, WalkState);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
}
if (ObjDesc)
{
/* Decrement reference count by the ref count of the parent package */for (i = 0;
i < ((ACPI_OPERAND_OBJECT *)
IndexDesc->Reference.Object)->Common.ReferenceCount;
i++)
{
AcpiUtRemoveReference (ObjDesc);
}
}
*(IndexDesc->Reference.Where) = NewDesc;
/* Increment ref count by the ref count of the parent package-1 */for (i = 1;
i < ((ACPI_OPERAND_OBJECT *)
IndexDesc->Reference.Object)->Common.ReferenceCount;
i++)
{
AcpiUtAddReference (NewDesc);
}
break;
caseACPI_TYPE_BUFFER_FIELD:
/* * Store into a Buffer or String (not actually a real BufferField) * at a location defined by an Index. * * The first 8-bit element of the source object is written to the * 8-bit Buffer location defined by the Index destination object, * according to the ACPI 2.0 specification. *//* * Make sure the target is a Buffer or String. An error should * not happen here, since the ReferenceObject was constructed * by the INDEX_OP code. */
ObjDesc = IndexDesc->Reference.Object;
if ((ObjDesc->Common.Type != ACPI_TYPE_BUFFER) &&
(ObjDesc->Common.Type != ACPI_TYPE_STRING))
{
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
/* * The assignment of the individual elements will be slightly * different for each source type. */switch (SourceDesc->Common.Type)
{
caseACPI_TYPE_INTEGER:
/* Use the least-significant byte of the integer */
Value = (UINT8) (SourceDesc->Integer.Value);
break;
caseACPI_TYPE_BUFFER:
caseACPI_TYPE_STRING:
/* Note: Takes advantage of common string/buffer fields */
Value = SourceDesc->Buffer.Pointer[0];
break;
default:
/* All other types are invalid */ACPI_ERROR ((AE_INFO,
"Source must be Integer/Buffer/String type, not %s",
AcpiUtGetObjectTypeName (SourceDesc)));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
/* Store the source value into the target buffer byte */
ObjDesc->Buffer.Pointer[IndexDesc->Reference.Value] = Value;
break;
default:
ACPI_ERROR ((AE_INFO,
"Target is not a Package or BufferField"));
Status = AE_AML_OPERAND_TYPE;
break;
}
return_ACPI_STATUS (Status);
}
Generated on Mon May 28 2012 05:22:18 for ReactOS by
1.7.6.1
ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.