FreeBSD/sys/contrib/dev/acpica/components/debugger/dbtest.c
/*******************************************************************************
 *
 * FUNCTION:    AcpiDbReadFromObject
 *
 * PARAMETERS:  Node                - Parent NS node for the object
 *              ExpectedType        - Object type expected from the read
 *              Value               - Where the value read is returned
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Performs a read from the specified object by invoking the
 *              special debugger control method that reads the object. Thus,
 *              the AML interpreter is doing all of the work, increasing the
 *              validity of the test.
 *
 ******************************************************************************/
AcpiDbReadFromObject
PARAMETERS:  Node                - Parent NS node for the object
ExpectedType        - Object type expected from the read
Value               - Where the value read is returned

Status

Performs a read from the specified object by invoking the
special debugger control method that reads the object. Thus,
the AML interpreter is doing all of the work, increasing the
validity of the test.
AcpiDbReadFromObject PARAMETERS : Node - Parent NS node for the object ExpectedType - Object type expected from the read Value - Where the value read is returned Status Performs a read from the specified object by invoking the special debugger control method that reads the object . Thus the AML interpreter is doing all of the work increasing the validity of the test .
static ACPI_STATUS
AcpiDbReadFromObject (
    ACPI_NAMESPACE_NODE     *Node,
    ACPI_OBJECT_TYPE        ExpectedType,
    ACPI_OBJECT             **Value)
{
    ACPI_OBJECT             *RetValue;
    ACPI_OBJECT_LIST        ParamObjects;
    ACPI_OBJECT             Params[2];
    ACPI_BUFFER             ReturnObj;
    ACPI_STATUS             Status;
    Params[0].Type = ACPI_TYPE_LOCAL_REFERENCE;
    Params[0].Reference.ActualType = Node->Type;
    Params[0].Reference.Handle = ACPI_CAST_PTR (ACPI_HANDLE, Node);
    ParamObjects.Count = 1;
    ParamObjects.Pointer = Params;
    ReturnObj.Length  = ACPI_ALLOCATE_BUFFER;
    AcpiGbl_MethodExecuting = TRUE;
    Status = AcpiEvaluateObject (ReadHandle, NULL,
        &ParamObjects, &ReturnObj);
    AcpiGbl_MethodExecuting = FALSE;
    if (ACPI_FAILURE (Status))
    {
        AcpiOsPrintf ("Could not read from object, %s",
            AcpiFormatException (Status));
        return (Status);
    }
    RetValue = (ACPI_OBJECT *) ReturnObj.Pointer;
    switch (RetValue->Type)
    {
    case ACPI_TYPE_INTEGER:
    case ACPI_TYPE_BUFFER:
    case ACPI_TYPE_STRING:
        if (RetValue->Type != ExpectedType)
        {
            AcpiOsPrintf (" Type mismatch:  Expected %s, Received %s",
                AcpiUtGetTypeName (ExpectedType),
                AcpiUtGetTypeName (RetValue->Type));
            return (AE_TYPE);
        }
        *Value = RetValue;
        break;
    default:
        AcpiOsPrintf (" Unsupported return object type, %s",
            AcpiUtGetTypeName (RetValue->Type));
        AcpiOsFree (ReturnObj.Pointer);
        return (AE_TYPE);
    }
    return (Status);
}
static ACPI_STATUS AcpiDbReadFromObject ( ACPI_NAMESPACE_NODE * Node , ACPI_OBJECT_TYPE ExpectedType , ACPI_OBJECT * * Value ) { ACPI_OBJECT * RetValue ; ACPI_OBJECT_LIST ParamObjects ; ACPI_OBJECT Params [ 2 ] ; ACPI_BUFFER ReturnObj ; ACPI_STATUS Status ; Params [ 0 ] . Type = ACPI_TYPE_LOCAL_REFERENCE ; Params [ 0 ] . Reference . ActualType = Node -> Type ; Params [ 0 ] . Reference . Handle = ACPI_CAST_PTR ( ACPI_HANDLE , Node ) ; ParamObjects . Count = 1 ; ParamObjects . Pointer = Params ; ReturnObj . Length = ACPI_ALLOCATE_BUFFER ; AcpiGbl_MethodExecuting = TRUE ; Status = AcpiEvaluateObject ( ReadHandle , NULL , & ParamObjects , & ReturnObj ) ; AcpiGbl_MethodExecuting = FALSE ; if ( ACPI_FAILURE ( Status ) ) { AcpiOsPrintf ( " " , AcpiFormatException ( Status ) ) ; return ( Status ) ; } RetValue = ( ACPI_OBJECT * ) ReturnObj . Pointer ; switch ( RetValue -> Type ) { case ACPI_TYPE_INTEGER : case ACPI_TYPE_BUFFER : case ACPI_TYPE_STRING : if ( RetValue -> Type != ExpectedType ) { AcpiOsPrintf ( " " , AcpiUtGetTypeName ( ExpectedType ) , AcpiUtGetTypeName ( RetValue -> Type ) ) ; return ( AE_TYPE ) ; } * Value = RetValue ; break ; default : AcpiOsPrintf ( " " , AcpiUtGetTypeName ( RetValue -> Type ) ) ; AcpiOsFree ( ReturnObj . Pointer ) ; return ( AE_TYPE ) ; } return ( Status ) ; }
FUNCTION:    AcpiDbReadFromObject
 PARAMETERS:  Node                - Parent NS node for the object
              ExpectedType        - Object type expected from the read
              Value               - Where the value read is returned
FUNCTION : AcpiDbReadFromObject PARAMETERS : Node - Parent NS node for the object ExpectedType - Object type expected from the read Value - Where the value read is returned
/*
         * Did we receive the type we wanted? Most important for the
         * Integer/Buffer case (when a field is larger than an Integer,
         * it should return a Buffer).
         */