Ignore:
Timestamp:
Mar 18, 2020, 11:16:59 PM (4 years ago)
Author:
alain
Message:

Introduce remote_buf.c/.h & socket.c/.h files.
Update dev_nic.c/.h files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/devices/dev_txt.c

    r647 r657  
    133133}  // end dev_txt_init()
    134134
    135 //////////////////////////////////////////////////////////////////////////////////
    136 // This static function is called by dev_txt_read(), dev_txt_write() functions.
    137 ////////////////////////////////////i/////////////////////////////////////////////
    138 static error_t dev_txt_access( uint32_t   type,
    139                                uint32_t   channel,
    140                                char     * buffer,
    141                                uint32_t   count )
    142 {
    143     xptr_t     dev_xp;
    144     thread_t * this = CURRENT_THREAD;
    145 
    146     // check channel argument
    147     assert( (channel < CONFIG_MAX_TXT_CHANNELS) , "illegal channel index" );
    148 
    149     // get extended pointer on remote TXT chdev descriptor
    150     if( type == TXT_WRITE )  dev_xp = chdev_dir.txt_tx[channel];
    151     else                     dev_xp = chdev_dir.txt_rx[channel];
    152 
    153     assert( (dev_xp != XPTR_NULL) , "undefined TXT chdev descriptor" );
    154 
    155     // register command in calling thread descriptor
    156     this->txt_cmd.dev_xp  = dev_xp;
    157     this->txt_cmd.type    = type;
    158     this->txt_cmd.buf_xp  = XPTR( local_cxy , buffer );
    159     this->txt_cmd.count   = count;
    160 
    161     // register client thread in waiting queue, activate server thread
    162     // block client thread on THREAD_BLOCKED_IO and deschedule.
    163     // it is re-activated by the ISR signaling IO operation completion.
    164     chdev_register_command( dev_xp );
    165 
    166     // return I/O operation status from calling thread descriptor
    167     return this->txt_cmd.error;
    168 
    169 }  // end dev_txt_access()
    170 
    171135/////////////////////////////////////////
    172136error_t dev_txt_write( uint32_t   channel,
     
    180144#endif
    181145
     146    thread_t * this = CURRENT_THREAD;
     147
    182148#if DEBUG_DEV_TXT_TX
    183 thread_t * this  = CURRENT_THREAD;
    184149uint32_t   cycle = (uint32_t)hal_get_cycles();
    185150if( DEBUG_DEV_TXT_TX < cycle )
     
    188153#endif
    189154
     155// check channel argument
     156assert( (channel < CONFIG_MAX_TXT_CHANNELS) , "illegal channel index" );
     157
     158    // get pointers on chdev
     159    xptr_t    dev_xp  = chdev_dir.txt_tx[channel];
     160    cxy_t     dev_cxy = GET_CXY( dev_xp );
     161    chdev_t * dev_ptr = GET_PTR( dev_xp );
     162
     163// check dev_xp
     164assert( (dev_xp != XPTR_NULL) , "undefined TXT chdev descriptor" );
     165
    190166    // If we use MTTY (vci_multi_tty), we do a synchronous write on TXT[0]
    191167    // If we use TTY  (vci_tty_tsar), we do a standard asynchronous write
    192168    // TODO this is not very clean ... [AG]
    193169
    194     // get pointers on chdev
    195     xptr_t dev_xp = chdev_dir.txt_tx[0];
    196     cxy_t     dev_cxy = GET_CXY( dev_xp );
    197     chdev_t * dev_ptr = GET_PTR( dev_xp );
    198 
    199     if( dev_ptr->impl == IMPL_TXT_MTY )
     170    if( dev_ptr->impl == IMPL_TXT_MTY ) 
    200171    {
    201172        // get driver command function
     
    216187    else
    217188    {
    218         // register command in chdev queue for an asynchronous access
    219         error = dev_txt_access( TXT_WRITE , channel , buffer , count );
     189        // register command in calling thread descriptor
     190        this->txt_cmd.dev_xp  = dev_xp;
     191        this->txt_cmd.type    = TXT_WRITE;
     192        this->txt_cmd.buf_xp  = XPTR( local_cxy , buffer );
     193        this->txt_cmd.count   = count;
     194
     195        // register client thread in waiting queue, activate server thread
     196        // block client thread on THREAD_BLOCKED_IO and deschedule.
     197        // it is re-activated by the ISR signaling IO operation completion.
     198        chdev_register_command( dev_xp );
     199
     200        // get I/O operation status from calling thread descriptor
     201        error = this->txt_cmd.error;
    220202
    221203        if( error )
     
    251233#endif
    252234
     235    thread_t * this = CURRENT_THREAD;
     236
    253237#if DEBUG_DEV_TXT_RX
    254 thread_t * this  = CURRENT_THREAD;
    255238uint32_t   cycle = (uint32_t)hal_get_cycles();
    256239if( DEBUG_DEV_TXT_RX < cycle )
     
    259242#endif
    260243
    261     // register command in chdev queue for an asynchronous access
    262     error = dev_txt_access( TXT_READ , channel , buffer , 1 );
     244// check channel argument
     245assert( (channel < CONFIG_MAX_TXT_CHANNELS) , "illegal channel index" );
     246
     247    // get pointers on chdev
     248    xptr_t    dev_xp  = chdev_dir.txt_rx[channel];
     249
     250// check dev_xp
     251assert( (dev_xp != XPTR_NULL) , "undefined TXT chdev descriptor" );
     252
     253    // register command in calling thread descriptor
     254    this->txt_cmd.dev_xp  = dev_xp;
     255    this->txt_cmd.type    = TXT_READ;
     256    this->txt_cmd.buf_xp  = XPTR( local_cxy , buffer );
     257    this->txt_cmd.count   = 1;
     258
     259    // register client thread in waiting queue, activate server thread
     260    // block client thread on THREAD_BLOCKED_IO and deschedule.
     261    // it is re-activated by the ISR signaling IO operation completion.
     262    chdev_register_command( dev_xp );
     263
     264    // get I/O operation status from calling thread descriptor
     265    error = this->txt_cmd.error;
    263266
    264267    if( error )
    265268    {
    266         printk("\n[ERROR] in %s : cannot get character / cycle %d\n",
    267         __FUNCTION__, (uint32_t)hal_get_cycles() );
     269         printk("\n[ERROR] in %s : cannot write string %s / cycle %d\n",
     270         __FUNCTION__, buffer, (uint32_t)hal_get_cycles() );
    268271    }
    269272
Note: See TracChangeset for help on using the changeset viewer.