sys/contrib/dev/acpica/source/compiler/aslrestype2s.c
/*******************************************************************************
 *
 * FUNCTION:    RsDoSpiSerialBusDescriptor
 *
 * PARAMETERS:  Info                - Parse Op and resource template offset
 *
 * RETURN:      Completed resource node
 *
 * DESCRIPTION: Construct a long "SPI Serial Bus" descriptor
 *
 ******************************************************************************/
RsDoSpiSerialBusDescriptor
PARAMETERS:  Info                - Parse Op and resource template offset

Completed resource node

Construct a long "SPI Serial Bus" descriptor
RsDoSpiSerialBusDescriptor PARAMETERS : Info - Parse Op and resource template offset Completed resource node Construct a long " SPI Serial Bus " descriptor
ASL_RESOURCE_NODE *
RsDoSpiSerialBusDescriptor (
    ASL_RESOURCE_INFO       *Info)
{
    AML_RESOURCE            *Descriptor;
    ACPI_PARSE_OBJECT       *InitializerOp;
    ASL_RESOURCE_NODE       *Rnode;
    char                    *ResourceSource = NULL;
    UINT8                   *VendorData = NULL;
    UINT16                  ResSourceLength;
    UINT16                  VendorLength;
    UINT16                  DescriptorSize;
    UINT32                  CurrentByteOffset;
    UINT32                  i;
    InitializerOp = Info->DescriptorTypeOp->Asl.Child;
    CurrentByteOffset = Info->CurrentByteOffset;
    ResSourceLength = RsGetStringDataLength (InitializerOp);
    VendorLength = RsGetBufferDataLength (InitializerOp);
    DescriptorSize = ACPI_AML_SIZE_LARGE (AML_RESOURCE_SPI_SERIALBUS) +
        ResSourceLength + VendorLength;
    Rnode = RsAllocateResourceNode (DescriptorSize +
        sizeof (AML_RESOURCE_LARGE_HEADER));
    Descriptor = Rnode->Buffer;
    Descriptor->SpiSerialBus.ResourceLength = DescriptorSize;
    Descriptor->SpiSerialBus.DescriptorType = ACPI_RESOURCE_NAME_SERIAL_BUS;
    Descriptor->SpiSerialBus.RevisionId = AML_RESOURCE_SPI_REVISION;
    Descriptor->SpiSerialBus.TypeRevisionId = AML_RESOURCE_SPI_TYPE_REVISION;
    Descriptor->SpiSerialBus.Type = AML_RESOURCE_SPI_SERIALBUSTYPE;
    Descriptor->SpiSerialBus.TypeDataLength = AML_RESOURCE_SPI_MIN_DATA_LEN + VendorLength;
    if (Info->DescriptorTypeOp->Asl.ParseOpcode == PARSEOP_SPI_SERIALBUS_V2)
    {
        Descriptor->I2cSerialBus.RevisionId = 2;
    }
    VendorData = ACPI_ADD_PTR (UINT8, Descriptor,
        sizeof (AML_RESOURCE_SPI_SERIALBUS));
    ResourceSource = ACPI_ADD_PTR (char, VendorData, VendorLength);
    for (i = 0; InitializerOp; i++)
    {
        switch (i)
        {
        case 0: 
            Descriptor->SpiSerialBus.DeviceSelection = (UINT16) InitializerOp->Asl.Value.Integer;
            RsCreateWordField (InitializerOp, ACPI_RESTAG_ADDRESS,
                CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.DeviceSelection));
            break;
        case 1: 
            RsSetFlagBits16 (&Descriptor->SpiSerialBus.TypeSpecificFlags, InitializerOp, 1, 0);
            RsCreateBitField (InitializerOp, ACPI_RESTAG_DEVICEPOLARITY,
                CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.TypeSpecificFlags), 1);
            break;
        case 2: 
            RsSetFlagBits16 (&Descriptor->SpiSerialBus.TypeSpecificFlags, InitializerOp, 0, 0);
            RsCreateBitField (InitializerOp, ACPI_RESTAG_MODE,
                CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.TypeSpecificFlags), 0);
            break;
        case 3: 
            Descriptor->SpiSerialBus.DataBitLength = (UINT8) InitializerOp->Asl.Value.Integer;
            RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH,
                CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.DataBitLength));
            break;
        case 4: 
            RsSetFlagBits (&Descriptor->SpiSerialBus.Flags, InitializerOp, 0, 0);
            RsCreateBitField (InitializerOp, ACPI_RESTAG_SLAVEMODE,
                CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.Flags), 0);
            break;
        case 5: 
            Descriptor->SpiSerialBus.ConnectionSpeed = (UINT32) InitializerOp->Asl.Value.Integer;
            RsCreateDwordField (InitializerOp, ACPI_RESTAG_SPEED,
                CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.ConnectionSpeed));
            break;
        case 6: 
            Descriptor->SpiSerialBus.ClockPolarity = (UINT8) InitializerOp->Asl.Value.Integer;
            RsCreateByteField (InitializerOp, ACPI_RESTAG_POLARITY,
                CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.ClockPolarity));
            break;
        case 7: 
            Descriptor->SpiSerialBus.ClockPhase = (UINT8) InitializerOp->Asl.Value.Integer;
            RsCreateByteField (InitializerOp, ACPI_RESTAG_PHASE,
                CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.ClockPhase));
            break;
        case 8: 
            if (ResSourceLength)
            {
                strcpy (ResourceSource,
                    InitializerOp->Asl.Value.String);
            }
            break;
        case 9: 
            if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
            {
                Descriptor->SpiSerialBus.ResSourceIndex =
                    (UINT8) InitializerOp->Asl.Value.Integer;
            }
            break;
        case 10: 
            RsSetFlagBits (&Descriptor->SpiSerialBus.Flags, InitializerOp, 1, 1);
            break;
        case 11: 
            UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
            break;
        case 12:
            RsSetFlagBits (&Descriptor->SpiSerialBus.Flags, InitializerOp, 2, 0);
            RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTSHARE,
                CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.Flags), 2);
            break;
        case 13: 
            RsGetVendorData (InitializerOp, VendorData,
                CurrentByteOffset + sizeof (AML_RESOURCE_SPI_SERIALBUS));
            break;
        default:    
            break;
        }
        InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
    }
    MpSaveSerialInfo (Info->MappingOp, Descriptor, ResourceSource);
    return (Rnode);
}
ASL_RESOURCE_NODE * RsDoSpiSerialBusDescriptor ( ASL_RESOURCE_INFO * Info ) { AML_RESOURCE * Descriptor ; ACPI_PARSE_OBJECT * InitializerOp ; ASL_RESOURCE_NODE * Rnode ; char * ResourceSource = NULL ; UINT8 * VendorData = NULL ; UINT16 ResSourceLength ; UINT16 VendorLength ; UINT16 DescriptorSize ; UINT32 CurrentByteOffset ; UINT32 i ; InitializerOp = Info -> DescriptorTypeOp -> Asl . Child ; CurrentByteOffset = Info -> CurrentByteOffset ; ResSourceLength = RsGetStringDataLength ( InitializerOp ) ; VendorLength = RsGetBufferDataLength ( InitializerOp ) ; DescriptorSize = ACPI_AML_SIZE_LARGE ( AML_RESOURCE_SPI_SERIALBUS ) + ResSourceLength + VendorLength ; Rnode = RsAllocateResourceNode ( DescriptorSize + sizeof ( AML_RESOURCE_LARGE_HEADER ) ) ; Descriptor = Rnode -> Buffer ; Descriptor -> SpiSerialBus . ResourceLength = DescriptorSize ; Descriptor -> SpiSerialBus . DescriptorType = ACPI_RESOURCE_NAME_SERIAL_BUS ; Descriptor -> SpiSerialBus . RevisionId = AML_RESOURCE_SPI_REVISION ; Descriptor -> SpiSerialBus . TypeRevisionId = AML_RESOURCE_SPI_TYPE_REVISION ; Descriptor -> SpiSerialBus . Type = AML_RESOURCE_SPI_SERIALBUSTYPE ; Descriptor -> SpiSerialBus . TypeDataLength = AML_RESOURCE_SPI_MIN_DATA_LEN + VendorLength ; if ( Info -> DescriptorTypeOp -> Asl . ParseOpcode == PARSEOP_SPI_SERIALBUS_V2 ) { Descriptor -> I2cSerialBus . RevisionId = 2 ; } VendorData = ACPI_ADD_PTR ( UINT8 , Descriptor , sizeof ( AML_RESOURCE_SPI_SERIALBUS ) ) ; ResourceSource = ACPI_ADD_PTR ( char , VendorData , VendorLength ) ; for ( i = 0 ; InitializerOp ; i ++ ) { switch ( i ) { case 0 : Descriptor -> SpiSerialBus . DeviceSelection = ( UINT16 ) InitializerOp -> Asl . Value . Integer ; RsCreateWordField ( InitializerOp , ACPI_RESTAG_ADDRESS , CurrentByteOffset + ASL_RESDESC_OFFSET ( SpiSerialBus . DeviceSelection ) ) ; break ; case 1 : RsSetFlagBits16 ( & Descriptor -> SpiSerialBus . TypeSpecificFlags , InitializerOp , 1 , 0 ) ; RsCreateBitField ( InitializerOp , ACPI_RESTAG_DEVICEPOLARITY , CurrentByteOffset + ASL_RESDESC_OFFSET ( SpiSerialBus . TypeSpecificFlags ) , 1 ) ; break ; case 2 : RsSetFlagBits16 ( & Descriptor -> SpiSerialBus . TypeSpecificFlags , InitializerOp , 0 , 0 ) ; RsCreateBitField ( InitializerOp , ACPI_RESTAG_MODE , CurrentByteOffset + ASL_RESDESC_OFFSET ( SpiSerialBus . TypeSpecificFlags ) , 0 ) ; break ; case 3 : Descriptor -> SpiSerialBus . DataBitLength = ( UINT8 ) InitializerOp -> Asl . Value . Integer ; RsCreateByteField ( InitializerOp , ACPI_RESTAG_LENGTH , CurrentByteOffset + ASL_RESDESC_OFFSET ( SpiSerialBus . DataBitLength ) ) ; break ; case 4 : RsSetFlagBits ( & Descriptor -> SpiSerialBus . Flags , InitializerOp , 0 , 0 ) ; RsCreateBitField ( InitializerOp , ACPI_RESTAG_SLAVEMODE , CurrentByteOffset + ASL_RESDESC_OFFSET ( SpiSerialBus . Flags ) , 0 ) ; break ; case 5 : Descriptor -> SpiSerialBus . ConnectionSpeed = ( UINT32 ) InitializerOp -> Asl . Value . Integer ; RsCreateDwordField ( InitializerOp , ACPI_RESTAG_SPEED , CurrentByteOffset + ASL_RESDESC_OFFSET ( SpiSerialBus . ConnectionSpeed ) ) ; break ; case 6 : Descriptor -> SpiSerialBus . ClockPolarity = ( UINT8 ) InitializerOp -> Asl . Value . Integer ; RsCreateByteField ( InitializerOp , ACPI_RESTAG_POLARITY , CurrentByteOffset + ASL_RESDESC_OFFSET ( SpiSerialBus . ClockPolarity ) ) ; break ; case 7 : Descriptor -> SpiSerialBus . ClockPhase = ( UINT8 ) InitializerOp -> Asl . Value . Integer ; RsCreateByteField ( InitializerOp , ACPI_RESTAG_PHASE , CurrentByteOffset + ASL_RESDESC_OFFSET ( SpiSerialBus . ClockPhase ) ) ; break ; case 8 : if ( ResSourceLength ) { strcpy ( ResourceSource , InitializerOp -> Asl . Value . String ) ; } break ; case 9 : if ( InitializerOp -> Asl . ParseOpcode != PARSEOP_DEFAULT_ARG ) { Descriptor -> SpiSerialBus . ResSourceIndex = ( UINT8 ) InitializerOp -> Asl . Value . Integer ; } break ; case 10 : RsSetFlagBits ( & Descriptor -> SpiSerialBus . Flags , InitializerOp , 1 , 1 ) ; break ; case 11 : UtAttachNamepathToOwner ( Info -> DescriptorTypeOp , InitializerOp ) ; break ; case 12 : RsSetFlagBits ( & Descriptor -> SpiSerialBus . Flags , InitializerOp , 2 , 0 ) ; RsCreateBitField ( InitializerOp , ACPI_RESTAG_INTERRUPTSHARE , CurrentByteOffset + ASL_RESDESC_OFFSET ( SpiSerialBus . Flags ) , 2 ) ; break ; case 13 : RsGetVendorData ( InitializerOp , VendorData , CurrentByteOffset + sizeof ( AML_RESOURCE_SPI_SERIALBUS ) ) ; break ; default : break ; } InitializerOp = RsCompleteNodeAndGetNext ( InitializerOp ) ; } MpSaveSerialInfo ( Info -> MappingOp , Descriptor , ResourceSource ) ; return ( Rnode ) ; }
FUNCTION:    RsDoSpiSerialBusDescriptor
 PARAMETERS:  Info                - Parse Op and resource template offset
FUNCTION : RsDoSpiSerialBusDescriptor PARAMETERS : Info - Parse Op and resource template offset
/*
     * Calculate lengths for fields that have variable length:
     * 1) Resource Source string
     * 2) Vendor Data buffer
     */ /* Allocate the local resource node and initialize */ /* Build pointers to optional areas */ /* Process all child initialization nodes */ /* Device Selection [WORD] (_ADR) */ /* Device Polarity [Flag] (_DPL) */ /* Wire Mode [Flag] (_MOD) */ /* Device Bit Length [BYTE] (_LEN) */ /* Slave Mode [Flag] (_SLV) */ /* Connection Speed [DWORD] (_SPE) */ /* Clock Polarity [BYTE] (_POL) */ /* Clock Phase [BYTE] (_PHA) */ /* ResSource [Optional Field - STRING] */ /* Copy string to the descriptor */ /* Resource Index */ /* Resource Usage (consumer/producer) */ /* Resource Tag (Descriptor Name) */ /*
             * Connection Share - Added for V2 (ACPI 6.0) version of the descriptor
             * Note: For V1, the share bit will be zero (Op is DEFAULT_ARG from
             * the ASL parser)
             */ /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */ /* Ignore any extra nodes */