FreeBSD/sys/contrib/dev/acpica/components/dispatcher/dsfield.c
/*******************************************************************************
 *
 * FUNCTION:    AcpiDsGetFieldNames
 *
 * PARAMETERS:  Info            - CreateField info structure
 *  `           WalkState       - Current method state
 *              Arg             - First parser arg for the field name list
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Process all named fields in a field declaration. Names are
 *              entered into the namespace.
 *
 ******************************************************************************/
AcpiDsGetFieldNames
PARAMETERS:  Info            - CreateField info structure
`           WalkState       - Current method state
Arg             - First parser arg for the field name list

Status

Process all named fields in a field declaration. Names are
entered into the namespace.
AcpiDsGetFieldNames PARAMETERS : Info - CreateField info structure ` WalkState - Current method state Arg - First parser arg for the field name list Status Process all named fields in a field declaration . Names are entered into the namespace .
static ACPI_STATUS
AcpiDsGetFieldNames (
    ACPI_CREATE_FIELD_INFO  *Info,
    ACPI_WALK_STATE         *WalkState,
    ACPI_PARSE_OBJECT       *Arg)
{
    ACPI_STATUS             Status;
    UINT64                  Position;
    ACPI_PARSE_OBJECT       *Child;
    ACPI_FUNCTION_TRACE_PTR (DsGetFieldNames, Info);
    Info->FieldBitPosition = 0;
    while (Arg)
    {
        switch (Arg->Common.AmlOpcode)
        {
        case AML_INT_RESERVEDFIELD_OP:
            Position = (UINT64) Info->FieldBitPosition +
                (UINT64) Arg->Common.Value.Size;
            if (Position > ACPI_UINT32_MAX)
            {
                ACPI_ERROR ((AE_INFO,
                    "Bit offset within field too large (> 0xFFFFFFFF)"));
                return_ACPI_STATUS (AE_SUPPORT);
            }
            Info->FieldBitPosition = (UINT32) Position;
            break;
        case AML_INT_ACCESSFIELD_OP:
        case AML_INT_EXTACCESSFIELD_OP:
            Info->FieldFlags = (UINT8)
                ((Info->FieldFlags & ~(AML_FIELD_ACCESS_TYPE_MASK)) |
                ((UINT8) ((UINT32) (Arg->Common.Value.Integer & 0x07))));
            Info->Attribute = (UINT8)
                ((Arg->Common.Value.Integer >> 8) & 0xFF);
            Info->AccessLength = (UINT8)
                ((Arg->Common.Value.Integer >> 16) & 0xFF);
            break;
        case AML_INT_CONNECTION_OP:
            Info->ResourceBuffer = NULL;
            Info->ConnectionNode = NULL;
            Info->PinNumberIndex = 0;
            Child = Arg->Common.Value.Arg;
            if (Child->Common.AmlOpcode == AML_INT_BYTELIST_OP)
            {
                Info->ResourceBuffer = Child->Named.Data;
                Info->ResourceLength = (UINT16) Child->Named.Value.Integer;
            }
            else
            {
                Status = AcpiNsLookup (WalkState->ScopeInfo,
                    Child->Common.Value.Name, ACPI_TYPE_ANY,
                    ACPI_IMODE_EXECUTE, ACPI_NS_DONT_OPEN_SCOPE,
                    WalkState, &Info->ConnectionNode);
                if (ACPI_FAILURE (Status))
                {
                    ACPI_ERROR_NAMESPACE (Child->Common.Value.Name, Status);
                    return_ACPI_STATUS (Status);
                }
            }
            break;
        case AML_INT_NAMEDFIELD_OP:
            Status = AcpiNsLookup (WalkState->ScopeInfo,
                (char *) &Arg->Named.Name, Info->FieldType,
                ACPI_IMODE_EXECUTE, ACPI_NS_DONT_OPEN_SCOPE,
                WalkState, &Info->FieldNode);
            if (ACPI_FAILURE (Status))
            {
                ACPI_ERROR_NAMESPACE ((char *) &Arg->Named.Name, Status);
                return_ACPI_STATUS (Status);
            }
            else
            {
                Arg->Common.Node = Info->FieldNode;
                Info->FieldBitLength = Arg->Common.Value.Size;
                if (!AcpiNsGetAttachedObject (Info->FieldNode))
                {
                    Status = AcpiExPrepFieldValue (Info);
                    if (ACPI_FAILURE (Status))
                    {
                        return_ACPI_STATUS (Status);
                    }
                }
            }
            Position = (UINT64) Info->FieldBitPosition +
                (UINT64) Arg->Common.Value.Size;
            if (Position > ACPI_UINT32_MAX)
            {
                ACPI_ERROR ((AE_INFO,
                    "Field [%4.4s] bit offset too large (> 0xFFFFFFFF)",
                    ACPI_CAST_PTR (char, &Info->FieldNode->Name)));
                return_ACPI_STATUS (AE_SUPPORT);
            }
            Info->FieldBitPosition += Info->FieldBitLength;
            Info->PinNumberIndex++; 
            break;
        default:
            ACPI_ERROR ((AE_INFO,
                "Invalid opcode in field list: 0x%X",
                Arg->Common.AmlOpcode));
            return_ACPI_STATUS (AE_AML_BAD_OPCODE);
        }
        Arg = Arg->Common.Next;
    }
    return_ACPI_STATUS (AE_OK);
}
static ACPI_STATUS AcpiDsGetFieldNames ( ACPI_CREATE_FIELD_INFO * Info , ACPI_WALK_STATE * WalkState , ACPI_PARSE_OBJECT * Arg ) { ACPI_STATUS Status ; UINT64 Position ; ACPI_PARSE_OBJECT * Child ; ACPI_FUNCTION_TRACE_PTR ( DsGetFieldNames , Info ) ; Info -> FieldBitPosition = 0 ; while ( Arg ) { switch ( Arg -> Common . AmlOpcode ) { case AML_INT_RESERVEDFIELD_OP : Position = ( UINT64 ) Info -> FieldBitPosition + ( UINT64 ) Arg -> Common . Value . Size ; if ( Position > ACPI_UINT32_MAX ) { ACPI_ERROR ( ( AE_INFO , " " ) ) ; return_ACPI_STATUS ( AE_SUPPORT ) ; } Info -> FieldBitPosition = ( UINT32 ) Position ; break ; case AML_INT_ACCESSFIELD_OP : case AML_INT_EXTACCESSFIELD_OP : Info -> FieldFlags = ( UINT8 ) ( ( Info -> FieldFlags & ~ ( AML_FIELD_ACCESS_TYPE_MASK ) ) | ( ( UINT8 ) ( ( UINT32 ) ( Arg -> Common . Value . Integer & 0x07 ) ) ) ) ; Info -> Attribute = ( UINT8 ) ( ( Arg -> Common . Value . Integer >> 8 ) & 0xFF ) ; Info -> AccessLength = ( UINT8 ) ( ( Arg -> Common . Value . Integer >> 16 ) & 0xFF ) ; break ; case AML_INT_CONNECTION_OP : Info -> ResourceBuffer = NULL ; Info -> ConnectionNode = NULL ; Info -> PinNumberIndex = 0 ; Child = Arg -> Common . Value . Arg ; if ( Child -> Common . AmlOpcode == AML_INT_BYTELIST_OP ) { Info -> ResourceBuffer = Child -> Named . Data ; Info -> ResourceLength = ( UINT16 ) Child -> Named . Value . Integer ; } else { Status = AcpiNsLookup ( WalkState -> ScopeInfo , Child -> Common . Value . Name , ACPI_TYPE_ANY , ACPI_IMODE_EXECUTE , ACPI_NS_DONT_OPEN_SCOPE , WalkState , & Info -> ConnectionNode ) ; if ( ACPI_FAILURE ( Status ) ) { ACPI_ERROR_NAMESPACE ( Child -> Common . Value . Name , Status ) ; return_ACPI_STATUS ( Status ) ; } } break ; case AML_INT_NAMEDFIELD_OP : Status = AcpiNsLookup ( WalkState -> ScopeInfo , ( char * ) & Arg -> Named . Name , Info -> FieldType , ACPI_IMODE_EXECUTE , ACPI_NS_DONT_OPEN_SCOPE , WalkState , & Info -> FieldNode ) ; if ( ACPI_FAILURE ( Status ) ) { ACPI_ERROR_NAMESPACE ( ( char * ) & Arg -> Named . Name , Status ) ; return_ACPI_STATUS ( Status ) ; } else { Arg -> Common . Node = Info -> FieldNode ; Info -> FieldBitLength = Arg -> Common . Value . Size ; if ( ! AcpiNsGetAttachedObject ( Info -> FieldNode ) ) { Status = AcpiExPrepFieldValue ( Info ) ; if ( ACPI_FAILURE ( Status ) ) { return_ACPI_STATUS ( Status ) ; } } } Position = ( UINT64 ) Info -> FieldBitPosition + ( UINT64 ) Arg -> Common . Value . Size ; if ( Position > ACPI_UINT32_MAX ) { ACPI_ERROR ( ( AE_INFO , " " , ACPI_CAST_PTR ( char , & Info -> FieldNode -> Name ) ) ) ; return_ACPI_STATUS ( AE_SUPPORT ) ; } Info -> FieldBitPosition += Info -> FieldBitLength ; Info -> PinNumberIndex ++ ; break ; default : ACPI_ERROR ( ( AE_INFO , " " , Arg -> Common . AmlOpcode ) ) ; return_ACPI_STATUS ( AE_AML_BAD_OPCODE ) ; } Arg = Arg -> Common . Next ; } return_ACPI_STATUS ( AE_OK ) ; }
FUNCTION:    AcpiDsGetFieldNames
 PARAMETERS:  Info            - CreateField info structure
  `           WalkState       - Current method state
              Arg             - First parser arg for the field name list
FUNCTION : AcpiDsGetFieldNames PARAMETERS : Info - CreateField info structure ` WalkState - Current method state Arg - First parser arg for the field name list
/* First field starts at bit zero */ /* Process all elements in the field list (of parse nodes) */ /*
         * Four types of field elements are handled:
         * 1) Name - Enters a new named field into the namespace
         * 2) Offset - specifies a bit offset
         * 3) AccessAs - changes the access mode/attributes
         * 4) Connection - Associate a resource template with the field
         */ /*
             * Get new AccessType, AccessAttribute, and AccessLength fields
             * -- to be used for all field units that follow, until the
             * end-of-field or another AccessAs keyword is encountered.
             * NOTE. These three bytes are encoded in the integer value
             * of the parseop for convenience.
             *
             * In FieldFlags, preserve the flag bits other than the
             * ACCESS_TYPE bits.
             */ /* AccessType (ByteAcc, WordAcc, etc.) */ /* AccessAttribute (AttribQuick, AttribByte, etc.) */ /* AccessLength (for serial/buffer protocols) */ /*
             * Clear any previous connection. New connection is used for all
             * fields that follow, similar to AccessAs
             */ /*
             * A Connection() is either an actual resource descriptor (buffer)
             * or a named reference to a resource template
             */ /* Lookup the Connection() namepath, it should already exist */ /* Lookup the name, it should already exist */ /*
                 * If there is no object attached to the node, this node was
                 * just created and we need to create the field object.
                 * Otherwise, this was a lookup of an existing node and we
                 * don't want to create the field object again.
                 */ /* Keep track of bit position for the next field */ /* Index relative to previous Connection() */