Ignore:
Timestamp:
Nov 20, 2020, 12:04:01 AM (4 years ago)
Author:
alain
Message:

1) Introduce up to 4 command lines arguments in the KSH "load" command.
These arguments are transfered to the user process through the
argc/argv mechanism, using the user space "args" vseg.

2) Introduce the named and anonymous "pipes", for inter-process communication
through the pipe() and mkfifo() syscalls.

3) Introduce the "chat" application to validate the two above mechanisms.

4) Improve printk() and assert() fonctions in printk.c.

File:
1 edited

Legend:

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

    r668 r674  
    5454
    5555    // set chdev name
    56     if( is_rx ) snprintf( chdev->name , 16 , "nic%d_rx" , channel );
    57     else        snprintf( chdev->name , 16 , "nic%d_tx" , channel );
     56    if( is_rx ) snprintk( chdev->name , 16 , "nic%d_rx" , channel );
     57    else        snprintk( chdev->name , 16 , "nic%d_tx" , channel );
    5858
    5959    // initialize the root of the listening sockets list
     
    360360
    361361///////////////////////////////////////////////////////////////////////////////////////////
    362 // This static function can be called by the NIC_TX or NIC_RX server threads to unblock
     362// This static function is called by the NIC_TX or NIC_RX server threads to unblock
    363363// the TX client thread after completion (success or error) of a TX command registered
    364364// in a socket identified by the <socket_xp> argument. The <status> argument defines
     
    401401
    402402///////////////////////////////////////////////////////////////////////////////////////////
    403 // This static function can be called by the NIC_TX or NIC_RX server threads to unblock
     403// This static function is called by the NIC_TX or NIC_RX server threads to unblock
    404404// the RX client thread after completion (success or error) of an RX command registered
    405405// in a socket identified by the <socket_xp> argument. The <status> argument defines
     
    440440
    441441}  // end dev_nic_unblock_rx_client()
    442 
    443 
    444442
    445443///////////////////////////////////////////////////////////////////////////////////////////
     
    680678    // get status & space from rx_buf
    681679    status = remote_buf_status( socket_rbuf_xp );
    682     space  = NIC_RX_BUF_SIZE - status;
     680    space  = CONFIG_SOCK_RX_BUF_SIZE - status;
    683681
    684682    // get client thread
     
    12681266
    12691267                        // compute empty space in rx_buf
    1270                         uint32_t space = NIC_RX_BUF_SIZE - status;
     1268                        uint32_t space = CONFIG_SOCK_RX_BUF_SIZE - status;
    12711269
    12721270                        // compute number of bytes to move : min (space , seg_data_len)
     
    14061404                        // update socket.state
    14071405                        hal_remote_s32( XPTR( socket_cxy , &socket_ptr->state ),
    1408                                         TCP_STATE_CLOSED );  // TODO change to TIME_WAIT
     1406                                        TCP_STATE_CLOSED );
    14091407
    14101408                        // make an ACK request to R2T queue
     
    14151413                        // report success to TX client thread
    14161414                        dev_nic_unblock_tx_client( socket_xp , CMD_STS_SUCCESS );
    1417 
    1418                         // TODO start the MSL timer / turn off others timers
    1419 
    14201415                    }
    14211416                }
     
    14241419                    // update socket.state
    14251420                    hal_remote_s32( XPTR( socket_cxy , &socket_ptr->state ),
    1426                                     TCP_STATE_CLOSED );  // todo change to TIME_WAIT
    1427 
    1428                     // TODO start the MSL timer / turn off others timers
    1429 
    1430                 }
    1431                 else if( socket_state == TCP_STATE_TIME_WAIT )
    1432                 {
    1433                     // TODO wait msl_time_out before unblocking TX thread
    1434 
    1435                     // update socket.state when ACK received
    1436                     hal_remote_s32( XPTR( socket_cxy , &socket_ptr->state ),
    1437                                     TCP_STATE_CLOSED );
    1438 
    1439                     // unblock TX client thead for success
     1421                                    TCP_STATE_CLOSED ); 
     1422
     1423                    // report success to TX client thread
    14401424                    dev_nic_unblock_tx_client( socket_xp , CMD_STS_SUCCESS );
     1425
    14411426                }
    14421427                else if( socket_state == TCP_STATE_CLOSE_WAIT )
     
    14911476               
    14921477// check socket type and state
    1493 assert( (socket_type  == SOCK_STREAM ) , "illegal socket type" );
    1494 assert( (socket_state == TCP_STATE_LISTEN ) , "illegal socket state" );
     1478assert( __FUNCTION__, (socket_type  == SOCK_STREAM ) , "illegal socket type" );
     1479assert( __FUNCTION__, (socket_state == TCP_STATE_LISTEN ) , "illegal socket state" );
    14951480
    14961481        // get relevant socket infos for matching
     
    16381623
    16391624// check chdev direction and type
    1640 assert( (chdev->func == DEV_FUNC_NIC) && (chdev->is_rx == true) ,
     1625assert( __FUNCTION__, (chdev->func == DEV_FUNC_NIC) && (chdev->is_rx == true) ,
    16411626"illegal chdev type or direction" );
    16421627
     
    23742359                    // initialize socket tx_nxt, and rx_wnd
    23752360                    hal_remote_s32(XPTR(socket_cxy , &socket_ptr->tx_nxt), TCP_ISS_SERVER );
    2376                     hal_remote_s32(XPTR(socket_cxy , &socket_ptr->rx_wnd), NIC_RX_BUF_SIZE);
     2361                    hal_remote_s32(XPTR(socket_cxy , &socket_ptr->rx_wnd), CONFIG_SOCK_RX_BUF_SIZE);
    23772362               
    23782363                    // build TCP ACK-SYN segment
     
    26242609void dev_nic_tx_server( chdev_t * chdev )
    26252610{
    2626     uint8_t       k_buf[NIC_KERNEL_BUF_SIZE];  // buffer for one packet
     2611    uint8_t       k_buf[CONFIG_SOCK_PKT_BUF_SIZE];  // buffer for one packet
    26272612
    26282613    xptr_t        queue_root_xp;       // extended pointer on sockets list root
     
    26502635
    26512636// check chdev direction and type
    2652 assert( (chdev->func == DEV_FUNC_NIC) && (chdev->is_rx == false) ,
     2637assert( __FUNCTION__, (chdev->func == DEV_FUNC_NIC) && (chdev->is_rx == false) ,
    26532638"illegal chdev type or direction" );
    26542639
Note: See TracChangeset for help on using the changeset viewer.