FreeBSD/sys/contrib/dev/acpica/components/debugger/dbtest.c
/*******************************************************************************
 *
 * FUNCTION:    AcpiDbTestIntegerType
 *
 * PARAMETERS:  Node                - Parent NS node for the object
 *              BitLength           - Actual length of the object. Used for
 *                                    support of arbitrary length FieldUnit
 *                                    and BufferField objects.
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Test read/write for an Integer-valued object. Performs a
 *              write/read/compare of an arbitrary new value, then performs
 *              a write/read/compare of the original value.
 *
 ******************************************************************************/
AcpiDbTestIntegerType
PARAMETERS:  Node                - Parent NS node for the object
BitLength           - Actual length of the object. Used for
support of arbitrary length FieldUnit
and BufferField objects.

Status

Test read/write for an Integer-valued object. Performs a
write/read/compare of an arbitrary new value, then performs
a write/read/compare of the original value.
AcpiDbTestIntegerType PARAMETERS : Node - Parent NS node for the object BitLength - Actual length of the object . Used for support of arbitrary length FieldUnit and BufferField objects . Status Test read / write for an Integer - valued object . Performs a write / read / compare of an arbitrary new value then performs a write / read / compare of the original value .
static ACPI_STATUS
AcpiDbTestIntegerType (
    ACPI_NAMESPACE_NODE     *Node,
    UINT32                  BitLength)
{
    ACPI_OBJECT             *Temp1 = NULL;
    ACPI_OBJECT             *Temp2 = NULL;
    ACPI_OBJECT             *Temp3 = NULL;
    ACPI_OBJECT             WriteValue;
    UINT64                  ValueToWrite;
    ACPI_STATUS             Status;
    if (BitLength > 64)
    {
        AcpiOsPrintf (" Invalid length for an Integer: %u", BitLength);
        return (AE_OK);
    }
    Status = AcpiDbReadFromObject (Node, ACPI_TYPE_INTEGER, &Temp1);
    if (ACPI_FAILURE (Status))
    {
        return (Status);
    }
    AcpiOsPrintf (" (%4.4X/%3.3X) %8.8X%8.8X",
        BitLength, ACPI_ROUND_BITS_UP_TO_BYTES (BitLength),
        ACPI_FORMAT_UINT64 (Temp1->Integer.Value));
    ValueToWrite = ACPI_UINT64_MAX >> (64 - BitLength);
    if (Temp1->Integer.Value == ValueToWrite)
    {
        ValueToWrite = 0;
    }
    WriteValue.Type = ACPI_TYPE_INTEGER;
    WriteValue.Integer.Value = ValueToWrite;
    Status = AcpiDbWriteToObject (Node, &WriteValue);
    if (ACPI_FAILURE (Status))
    {
        goto Exit;
    }
    Status = AcpiDbReadFromObject (Node, ACPI_TYPE_INTEGER, &Temp2);
    if (ACPI_FAILURE (Status))
    {
        goto Exit;
    }
    if (Temp2->Integer.Value != ValueToWrite)
    {
        AcpiOsPrintf (" MISMATCH 2: %8.8X%8.8X, expecting %8.8X%8.8X",
            ACPI_FORMAT_UINT64 (Temp2->Integer.Value),
            ACPI_FORMAT_UINT64 (ValueToWrite));
    }
    WriteValue.Integer.Value = Temp1->Integer.Value;
    Status = AcpiDbWriteToObject (Node, &WriteValue);
    if (ACPI_FAILURE (Status))
    {
        goto Exit;
    }
    Status = AcpiDbReadFromObject (Node, ACPI_TYPE_INTEGER, &Temp3);
    if (ACPI_FAILURE (Status))
    {
        goto Exit;
    }
    if (Temp3->Integer.Value != Temp1->Integer.Value)
    {
        AcpiOsPrintf (" MISMATCH 3: %8.8X%8.8X, expecting %8.8X%8.8X",
            ACPI_FORMAT_UINT64 (Temp3->Integer.Value),
            ACPI_FORMAT_UINT64 (Temp1->Integer.Value));
    }
Exit:
    if (Temp1) {AcpiOsFree (Temp1);}
    if (Temp2) {AcpiOsFree (Temp2);}
    if (Temp3) {AcpiOsFree (Temp3);}
    return (AE_OK);
}
static ACPI_STATUS AcpiDbTestIntegerType ( ACPI_NAMESPACE_NODE * Node , UINT32 BitLength ) { ACPI_OBJECT * Temp1 = NULL ; ACPI_OBJECT * Temp2 = NULL ; ACPI_OBJECT * Temp3 = NULL ; ACPI_OBJECT WriteValue ; UINT64 ValueToWrite ; ACPI_STATUS Status ; if ( BitLength > 64 ) { AcpiOsPrintf ( " " , BitLength ) ; return ( AE_OK ) ; } Status = AcpiDbReadFromObject ( Node , ACPI_TYPE_INTEGER , & Temp1 ) ; if ( ACPI_FAILURE ( Status ) ) { return ( Status ) ; } AcpiOsPrintf ( " " , BitLength , ACPI_ROUND_BITS_UP_TO_BYTES ( BitLength ) , ACPI_FORMAT_UINT64 ( Temp1 -> Integer . Value ) ) ; ValueToWrite = ACPI_UINT64_MAX >> ( 64 - BitLength ) ; if ( Temp1 -> Integer . Value == ValueToWrite ) { ValueToWrite = 0 ; } WriteValue . Type = ACPI_TYPE_INTEGER ; WriteValue . Integer . Value = ValueToWrite ; Status = AcpiDbWriteToObject ( Node , & WriteValue ) ; if ( ACPI_FAILURE ( Status ) ) { goto Exit ; } Status = AcpiDbReadFromObject ( Node , ACPI_TYPE_INTEGER , & Temp2 ) ; if ( ACPI_FAILURE ( Status ) ) { goto Exit ; } if ( Temp2 -> Integer . Value != ValueToWrite ) { AcpiOsPrintf ( " " , ACPI_FORMAT_UINT64 ( Temp2 -> Integer . Value ) , ACPI_FORMAT_UINT64 ( ValueToWrite ) ) ; } WriteValue . Integer . Value = Temp1 -> Integer . Value ; Status = AcpiDbWriteToObject ( Node , & WriteValue ) ; if ( ACPI_FAILURE ( Status ) ) { goto Exit ; } Status = AcpiDbReadFromObject ( Node , ACPI_TYPE_INTEGER , & Temp3 ) ; if ( ACPI_FAILURE ( Status ) ) { goto Exit ; } if ( Temp3 -> Integer . Value != Temp1 -> Integer . Value ) { AcpiOsPrintf ( " " , ACPI_FORMAT_UINT64 ( Temp3 -> Integer . Value ) , ACPI_FORMAT_UINT64 ( Temp1 -> Integer . Value ) ) ; } Exit : if ( Temp1 ) { AcpiOsFree ( Temp1 ) ; } if ( Temp2 ) { AcpiOsFree ( Temp2 ) ; } if ( Temp3 ) { AcpiOsFree ( Temp3 ) ; } return ( AE_OK ) ; }
FUNCTION:    AcpiDbTestIntegerType
 PARAMETERS:  Node                - Parent NS node for the object
              BitLength           - Actual length of the object.
FUNCTION : AcpiDbTestIntegerType PARAMETERS : Node - Parent NS node for the object BitLength - Actual length of the object .
/* Read the original value */ /* Write a new value */ /* Ensure that we can read back the new value */ /* Write back the original value */ /* Ensure that we can read back the original value */