Changeset 657 for trunk/kernel/devices/dev_txt.c
- Timestamp:
- Mar 18, 2020, 11:16:59 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/devices/dev_txt.c
r647 r657 133 133 } // end dev_txt_init() 134 134 135 //////////////////////////////////////////////////////////////////////////////////136 // This static function is called by dev_txt_read(), dev_txt_write() functions.137 ////////////////////////////////////i/////////////////////////////////////////////138 static error_t dev_txt_access( uint32_t type,139 uint32_t channel,140 char * buffer,141 uint32_t count )142 {143 xptr_t dev_xp;144 thread_t * this = CURRENT_THREAD;145 146 // check channel argument147 assert( (channel < CONFIG_MAX_TXT_CHANNELS) , "illegal channel index" );148 149 // get extended pointer on remote TXT chdev descriptor150 if( type == TXT_WRITE ) dev_xp = chdev_dir.txt_tx[channel];151 else dev_xp = chdev_dir.txt_rx[channel];152 153 assert( (dev_xp != XPTR_NULL) , "undefined TXT chdev descriptor" );154 155 // register command in calling thread descriptor156 this->txt_cmd.dev_xp = dev_xp;157 this->txt_cmd.type = type;158 this->txt_cmd.buf_xp = XPTR( local_cxy , buffer );159 this->txt_cmd.count = count;160 161 // register client thread in waiting queue, activate server thread162 // block client thread on THREAD_BLOCKED_IO and deschedule.163 // it is re-activated by the ISR signaling IO operation completion.164 chdev_register_command( dev_xp );165 166 // return I/O operation status from calling thread descriptor167 return this->txt_cmd.error;168 169 } // end dev_txt_access()170 171 135 ///////////////////////////////////////// 172 136 error_t dev_txt_write( uint32_t channel, … … 180 144 #endif 181 145 146 thread_t * this = CURRENT_THREAD; 147 182 148 #if DEBUG_DEV_TXT_TX 183 thread_t * this = CURRENT_THREAD;184 149 uint32_t cycle = (uint32_t)hal_get_cycles(); 185 150 if( DEBUG_DEV_TXT_TX < cycle ) … … 188 153 #endif 189 154 155 // check channel argument 156 assert( (channel < CONFIG_MAX_TXT_CHANNELS) , "illegal channel index" ); 157 158 // get pointers on chdev 159 xptr_t dev_xp = chdev_dir.txt_tx[channel]; 160 cxy_t dev_cxy = GET_CXY( dev_xp ); 161 chdev_t * dev_ptr = GET_PTR( dev_xp ); 162 163 // check dev_xp 164 assert( (dev_xp != XPTR_NULL) , "undefined TXT chdev descriptor" ); 165 190 166 // If we use MTTY (vci_multi_tty), we do a synchronous write on TXT[0] 191 167 // If we use TTY (vci_tty_tsar), we do a standard asynchronous write 192 168 // TODO this is not very clean ... [AG] 193 169 194 // get pointers on chdev 195 xptr_t dev_xp = chdev_dir.txt_tx[0]; 196 cxy_t dev_cxy = GET_CXY( dev_xp ); 197 chdev_t * dev_ptr = GET_PTR( dev_xp ); 198 199 if( dev_ptr->impl == IMPL_TXT_MTY ) 170 if( dev_ptr->impl == IMPL_TXT_MTY ) 200 171 { 201 172 // get driver command function … … 216 187 else 217 188 { 218 // register command in chdev queue for an asynchronous access 219 error = dev_txt_access( TXT_WRITE , channel , buffer , count ); 189 // register command in calling thread descriptor 190 this->txt_cmd.dev_xp = dev_xp; 191 this->txt_cmd.type = TXT_WRITE; 192 this->txt_cmd.buf_xp = XPTR( local_cxy , buffer ); 193 this->txt_cmd.count = count; 194 195 // register client thread in waiting queue, activate server thread 196 // block client thread on THREAD_BLOCKED_IO and deschedule. 197 // it is re-activated by the ISR signaling IO operation completion. 198 chdev_register_command( dev_xp ); 199 200 // get I/O operation status from calling thread descriptor 201 error = this->txt_cmd.error; 220 202 221 203 if( error ) … … 251 233 #endif 252 234 235 thread_t * this = CURRENT_THREAD; 236 253 237 #if DEBUG_DEV_TXT_RX 254 thread_t * this = CURRENT_THREAD;255 238 uint32_t cycle = (uint32_t)hal_get_cycles(); 256 239 if( DEBUG_DEV_TXT_RX < cycle ) … … 259 242 #endif 260 243 261 // register command in chdev queue for an asynchronous access 262 error = dev_txt_access( TXT_READ , channel , buffer , 1 ); 244 // check channel argument 245 assert( (channel < CONFIG_MAX_TXT_CHANNELS) , "illegal channel index" ); 246 247 // get pointers on chdev 248 xptr_t dev_xp = chdev_dir.txt_rx[channel]; 249 250 // check dev_xp 251 assert( (dev_xp != XPTR_NULL) , "undefined TXT chdev descriptor" ); 252 253 // register command in calling thread descriptor 254 this->txt_cmd.dev_xp = dev_xp; 255 this->txt_cmd.type = TXT_READ; 256 this->txt_cmd.buf_xp = XPTR( local_cxy , buffer ); 257 this->txt_cmd.count = 1; 258 259 // register client thread in waiting queue, activate server thread 260 // block client thread on THREAD_BLOCKED_IO and deschedule. 261 // it is re-activated by the ISR signaling IO operation completion. 262 chdev_register_command( dev_xp ); 263 264 // get I/O operation status from calling thread descriptor 265 error = this->txt_cmd.error; 263 266 264 267 if( error ) 265 268 { 266 printk("\n[ERROR] in %s : cannot get character/ cycle %d\n",267 __FUNCTION__, (uint32_t)hal_get_cycles() );269 printk("\n[ERROR] in %s : cannot write string %s / cycle %d\n", 270 __FUNCTION__, buffer, (uint32_t)hal_get_cycles() ); 268 271 } 269 272
Note: See TracChangeset
for help on using the changeset viewer.