FreeBSD/sys/contrib/dev/acpica/components/debugger/dbtest.c
/*******************************************************************************
 *
 * FUNCTION:    AcpiDbTestStringType
 *
 * PARAMETERS:  Node                - Parent NS node for the object
 *              ByteLength          - Actual length of the object.
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Test read/write for an String-valued object. Performs a
 *              write/read/compare of an arbitrary new value, then performs
 *              a write/read/compare of the original value.
 *
 ******************************************************************************/
AcpiDbTestStringType
PARAMETERS:  Node                - Parent NS node for the object
ByteLength          - Actual length of the object.

Status

Test read/write for an String-valued object. Performs a
write/read/compare of an arbitrary new value, then performs
a write/read/compare of the original value.
AcpiDbTestStringType PARAMETERS : Node - Parent NS node for the object ByteLength - Actual length of the object . Status Test read / write for an String - 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
AcpiDbTestStringType (
    ACPI_NAMESPACE_NODE     *Node,
    UINT32                  ByteLength)
{
    ACPI_OBJECT             *Temp1 = NULL;
    ACPI_OBJECT             *Temp2 = NULL;
    ACPI_OBJECT             *Temp3 = NULL;
    char                    *ValueToWrite = "Test String from AML Debugger";
    ACPI_OBJECT             WriteValue;
    ACPI_STATUS             Status;
    Status = AcpiDbReadFromObject (Node, ACPI_TYPE_STRING, &Temp1);
    if (ACPI_FAILURE (Status))
    {
        return (Status);
    }
    AcpiOsPrintf (" (%4.4X/%3.3X) \"%s\"", (Temp1->String.Length * 8),
        Temp1->String.Length, Temp1->String.Pointer);
    WriteValue.Type = ACPI_TYPE_STRING;
    WriteValue.String.Length = strlen (ValueToWrite);
    WriteValue.String.Pointer = ValueToWrite;
    Status = AcpiDbWriteToObject (Node, &WriteValue);
    if (ACPI_FAILURE (Status))
    {
        goto Exit;
    }
    Status = AcpiDbReadFromObject (Node, ACPI_TYPE_STRING, &Temp2);
    if (ACPI_FAILURE (Status))
    {
        goto Exit;
    }
    if (strcmp (Temp2->String.Pointer, ValueToWrite))
    {
        AcpiOsPrintf (" MISMATCH 2: %s, expecting %s",
            Temp2->String.Pointer, ValueToWrite);
    }
    WriteValue.String.Length = strlen (Temp1->String.Pointer);
    WriteValue.String.Pointer = Temp1->String.Pointer;
    Status = AcpiDbWriteToObject (Node, &WriteValue);
    if (ACPI_FAILURE (Status))
    {
        goto Exit;
    }
    Status = AcpiDbReadFromObject (Node, ACPI_TYPE_STRING, &Temp3);
    if (ACPI_FAILURE (Status))
    {
        goto Exit;
    }
    if (strcmp (Temp1->String.Pointer, Temp3->String.Pointer))
    {
        AcpiOsPrintf (" MISMATCH 3: %s, expecting %s",
            Temp3->String.Pointer, Temp1->String.Pointer);
    }
Exit:
    if (Temp1) {AcpiOsFree (Temp1);}
    if (Temp2) {AcpiOsFree (Temp2);}
    if (Temp3) {AcpiOsFree (Temp3);}
    return (Status);
}
static ACPI_STATUS AcpiDbTestStringType ( ACPI_NAMESPACE_NODE * Node , UINT32 ByteLength ) { ACPI_OBJECT * Temp1 = NULL ; ACPI_OBJECT * Temp2 = NULL ; ACPI_OBJECT * Temp3 = NULL ; char * ValueToWrite = " " ; ACPI_OBJECT WriteValue ; ACPI_STATUS Status ; Status = AcpiDbReadFromObject ( Node , ACPI_TYPE_STRING , & Temp1 ) ; if ( ACPI_FAILURE ( Status ) ) { return ( Status ) ; } AcpiOsPrintf ( " \" \" " , ( Temp1 -> String . Length * 8 ) , Temp1 -> String . Length , Temp1 -> String . Pointer ) ; WriteValue . Type = ACPI_TYPE_STRING ; WriteValue . String . Length = strlen ( ValueToWrite ) ; WriteValue . String . Pointer = ValueToWrite ; Status = AcpiDbWriteToObject ( Node , & WriteValue ) ; if ( ACPI_FAILURE ( Status ) ) { goto Exit ; } Status = AcpiDbReadFromObject ( Node , ACPI_TYPE_STRING , & Temp2 ) ; if ( ACPI_FAILURE ( Status ) ) { goto Exit ; } if ( strcmp ( Temp2 -> String . Pointer , ValueToWrite ) ) { AcpiOsPrintf ( " " , Temp2 -> String . Pointer , ValueToWrite ) ; } WriteValue . String . Length = strlen ( Temp1 -> String . Pointer ) ; WriteValue . String . Pointer = Temp1 -> String . Pointer ; Status = AcpiDbWriteToObject ( Node , & WriteValue ) ; if ( ACPI_FAILURE ( Status ) ) { goto Exit ; } Status = AcpiDbReadFromObject ( Node , ACPI_TYPE_STRING , & Temp3 ) ; if ( ACPI_FAILURE ( Status ) ) { goto Exit ; } if ( strcmp ( Temp1 -> String . Pointer , Temp3 -> String . Pointer ) ) { AcpiOsPrintf ( " " , Temp3 -> String . Pointer , Temp1 -> String . Pointer ) ; } Exit : if ( Temp1 ) { AcpiOsFree ( Temp1 ) ; } if ( Temp2 ) { AcpiOsFree ( Temp2 ) ; } if ( Temp3 ) { AcpiOsFree ( Temp3 ) ; } return ( Status ) ; }
FUNCTION:    AcpiDbTestStringType
 PARAMETERS:  Node                - Parent NS node for the object
              ByteLength          - Actual length of the object.
FUNCTION : AcpiDbTestStringType PARAMETERS : Node - Parent NS node for the object ByteLength - 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 */