Changeset 610 for trunk/hal/tsar_mips32/drivers
- Timestamp:
- Dec 27, 2018, 7:38:58 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/tsar_mips32/drivers/soclib_bdv.c
r570 r610 32 32 void soclib_bdv_init( chdev_t * chdev ) 33 33 { 34 // get extended pointer on SOCLIB_BDV peripheral base address34 // get extended pointer on SOCLIB_BDV peripheral base 35 35 xptr_t bdv_xp = chdev->base; 36 36 … … 62 62 xptr_t buf_xp; 63 63 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 64 67 65 68 // get client thread cluster and local pointer … … 67 70 thread_t * th_ptr = GET_PTR( th_xp ); 68 71 72 #if (DEBUG_HAL_IOC_RX || DEBUG_HAL_IOC_TX) 73 uint32_t cycle = (uint32_t)hal_get_cycles(); 74 thread_t * this = CURRENT_THREAD; 75 process_t * process = hal_remote_lpt( XPTR( th_cxy , &th_ptr->process ) ); 76 pid_t client_pid = hal_remote_l32( XPTR( th_cxy , &process->pid ) ); 77 trdid_t client_trdid = hal_remote_l32( XPTR( th_cxy , &th_ptr->trdid ) ); 78 #endif 79 69 80 // get command arguments and extended pointer on IOC device 70 cmd_type = hal_remote_l32 71 lba = hal_remote_l32 72 count = hal_remote_l32 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 ) ); 73 84 buf_xp = (xptr_t)hal_remote_l64( XPTR( th_cxy , &th_ptr->ioc_cmd.buf_xp ) ); 74 85 ioc_xp = (xptr_t)hal_remote_l64( XPTR( th_cxy , &th_ptr->ioc_cmd.dev_xp ) ); 75 86 76 87 #if DEBUG_HAL_IOC_RX 77 uint32_t cycle = (uint32_t)hal_get_cycles();78 88 if( (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(); 89 printk("\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 85 94 if( (DEBUG_HAL_IOC_TX < cycle) && (cmd_type == IOC_WRITE) ) 86 printk("\n[ DBG] %s : thread %x enter forTX / cycle %d\n",87 __FUNCTION__ , CURRENT_THREAD, cycle );95 printk("\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 ); 88 97 #endif 89 98 … … 101 110 uint32_t buf_msb = (uint32_t)(buf_xp>>32); 102 111 103 // set operation 104 uint32_t op; 112 // select operation 105 113 if( cmd_type == IOC_WRITE ) op = BDV_OP_WRITE; 106 114 else op = BDV_OP_READ; 107 115 108 // set SOCLIB_BDV registers to start one I/O operation116 // set SOCLIB_BDV registers to configure the I/O operation 109 117 hal_remote_s32( XPTR( seg_cxy , seg_ptr + BDV_IRQ_ENABLE_REG ) , 1 ); 110 118 hal_remote_s32( XPTR( seg_cxy , seg_ptr + BDV_BUFFER_REG ) , buf_lsb ); … … 112 120 hal_remote_s32( XPTR( seg_cxy , seg_ptr + BDV_LBA_REG ) , lba ); 113 121 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 );115 122 116 123 // waiting policy depends on the command type 117 124 // - 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. 119 129 120 130 if( cmd_type == IOC_SYNC_READ ) // status polling policy 121 131 { 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 123 136 while (1) 124 137 { … … 143 156 else // descheduling + IRQ policy 144 157 { 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 145 166 thread_block( XPTR( local_cxy , CURRENT_THREAD ) , THREAD_BLOCKED_ISR ); 167 168 #if DEBUG_HAL_IOC_RX 169 if( (DEBUG_HAL_IOC_RX < cycle) && (cmd_type != IOC_WRITE ) ) 170 printk("\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 175 if( (DEBUG_HAL_IOC_TX < cycle) && (cmd_type == IOC_WRITE) ) 176 printk("\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 146 180 sched_yield("blocked on ISR"); 147 181 148 // the IO operation status is reported in the command by the ISR 182 // exit critical section 183 hal_restore_irq( save_sr ); 149 184 } 150 185 151 186 #if DEBUG_HAL_IOC_RX 152 187 cycle = (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 );188 if( (DEBUG_HAL_IOC_RX < cycle) && (cmd_type != IOC_WRITE) ) 189 printk("\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 ); 156 191 #endif 157 192 158 193 #if DEBUG_HAL_IOC_TX 159 194 cycle = (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 );195 if( (DEBUG_HAL_IOC_TX < cycle) && (cmd_type == IOC_WRITE) ) 196 printk("\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 ); 163 198 #endif 164 199 … … 171 206 error_t error = 0; 172 207 208 // get extended pointer on server thread 209 xptr_t server_xp = XPTR( local_cxy , chdev->server ); 210 173 211 // 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 ); 175 213 xptr_t client_xp = XLIST_FIRST( root , thread_t , wait_list ); 176 177 // get extended pointer on server thread178 xptr_t server_xp = XPTR( local_cxy , &chdev->server );179 214 180 215 // get client thread cluster and local pointer 181 216 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 ); 183 218 184 219 // get command type 185 220 uint32_t cmd_type = hal_remote_l32( XPTR( client_cxy , &client_ptr->ioc_cmd.type ) ); 186 221 222 #if (DEBUG_HAL_IOC_RX || DEBUG_HAL_IOC_TX) 223 uint32_t cycle = (uint32_t)hal_get_cycles(); 224 process_t * process = hal_remote_lpt( XPTR( client_cxy , &client_ptr->process ) ); 225 pid_t client_pid = hal_remote_l32( XPTR( client_cxy , &process->pid ) ); 226 trdid_t client_trdid = hal_remote_l32( XPTR( client_cxy , &client_ptr->trdid ) ); 227 thread_t * server = GET_PTR( server_xp ); 228 pid_t server_pid = server->process->pid; 229 trdid_t server_trdid = server->trdid; 230 #endif 231 187 232 // get SOCLIB_BDV device cluster and local pointer 188 233 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 ); 190 235 191 236 // get BDV status register and acknowledge IRQ … … 197 242 198 243 #if DEBUG_HAL_IOC_RX 199 uint32_t cycle = (uint32_t)hal_get_cycles();200 244 if( DEBUG_HAL_IOC_RX < cycle ) 201 printk("\n[ DBG] %s : IOC_IRQ / RX transfer / client %x / server %x/ cycle %d\n",202 __FUNCTION__, client_p tr , chdev->server, cycle );245 printk("\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 ); 203 247 #endif 204 248 … … 209 253 210 254 #if DEBUG_HAL_IOC_TX 211 uint32_t cycle = (uint32_t)hal_get_cycles();212 255 if( DEBUG_HAL_IOC_TX < cycle ) 213 printk("\n[ DBG] %s : IOC_IRQ / RX transfer / client %x / server %x/ cycle %d\n",214 __FUNCTION__, client_p tr , chdev->server, cycle );256 printk("\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 ); 215 258 #endif 216 259
Note: See TracChangeset
for help on using the changeset viewer.