Ignore:
Timestamp:
Oct 22, 2019, 1:48:51 PM (5 years ago)
Author:
alain
Message:

...miscelaneous...

File:
1 edited

Legend:

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

    r626 r647  
    3333void soclib_bdv_init( chdev_t * chdev )
    3434{
    35     // get extended pointer on SOCLIB_BDV peripheral base
    36         xptr_t  bdv_xp = chdev->base;
    37 
    38     // set driver specific fields
     35    // set driver specific fields in IOC chdev
    3936    chdev->cmd = &soclib_bdv_cmd;
    4037    chdev->isr = &soclib_bdv_isr;
    4138
     39    // get extended pointer on SOCLIB_BDV peripheral base
     40        xptr_t  base_xp = chdev->base;
     41
    4242    // get hardware device cluster and local pointer
    43     cxy_t      bdv_cxy  = GET_CXY( bdv_xp );
    44     uint32_t * bdv_ptr  = (uint32_t *)GET_PTR( bdv_xp );
     43    cxy_t      base_cxy  = GET_CXY( base_xp );
     44    uint32_t * base_ptr  = GET_PTR( base_xp );
    4545
    4646    // get block_size and block_count 
    47         uint32_t block_size = hal_remote_l32( XPTR( bdv_cxy , bdv_ptr + BDV_BLOCK_SIZE_REG ) );
    48         uint32_t block_count = hal_remote_l32( XPTR( bdv_cxy , bdv_ptr + BDV_SIZE_REG ) );
    49 
    50     // set IOC device descriptor extension
     47        uint32_t block_size  = hal_remote_l32( XPTR( base_cxy , base_ptr + BDV_BLOCK_SIZE_REG ) );
     48        uint32_t block_count = hal_remote_l32( XPTR( base_cxy , base_ptr + BDV_SIZE_REG ) );
     49
     50    // set IOC chdev extension fields
    5151    chdev->ext.ioc.size  = block_size;
    5252    chdev->ext.ioc.count = block_count;
     
    9191    else     assert( false , "illegal command" );
    9292
    93     // get IOC device cluster and local pointer
     93    // get cluster and local pointer on IOC chdev
    9494    cxy_t      ioc_cxy = GET_CXY( ioc_xp );
    9595    chdev_t  * ioc_ptr = GET_PTR( ioc_xp );
     
    131131    // waiting policy  depends on the command type
    132132    // - for IOC_READ / IOC_WRITE commands, this function is called by the server thread
    133     //   that blocks and deschedules after launching the I/O transfer.
    134     //   The I/O operation status is reported in the command by the ISR.
    135     // - for IOC_SYNC_READ / IOC_SYNC_WRITE command, this function is called by the client
    136     //   thread that polls the BDV status register until I/O transfer completion.
     133    //   => block and deschedule after launching the I/O transfer.
     134    //   The I/O operation status is reported in the command by the ISR, and the
     135    //   server thread is re-activated by the ISR.
     136    // - for IOC_SYNC_READ / IOC_SYNC_WRITE, this function is called by the client thread
     137    //   => mask the IOC IRQ and poll the BDV status register until I/O transfer completion,
     138    //   and report status in the command.
    137139
    138140    if( (cmd_type == IOC_SYNC_READ) || (cmd_type == IOC_SYNC_WRITE) )  // polling policy
    139141    {
     142        // get core handling the IOC IRQ
     143        thread_t * server = (thread_t *)hal_remote_lpt( XPTR( ioc_cxy , &ioc_ptr->server ) );
     144        core_t   * core   = (core_t *)hal_remote_lpt( XPTR( ioc_cxy , &server->core ) );
     145        lid_t      lid    = (lid_t)hal_remote_l32( XPTR( ioc_cxy , &core->lid ) );
     146
     147        // mask the IOC IRQ
     148        dev_pic_disable_irq( lid , ioc_xp );
     149
    140150        // launch I/O operation on BDV device
    141151        hal_remote_s32( XPTR( seg_cxy , seg_ptr + BDV_OP_REG ) , op );
     
    149159                (status == BDV_WRITE_SUCCESS) ) // successfully completed
    150160            {
     161                // unmask IOC IRQ
     162                dev_pic_enable_irq( lid , ioc_xp );
     163
     164                // report success in command
    151165                hal_remote_s32( XPTR( th_cxy , &th_ptr->ioc_cmd.error ) , 0 );
    152166
     
    154168cycle = (uint32_t)hal_get_cycles();
    155169if( (DEBUG_HAL_IOC_RX < cycle) && (cmd_type == IOC_SYNC_READ) )
    156 printk("\n[%s] thread[%x,%x] exit after SYNC_READ for client thread[%x,%x] / cycle %d\n",
     170printk("\n[%s] thread[%x,%x] SYNC_READ success for client thread[%x,%x] / cycle %d\n",
    157171__FUNCTION__, this->process->pid, this->trdid, client_pid, client_trdid, cycle );
    158172#endif
     
    161175cycle = (uint32_t)hal_get_cycles();
    162176if( (DEBUG_HAL_IOC_TX < cycle) && (cmd_type == IOC_SYNC_WRITE) )
    163 printk("\n[%s] thread[%x,%x] exit after SYNC_WRITE for client thread[%x,%x] / cycle %d\n",
     177printk("\n[%s] thread[%x,%x] SYNC_WRITE success for client thread[%x,%x] / cycle %d\n",
    164178__FUNCTION__, this->process->pid, this->trdid, client_pid, client_trdid, cycle );
    165179#endif
     
    172186            else                               // error reported
    173187            {
     188                // unmask IOC IRQ
     189                dev_pic_enable_irq( lid , ioc_xp );
     190
     191                // report failure in command
    174192                hal_remote_s32( XPTR( th_cxy , &th_ptr->ioc_cmd.error ) , 1 );
     193
     194#if DEBUG_HAL_IOC_RX
     195cycle = (uint32_t)hal_get_cycles();
     196if( (DEBUG_HAL_IOC_RX < cycle) && (cmd_type == IOC_SYNC_READ) )
     197printk("\n[%s] thread[%x,%x] SYNC_READ failure for client thread[%x,%x] / cycle %d\n",
     198__FUNCTION__, this->process->pid, this->trdid, client_pid, client_trdid, cycle );
     199#endif
     200
     201#if DEBUG_HAL_IOC_TX
     202cycle = (uint32_t)hal_get_cycles();
     203if( (DEBUG_HAL_IOC_TX < cycle) && (cmd_type == IOC_SYNC_WRITE) )
     204printk("\n[%s] thread[%x,%x] SYNC_WRITE failure for client thread[%x,%x] / cycle %d\n",
     205__FUNCTION__, this->process->pid, this->trdid, client_pid, client_trdid, cycle );
     206#endif
    175207                break;
    176208            }
Note: See TracChangeset for help on using the changeset viewer.