FreeBSD/sys/contrib/dev/acpica/components/namespace/nspredef.c
/*******************************************************************************
 *
 * FUNCTION:    AcpiNsCheckObjectType
 *
 * PARAMETERS:  Info            - Method execution information block
 *              ReturnObjectPtr - Pointer to the object returned from the
 *                                evaluation of a method or object
 *              ExpectedBtypes  - Bitmap of expected return type(s)
 *              PackageIndex    - Index of object within parent package (if
 *                                applicable - ACPI_NOT_PACKAGE_ELEMENT
 *                                otherwise)
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Check the type of the return object against the expected object
 *              type(s). Use of Btype allows multiple expected object types.
 *
 ******************************************************************************/


Status

Check the type of the return object against the expected object
type(s). Use of Btype allows multiple expected object types.
Status Check the type of the return object against the expected object type ( s ) . Use of Btype allows multiple expected object types .
ACPI_STATUS
AcpiNsCheckObjectType (
    ACPI_EVALUATE_INFO          *Info,
    ACPI_OPERAND_OBJECT         **ReturnObjectPtr,
    UINT32                      ExpectedBtypes,
    UINT32                      PackageIndex)
{
    ACPI_OPERAND_OBJECT         *ReturnObject = *ReturnObjectPtr;
    ACPI_STATUS                 Status = AE_OK;
    char                        TypeBuffer[96]; 
    if (ReturnObject &&
        ACPI_GET_DESCRIPTOR_TYPE (ReturnObject) == ACPI_DESC_TYPE_NAMED)
    {
        ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags,
            "Invalid return type - Found a Namespace node [%4.4s] type %s",
            ReturnObject->Node.Name.Ascii,
            AcpiUtGetTypeName (ReturnObject->Node.Type)));
        return (AE_AML_OPERAND_TYPE);
    }
    Info->ReturnBtype = AcpiNsGetBitmappedType (ReturnObject);
    if (Info->ReturnBtype == ACPI_RTYPE_ANY)
    {
        goto TypeErrorExit;
    }
    if ((Info->ReturnBtype & ExpectedBtypes) == ACPI_RTYPE_REFERENCE)
    {
        Status = AcpiNsCheckReference (Info, ReturnObject);
        return (Status);
    }
    Status = AcpiNsSimpleRepair (Info, ExpectedBtypes,
        PackageIndex, ReturnObjectPtr);
    if (ACPI_SUCCESS (Status))
    {
        return (AE_OK); 
    }
TypeErrorExit:
    AcpiUtGetExpectedReturnTypes (TypeBuffer, ExpectedBtypes);
    if (!ReturnObject)
    {
        ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags,
            "Expected return object of type %s",
            TypeBuffer));
    }
    else if (PackageIndex == ACPI_NOT_PACKAGE_ELEMENT)
    {
        ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags,
            "Return type mismatch - found %s, expected %s",
            AcpiUtGetObjectTypeName (ReturnObject), TypeBuffer));
    }
    else
    {
        ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags,
            "Return Package type mismatch at index %u - "
            "found %s, expected %s", PackageIndex,
            AcpiUtGetObjectTypeName (ReturnObject), TypeBuffer));
    }
    return (AE_AML_OPERAND_TYPE);
}
ACPI_STATUS AcpiNsCheckObjectType ( ACPI_EVALUATE_INFO * Info , ACPI_OPERAND_OBJECT * * ReturnObjectPtr , UINT32 ExpectedBtypes , UINT32 PackageIndex ) { ACPI_OPERAND_OBJECT * ReturnObject = * ReturnObjectPtr ; ACPI_STATUS Status = AE_OK ; char TypeBuffer [ 96 ] ; if ( ReturnObject && ACPI_GET_DESCRIPTOR_TYPE ( ReturnObject ) == ACPI_DESC_TYPE_NAMED ) { ACPI_WARN_PREDEFINED ( ( AE_INFO , Info -> FullPathname , Info -> NodeFlags , " " , ReturnObject -> Node . Name . Ascii , AcpiUtGetTypeName ( ReturnObject -> Node . Type ) ) ) ; return ( AE_AML_OPERAND_TYPE ) ; } Info -> ReturnBtype = AcpiNsGetBitmappedType ( ReturnObject ) ; if ( Info -> ReturnBtype == ACPI_RTYPE_ANY ) { goto TypeErrorExit ; } if ( ( Info -> ReturnBtype & ExpectedBtypes ) == ACPI_RTYPE_REFERENCE ) { Status = AcpiNsCheckReference ( Info , ReturnObject ) ; return ( Status ) ; } Status = AcpiNsSimpleRepair ( Info , ExpectedBtypes , PackageIndex , ReturnObjectPtr ) ; if ( ACPI_SUCCESS ( Status ) ) { return ( AE_OK ) ; } TypeErrorExit : AcpiUtGetExpectedReturnTypes ( TypeBuffer , ExpectedBtypes ) ; if ( ! ReturnObject ) { ACPI_WARN_PREDEFINED ( ( AE_INFO , Info -> FullPathname , Info -> NodeFlags , " " , TypeBuffer ) ) ; } else if ( PackageIndex == ACPI_NOT_PACKAGE_ELEMENT ) { ACPI_WARN_PREDEFINED ( ( AE_INFO , Info -> FullPathname , Info -> NodeFlags , " " , AcpiUtGetObjectTypeName ( ReturnObject ) , TypeBuffer ) ) ; } else { ACPI_WARN_PREDEFINED ( ( AE_INFO , Info -> FullPathname , Info -> NodeFlags , " " " " , PackageIndex , AcpiUtGetObjectTypeName ( ReturnObject ) , TypeBuffer ) ) ; } return ( AE_AML_OPERAND_TYPE ) ; }
FUNCTION:    AcpiNsCheckObjectType
 PARAMETERS:  Info            - Method execution information block
              ReturnObjectPtr - Pointer to the object returned from the
                                evaluation of a method or object
              ExpectedBtypes  - Bitmap of expected return type(s)
              PackageIndex    - Index of object within parent package (if
                                applicable - ACPI_NOT_PACKAGE_ELEMENT
                                otherwise)
FUNCTION : AcpiNsCheckObjectType PARAMETERS : Info - Method execution information block ReturnObjectPtr - Pointer to the object returned from the evaluation of a method or object ExpectedBtypes - Bitmap of expected return type ( s ) PackageIndex - Index of object within parent package ( if applicable - ACPI_NOT_PACKAGE_ELEMENT otherwise )
/* Room for 10 types */ /* A Namespace node should not get here, but make sure */ /*
     * Convert the object type (ACPI_TYPE_xxx) to a bitmapped object type.
     * The bitmapped type allows multiple possible return types.
     *
     * Note, the cases below must handle all of the possible types returned
     * from all of the predefined names (including elements of returned
     * packages)
     */ /* Not one of the supported objects, must be incorrect */ /* For reference objects, check that the reference type is correct */ /* Attempt simple repair of the returned object if necessary */ /* Successful repair */ /* Create a string with all expected types for this predefined object */