Ignore:
Timestamp:
Jun 18, 2017, 10:06:41 PM (7 years ago)
Author:
alain
Message:

Introduce syscalls.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/drivers/soclib/soclib_bdv.c

    r4 r23  
    5353void __attribute__ ((noinline)) soclib_bdv_cmd( xptr_t th_xp )
    5454{
    55     uint32_t   to_mem;       // command argument
     55    uint32_t   cmd_type;     // IOC_READ / IOC_WRITE / IOC_SYNC_READ
    5656    uint32_t   lba;          // command argument
    5757    uint32_t   count;        // command argument
     
    6464
    6565    // get command arguments and extended pointer on IOC device
    66     to_mem =         hal_remote_lw ( XPTR( th_cxy , &th_ptr->command.ioc.to_mem ) );
    67     lba    =         hal_remote_lw ( XPTR( th_cxy , &th_ptr->command.ioc.lba    ) );
    68     count  =         hal_remote_lw ( XPTR( th_cxy , &th_ptr->command.ioc.count  ) );
    69     buf_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr->command.ioc.buf_xp ) );
    70     dev_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr->command.ioc.dev_xp ) );
     66    cmd_type =         hal_remote_lw ( XPTR( th_cxy , &th_ptr->command.ioc.type  ) );
     67    lba      =         hal_remote_lw ( XPTR( th_cxy , &th_ptr->command.ioc.lba    ) );
     68    count    =         hal_remote_lw ( XPTR( th_cxy , &th_ptr->command.ioc.count  ) );
     69    buf_xp   = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr->command.ioc.buf_xp ) );
     70    dev_xp   = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr->command.ioc.dev_xp ) );
    7171
    7272    // get IOC device cluster and local pointer
     
    8585    uint32_t   buf_msb = (uint32_t)(buf_xp>>32);
    8686
    87     // get access type
    88     uint32_t   type =  to_mem ? BDV_OP_READ : BDV_OP_WRITE;
     87    // set operation
     88    uint32_t   op;
     89    if( cmd_type == IOC_WRITE ) op = BDV_OP_WRITE;
     90    else                        op = BDV_OP_READ;
    8991
    9092    // set SOCLIB_BDV registers to start one I/O operation
     
    9496    hal_remote_sw( XPTR( bdv_cxy , bdv_ptr + BDV_LBA_REG        ) , lba     );
    9597    hal_remote_sw( XPTR( bdv_cxy , bdv_ptr + BDV_COUNT_REG      ) , count   );
    96     hal_remote_sw( XPTR( bdv_cxy , bdv_ptr + BDV_OP_REG         ) , type    );
     98    hal_remote_sw( XPTR( bdv_cxy , bdv_ptr + BDV_OP_REG         ) , op      );
    9799
    98     // Block and deschedule server thread
    99     thread_block( CURRENT_THREAD , THREAD_BLOCKED_DEV_ISR );
    100     sched_yield();
     100    // waiting policy  depends on the command type
     101
     102    if( cmd_type == IOC_SYNC_READ )                  // polling policy
     103    {
     104        uint32_t status;
     105        while (1)
     106        {
     107            status = hal_remote_lw( XPTR( bdv_cxy , bdv_ptr + BDV_STATUS_REG ) );
     108
     109            if( status == BDV_READ_SUCCESS ) // successfully completed
     110            {
     111                hal_remote_sw( XPTR( th_cxy , &th_ptr->command.ioc.error ) , 0 );
     112                break;
     113            }
     114            else if( status == BDV_BUSY )   // non completed
     115            {
     116                continue;
     117            }
     118            else                            // error reported
     119            {
     120                hal_remote_sw( XPTR( th_cxy , &th_ptr->command.ioc.error ) , 1 );
     121                break;
     122            }
     123        }
     124    }
     125    else                                            // descheduling + IRQ policy
     126    {
     127        thread_block( CURRENT_THREAD , THREAD_BLOCKED_DEV_ISR );
     128        sched_yield();
     129    }
    101130   
    102131} // end soclib_bdv_cmd()
Note: See TracChangeset for help on using the changeset viewer.