Changeset 23 for trunk/kernel/drivers/soclib/soclib_bdv.c
- Timestamp:
- Jun 18, 2017, 10:06:41 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/drivers/soclib/soclib_bdv.c
r4 r23 53 53 void __attribute__ ((noinline)) soclib_bdv_cmd( xptr_t th_xp ) 54 54 { 55 uint32_t to_mem; // command argument55 uint32_t cmd_type; // IOC_READ / IOC_WRITE / IOC_SYNC_READ 56 56 uint32_t lba; // command argument 57 57 uint32_t count; // command argument … … 64 64 65 65 // 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 ) ); 71 71 72 72 // get IOC device cluster and local pointer … … 85 85 uint32_t buf_msb = (uint32_t)(buf_xp>>32); 86 86 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; 89 91 90 92 // set SOCLIB_BDV registers to start one I/O operation … … 94 96 hal_remote_sw( XPTR( bdv_cxy , bdv_ptr + BDV_LBA_REG ) , lba ); 95 97 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 ); 97 99 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 } 101 130 102 131 } // end soclib_bdv_cmd()
Note: See TracChangeset
for help on using the changeset viewer.