Пример #1
0
_mqx_int _io_pcb_shm_write
    (
        /* [IN] the file descriptor */
        FILE_DEVICE_STRUCT_PTR  fd_ptr,

        /* [IN] the pcb address from which to write data */
        IO_PCB_STRUCT_PTR       pcb_ptr
    )
{
    IO_PCB_SHM_INFO_STRUCT_PTR info_ptr;

    info_ptr = fd_ptr->DEV_DATA_PTR;


    _queue_enqueue((QUEUE_STRUCT_PTR)((pointer)&info_ptr->WRITE_QUEUE),
        (QUEUE_ELEMENT_STRUCT_PTR)((pointer)&pcb_ptr->QUEUE));
    _DCACHE_FLUSH_MLINES(pcb_ptr, sizeof(IO_PCB_STRUCT));
    _io_pcb_shm_tx((pointer)info_ptr);

    return(MQX_OK);
}
Пример #2
0
_mqx_int _io_pcb_shm_write
    (
        /* [IN] the file descriptor */
        FILE_DEVICE_STRUCT_PTR  fd_ptr,

        /* [IN] the pcb address from which to read data */
        char            *data_ptr,

        /* [IN] the number of characters to input */
        _mqx_int        num
    )
{
    IO_PCB_SHM_INFO_STRUCT_PTR info_ptr = fd_ptr->DEV_DATA_PTR;
    IO_PCB_STRUCT_PTR pcb_ptr = (IO_PCB_STRUCT_PTR)data_ptr;

    _queue_enqueue((QUEUE_STRUCT_PTR)((void *)&info_ptr->WRITE_QUEUE),
        (QUEUE_ELEMENT_STRUCT_PTR)((void *)&pcb_ptr->QUEUE));
    _DCACHE_FLUSH_MLINES(pcb_ptr, sizeof(IO_PCB_STRUCT));
    _io_pcb_shm_tx((void *)info_ptr);

    return(MQX_OK);
}
Пример #3
0
void _io_pcb_shm_tx
    (
        /* [IN] the device info */
        pointer handle
    )
{
    IO_PCB_SHM_INFO_STRUCT_PTR   info_ptr;
    IO_PCB_STRUCT_PTR            pcb_ptr;
    IO_PCB_SHM_BUFFER_STRUCT_PTR bd_ptr;
    IO_PCB_SHM_INIT_STRUCT_PTR   init_ptr;
    IO_PCB_FRAGMENT_STRUCT_PTR   frag_ptr;
    uint_32                      work = FALSE;
    uint_16                      num_frags;

    info_ptr = (IO_PCB_SHM_INFO_STRUCT_PTR)handle;
    init_ptr = &info_ptr->INIT;

    while (TRUE) {

        _int_disable();

        /* Check if queue empty */
        if (!_queue_get_size(&info_ptr->WRITE_QUEUE)) {
          _int_enable();
            break;
        }

        /* Check if queue empty */
        if (!(info_ptr->TXENTRIES)) {
          _int_enable();
          info_ptr->TX_BD_RUNOVER++;
          break;
        }

        /* Get the packet from output queue */
        pcb_ptr = (IO_PCB_STRUCT_PTR)((pointer)
            _queue_dequeue(&info_ptr->WRITE_QUEUE));

        /* Get the next buffer descriptor */
        bd_ptr = &info_ptr->TX_RING_PTR[info_ptr->TXNEXT];

        /* Flush packet */
        num_frags = pcb_ptr->NUMBER_OF_FRAGMENTS;
        for(frag_ptr = (IO_PCB_FRAGMENT_STRUCT_PTR) &(pcb_ptr->FRAGMENTS[0]); num_frags; num_frags--, frag_ptr++)
        {
             _DCACHE_FLUSH_MLINES(frag_ptr->FRAGMENT,frag_ptr->LENGTH);
            frag_ptr->FRAGMENT = _bsp_vtop(frag_ptr->FRAGMENT);
        }


        /* Set the buffer descriptor */
        bd_ptr->PACKET_PTR = (IO_PCB_STRUCT_PTR) _bsp_vtop(pcb_ptr);
        bd_ptr->CONTROL = (IO_PCB_SHM_BUFFER_OWN|IO_PCB_SHM_BUFFER_ALOCATED);
        _DCACHE_FLUSH_LINE(bd_ptr);

        /* Update Info structure  */
        info_ptr->TXNEXT = NEXT_INDEX(info_ptr->TXNEXT, info_ptr->TX_LENGTH);
        info_ptr->TXENTRIES--;
        work = TRUE;
        _int_enable();

    }

    if (work) {
        /* Trigger remote ISR */
        (*init_ptr->INT_TRIGGER)(init_ptr->REMOTE_RX_VECTOR);
    }
}