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

Completed resource node

Construct a long "UART Serial Bus" descriptor
RsDoUartSerialBusDescriptor PARAMETERS : Info - Parse Op and resource template offset Completed resource node Construct a long " UART Serial Bus " descriptor
ASL_RESOURCE_NODE *
RsDoUartSerialBusDescriptor (
    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_UART_SERIALBUS) +
        ResSourceLength + VendorLength;
    Rnode = RsAllocateResourceNode (DescriptorSize +
        sizeof (AML_RESOURCE_LARGE_HEADER));
    Descriptor = Rnode->Buffer;
    Descriptor->UartSerialBus.ResourceLength = DescriptorSize;
    Descriptor->UartSerialBus.DescriptorType = ACPI_RESOURCE_NAME_SERIAL_BUS;
    Descriptor->UartSerialBus.RevisionId = AML_RESOURCE_UART_REVISION;
    Descriptor->UartSerialBus.TypeRevisionId = AML_RESOURCE_UART_TYPE_REVISION;
    Descriptor->UartSerialBus.Type = AML_RESOURCE_UART_SERIALBUSTYPE;
    Descriptor->UartSerialBus.TypeDataLength = AML_RESOURCE_UART_MIN_DATA_LEN + VendorLength;
    if (Info->DescriptorTypeOp->Asl.ParseOpcode == PARSEOP_UART_SERIALBUS_V2)
    {
        Descriptor->I2cSerialBus.RevisionId = 2;
    }
    VendorData = ACPI_ADD_PTR (UINT8, Descriptor, sizeof (AML_RESOURCE_UART_SERIALBUS));
    ResourceSource = ACPI_ADD_PTR (char, VendorData, VendorLength);
    for (i = 0; InitializerOp; i++)
    {
        switch (i)
        {
        case 0: 
            Descriptor->UartSerialBus.DefaultBaudRate = (UINT32) InitializerOp->Asl.Value.Integer;
            RsCreateDwordField (InitializerOp, ACPI_RESTAG_SPEED,
                CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.DefaultBaudRate));
            break;
        case 1: 
            RsSetFlagBits16 (&Descriptor->UartSerialBus.TypeSpecificFlags, InitializerOp, 4, 3);
            RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_LENGTH,
                CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TypeSpecificFlags), 4, 3);
            break;
        case 2: 
            RsSetFlagBits16 (&Descriptor->UartSerialBus.TypeSpecificFlags, InitializerOp, 2, 1);
            RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_STOPBITS,
                CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TypeSpecificFlags), 2, 2);
            break;
        case 3: 
            Descriptor->UartSerialBus.LinesEnabled = (UINT8) InitializerOp->Asl.Value.Integer;
            RsCreateByteField (InitializerOp, ACPI_RESTAG_LINE,
                CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.LinesEnabled));
            break;
        case 4: 
            RsSetFlagBits16 (&Descriptor->UartSerialBus.TypeSpecificFlags, InitializerOp, 7, 0);
            RsCreateBitField (InitializerOp, ACPI_RESTAG_ENDIANNESS,
                CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TypeSpecificFlags), 7);
            break;
        case 5: 
            Descriptor->UartSerialBus.Parity = (UINT8) InitializerOp->Asl.Value.Integer;
            RsCreateByteField (InitializerOp, ACPI_RESTAG_PARITY,
                CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.Parity));
            break;
        case 6: 
            RsSetFlagBits16 (&Descriptor->UartSerialBus.TypeSpecificFlags, InitializerOp, 0, 0);
            RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_FLOWCONTROL,
                CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TypeSpecificFlags), 0, 2);
            break;
        case 7: 
            Descriptor->UartSerialBus.RxFifoSize = (UINT16) InitializerOp->Asl.Value.Integer;
            RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH_RX,
                CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.RxFifoSize));
            break;
        case 8: 
            Descriptor->UartSerialBus.TxFifoSize = (UINT16) InitializerOp->Asl.Value.Integer;
            RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH_TX,
                CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TxFifoSize));
            break;
        case 9: 
            if (ResSourceLength)
            {
                strcpy (ResourceSource,
                    InitializerOp->Asl.Value.String);
            }
            break;
        case 10: 
            if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
            {
                Descriptor->UartSerialBus.ResSourceIndex =
                    (UINT8) InitializerOp->Asl.Value.Integer;
            }
            break;
        case 11: 
            RsSetFlagBits (&Descriptor->UartSerialBus.Flags, InitializerOp, 1, 1);
            RsCreateBitField (InitializerOp, ACPI_RESTAG_SLAVEMODE,
                CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.Flags), 0);
            break;
        case 12: 
            UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
            break;
        case 13:
            RsSetFlagBits (&Descriptor->UartSerialBus.Flags, InitializerOp, 2, 0);
            RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTSHARE,
                CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.Flags), 2);
            break;
        case 14: 
            RsGetVendorData (InitializerOp, VendorData,
                CurrentByteOffset + sizeof (AML_RESOURCE_UART_SERIALBUS));
            break;
        default:    
            break;
        }
        InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
    }
    MpSaveSerialInfo (Info->MappingOp, Descriptor, ResourceSource);
    return (Rnode);
}
ASL_RESOURCE_NODE * RsDoUartSerialBusDescriptor ( 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_UART_SERIALBUS ) + ResSourceLength + VendorLength ; Rnode = RsAllocateResourceNode ( DescriptorSize + sizeof ( AML_RESOURCE_LARGE_HEADER ) ) ; Descriptor = Rnode -> Buffer ; Descriptor -> UartSerialBus . ResourceLength = DescriptorSize ; Descriptor -> UartSerialBus . DescriptorType = ACPI_RESOURCE_NAME_SERIAL_BUS ; Descriptor -> UartSerialBus . RevisionId = AML_RESOURCE_UART_REVISION ; Descriptor -> UartSerialBus . TypeRevisionId = AML_RESOURCE_UART_TYPE_REVISION ; Descriptor -> UartSerialBus . Type = AML_RESOURCE_UART_SERIALBUSTYPE ; Descriptor -> UartSerialBus . TypeDataLength = AML_RESOURCE_UART_MIN_DATA_LEN + VendorLength ; if ( Info -> DescriptorTypeOp -> Asl . ParseOpcode == PARSEOP_UART_SERIALBUS_V2 ) { Descriptor -> I2cSerialBus . RevisionId = 2 ; } VendorData = ACPI_ADD_PTR ( UINT8 , Descriptor , sizeof ( AML_RESOURCE_UART_SERIALBUS ) ) ; ResourceSource = ACPI_ADD_PTR ( char , VendorData , VendorLength ) ; for ( i = 0 ; InitializerOp ; i ++ ) { switch ( i ) { case 0 : Descriptor -> UartSerialBus . DefaultBaudRate = ( UINT32 ) InitializerOp -> Asl . Value . Integer ; RsCreateDwordField ( InitializerOp , ACPI_RESTAG_SPEED , CurrentByteOffset + ASL_RESDESC_OFFSET ( UartSerialBus . DefaultBaudRate ) ) ; break ; case 1 : RsSetFlagBits16 ( & Descriptor -> UartSerialBus . TypeSpecificFlags , InitializerOp , 4 , 3 ) ; RsCreateMultiBitField ( InitializerOp , ACPI_RESTAG_LENGTH , CurrentByteOffset + ASL_RESDESC_OFFSET ( UartSerialBus . TypeSpecificFlags ) , 4 , 3 ) ; break ; case 2 : RsSetFlagBits16 ( & Descriptor -> UartSerialBus . TypeSpecificFlags , InitializerOp , 2 , 1 ) ; RsCreateMultiBitField ( InitializerOp , ACPI_RESTAG_STOPBITS , CurrentByteOffset + ASL_RESDESC_OFFSET ( UartSerialBus . TypeSpecificFlags ) , 2 , 2 ) ; break ; case 3 : Descriptor -> UartSerialBus . LinesEnabled = ( UINT8 ) InitializerOp -> Asl . Value . Integer ; RsCreateByteField ( InitializerOp , ACPI_RESTAG_LINE , CurrentByteOffset + ASL_RESDESC_OFFSET ( UartSerialBus . LinesEnabled ) ) ; break ; case 4 : RsSetFlagBits16 ( & Descriptor -> UartSerialBus . TypeSpecificFlags , InitializerOp , 7 , 0 ) ; RsCreateBitField ( InitializerOp , ACPI_RESTAG_ENDIANNESS , CurrentByteOffset + ASL_RESDESC_OFFSET ( UartSerialBus . TypeSpecificFlags ) , 7 ) ; break ; case 5 : Descriptor -> UartSerialBus . Parity = ( UINT8 ) InitializerOp -> Asl . Value . Integer ; RsCreateByteField ( InitializerOp , ACPI_RESTAG_PARITY , CurrentByteOffset + ASL_RESDESC_OFFSET ( UartSerialBus . Parity ) ) ; break ; case 6 : RsSetFlagBits16 ( & Descriptor -> UartSerialBus . TypeSpecificFlags , InitializerOp , 0 , 0 ) ; RsCreateMultiBitField ( InitializerOp , ACPI_RESTAG_FLOWCONTROL , CurrentByteOffset + ASL_RESDESC_OFFSET ( UartSerialBus . TypeSpecificFlags ) , 0 , 2 ) ; break ; case 7 : Descriptor -> UartSerialBus . RxFifoSize = ( UINT16 ) InitializerOp -> Asl . Value . Integer ; RsCreateWordField ( InitializerOp , ACPI_RESTAG_LENGTH_RX , CurrentByteOffset + ASL_RESDESC_OFFSET ( UartSerialBus . RxFifoSize ) ) ; break ; case 8 : Descriptor -> UartSerialBus . TxFifoSize = ( UINT16 ) InitializerOp -> Asl . Value . Integer ; RsCreateWordField ( InitializerOp , ACPI_RESTAG_LENGTH_TX , CurrentByteOffset + ASL_RESDESC_OFFSET ( UartSerialBus . TxFifoSize ) ) ; break ; case 9 : if ( ResSourceLength ) { strcpy ( ResourceSource , InitializerOp -> Asl . Value . String ) ; } break ; case 10 : if ( InitializerOp -> Asl . ParseOpcode != PARSEOP_DEFAULT_ARG ) { Descriptor -> UartSerialBus . ResSourceIndex = ( UINT8 ) InitializerOp -> Asl . Value . Integer ; } break ; case 11 : RsSetFlagBits ( & Descriptor -> UartSerialBus . Flags , InitializerOp , 1 , 1 ) ; RsCreateBitField ( InitializerOp , ACPI_RESTAG_SLAVEMODE , CurrentByteOffset + ASL_RESDESC_OFFSET ( UartSerialBus . Flags ) , 0 ) ; break ; case 12 : UtAttachNamepathToOwner ( Info -> DescriptorTypeOp , InitializerOp ) ; break ; case 13 : RsSetFlagBits ( & Descriptor -> UartSerialBus . Flags , InitializerOp , 2 , 0 ) ; RsCreateBitField ( InitializerOp , ACPI_RESTAG_INTERRUPTSHARE , CurrentByteOffset + ASL_RESDESC_OFFSET ( UartSerialBus . Flags ) , 2 ) ; break ; case 14 : RsGetVendorData ( InitializerOp , VendorData , CurrentByteOffset + sizeof ( AML_RESOURCE_UART_SERIALBUS ) ) ; break ; default : break ; } InitializerOp = RsCompleteNodeAndGetNext ( InitializerOp ) ; } MpSaveSerialInfo ( Info -> MappingOp , Descriptor , ResourceSource ) ; return ( Rnode ) ; }
FUNCTION:    RsDoUartSerialBusDescriptor
 PARAMETERS:  Info                - Parse Op and resource template offset
FUNCTION : RsDoUartSerialBusDescriptor 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 */ /* Connection Speed (Baud Rate) [DWORD] (_SPE) */ /* Bits Per Byte [Flags] (_LEN) */ /* Stop Bits [Flags] (_STB) */ /* Lines In Use [BYTE] (_LIN) */ /* Endianness [Flag] (_END) */ /* Parity [BYTE] (_PAR) */ /* Flow Control [Flags] (_FLC) */ /* Rx Buffer Size [WORD] (_RXL) */ /* Tx Buffer Size [WORD] (_TXL) */ /* ResSource [Optional Field - STRING] */ /* Copy string to the descriptor */ /* Resource Index */ /* Resource Usage (consumer/producer) */ /*
             * Slave Mode [Flag] (_SLV)
             *
             * Note: There is no SlaveMode argument to the UartSerialBus macro, but
             * we add this name anyway to allow the flag to be set by ASL in the
             * rare case where there is a slave mode associated with the UART.
             */ /* 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 */