Changeset 598 for trunk/kernel/fs/devfs.c
- Timestamp:
- Nov 10, 2018, 3:06:00 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/fs/devfs.c
r568 r598 104 104 105 105 #if DEBUG_DEVFS_INIT 106 uint32_t cycle = (uint32_t)hal_get_cycles(); 107 if( DEBUG_DEVFS_INIT < cycle ) 108 printk("\n[DBG] %s : thread %x in process %x created <dev> inode / cycle %d\n", 109 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid ,cycle ); 106 uint32_t cycle = (uint32_t)hal_get_cycles(); 107 thread_t * this = CURRENT_THREAD; 108 if( DEBUG_DEVFS_INIT < cycle ) 109 printk("\n[%s] thread[%x,%x] created <dev> inode / cycle %d\n", 110 __FUNCTION__, this->process->pid, this->trdid, cycle ); 110 111 #endif 111 112 … … 124 125 cycle = (uint32_t)hal_get_cycles(); 125 126 if( DEBUG_DEVFS_INIT < cycle ) 126 printk("\n[ DBG] %s : thread %x in process %xcreated <external> inode / cycle %d\n",127 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, cycle );127 printk("\n[%s] thread[%x,%x] created <external> inode / cycle %d\n", 128 __FUNCTION__, this->process->pid, this->trdid, cycle ); 128 129 #endif 129 130 … … 152 153 devfs_internal_inode_xp ); 153 154 #if DEBUG_DEVFS_INIT 154 uint32_t cycle = (uint32_t)hal_get_cycles(); 155 trdid_t trdid = CURRENT_THREAD->trdid; 156 pid_t pid = CURRENT_THREAD->process->pid; 157 if( DEBUG_DEVFS_INIT < cycle ) 158 printk("\n[DBG] %s : thread %x in process %x created <%s> in cluster %x / cycle %d\n", 159 __FUNCTION__, trdid, pid, node_name, local_cxy, cycle ); 155 uint32_t cycle = (uint32_t)hal_get_cycles(); 156 thread_t * this = CURRENT_THREAD; 157 if( DEBUG_DEVFS_INIT < cycle ) 158 printk("\n[%s] thread[%x,%x] created <%s> inode in cluster %x / cycle %d\n", 159 __FUNCTION__, this->process->pid, this->trdid, node_name, local_cxy, cycle ); 160 160 #endif 161 161 … … 175 175 cycle = (uint32_t)hal_get_cycles(); 176 176 if( DEBUG_DEVFS_INIT < cycle ) 177 printk("\n[ DBG] %s : thread %x in process %xcreated <mmc> inode in cluster %x\n",178 __FUNCTION__, t rdid, pid, local_cxy, cycle );177 printk("\n[%s] thread[%x,%x] created <mmc> inode in cluster %x\n", 178 __FUNCTION__, this->process->pid, this->trdid, local_cxy, cycle ); 179 179 #endif 180 180 … … 198 198 cycle = (uint32_t)hal_get_cycles(); 199 199 if( DEBUG_DEVFS_INIT < cycle ) 200 printk("\n[ DBG] %s : thread %x in process %xcreated <dma[%d]> inode in cluster %x\n",201 __FUNCTION__, t rdid, pid, channel, local_cxy, cycle );200 printk("\n[%s] thread [%x,%x] created <dma[%d]> inode in cluster %x\n", 201 __FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle ); 202 202 #endif 203 203 } … … 222 222 cycle = (uint32_t)hal_get_cycles(); 223 223 if( DEBUG_DEVFS_INIT < cycle ) 224 printk("\n[ DBG] %s : thread %x in process %xcreated <iob> inode in cluster %x\n",225 __FUNCTION__, t rdid, pid, local_cxy, cycle );224 printk("\n[%s] thread[%x,%x] created <iob> inode in cluster %x\n", 225 __FUNCTION__, this->process->pid, this->trdid, local_cxy, cycle ); 226 226 #endif 227 227 } … … 246 246 cycle = (uint32_t)hal_get_cycles(); 247 247 if( DEBUG_DEVFS_INIT < cycle ) 248 printk("\n[ DBG] %s : thread %x in process %xcreated <pic> inode in cluster %x\n",249 __FUNCTION__, t rdid, pid, local_cxy, cycle );248 printk("\n[%s] thread[%x,%x] created <pic> inode in cluster %x\n", 249 __FUNCTION__, this->process->pid, this->trdid, local_cxy, cycle ); 250 250 #endif 251 251 } … … 272 272 cycle = (uint32_t)hal_get_cycles(); 273 273 if( DEBUG_DEVFS_INIT < cycle ) 274 printk("\n[ DBG] %s : thread %x in process %xcreated <txt_rx[%d]> inode in cluster %x\n",275 __FUNCTION__, t rdid, pid, channel, local_cxy, cycle );274 printk("\n[%s] thread[%x,%x] created <txt_rx[%d]> inode in cluster %x\n", 275 __FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle ); 276 276 #endif 277 277 } … … 299 299 cycle = (uint32_t)hal_get_cycles(); 300 300 if( DEBUG_DEVFS_INIT < cycle ) 301 printk("\n[ DBG] %s : thread %x in process %xcreated <txt_tx[%d]> inode in cluster %x\n",302 __FUNCTION__, t rdid, pid, channel, local_cxy, cycle );301 printk("\n[%s] thread[%x,%x] created <txt_tx[%d]> inode in cluster %x\n", 302 __FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle ); 303 303 #endif 304 304 } … … 326 326 cycle = (uint32_t)hal_get_cycles(); 327 327 if( DEBUG_DEVFS_INIT < cycle ) 328 printk("\n[ DBG] %s : thread %x in process %xcreated <ioc[%d]> inode in cluster %x\n",329 __FUNCTION__, t rdid, pid, channel, local_cxy, cycle );328 printk("\n[%s] thread[%x,%x] created <ioc[%d]> inode in cluster %x\n", 329 __FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle ); 330 330 #endif 331 331 } … … 353 353 cycle = (uint32_t)hal_get_cycles(); 354 354 if( DEBUG_DEVFS_INIT < cycle ) 355 printk("\n[ DBG] %s : thread %x in process %xcreated <fbf[%d]> inode in cluster %x\n",356 __FUNCTION__, t rdid, pid, channel, local_cxy, cycle );355 printk("\n[%s] thread[%x,%x] created <fbf[%d]> inode in cluster %x\n", 356 __FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle ); 357 357 #endif 358 358 } … … 380 380 cycle = (uint32_t)hal_get_cycles(); 381 381 if( DEBUG_DEVFS_INIT < cycle ) 382 printk("\n[ DBG] %s : thread %x in process %xcreated <nic_rx[%d]> inode in cluster %x\n",383 __FUNCTION__, t rdid, pid, channel, local_cxy, cycle );382 printk("\n[%s] thread[%x,%x] created <nic_rx[%d]> inode in cluster %x\n", 383 __FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle ); 384 384 #endif 385 385 } … … 407 407 cycle = (uint32_t)hal_get_cycles(); 408 408 if( DEBUG_DEVFS_INIT < cycle ) 409 printk("\n[ DBG] %s : thread %x in process %xcreated <nic_tx[%d]> inode in cluster %x\n",410 __FUNCTION__, t rdid, pid, channel, local_cxy, cycle );409 printk("\n[%s] thread[%x,%x] created <nic_tx[%d]> inode in cluster %x\n", 410 __FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle ); 411 411 #endif 412 412 } … … 418 418 int devfs_user_move( bool_t to_buffer, 419 419 xptr_t file_xp, 420 void* u_buf,420 char * u_buf, 421 421 uint32_t size ) 422 422 { 423 assert( ( file_xp != XPTR_NULL ) , "file_xp == XPTR_NULL" ); 424 425 assert( ( size < CONFIG_TXT_KBUF_SIZE ) , "string size too large" ); 426 427 xptr_t chdev_xp; 428 cxy_t chdev_cxy; 429 chdev_t * chdev_ptr; // associated chdev type 430 uint32_t func; // chdev functionnal type 431 uint32_t channel; // chdev channel index 432 error_t error; 433 434 char k_buf[CONFIG_TXT_KBUF_SIZE]; // local kernel buffer 423 xptr_t chdev_xp; 424 cxy_t chdev_cxy; 425 chdev_t * chdev_ptr; // associated chdev type 426 uint32_t func; // chdev functionnal type 427 uint32_t channel; // chdev channel index 428 uint32_t burst; // number of bytes in a burst 429 uint32_t todo; // number of bytes not yet moved 430 error_t error; 431 uint32_t i; 432 433 char k_buf[CONFIG_TXT_KBUF_SIZE]; // local kernel buffer 434 435 assert( ( file_xp != XPTR_NULL ) , "file_xp == XPTR_NULL" ); 435 436 436 437 #if (DEBUG_SYS_READ & 1) … … 443 444 444 445 #if DEBUG_DEVFS_MOVE 445 uint32_t cycle = (uint32_t)hal_get_cycles(); 446 uint32_t cycle = (uint32_t)hal_get_cycles(); 447 thread_t * this = CURRENT_THREAD; 446 448 if( DEBUG_DEVFS_MOVE < cycle ) 447 printk("\n[ DBG] %s : thread %xenter / to_mem %d / cycle %d\n",448 __FUNCTION__ , CURRENT_THREAD , to_buffer, cycle );449 printk("\n[%s] thread[%x,%x] enter / to_mem %d / cycle %d\n", 450 __FUNCTION__, this->process->pid, this->trdid, to_buffer, cycle ); 449 451 #endif 450 452 … … 460 462 channel = hal_remote_l32( XPTR( chdev_cxy , &chdev_ptr->channel ) ); 461 463 462 // action depends on "func" and "to_buffer" 463 if( func == DEV_FUNC_TXT ) 464 { 465 if( to_buffer ) // TXT read 466 { 467 uint32_t i; 468 for( i = 0 ; i < size ; i++ ) 464 assert( ( func == DEV_FUNC_TXT ) , __FUNCTION__, "illegal device func_type"); 465 466 // initialise number of bytes to move 467 todo = size; 468 469 /////////////// TXT read 470 if( to_buffer ) 471 { 472 while( todo ) 473 { 474 // set burst size 475 if( todo > CONFIG_TXT_KBUF_SIZE ) burst = CONFIG_TXT_KBUF_SIZE; 476 else burst = todo; 477 478 // read burst bytes from TXT device to kernel buffer 479 for( i = 0 ; i < burst ; i++ ) 469 480 { 470 481 error = dev_txt_read( channel , &k_buf[i] ); 471 482 472 if( error ) 473 { 474 return -1; 475 } 476 else 477 { 478 hal_strcpy_to_uspace( u_buf , k_buf , size ); 479 } 480 } 483 if( error ) return -1; 484 } 485 486 // move burst bytes from k_buf to u_buf 487 hal_strcpy_to_uspace( u_buf , k_buf , burst ); 488 489 // update loop variables 490 todo -= burst; 491 u_buf += burst; 492 } 481 493 482 494 #if DEBUG_DEVFS_MOVE 483 495 cycle = (uint32_t)hal_get_cycles(); 484 496 if( DEBUG_DEVFS_MOVE < cycle ) 485 printk("\n[ DBG] %s : thread %xexit / to_mem %d / cycle %d\n",486 __FUNCTION__ , CURRENT_THREAD , to_buffer /cycle );497 printk("\n[%s] thread[%x,%x] exit / to_mem %d / cycle %d\n", 498 __FUNCTION__, this->process->pid, this->trdid, to_buffer, cycle ); 487 499 #endif 488 500 … … 491 503 #endif 492 504 return size; 505 } 506 ///////////// TXT write 507 else 508 { 509 while( todo ) 510 { 511 // set burst size 512 if( todo > CONFIG_TXT_KBUF_SIZE ) burst = CONFIG_TXT_KBUF_SIZE; 513 else burst = todo; 514 515 // move burst bytes from u_buf to k_buf 516 hal_strcpy_from_uspace( k_buf , u_buf , burst ); 517 518 // write burst bytes from kernel buffer to TXT device 519 error = dev_txt_write( channel , k_buf , burst ); 520 521 if( error ) return -1; 522 523 // update loop variables 524 todo -= burst; 525 u_buf += burst; 493 526 } 494 else // TXT write495 {496 hal_strcpy_from_uspace( k_buf , u_buf , size );497 498 error = dev_txt_write( channel , k_buf , size );499 if( error )500 {501 return -1;502 }503 else504 {505 527 506 528 #if DEBUG_DEVFS_MOVE 507 529 cycle = (uint32_t)hal_get_cycles(); 508 530 if( DEBUG_DEVFS_MOVE < cycle ) 509 printk("\n[ DBG] %s : thread %xexit / to_mem %d / cycle %d\n",510 __FUNCTION__ , CURRENT_THREAD , to_buffer /cycle );531 printk("\n[%s] thread[%x,%x] exit / to_mem %d / cycle %d\n", 532 __FUNCTION__, this->process->pid, this->trdid, to_buffer, cycle ); 511 533 #endif 512 534 … … 514 536 exit_devfs_write = hal_time_stamp(); 515 537 #endif 516 return size; 517 } 518 } 519 } 520 else 521 { 522 assert( false , "%s does not support direct user access", 523 chdev_func_str(func) ); 524 525 return -1; 538 return size; 526 539 } 527 540
Note: See TracChangeset
for help on using the changeset viewer.