Ignore:
Timestamp:
Dec 27, 2018, 7:38:58 PM (3 years ago)
Author:
alain
Message:

Fix several bugs in VFS to support the following
ksh commandis : cp, mv, rm, mkdir, cd, pwd

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/hal/tsar_mips32/drivers/soclib_bdv.c

    r570 r610  
    3232void soclib_bdv_init( chdev_t * chdev )
    3333{
    34     // get extended pointer on SOCLIB_BDV peripheral base address
     34    // get extended pointer on SOCLIB_BDV peripheral base
    3535        xptr_t  bdv_xp = chdev->base;
    3636
     
    6262    xptr_t     buf_xp;
    6363    xptr_t     ioc_xp;
     64    uint32_t   status;      // I/0 operation status (from BDV)
     65    reg_t      save_sr;     // for critical section
     66    uint32_t   op;          // BDV_OP_READ / BDV_OP_WRITE
    6467
    6568    // get client thread cluster and local pointer
     
    6770    thread_t * th_ptr = GET_PTR( th_xp );
    6871
     72#if (DEBUG_HAL_IOC_RX || DEBUG_HAL_IOC_TX)
     73uint32_t    cycle        = (uint32_t)hal_get_cycles();
     74thread_t  * this         = CURRENT_THREAD;
     75process_t * process      = hal_remote_lpt( XPTR( th_cxy , &th_ptr->process ) );
     76pid_t       client_pid   = hal_remote_l32( XPTR( th_cxy , &process->pid ) );
     77trdid_t     client_trdid = hal_remote_l32( XPTR( th_cxy , &th_ptr->trdid ) );
     78#endif
     79
    6980    // get command arguments and extended pointer on IOC device
    70     cmd_type =         hal_remote_l32 ( XPTR( th_cxy , &th_ptr->ioc_cmd.type   ) );
    71     lba      =         hal_remote_l32 ( XPTR( th_cxy , &th_ptr->ioc_cmd.lba    ) );
    72     count    =         hal_remote_l32 ( XPTR( th_cxy , &th_ptr->ioc_cmd.count  ) );
     81    cmd_type =         hal_remote_l32( XPTR( th_cxy , &th_ptr->ioc_cmd.type   ) );
     82    lba      =         hal_remote_l32( XPTR( th_cxy , &th_ptr->ioc_cmd.lba    ) );
     83    count    =         hal_remote_l32( XPTR( th_cxy , &th_ptr->ioc_cmd.count  ) );
    7384    buf_xp   = (xptr_t)hal_remote_l64( XPTR( th_cxy , &th_ptr->ioc_cmd.buf_xp ) );
    7485    ioc_xp   = (xptr_t)hal_remote_l64( XPTR( th_cxy , &th_ptr->ioc_cmd.dev_xp ) );
    7586
    7687#if DEBUG_HAL_IOC_RX
    77 uint32_t cycle = (uint32_t)hal_get_cycles();
    7888if( (DEBUG_HAL_IOC_RX < cycle) && (cmd_type != IOC_WRITE ) )
    79 printk("\n[DBG] %s : thread %x enter for RX / cycle %d\n",
    80 __FUNCTION__ , CURRENT_THREAD , cycle );
    81 #endif
    82 
    83 #if DEBUG_HAL_IOC_TX
    84 uint32_t cycle = (uint32_t)hal_get_cycles();
     89printk("\n[%s] thread[%x,%x] enters for client thread[%x,%x] / RX / cycle %d\n",
     90__FUNCTION__ , this->process->pid, this->trdid, client_pid, client_trdid, cycle );
     91#endif
     92
     93#if DEBUG_HAL_IOC_TX
    8594if( (DEBUG_HAL_IOC_TX < cycle) && (cmd_type == IOC_WRITE) )
    86 printk("\n[DBG] %s : thread %x enter for TX / cycle %d\n",
    87 __FUNCTION__ , CURRENT_THREAD , cycle );
     95printk("\n[%s] thread[%x,%x] enters for client thread[%x,%x] / TX / cycle %d\n",
     96__FUNCTION__ , this->process->pid, this->trdid, client_pid, client_trdid, cycle );
    8897#endif
    8998
     
    101110    uint32_t   buf_msb = (uint32_t)(buf_xp>>32);
    102111
    103     // set operation
    104     uint32_t   op;
     112    // select operation
    105113    if( cmd_type == IOC_WRITE ) op = BDV_OP_WRITE;
    106114    else                        op = BDV_OP_READ;
    107115
    108     // set SOCLIB_BDV registers to start one I/O operation
     116    // set SOCLIB_BDV registers to configure the I/O operation
    109117    hal_remote_s32( XPTR( seg_cxy , seg_ptr + BDV_IRQ_ENABLE_REG ) , 1       );
    110118    hal_remote_s32( XPTR( seg_cxy , seg_ptr + BDV_BUFFER_REG     ) , buf_lsb );
     
    112120    hal_remote_s32( XPTR( seg_cxy , seg_ptr + BDV_LBA_REG        ) , lba     );
    113121    hal_remote_s32( XPTR( seg_cxy , seg_ptr + BDV_COUNT_REG      ) , count   );
    114     hal_remote_s32( XPTR( seg_cxy , seg_ptr + BDV_OP_REG         ) , op      );
    115122
    116123    // waiting policy  depends on the command type
    117124    // - for IOC_READ / IOC_WRITE commands, this function is called by the server thread
    118     // - for IOC_SYNC_READ command, this function is directly called by the client thread
     125    //   that blocks and deschedules after launching the I/O transfer.
     126    //   The I/O operation status is reported in the command by the ISR.
     127    // - for IOC_SYNC_READ command, this function is called by the client thread
     128    //   that polls the BDV status register until I/O transfer completion.
    119129
    120130    if( cmd_type == IOC_SYNC_READ )                   // status polling policy
    121131    {
    122         uint32_t status;
     132        // launch I/O operation on BDV device
     133        hal_remote_s32( XPTR( seg_cxy , seg_ptr + BDV_OP_REG ) , op );
     134       
     135        // wait completion
    123136        while (1)
    124137        {
     
    143156    else                                            // descheduling + IRQ policy
    144157    {
     158        // enter critical section to atomically
     159        // lauch I/O operation and deschedule 
     160        hal_disable_irq( &save_sr );
     161
     162        // launch I/O operation on BDV device
     163        hal_remote_s32( XPTR( seg_cxy , seg_ptr + BDV_OP_REG ) , op );
     164       
     165        // server thread blocks on ISR
    145166        thread_block( XPTR( local_cxy , CURRENT_THREAD ) , THREAD_BLOCKED_ISR );
     167
     168#if DEBUG_HAL_IOC_RX
     169if( (DEBUG_HAL_IOC_RX < cycle) && (cmd_type != IOC_WRITE ) )
     170printk("\n[%s] thread[%x,%x] blocks & deschedules after lauching RX transfer\n",
     171__FUNCTION__ , this->process->pid, this->trdid );
     172#endif
     173
     174#if DEBUG_HAL_IOC_TX
     175if( (DEBUG_HAL_IOC_TX < cycle) && (cmd_type == IOC_WRITE) )
     176printk("\n[%s] thread[%x,%x] blocks & deschedules after lauching TX transfer\n",
     177__FUNCTION__ , this->process->pid, this->trdid );
     178#endif
     179        // server thread deschedules
    146180        sched_yield("blocked on ISR");
    147181
    148         // the IO operation status is reported in the command by the ISR
     182        // exit critical section
     183        hal_restore_irq( save_sr );
    149184    }
    150185   
    151186#if DEBUG_HAL_IOC_RX
    152187cycle = (uint32_t)hal_get_cycles();
    153 if( (DEBUG_HAL_IOC_RX < cycle) && (cmd_type != TXT_WRITE) )
    154 printk("\n[DBG] %s : thread %x exit after RX / cycle %d\n",
    155 __FUNCTION__ , CURRENT_THREAD , cycle );
     188if( (DEBUG_HAL_IOC_RX < cycle) && (cmd_type != IOC_WRITE) )
     189printk("\n[%s] thread[%x,%x] exit after RX for client thread[%x,%x] / cycle %d\n",
     190__FUNCTION__, this->process->pid, this->trdid, client_pid, client_trdid, cycle );
    156191#endif
    157192
    158193#if DEBUG_HAL_IOC_TX
    159194cycle = (uint32_t)hal_get_cycles();
    160 if( (DEBUG_HAL_IOC_TX < cycle) && (cmd_type == TXT_WRITE) )
    161 printk("\n[DBG] %s : thread %x exit after TX / cycle %d\n",
    162 __FUNCTION__ , CURRENT_THREAD , cycle );
     195if( (DEBUG_HAL_IOC_TX < cycle) && (cmd_type == IOC_WRITE) )
     196printk("\n[%s] thread[%x,%x] exit after TX for client thread[%x,%x] / cycle %d\n",
     197__FUNCTION__, this->process->pid, this->trdid, client_pid, client_trdid, cycle );
    163198#endif
    164199
     
    171206    error_t  error = 0;
    172207
     208    // get extended pointer on server thread
     209    xptr_t server_xp = XPTR( local_cxy , chdev->server );
     210
    173211    // get extended pointer on client thread
    174     xptr_t root = XPTR( local_cxy , &chdev->wait_root );
     212    xptr_t root      = XPTR( local_cxy , &chdev->wait_root );
    175213    xptr_t client_xp = XLIST_FIRST( root , thread_t , wait_list );
    176 
    177     // get extended pointer on server thread
    178     xptr_t server_xp = XPTR( local_cxy , &chdev->server );
    179214
    180215    // get client thread cluster and local pointer
    181216    cxy_t      client_cxy = GET_CXY( client_xp );
    182     thread_t * client_ptr = (thread_t *)GET_PTR( client_xp );
     217    thread_t * client_ptr = GET_PTR( client_xp );
    183218
    184219    // get command type
    185220    uint32_t   cmd_type = hal_remote_l32( XPTR( client_cxy , &client_ptr->ioc_cmd.type ) );
    186221   
     222#if (DEBUG_HAL_IOC_RX || DEBUG_HAL_IOC_TX)
     223uint32_t    cycle        = (uint32_t)hal_get_cycles();
     224process_t * process      = hal_remote_lpt( XPTR( client_cxy , &client_ptr->process ) );
     225pid_t       client_pid   = hal_remote_l32( XPTR( client_cxy , &process->pid ) );
     226trdid_t     client_trdid = hal_remote_l32( XPTR( client_cxy , &client_ptr->trdid ) );
     227thread_t  * server       = GET_PTR( server_xp );
     228pid_t       server_pid   = server->process->pid;
     229trdid_t     server_trdid = server->trdid;
     230#endif
     231
    187232    // get SOCLIB_BDV device cluster and local pointer
    188233    cxy_t      bdv_cxy  = GET_CXY( chdev->base );
    189     uint32_t * bdv_ptr  = (uint32_t *)GET_PTR( chdev->base );
     234    uint32_t * bdv_ptr  = GET_PTR( chdev->base );
    190235
    191236    // get BDV status register and acknowledge IRQ
     
    197242
    198243#if DEBUG_HAL_IOC_RX
    199 uint32_t cycle = (uint32_t)hal_get_cycles();
    200244if( DEBUG_HAL_IOC_RX < cycle )
    201 printk("\n[DBG] %s : IOC_IRQ / RX transfer / client %x / server %x / cycle %d\n",
    202 __FUNCTION__, client_ptr , chdev->server , cycle );
     245printk("\n[%s] RX transfer completed for client[%x,%x] / server[%x,%x] / cycle %d\n",
     246__FUNCTION__, client_pid, client_trdid, server_pid, server_trdid, cycle );
    203247#endif
    204248
     
    209253
    210254#if DEBUG_HAL_IOC_TX
    211 uint32_t cycle = (uint32_t)hal_get_cycles();
    212255if( DEBUG_HAL_IOC_TX < cycle )
    213 printk("\n[DBG] %s : IOC_IRQ / RX transfer / client %x / server %x / cycle %d\n",
    214 __FUNCTION__, client_ptr , chdev->server , cycle );
     256printk("\n[%s] TX transfer completed for client[%x,%x] / server[%x,%x] / cycle %d\n",
     257__FUNCTION__, client_pid, client_trdid, server_pid, server_trdid, cycle );
    215258#endif
    216259
Note: See TracChangeset for help on using the changeset viewer.