FreeBSD/sys/contrib/dev/acpica/common/dmrestag.c
/*******************************************************************************
 *
 * FUNCTION:    AcpiDmCheckResourceReference
 *
 * PARAMETERS:  Op                  - Parse Op for the AML opcode
 *              WalkState           - Current walk state (with valid scope)
 *
 * RETURN:      None
 *
 * DESCRIPTION: Convert a reference to a resource descriptor to a symbolic
 *              reference if possible
 *
 * NOTE:        Bit index is used to transparently handle both resource bit
 *              fields and byte fields.
 *
 ******************************************************************************/
AcpiDmCheckResourceReference
PARAMETERS:  Op                  - Parse Op for the AML opcode
WalkState           - Current walk state (with valid scope)

None

Convert a reference to a resource descriptor to a symbolic
reference if possible

Bit index is used to transparently handle both resource bit
fields and byte fields.
AcpiDmCheckResourceReference PARAMETERS : Op - Parse Op for the AML opcode WalkState - Current walk state ( with valid scope ) None Convert a reference to a resource descriptor to a symbolic reference if possible Bit index is used to transparently handle both resource bit fields and byte fields .
void
AcpiDmCheckResourceReference (
    ACPI_PARSE_OBJECT       *Op,
    ACPI_WALK_STATE         *WalkState)
{
    ACPI_STATUS             Status;
    ACPI_PARSE_OBJECT       *BufferNameOp;
    ACPI_PARSE_OBJECT       *IndexOp;
    ACPI_NAMESPACE_NODE     *BufferNode;
    ACPI_NAMESPACE_NODE     *ResourceNode;
    const ACPI_OPCODE_INFO  *OpInfo;
    UINT32                  BitIndex;
    OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
    if (OpInfo->Type != AML_TYPE_CREATE_FIELD)
    {
        return;
    }
    BufferNameOp = AcpiPsGetDepthNext (NULL, Op);
    if (BufferNameOp->Common.AmlOpcode != AML_INT_NAMEPATH_OP)
    {
        return;
    }
    IndexOp = BufferNameOp->Common.Next;
    IndexOp->Common.Node = NULL;
    OpInfo = AcpiPsGetOpcodeInfo (IndexOp->Common.AmlOpcode);
    if (OpInfo->ObjectType != ACPI_TYPE_INTEGER)
    {
        return;
    }
    if ((Op->Common.AmlOpcode == AML_CREATE_BIT_FIELD_OP) ||
        (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP))
    {
        BitIndex = (UINT32) IndexOp->Common.Value.Integer;
    }
    else
    {
        BitIndex = (UINT32) ACPI_MUL_8 (IndexOp->Common.Value.Integer);
    }
    Status = AcpiNsLookup (WalkState->ScopeInfo,
        BufferNameOp->Common.Value.String, ACPI_TYPE_BUFFER,
        ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState,
        &BufferNode);
    if (ACPI_FAILURE (Status))
    {
        return;
    }
    if (BufferNode->Type != ACPI_TYPE_BUFFER)
    {
        return;
    }
    ResourceNode = AcpiDmGetResourceNode (BufferNode, BitIndex);
    if (!ResourceNode)
    {
        return;
    }
    AcpiGetTagPathname (IndexOp, BufferNode, ResourceNode, BitIndex);
}
void AcpiDmCheckResourceReference ( ACPI_PARSE_OBJECT * Op , ACPI_WALK_STATE * WalkState ) { ACPI_STATUS Status ; ACPI_PARSE_OBJECT * BufferNameOp ; ACPI_PARSE_OBJECT * IndexOp ; ACPI_NAMESPACE_NODE * BufferNode ; ACPI_NAMESPACE_NODE * ResourceNode ; const ACPI_OPCODE_INFO * OpInfo ; UINT32 BitIndex ; OpInfo = AcpiPsGetOpcodeInfo ( Op -> Common . AmlOpcode ) ; if ( OpInfo -> Type != AML_TYPE_CREATE_FIELD ) { return ; } BufferNameOp = AcpiPsGetDepthNext ( NULL , Op ) ; if ( BufferNameOp -> Common . AmlOpcode != AML_INT_NAMEPATH_OP ) { return ; } IndexOp = BufferNameOp -> Common . Next ; IndexOp -> Common . Node = NULL ; OpInfo = AcpiPsGetOpcodeInfo ( IndexOp -> Common . AmlOpcode ) ; if ( OpInfo -> ObjectType != ACPI_TYPE_INTEGER ) { return ; } if ( ( Op -> Common . AmlOpcode == AML_CREATE_BIT_FIELD_OP ) || ( Op -> Common . AmlOpcode == AML_CREATE_FIELD_OP ) ) { BitIndex = ( UINT32 ) IndexOp -> Common . Value . Integer ; } else { BitIndex = ( UINT32 ) ACPI_MUL_8 ( IndexOp -> Common . Value . Integer ) ; } Status = AcpiNsLookup ( WalkState -> ScopeInfo , BufferNameOp -> Common . Value . String , ACPI_TYPE_BUFFER , ACPI_IMODE_EXECUTE , ACPI_NS_SEARCH_PARENT , WalkState , & BufferNode ) ; if ( ACPI_FAILURE ( Status ) ) { return ; } if ( BufferNode -> Type != ACPI_TYPE_BUFFER ) { return ; } ResourceNode = AcpiDmGetResourceNode ( BufferNode , BitIndex ) ; if ( ! ResourceNode ) { return ; } AcpiGetTagPathname ( IndexOp , BufferNode , ResourceNode , BitIndex ) ; }
FUNCTION:    AcpiDmCheckResourceReference
 PARAMETERS:  Op                  - Parse Op for the AML opcode
              WalkState           - Current walk state (with valid scope)
FUNCTION : AcpiDmCheckResourceReference PARAMETERS : Op - Parse Op for the AML opcode WalkState - Current walk state ( with valid scope )
/* We are only interested in the CreateXxxxField opcodes */ /* Get the buffer term operand */ /* Must be a named buffer, not an arg or local or method call */ /* Get the Index term, must be an integer constant to convert */ /* Major cheat: The Node field is also used for the Tag ptr. Clear it now */ /* Get the bit offset of the descriptor within the buffer */ /* Index operand is a bit offset */ /* Index operand is a byte offset, convert to bits */ /* Lookup the buffer in the namespace */ /* Validate object type, we must have a buffer */ /* Find the resource descriptor node corresponding to the index */ /* Translate the Index to a resource tag pathname */