Changeset 674
- Timestamp:
- Nov 20, 2020, 12:04:01 AM (4 years ago)
- Location:
- trunk/kernel/devices
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/devices/dev_dma.c
r657 r674 45 45 46 46 // set dma name 47 snprint f( dma->name , 16 , "dma%d_%x" , channel , local_cxy );47 snprintk( dma->name , 16 , "dma%d_%x" , channel , local_cxy ); 48 48 49 49 // call driver init function … … 69 69 if( error ) 70 70 { 71 assert( false , "cannot create server thread" );71 assert( __FUNCTION__, false , "cannot create server thread" ); 72 72 } 73 73 … … 104 104 105 105 // check DMA chdev definition 106 assert( (dev_xp != XPTR_NULL) , "undefined DMA chdev descriptor" );106 assert( __FUNCTION__, (dev_xp != XPTR_NULL) , "undefined DMA chdev descriptor" ); 107 107 108 108 // register command in calling thread descriptor … … 151 151 152 152 // check DMA chdev definition 153 assert( (dev_xp != XPTR_NULL) , "undefined DMA chdev descriptor" );153 assert( __FUNCTION__, (dev_xp != XPTR_NULL) , "undefined DMA chdev descriptor" ); 154 154 155 155 // register command in calling thread descriptor -
trunk/kernel/devices/dev_fbf.c
r657 r674 48 48 if ( cmd_type == FBF_GET_CONFIG ) return "GET_CONFIG"; 49 49 else if( cmd_type == FBF_CREATE_WINDOW ) return "CREATE_WINDOW"; 50 else if( cmd_type == FBF_ACTIVE_WINDOW ) return "ACTIVE_WINDOW"; 50 51 else if( cmd_type == FBF_DELETE_WINDOW ) return "DELETE_WINDOW"; 51 52 else if( cmd_type == FBF_MOVE_WINDOW ) return "MOVE_WINDOW"; 52 53 else if( cmd_type == FBF_REFRESH_WINDOW ) return "REFRESH_WINDOW"; 54 else if( cmd_type == FBF_FRONT_WINDOW ) return "FRONT_WINDOW"; 55 else if( cmd_type == FBF_RESIZE_WINDOW ) return "RESIZE_WINDOW"; 56 53 57 else if( cmd_type == FBF_DIRECT_WRITE ) return "DIRECT_WRITE"; 54 58 else if( cmd_type == FBF_DIRECT_READ ) return "DIRECT_READ"; … … 56 60 } 57 61 62 //////////////////////////////////////////////// 63 xptr_t dev_fbf_get_xptr_from_wid( uint32_t wid ) 64 { 65 thread_t * this = CURRENT_THREAD; 66 pid_t pid = this->process->pid; 67 trdid_t trdid = this->trdid; 68 69 // get cluster and pointers on FBF chdev 70 xptr_t fbf_xp = chdev_dir.fbf[0]; 71 cxy_t fbf_cxy = GET_CXY( fbf_xp ); 72 chdev_t * fbf_ptr = GET_PTR( fbf_xp ); 73 74 // build extended pointer on windows_tbl[wid] 75 xptr_t entry_xp = XPTR( fbf_cxy , &fbf_ptr->ext.fbf.windows_tbl[wid] ); 76 77 // get pointers on searched window 78 xptr_t window_xp = hal_remote_l64( entry_xp ); 79 cxy_t window_cxy = GET_CXY( window_xp ); 80 fbf_window_t * window_ptr = GET_PTR( window_xp ); 81 82 if( window_xp == XPTR_NULL ) 83 { 84 printk("\n[ERROR] in %s / client thread[%x,%x] request a non registered wid (%d)\n", 85 __FUNCTION__, pid, trdid, wid ); 86 return XPTR_NULL; 87 } 88 89 // get owner process PID from window descriptor 90 pid_t owner_pid = hal_remote_l32( XPTR( window_cxy , &window_ptr->pid ) ); 91 92 if( pid != owner_pid ) 93 { 94 printk("\n[ERROR] in %s / client thread[%x,%x] not owner of wid (%d) / owner is (%x)\n", 95 __FUNCTION__, pid, trdid, owner_pid, wid ); 96 return XPTR_NULL; 97 } 98 99 return window_xp; 100 101 } // end dev_fbf_get_xptr_from_wid() 102 58 103 //////////////////////////////////// 59 104 void dev_fbf_init( chdev_t * fbf ) … … 94 139 xptr_t dev_xp = chdev_dir.fbf[0]; 95 140 96 assert( (dev_xp != XPTR_NULL) , "undefined FBF chdev descriptor" );141 assert( __FUNCTION__, (dev_xp != XPTR_NULL) , "undefined FBF chdev descriptor" ); 97 142 98 143 // get FBF chdev cluster and local pointer … … 107 152 } // end dev_fbf_get_config() 108 153 109 /////////////////////////////////////////////// 154 ///////////////////////////////////////////////// 110 155 uint32_t dev_fbf_create_window( uint32_t nlines, 111 156 uint32_t npixels, … … 136 181 137 182 // check fbf_xp definition 138 assert( (fbf_xp != XPTR_NULL) , "undefined FBF chdev descriptor" );183 assert( __FUNCTION__, (fbf_xp != XPTR_NULL) , "undefined FBF chdev descriptor" ); 139 184 140 185 // get FBF width and height … … 249 294 window->l_min = l_min; 250 295 window->p_min = p_min; 251 window->hidden = false;296 window->hidden = true; 252 297 window->buffer = (uint8_t *)vseg_base; 253 298 … … 271 316 #endif 272 317 273 #if (DEBUG_DEV_FBF & 1)274 hal_vmm_display( ref_xp , true );275 #endif276 277 318 // return pointer on allocated buffer 278 319 *user_buffer = vseg_base; … … 282 323 } // end dev_fbf_create_window() 283 324 284 //////////////////////////////////////////////////////////////////////////////////////// 285 // This static function is called by the dev_fbf_display() function. 286 // For a partial FBF line, identified by the <f_line>, <f_p_min>, <f_p_max> arguments 287 // in FBF reference, and for one remote window, identified by the <window_xp> argument, 288 // it updates the target buffer identified by <t_buffer>, and containing exactly 289 // (f_p_max - f_p_min) pixels. 290 // Depending on the actual overlap between the window and the <t_buffer> representing 291 // the partial FBF line, it moves up to (f_p_max - f_p_min) pixels from the window 292 // buffer to the target buffer. The number of moved pixels can be nul if no overlap. 293 //////////////////////////////////////////////////////////////////////////////////////// 294 // @ f_line : [in] line index in FBF reference (from 0 to fbf_height-1). 295 // @ f_p_min : [in] first pixel in FBF line. 296 // @ f_p_max : [in] last pixel in FBF line (excluded). 297 // @ window_xp : [in] extended pointer on checked window . 298 // @ t_buffer : [out] local pointer on target buffer to be updated. 299 /////////////////////////////////////////////////////////////////////////////////////// 300 __attribute__ ((noinline)) static void handle_one_window( uint32_t f_line, 301 uint32_t f_p_min, 302 uint32_t f_p_max, 303 xptr_t window_xp, 304 uint8_t * t_buffer ) 305 { 306 // get remote window descriptor cluster and local pointer 325 ///////////////////////////////////////////// 326 error_t dev_fbf_active_window( uint32_t wid, 327 uint32_t active ) 328 { 329 330 #if DEBUG_DEV_FBF 331 thread_t * thi = CURRENT_THREAD; 332 uint32_t cycle = (uint32_t)hal_get_cycles(); 333 if( DEBUG_DEV_FBF < cycle ) 334 printk("\n[%s] thread[%x,%x] enters : wid %d / active %d / cycle %d\n", 335 __FUNCTION__ , this->process->pid, this->trdid, wid, active, cycle ); 336 #endif 337 338 // get extended pointer on window to be activated 339 xptr_t window_xp = dev_fbf_get_xptr_from_wid( wid ); 340 341 if( window_xp == XPTR_NULL ) return -1; 342 343 // get cluster and local pointer on target window 307 344 cxy_t window_cxy = GET_CXY( window_xp ); 308 345 fbf_window_t * window_ptr = GET_PTR( window_xp ); 309 346 310 // get remote window min/max coordinates in FBF reference 311 uint32_t w_l_min = hal_remote_l32( XPTR( window_cxy , &window_ptr->l_min ) ); 312 uint32_t w_p_min = hal_remote_l32( XPTR( window_cxy , &window_ptr->p_min ) ); 313 uint32_t w_height = hal_remote_l32( XPTR( window_cxy , &window_ptr->height ) ); 314 uint32_t w_width = hal_remote_l32( XPTR( window_cxy , &window_ptr->width ) ); 315 uint32_t w_l_max = w_l_min + w_height; 316 uint32_t w_p_max = w_p_min + w_width; 317 318 // does nothing if partial FBF line does not overlap the window 319 if( (f_line < w_l_min) || (f_line >= w_l_max) || 320 (f_p_max < w_p_min) || (f_p_min >= w_p_max) ) return; 321 322 // get pointer on window buffer in user space 323 uint8_t * w_buffer = hal_remote_lpt( XPTR( window_cxy , &window_ptr->buffer ) ); 324 325 // get min & max indexes for pixels to be moved in FBF reference 326 uint32_t f_pixel_min = (f_p_min < w_p_min) ? w_p_min : f_p_min; 327 uint32_t f_pixel_max = (f_p_max < w_p_max) ? f_p_max : w_p_max; 328 329 // compute number of pixels to move from w_buffer to f_buffer 330 uint32_t npixels = f_pixel_max - f_pixel_min; 331 332 // compute offset in target buffer 333 uint32_t t_offset = f_pixel_min - f_p_min; 334 335 // compute line index in window 336 uint32_t w_line = f_line - w_l_min; 337 338 // compute offset in window buffer 339 uint32_t w_offset = (w_line * w_height) + f_pixel_min - w_p_min; 340 341 // move pixels from w_buffer (user space) to t_buffer in kernel space 342 hal_copy_from_uspace( XPTR( local_cxy , &t_buffer[t_offset] ), 343 &w_buffer[w_offset], 344 npixels ); 345 346 } // end handle_one_window() 347 // set/reset hidden flag in window descriptor 348 hal_remote_s32( XPTR( window_cxy , &window_ptr->hidden ) , (active == 0) ? 1 : 0 ); 349 350 #if DEBUG_DEV_FBF 351 cycle = (uint32_t)hal_get_cycles(); 352 if( DEBUG_DEV_FBF < cycle ) 353 printk("\n[%s] thread[%x,%x] exit / cycle %d\n", 354 __FUNCTION__ , this->process->pid, this->trdid, cycle ); 355 #endif 356 357 return 0; 358 359 } // end dev_fbf_active_window() 347 360 348 361 //////////////////////////////////////////////////////////////////////////////////////// 349 362 // This static function is called by dev_fbf_refresh_window(), dev_fbf_move_window(), 350 // dev_fbf_ resize_window(), and dev_fbf_delete_window(). It updates all lines of the351 // window identified by the <window_xp>, <line_first>, and <line_last>> arguments.352 // It scan all registered windows to take into account the overlap priorities defined353 // by the windows xlist. It does not take the lock protecting the xlist, that must be354 // taken by the calling function.363 // dev_fbf_front_window(), dev_fbf_delete_window(), and dev_fbf_resize_window(). 364 // It updates all lines of a pseudo window identified by the <p_min>, <p_max>, <l_min>, 365 // and <l_max> arguments, that are dynamically computed by the caller. 366 // This function scan all registered windows to take into account the overlap priorities 367 // defined by the FBF xlist of windows. It takes the lock protecting xlist in read mode. 355 368 //////////////////////////////////////////////////////////////////////////////////////// 356 // @ window_xp : [in] extended pointer on window defining the FBF pixels to refresh. 357 // @ line_first : [in] first line index. 358 // @ line_last : [in] last line index (excluded). 369 // Implementation Note: 370 // This function contains two loops. 371 // - the external loop builds one line of the pseudo window per iteraiion in a local 372 // line_buffer. One line contains [p_max - p_min] pixels. Then, it calls the FBF 373 // driver (one driver call per line) to write this line into the Frame Buffer. 374 // - the internal loop scan the list of the registered windows in increasing priority, 375 // and for each registered window that has a non empty intersection with the handled 376 // line, it updates the line_buffer, using the hal_copy_from_uspace() function 377 // to get the most up-to-date user-defined data. 359 378 //////////////////////////////////////////////////////////////////////////////////////// 360 error_t fbf_update( xptr_t window_xp, 361 uint32_t line_first, 362 uint32_t line_last ) 363 { 364 uint32_t line; // iterator to scan the FBF lines 365 uint32_t pixel; // iterator to scan pixels in one FBF line 366 xptr_t iter_xp; // iterator to scan the list of windows 379 // @ p_min : [in] upper left corner X coordinate in FBF reference 380 // @ p_max : [in] upper left corner Y coordinate in FBF reference. 381 // @ l_min : [in] lower right corner X coordinate in FBF reference (excluded). 382 // @ l_max : [in] lower right corner Y coordinate in FBF reference (excluded). 383 //////////////////////////////////////////////////////////////////////////////////////// 384 error_t fbf_update( uint32_t p_min, 385 uint32_t l_min, 386 uint32_t p_max, 387 uint32_t l_max ) 388 { 389 uint32_t line; // iterator to scan the FBF lines 390 uint32_t pixel; // iterator to scan pixels in one FBF line 391 xptr_t iter_xp; // iterator to scan the list of windows 367 392 error_t error; 368 393 369 // this intermediate buffer stores one line in 370 // target window, to handle other windows overlap 371 uint8_t line_buffer[CONFIG_FBF_WINDOWS_MAX_WIDTH]; 394 // this intermediate buffer to build one pseudo-window line 395 uint8_t line_buffer[CONFIG_FBF_WINDOWS_MAX_WIDTH]; 372 396 373 397 // get pointer on calling thread and core lid 374 398 thread_t * this = CURRENT_THREAD; 375 399 376 // get window cluster and local pointer 377 cxy_t window_cxy = GET_CXY( window_xp ); 378 fbf_window_t * window_ptr = GET_PTR( window_xp ); 379 380 #if DEBUG_DEV_FBF 381 uint32_t wid = hal_remote_l32( XPTR( window_cxy , &window_ptr->wid ) ); 382 uint32_t lid = this->core->lid; 400 #if DEBUG_DEV_FBF 383 401 uint32_t cycle = (uint32_t)hal_get_cycles(); 384 402 if( DEBUG_DEV_FBF < cycle ) 385 printk("\n[%s] core[%x,%d] enter / wid%d / cycle %d\n",386 __FUNCTION__, local_cxy, lid, wid, cycle );403 printk("\n[%s] enter : p_min %d / l_min %d / p_max %d / l_max %d / cycle %d\n", 404 __FUNCTION__, p_min, l_min, p_max, l_max, cycle ); 387 405 #endif 388 406 … … 392 410 chdev_t * fbf_ptr = GET_PTR( fbf_xp ); 393 411 394 // get frame buffer width 412 // get frame buffer width and height 395 413 uint32_t fbf_width = hal_remote_l32( XPTR( fbf_cxy , &fbf_ptr->ext.fbf.width ) ); 414 uint32_t fbf_height = hal_remote_l32( XPTR( fbf_cxy , &fbf_ptr->ext.fbf.height ) ); 415 416 // check arguments 417 assert( __FUNCTION__, (p_min < fbf_width) && (p_max <= fbf_width) && 418 (l_min < fbf_height) && (l_max <= fbf_height) , "illegal arguments" ); 396 419 397 420 // get pointer on driver command function 398 421 dev_cmd_t * cmd = hal_remote_lpt( XPTR( fbf_cxy , &fbf_ptr->cmd ) ); 399 422 400 // build extended pointers on windows xlist root 423 // build extended pointers on windows xlist root and lock 401 424 xptr_t windows_root_xp = XPTR( fbf_cxy , &fbf_ptr->ext.fbf.windows_root ); 402 403 // get window size and coordinates 404 uint32_t p_min = hal_remote_l32( XPTR( window_cxy , &window_ptr->p_min ) ); 405 uint32_t l_min = hal_remote_l32( XPTR( window_cxy , &window_ptr->l_min ) ); 406 uint32_t w_pixels = hal_remote_l32( XPTR( window_cxy , &window_ptr->width ) ); 425 xptr_t windows_lock_xp = XPTR( fbf_cxy , &fbf_ptr->ext.fbf.windows_lock ); 407 426 408 427 error = 0; 409 428 410 // loop on target window lines (FBF coordinates)411 for( line = l_min + line_first ; line < (l_min + line_last); line++ )429 // 1. external loop on pseudo window lines (in FBF reference) 430 for( line = l_min ; line < l_max ; line++ ) 412 431 { 413 432 // reset the line buffer to default value 414 for( pixel = 0 ; pixel < w_pixels ; pixel++ ) line_buffer[pixel] = 127; 415 416 // loop on all windows 433 for( pixel = 0 ; pixel < (p_max - p_min) ; pixel++ ) line_buffer[pixel] = 127; 434 435 // take the lock in read mode 436 remote_rwlock_rd_acquire( windows_lock_xp ); 437 438 // 2. internal loop on all registered windows 417 439 XLIST_FOREACH( windows_root_xp , iter_xp ) 418 440 { 419 // get pointers on remotewindow441 // get pointers on current target window 420 442 xptr_t tgt_xp = XLIST_ELEMENT( iter_xp , fbf_window_t , xlist ); 421 fbf_window_t * tgt_ptr = GET_PTR( window_xp ); 422 cxy_t tgt_cxy = GET_CXY( window_xp ); 423 424 bool_t hidden = hal_remote_l32( XPTR( tgt_cxy , &tgt_ptr->hidden ) ); 425 426 // fill the line_buf for this window if not hidden 427 if( hidden == false ) handle_one_window( line, // line index 428 p_min, // pixel_min 429 p_min + w_pixels, // pixel_max 430 tgt_xp, // window_xp 431 line_buffer ); 443 fbf_window_t * tgt_ptr = GET_PTR( tgt_xp ); 444 cxy_t tgt_cxy = GET_CXY( tgt_xp ); 445 446 // get target window min and max coordinates in FBF reference 447 bool_t hidden = hal_remote_l32( XPTR( tgt_cxy , &tgt_ptr->hidden ) ); 448 uint32_t w_l_min = hal_remote_l32( XPTR( tgt_cxy , &tgt_ptr->l_min ) ); 449 uint32_t w_p_min = hal_remote_l32( XPTR( tgt_cxy , &tgt_ptr->p_min ) ); 450 uint32_t w_height = hal_remote_l32( XPTR( tgt_cxy , &tgt_ptr->height ) ); 451 uint32_t w_width = hal_remote_l32( XPTR( tgt_cxy , &tgt_ptr->width ) ); 452 uint32_t w_l_max = w_l_min + w_height; 453 uint32_t w_p_max = w_p_min + w_width; 454 455 // does nothing when target window is hidden 456 // or the pseudo window line does not overlap the target window 457 if( (hidden == true) || 458 (line < w_l_min) || 459 (line >= w_l_max) || 460 (p_max < w_p_min) || 461 (p_min >= w_p_max) ) continue; 462 463 // get pointer on buffer associated to target window in user space 464 uint8_t * w_buffer = hal_remote_lpt( XPTR( tgt_cxy , &tgt_ptr->buffer ) ); 465 466 // get min & max indexes for pixels to be moved in FBF reference 467 uint32_t f_pixel_min = (p_min < w_p_min) ? w_p_min : p_min; 468 uint32_t f_pixel_max = (p_max < w_p_max) ? p_max : w_p_max; 469 470 // compute number of pixels to move from w_buffer to f_buffer 471 uint32_t npixels = f_pixel_max - f_pixel_min; 472 473 // compute offset in line_buffer 474 uint32_t line_offset = f_pixel_min - p_min; 475 476 // compute line index in window 477 uint32_t w_line = line - w_l_min; 478 479 // compute offset in window buffer 480 uint32_t w_offset = (w_line * w_height) + f_pixel_min - w_p_min; 481 482 // move pixels from w_buffer (user space) to line_buffer (kernel space) 483 hal_copy_from_uspace( XPTR( local_cxy , &line_buffer[line_offset] ), 484 &w_buffer[w_offset], 485 npixels ); 432 486 } // end for windows 487 488 // release the lock 489 remote_rwlock_rd_release( windows_lock_xp ); 433 490 434 491 // compute offset in FBF … … 439 496 this->fbf_cmd.type = FBF_DRIVER_KERNEL_WRITE; 440 497 this->fbf_cmd.buffer = line_buffer; 441 this->fbf_cmd.npixels = w_pixels;498 this->fbf_cmd.npixels = p_max - p_min; 442 499 this->fbf_cmd.offset = fbf_offset; 443 500 … … 452 509 cycle = (uint32_t)hal_get_cycles(); 453 510 if( DEBUG_DEV_FBF < cycle ) 454 printk("\n[%s] core[%x,%d] exit / wid %d/ cycle %d\n",455 __FUNCTION__, local_cxy, this->core->lid, wid,cycle );511 printk("\n[%s] exit / cycle %d\n", 512 __FUNCTION__, cycle ); 456 513 #endif 457 514 … … 475 532 __FUNCTION__ , process->pid, this->trdid, wid, cycle ); 476 533 #endif 534 535 // get extended pointer on window to be deleted 536 xptr_t window_xp = dev_fbf_get_xptr_from_wid( wid ); 537 538 if( window_xp == XPTR_NULL ) return -1; 477 539 478 540 // get cluster and pointers on FBF chdev … … 481 543 chdev_t * fbf_ptr = GET_PTR( fbf_xp ); 482 544 483 // build extended pointers on windows lock, and wid allocator545 // build extended pointers on windows lock, windows_tbl[wid] and wid allocator 484 546 xptr_t windows_lock_xp = XPTR( fbf_cxy , &fbf_ptr->ext.fbf.windows_lock ); 485 547 xptr_t wid_bitmap_xp = XPTR( fbf_cxy , fbf_ptr->ext.fbf.windows_bitmap ); 486 487 // build extended pointer on relevant entry in windows_tbl[] array 488 xptr_t windows_tbl_xp = XPTR( fbf_cxy , &fbf_ptr->ext.fbf.windows_tbl[wid] ); 489 490 // get extended pointer on remote window descriptor 491 xptr_t window_xp = hal_remote_l64( windows_tbl_xp ); 492 493 if( window_xp == XPTR_NULL ) 494 { 495 printk("\n[ERROR] in %s / thread[%x,%x] / wid %d non registered\n", 496 __FUNCTION__, process->pid, this->trdid, wid ); 497 return -1; 498 } 499 500 // get cluster and local pointer on remote window 548 xptr_t windows_tbl_xp = XPTR( fbf_cxy , &fbf_ptr->ext.fbf.windows_tbl[wid] ); 549 550 // get cluster and local pointer on window 501 551 cxy_t window_cxy = GET_CXY( window_xp ); 502 552 fbf_window_t * window_ptr = GET_PTR( window_xp ); 503 553 504 // get process owner PID 505 pid_t owner_pid = hal_remote_l32( XPTR( window_cxy , &window_ptr->pid ) ); 506 507 // check caller PID / owner PID 508 if( owner_pid != process->pid ) 509 { 510 printk("\n[ERROR] in %s : caller PID (%x) != owner PID (%x)\n", 511 __FUNCTION__, process->pid , owner_pid ); 512 return -1; 513 } 514 515 // get associated buffer, and number of lines 516 uint8_t * buffer = hal_remote_lpt( XPTR( window_cxy , &window_ptr->buffer ) ); 517 uint32_t nlines = hal_remote_l32( XPTR( window_cxy , &window_ptr->height ) ); 518 519 // 1. take the lock protecting windows in write mode 554 // get relevant info from window descriptor 555 uint32_t p_min = hal_remote_l32( XPTR( window_cxy , &window_ptr->p_min ) ); 556 uint32_t l_min = hal_remote_l32( XPTR( window_cxy , &window_ptr->l_min ) ); 557 uint32_t npixels = hal_remote_l32( XPTR( window_cxy , &window_ptr->width ) ); 558 uint32_t nlines = hal_remote_l32( XPTR( window_cxy , &window_ptr->height ) ); 559 uint8_t * buffer = hal_remote_lpt( XPTR( window_cxy , &window_ptr->buffer ) ); 560 561 // 1. set the hidden bit in window descriptor 562 hal_remote_s32( XPTR( window_cxy , &window_ptr->hidden ) , true ); 563 564 // 2. refresh the window in FBF 565 fbf_update( p_min, l_min, p_min + npixels, l_min + nlines ); 566 567 // 3. take the lock protecting windows in write mode 520 568 remote_rwlock_wr_acquire( windows_lock_xp ); 521 569 522 // 2. update the FBF window 523 fbf_update( window_xp , 0 , nlines ); 524 525 // 3. remove the window from windows_tbl[] array 570 // 4. remove the window from windows_tbl[] array 526 571 hal_remote_s64( windows_tbl_xp , XPTR_NULL ); 527 572 528 // 4. remove the window from xlist573 // 5. remove the window from xlist 529 574 xlist_unlink( XPTR( window_cxy , &window_ptr->xlist ) ); 530 575 531 // 5. release wid to bitmap576 // 6. release wid to bitmap 532 577 bitmap_remote_clear( wid_bitmap_xp , wid ); 533 578 534 // 6. release the lock protecting windows in write mode579 // 7. release the lock protecting windows in write mode 535 580 remote_rwlock_wr_release( windows_lock_xp ); 536 581 537 // 7. release memory allocated for window descriptor582 // 8. release memory allocated for window descriptor 538 583 req.type = KMEM_KCM; 539 584 req.ptr = window_ptr; 540 585 kmem_remote_free( window_cxy , &req ); 541 586 542 // 8. release the associated vseg587 // 9. release the associated vseg 543 588 vmm_global_delete_vseg( process , (intptr_t)buffer ); 544 589 … … 556 601 //////////////////////////////////////////// 557 602 error_t dev_fbf_move_window( uint32_t wid, 558 uint32_t l_min, 559 uint32_t p_min ) 560 { 561 thread_t * this = CURRENT_THREAD; 562 process_t * process = this->process; 563 564 #if DEBUG_DEV_FBF 565 uint32_t cycle = (uint32_t)hal_get_cycles(); 566 if( DEBUG_DEV_FBF < cycle ) 567 printk("\n[%s] thread[%x,%x] enters : wid %d / l_min %d / p_min %d / cycle %d\n", 568 __FUNCTION__ , process->pid, this->trdid, wid, l_min, p_min, cycle ); 569 #endif 603 uint32_t l_new, 604 uint32_t p_new ) 605 { 606 607 #if DEBUG_DEV_FBF 608 thread_t * this = CURRENT_THREAD; 609 uint32_t cycle = (uint32_t)hal_get_cycles(); 610 if( DEBUG_DEV_FBF < cycle ) 611 printk("\n[%s] thread[%x,%x] enters : wid %d / l_new %d / p_new %d / cycle %d\n", 612 __FUNCTION__ , this->process->pid, this->trdid, wid, l_new, p_new, cycle ); 613 #endif 614 615 // get extended pointer on window to be moved 616 xptr_t window_xp = dev_fbf_get_xptr_from_wid( wid ); 617 618 if( window_xp == XPTR_NULL ) return -1; 570 619 571 620 // get cluster and pointers on FBF chdev … … 578 627 xptr_t windows_root_xp = XPTR( fbf_cxy , &fbf_ptr->ext.fbf.windows_root ); 579 628 580 // build extended pointer on relevant entry in windows_tbl[] array 581 xptr_t windows_tbl_xp = XPTR( fbf_cxy , &fbf_ptr->ext.fbf.windows_tbl[wid] ); 582 583 // get extended pointer on remote window descriptor 584 xptr_t window_xp = hal_remote_l64( windows_tbl_xp ); 585 586 if( window_xp == XPTR_NULL ) 587 { 588 printk("\n[ERROR] in %s / thread[%x,%x] / wid %d non registered\n", 589 __FUNCTION__, process->pid, this->trdid, wid ); 590 return -1; 591 } 592 593 // get cluster and local pointer for remote window 629 630 // get cluster and local pointer on target window 594 631 cxy_t window_cxy = GET_CXY( window_xp ); 595 632 fbf_window_t * window_ptr = GET_PTR( window_xp ); 596 633 597 // get process owner PID, coordinates, and number of lines 598 pid_t owner_pid = hal_remote_l32( XPTR( window_cxy , &window_ptr->pid ) ); 599 uint32_t p_zero = hal_remote_l32( XPTR( window_cxy , &window_ptr->p_min ) ); 600 uint32_t l_zero = hal_remote_l32( XPTR( window_cxy , &window_ptr->l_min ) ); 634 // get target window coordinates, width and height 635 uint32_t p_old = hal_remote_l32( XPTR( window_cxy , &window_ptr->p_min ) ); 636 uint32_t l_old = hal_remote_l32( XPTR( window_cxy , &window_ptr->l_min ) ); 601 637 uint32_t nlines = hal_remote_l32( XPTR( window_cxy , &window_ptr->height ) ); 602 603 // check caller PID / owner PID 604 if( owner_pid != process->pid ) 605 { 606 printk("\n[ERROR] in %s : caller PID (%x) != owner PID (%x)\n", 607 __FUNCTION__, process->pid , owner_pid ); 608 return -1; 609 } 638 uint32_t npixels = hal_remote_l32( XPTR( window_cxy , &window_ptr->width ) ); 639 640 // build extended pointer on window xlist_entry 641 xptr_t xlist_entry_xp = XPTR( window_cxy , &window_ptr->xlist ); 610 642 611 643 // does nothing if no change 612 if( (p_zero == p_min) && (l_zero == l_min) ) return 0; 613 614 // 1. take the lock protecting windows in write mode 644 if( (p_new == p_old) && (l_new == l_old) ) return 0; 645 646 // 1. set the "hidden" flag in window descriptor 647 hal_remote_s32( XPTR( window_cxy , &window_ptr->hidden ) , true ); 648 649 #if ( DEBUG_DEV_FBF & 1 ) 650 printk("\n[%s] hidden set\n", __FUNCTION__ ); 651 #endif 652 653 // 2. update the FBF for the old window position 654 fbf_update( p_old , l_old , p_old + npixels, l_old + nlines ); 655 656 #if ( DEBUG_DEV_FBF & 1 ) 657 printk("\n[%s] refreshed old window\n", __FUNCTION__ ); 658 #endif 659 660 // 3. take the lock protecting windows in write mode 615 661 remote_rwlock_wr_acquire( windows_lock_xp ); 616 662 … … 619 665 #endif 620 666 621 // 2. gives the window the lowest priority 622 xptr_t xlist_entry_xp = XPTR( window_cxy , &window_ptr->xlist ); 623 xlist_unlink( xlist_entry_xp ); 624 xlist_add_first( windows_root_xp , xlist_entry_xp ); 625 626 #if ( DEBUG_DEV_FBF & 1 ) 627 printk("\n[%s] set low priority \n", __FUNCTION__ ); 628 #endif 629 630 // 3. set the "hidden" flag in window descriptor 631 hal_remote_s32( XPTR( window_cxy , &window_ptr->hidden ) , true ); 632 633 #if ( DEBUG_DEV_FBF & 1 ) 634 printk("\n[%s] hidden set\n", __FUNCTION__ ); 635 #endif 636 637 // 4. refresh the FBF for the current window position 638 fbf_update( window_xp , 0 , nlines ); 639 640 #if ( DEBUG_DEV_FBF & 1 ) 641 printk("\n[%s] refreshed old position\n", __FUNCTION__ ); 642 #endif 643 644 // 5. set the new coordinates in the window descriptor, 645 hal_remote_s32( XPTR( window_cxy , &window_ptr->l_min ), l_min ); 646 hal_remote_s32( XPTR( window_cxy , &window_ptr->p_min ), p_min ); 667 // 4. set the new coordinates in the window descriptor, 668 hal_remote_s32( XPTR( window_cxy , &window_ptr->l_min ), l_new ); 669 hal_remote_s32( XPTR( window_cxy , &window_ptr->p_min ), p_new ); 647 670 648 671 #if ( DEBUG_DEV_FBF & 1 ) … … 650 673 #endif 651 674 652 // 6. gives the window the highest priority675 // 5. gives the window the highest priority 653 676 xlist_unlink( xlist_entry_xp ); 654 677 xlist_add_last( windows_root_xp , xlist_entry_xp ); … … 658 681 #endif 659 682 683 // 6. release the lock protecting windows in write mode 684 remote_rwlock_wr_release( windows_lock_xp ); 685 686 #if ( DEBUG_DEV_FBF & 1 ) 687 printk("\n[%s] lock released\n", __FUNCTION__ ); 688 #endif 689 660 690 // 7. reset the "hidden" flag in window descriptor 661 691 hal_remote_s32( XPTR( window_cxy , &window_ptr->hidden ) , false ); … … 665 695 #endif 666 696 667 // 8. refresh the FBF for the new window position 668 fbf_update( window_xp , 0 , nlines ); 669 670 #if ( DEBUG_DEV_FBF & 1 ) 671 printk("\n[%s] refresh new position\n", __FUNCTION__ ); 672 #endif 673 674 // 9. release the lock protecting windows in write mode 675 remote_rwlock_wr_release( windows_lock_xp ); 676 697 // 8. update the FBF for the new window position 698 fbf_update( p_new , l_new , p_new + npixels, l_new + nlines ); 699 700 #if ( DEBUG_DEV_FBF & 1 ) 701 printk("\n[%s] refresh new new window\n", __FUNCTION__ ); 702 #endif 703 677 704 #if DEBUG_DEV_FBF 678 705 cycle = (uint32_t)hal_get_cycles(); 679 706 if( DEBUG_DEV_FBF < cycle ) 680 707 printk("\n[%s] thread[%x,%x] exit / cycle %d\n", 681 __FUNCTION__ , process->pid, this->trdid, cycle );708 __FUNCTION__ , this->process->pid, this->trdid, cycle ); 682 709 #endif 683 710 … … 695 722 696 723 #if DEBUG_DEV_FBF 697 uint32_t cycle = (uint32_t)hal_get_cycles();724 uint32_t cycle = (uint32_t)hal_get_cycles(); 698 725 if( DEBUG_DEV_FBF < cycle ) 699 726 printk("\n[%s] thread[%x,%x] enters : wid %d / width %d / height %d / cycle %d\n", 700 727 __FUNCTION__ , process->pid , this->trdid , wid, width , height , cycle ); 701 728 #endif 729 730 // get extended pointer on window to be resized 731 xptr_t window_xp = dev_fbf_get_xptr_from_wid( wid ); 732 733 if( window_xp == XPTR_NULL ) return -1; 702 734 703 735 // get cluster and pointers on FBF chdev … … 710 742 xptr_t windows_root_xp = XPTR( fbf_cxy , &fbf_ptr->ext.fbf.windows_root ); 711 743 712 // build extended pointer on relevant entry in windows_tbl[] array 713 xptr_t windows_tbl_xp = XPTR( fbf_cxy , &fbf_ptr->ext.fbf.windows_tbl[wid] ); 714 715 // get extended pointer on remote window descriptor 716 xptr_t window_xp = hal_remote_l64( windows_tbl_xp ); 717 718 if( window_xp == XPTR_NULL ) 719 { 720 printk("\n[ERROR] in %s / thread[%x,%x] / wid %d non registered\n", 721 __FUNCTION__, process->pid, this->trdid, wid ); 722 return -1; 723 } 724 725 // get cluster and local pointer for remote window 744 // get cluster and local pointer on target window 726 745 cxy_t window_cxy = GET_CXY( window_xp ); 727 746 fbf_window_t * window_ptr = GET_PTR( window_xp ); 728 747 729 748 // get process owner PID, width, height, and buffer 730 pid_t owner_pid = hal_remote_l32( XPTR( window_cxy , &window_ptr->pid ) ); 731 uint32_t nlines = hal_remote_l32( XPTR( window_cxy , &window_ptr->height ) ); 732 uint32_t npixels = hal_remote_l32( XPTR( window_cxy , &window_ptr->width ) ); 733 void * base = hal_remote_lpt( XPTR( window_cxy , &window_ptr->buffer ) ); 734 735 // check caller PID / owner PID 736 if( owner_pid != process->pid ) 737 { 738 printk("\n[ERROR] in %s : caller PID (%x) != owner PID (%x)\n", 739 __FUNCTION__, process->pid , owner_pid ); 740 return -1; 741 } 749 uint32_t p_min = hal_remote_l32( XPTR( window_cxy , &window_ptr->p_min ) ); 750 uint32_t l_min = hal_remote_l32( XPTR( window_cxy , &window_ptr->l_min ) ); 751 uint32_t nlines = hal_remote_l32( XPTR( window_cxy , &window_ptr->height ) ); 752 uint32_t npixels = hal_remote_l32( XPTR( window_cxy , &window_ptr->width ) ); 753 void * base = hal_remote_lpt( XPTR( window_cxy , &window_ptr->buffer ) ); 754 755 // build extended pointer on window xlist_entry 756 xptr_t xlist_entry_xp = XPTR( window_cxy , &window_ptr->xlist ); 742 757 743 758 // does nothing if no change … … 748 763 uint32_t new_size = width * height; 749 764 750 // 1. take the lock protecting windows in write mode 765 // 1. set the "hidden" flag in window descriptor 766 hal_remote_s32( XPTR( window_cxy , &window_ptr->hidden ) , true ); 767 768 #if ( DEBUG_DEV_FBF & 1 ) 769 printk("\n[%s] hidden set\n", __FUNCTION__ ); 770 #endif 771 772 // 2. refresh the FBF for the current window size 773 fbf_update( p_min , l_min , p_min + npixels, l_min + nlines ); 774 775 #if ( DEBUG_DEV_FBF & 1 ) 776 printk("\n[%s] refreshed old window\n", __FUNCTION__ ); 777 #endif 778 779 // 3. take the lock protecting windows in write mode 751 780 remote_rwlock_wr_acquire( windows_lock_xp ); 752 781 … … 755 784 #endif 756 785 757 // 2. gives the window the lowest priority (remove, then add first) 758 xptr_t xlist_entry_xp = XPTR( window_cxy , &window_ptr->xlist ); 759 xlist_unlink( xlist_entry_xp ); 760 xlist_add_first( windows_root_xp , xlist_entry_xp ); 761 762 #if ( DEBUG_DEV_FBF & 1 ) 763 printk("\n[%s] set low priority\n", __FUNCTION__ ); 764 #endif 765 766 // 3. set the "hidden" flag in window descriptor 767 hal_remote_s32( XPTR( window_cxy , &window_ptr->hidden ) , true ); 768 769 #if ( DEBUG_DEV_FBF & 1 ) 770 printk("\n[%s] hidden set\n", __FUNCTION__ ); 771 #endif 772 773 // 4. refresh the FBF for the current window size 774 fbf_update( window_xp , 0 , nlines ); 775 776 #if ( DEBUG_DEV_FBF & 1 ) 777 printk("\n[%s] refreshed old window\n", __FUNCTION__ ); 778 #endif 779 780 // 5. set the new width & height in the window descriptor, 786 // 4. set the new width & height in the window descriptor, 781 787 hal_remote_s32( XPTR( window_cxy , &window_ptr->width ), width ); 782 788 hal_remote_s32( XPTR( window_cxy , &window_ptr->height ), height ); … … 786 792 #endif 787 793 788 // 6. resize vseg if required794 // 5. resize vseg if required 789 795 vmm_global_resize_vseg( process, (intptr_t)base, (intptr_t)base, width * height ); 790 796 … … 793 799 #endif 794 800 795 // 7. fill buffer extension if required801 // 6. fill buffer extension if required 796 802 if( new_size > old_size ) memset( base + old_size , 0 , new_size - old_size ); 797 803 … … 800 806 #endif 801 807 802 // 8. gives the window the highest priority808 // 7. gives the window the highest priority 803 809 xlist_unlink( xlist_entry_xp ); 804 810 xlist_add_last( windows_root_xp , xlist_entry_xp ); … … 808 814 #endif 809 815 816 // 8. release the lock protecting windows in write mode 817 remote_rwlock_wr_release( windows_lock_xp ); 818 819 #if ( DEBUG_DEV_FBF & 1 ) 820 printk("\n[%s] lock released\n", __FUNCTION__ ); 821 #endif 822 810 823 // 9. reset the "hidden" flag in window descriptor 811 824 hal_remote_s32( XPTR( window_cxy , &window_ptr->hidden ) , false ); … … 816 829 817 830 // 10. refresh the FBF for the new window position 818 fbf_update( window_xp , 0 , height ); 819 820 #if ( DEBUG_DEV_FBF & 1 ) 821 printk("\n[%s] refresh new position\n", __FUNCTION__ ); 822 #endif 823 824 // 11. release the lock protecting windows in write mode 825 remote_rwlock_wr_release( windows_lock_xp ); 826 831 fbf_update( p_min , l_min , p_min + width, l_min + height ); 832 833 #if ( DEBUG_DEV_FBF & 1 ) 834 printk("\n[%s] refreshed new window\n", __FUNCTION__ ); 835 #endif 836 827 837 #if DEBUG_DEV_FBF 828 838 cycle = (uint32_t)hal_get_cycles(); … … 836 846 } // end dev_fbf_resize_window() 837 847 838 ////////////////////////////////////////////// /848 ////////////////////////////////////////////// 839 849 error_t dev_fbf_refresh_window( uint32_t wid, 840 uint32_t line_first, 841 uint32_t line_last ) 842 { 843 // get local pointers on calling thread and process 844 thread_t * this = CURRENT_THREAD; 845 process_t * process = this->process; 846 847 #if DEBUG_DEV_FBF 848 uint32_t cycle = (uint32_t)hal_get_cycles(); 850 uint32_t line_min, 851 uint32_t line_max ) 852 { 853 854 #if DEBUG_DEV_FBF 855 thread_t * thi = CURRENT_THREAD; 856 uint32_t cycle = (uint32_t)hal_get_cycles(); 849 857 if( DEBUG_DEV_FBF < cycle ) 850 858 printk("\n[%s] thread[%x,%x] enters for wid %d / first %d / last %d / cycle %d\n", 851 __FUNCTION__ , process->pid, this->trdid, wid, line_first, line_last, cycle ); 852 #endif 859 __FUNCTION__ , this->process->pid, this->trdid, wid, line_min, line_max, cycle ); 860 #endif 861 862 // get extended pointer on window to be refreshed 863 xptr_t window_xp = dev_fbf_get_xptr_from_wid( wid ); 864 865 if( window_xp == XPTR_NULL ) return -1; 866 867 // get cluster and local pointer on target window 868 cxy_t window_cxy = GET_CXY( window_xp ); 869 fbf_window_t * window_ptr = GET_PTR( window_xp ); 870 871 // get p_min, l_min, nlines & npixels from window descriptor 872 uint32_t p_min = hal_remote_l32( XPTR( window_cxy , &window_ptr->p_min ) ); 873 uint32_t l_min = hal_remote_l32( XPTR( window_cxy , &window_ptr->l_min ) ); 874 uint32_t npixels = hal_remote_l32( XPTR( window_cxy , &window_ptr->width ) ); 875 uint32_t nlines = hal_remote_l32( XPTR( window_cxy , &window_ptr->height ) ); 876 877 // check <line_min> and <line_max> arguments 878 if( (line_min >= nlines) || (line_max > nlines) || (line_min >= line_max) ) 879 { 880 printk("\n[ERROR] in %s : illegal arguments / l_first %d / l_last %d / nlines %d\n", 881 __FUNCTION__, line_min, line_max, nlines ); 882 return -1; 883 } 884 885 // update FBF 886 fbf_update( p_min , l_min + line_min , p_min + npixels , l_min + line_max ); 887 888 #if DEBUG_DEV_FBF 889 cycle = (uint32_t)hal_get_cycles(); 890 if( DEBUG_DEV_FBF < cycle ) 891 printk("\n[%s] thread[%x,%x] exit for wid %d / cycle %d\n", 892 __FUNCTION__, this->process->pid, this->trdid, wid, cycle ); 893 #endif 894 895 return 0; 896 897 } // end dev_fbf_refresh_window() 898 899 //////////////////////////////////////////// 900 error_t dev_fbf_front_window( uint32_t wid ) 901 { 902 903 #if DEBUG_DEV_FBF 904 thread_t * this = CURRENT_THREAD; 905 uint32_t cycle = (uint32_t)hal_get_cycles(); 906 if( DEBUG_DEV_FBF < cycle ) 907 printk("\n[%s] thread[%x,%x] enters for wid %d / cycle %d\n", 908 __FUNCTION__ , this->process->pid, this->trdid, wid, cycle ); 909 #endif 910 911 // get extended pointer on window to be refreshed 912 xptr_t window_xp = dev_fbf_get_xptr_from_wid( wid ); 913 914 if( window_xp == XPTR_NULL ) return -1; 853 915 854 916 // get cluster and pointers on FBF chdev … … 857 919 chdev_t * fbf_ptr = GET_PTR( fbf_xp ); 858 920 859 // build extended pointer on windows lock 921 // build extended pointer on windows lock and root 860 922 xptr_t windows_lock_xp = XPTR( fbf_cxy , &fbf_ptr->ext.fbf.windows_lock ); 861 862 // build extended pointer on relevant entry in windows_tbl[] array 863 xptr_t windows_tbl_xp = XPTR( fbf_cxy , &fbf_ptr->ext.fbf.windows_tbl[wid] ); 864 865 // get pointers on remote window descriptor 866 xptr_t window_xp = hal_remote_l64( windows_tbl_xp ); 923 xptr_t windows_root_xp = XPTR( fbf_cxy , &fbf_ptr->ext.fbf.windows_root ); 924 925 // get cluster and local pointers on window 867 926 cxy_t window_cxy = GET_CXY( window_xp ); 868 927 fbf_window_t * window_ptr = GET_PTR( window_xp ); 869 928 870 // check <wid> argument 871 if( window_xp == XPTR_NULL ) 872 { 873 printk("\n[ERROR] in %s / thread[%x,%x] / wid %d non registered\n", 874 __FUNCTION__, process->pid, this->trdid, wid ); 875 return -1; 929 // get target window coordinates, width, height, and hidden 930 uint32_t p_min = hal_remote_l32( XPTR( window_cxy , &window_ptr->p_min ) ); 931 uint32_t l_min = hal_remote_l32( XPTR( window_cxy , &window_ptr->l_min ) ); 932 uint32_t nlines = hal_remote_l32( XPTR( window_cxy , &window_ptr->height ) ); 933 uint32_t npixels = hal_remote_l32( XPTR( window_cxy , &window_ptr->width ) ); 934 bool_t hidden = hal_remote_l32( XPTR( window_cxy , &window_ptr->hidden ) ); 935 936 // build extended pointer on window xlist_entry 937 xptr_t xlist_entry_xp = XPTR( window_cxy , &window_ptr->xlist ); 938 939 // 1. take the lock protecting windows in write mode 940 remote_rwlock_wr_acquire( windows_lock_xp ); 941 942 #if ( DEBUG_DEV_FBF & 1 ) 943 printk("\n[%s] lock taken\n", __FUNCTION__ ); 944 #endif 945 946 // 2. gives the window the highest priority 947 xlist_unlink( xlist_entry_xp ); 948 xlist_add_last( windows_root_xp , xlist_entry_xp ); 949 950 #if ( DEBUG_DEV_FBF & 1 ) 951 printk("\n[%s] set high priority \n", __FUNCTION__ ); 952 #endif 953 954 // 3. release the lock protecting windows from write mode 955 remote_rwlock_wr_release( windows_lock_xp ); 956 957 #if ( DEBUG_DEV_FBF & 1 ) 958 printk("\n[%s] lock released\n", __FUNCTION__ ); 959 #endif 960 961 // 4. update the FBF for this window when not hidden 962 if( hidden == false ) fbf_update( p_min , l_min , p_min + npixels, l_min + nlines ); 963 964 #if ( DEBUG_DEV_FBF & 1 ) 965 printk("\n[%s] refresh window in FBF\n", __FUNCTION__ ); 966 #endif 967 968 #if DEBUG_DEV_FBF 969 cycle = (uint32_t)hal_get_cycles(); 970 if( DEBUG_DEV_FBF < cycle ) 971 printk("\n[%s] thread[%x,%x] exit for wid %d / cycle %d\n", 972 __FUNCTION__ , this->process->pid, this->trdid, wid, cycle ); 973 #endif 974 975 return 0; 976 977 } // end dev_fbf_front_window() 978 979 ///////////////////////////////////////// 980 void dev_fbf_display_windows( pid_t pid ) 981 { 982 xptr_t iter_xp; 983 984 // display header 985 printk("\n***** registered FBF windows *****\n" 986 " wid | hide | lzero | pzero | lines | pixel | pid\n" ); 987 988 // get cluster and pointers on FBF chdev 989 xptr_t fbf_xp = chdev_dir.fbf[0]; 990 cxy_t fbf_cxy = GET_CXY( fbf_xp ); 991 chdev_t * fbf_ptr = GET_PTR( fbf_xp ); 992 993 // build extended pointer on windows lock and root 994 xptr_t lock_xp = XPTR( fbf_cxy , &fbf_ptr->ext.fbf.windows_lock ); 995 xptr_t root_xp = XPTR( fbf_cxy , &fbf_ptr->ext.fbf.windows_root ); 996 997 // take the lock in read mode 998 remote_rwlock_rd_acquire( lock_xp ); 999 1000 XLIST_FOREACH_BACKWARD( root_xp , iter_xp ) 1001 { 1002 xptr_t w_xp = XLIST_ELEMENT( iter_xp , fbf_window_t , xlist ); 1003 fbf_window_t * w_ptr = GET_PTR( w_xp ); 1004 cxy_t w_cxy = GET_CXY( w_xp ); 1005 1006 uint32_t wid = hal_remote_l32( XPTR( w_cxy , &w_ptr->wid ) ); 1007 uint32_t owner_pid = hal_remote_l32( XPTR( w_cxy , &w_ptr->pid ) ); 1008 uint32_t hide = hal_remote_l32( XPTR( w_cxy , &w_ptr->hidden ) ); 1009 uint32_t lzero = hal_remote_l32( XPTR( w_cxy , &w_ptr->l_min ) ); 1010 uint32_t pzero = hal_remote_l32( XPTR( w_cxy , &w_ptr->p_min ) ); 1011 uint32_t lines = hal_remote_l32( XPTR( w_cxy , &w_ptr->height ) ); 1012 uint32_t pixels = hal_remote_l32( XPTR( w_cxy , &w_ptr->width ) ); 1013 1014 if( (pid == 0) || (pid == owner_pid) ) 1015 { 1016 printk("%d\t | %d\t | %d\t | %d\t | %d\t | %d\t | %x\n", 1017 wid, hide, lzero, pzero, lines, pixels, pid ); 1018 } 876 1019 } 877 1020 878 // get process owner PID 879 pid_t owner_pid = hal_remote_l32( XPTR( window_cxy , &window_ptr->pid ) ); 880 881 // check caller PID / owner PID 882 if( owner_pid != process->pid ) 883 { 884 printk("\n[ERROR] in %s : caller PID (%x) != owner PID (%x)\n", 885 __FUNCTION__, process->pid , owner_pid ); 886 return -1; 1021 // release the lock 1022 remote_rwlock_rd_release( lock_xp ); 1023 1024 } // end dev_fbf_display_windows() 1025 1026 ///////////////////////////////// 1027 void dev_fbf_cleanup( pid_t pid ) 1028 { 1029 xptr_t iter_xp; 1030 1031 // get cluster and pointers on FBF chdev 1032 xptr_t fbf_xp = chdev_dir.fbf[0]; 1033 cxy_t fbf_cxy = GET_CXY( fbf_xp ); 1034 chdev_t * fbf_ptr = GET_PTR( fbf_xp ); 1035 1036 // build extended pointer on windows lock and root 1037 xptr_t lock_xp = XPTR( fbf_cxy , &fbf_ptr->ext.fbf.windows_lock ); 1038 xptr_t root_xp = XPTR( fbf_cxy , &fbf_ptr->ext.fbf.windows_root ); 1039 1040 // take the lock in read mode 1041 remote_rwlock_rd_acquire( lock_xp ); 1042 1043 XLIST_FOREACH( root_xp , iter_xp ) 1044 { 1045 xptr_t w_xp = XLIST_ELEMENT( iter_xp , fbf_window_t , xlist ); 1046 fbf_window_t * w_ptr = GET_PTR( w_xp ); 1047 cxy_t w_cxy = GET_CXY( w_xp ); 1048 1049 // get owner process PID and WID 1050 uint32_t owner_pid = hal_remote_l32( XPTR( w_cxy , &w_ptr->pid ) ); 1051 uint32_t wid = hal_remote_l32( XPTR( w_cxy , &w_ptr->wid ) ); 1052 1053 // delete matching window 1054 if( pid == owner_pid ) dev_fbf_delete_window( wid ); 887 1055 } 888 1056 889 // get number of lines in window 890 uint32_t nlines = hal_remote_l32( XPTR( window_cxy , &window_ptr->height ) ); 891 892 // check <line_first> and <line_last> arguments 893 if( (line_first >= nlines) || (line_last > nlines) || (line_first >= line_last) ) 894 { 895 printk("\n[ERROR] in %s : illegal (l_first %d , l_last %d) / height %d\n", 896 __FUNCTION__, line_first, line_last, nlines ); 897 return -1; 898 } 899 900 // take the lock protecting windows xlist in read mode 901 remote_rwlock_rd_acquire( windows_lock_xp ); 902 903 // update FBF 904 fbf_update( window_xp , line_first , line_last ); 905 906 // release the lock protecting windows xlist in write mode 907 remote_rwlock_rd_release( windows_lock_xp ); 908 909 #if DEBUG_DEV_FBF 910 cycle = (uint32_t)hal_get_cycles(); 911 if( DEBUG_DEV_FBF < cycle ) 912 printk("\n[%s] thread[%x,%x] exit for wid %d / cycle %d\n", 913 __FUNCTION__, process->pid, this->trdid, wid, cycle ); 914 #endif 915 916 return 0; 917 918 } // end dev_fbf_refresh_window() 1057 // release the lock from read mode 1058 remote_rwlock_rd_release( lock_xp ); 1059 1060 } // end dev_fbf_cleanup() 1061 1062 1063 919 1064 920 1065 /////////////////////////////////////////////// -
trunk/kernel/devices/dev_fbf.h
r657 r674 39 39 * This device provide access to an external graphic display, that is seen 40 40 * as a fixed size frame buffer, mapped in the kernel address space. 41 * The only pixel encoding type in the current implementation is one byte per pixel42 * (256 levels of gray).41 * The only pixel encoding type in the current ALMOS-MKH implementation (oct 2020) 42 * is one byte per pixel (256 levels of gray). 43 43 * 44 44 * It supports a first API, for the user syscalls, implementing a simple windows manager. … … 78 78 * - FBF_DIRECT_WRITE : move synchronously pixels from an user buffer to the FBF. 79 79 * - FBF_DIRECT_READ : move synchronously pixels from the FBF to an user buffer. 80 *81 80 * For these deprecated operations, the client thread calls 82 81 * directly the driver to move data between the user buffer and the FBF. … … 105 104 bitmap_t windows_bitmap[CONFIG_FBF_WINDOWS_MAX_NR >> 5]; /*! wid allocator */ 106 105 107 uint32_t width; /*! number of pixels per line.*/108 uint32_t height; /*! total number of lines.*/109 uint32_t subsampling; /*! pixel encoding type.*/106 uint32_t width; /*! Frame Buffer number of pixels per line. */ 107 uint32_t height; /*! Frame Buffer total number of lines. */ 108 uint32_t subsampling; /*! Frame Buffer pixel encoding type. */ 110 109 } 111 110 fbf_extend_t; … … 169 168 fbf_window_t; 170 169 170 171 171 /****************************************************************************************** 172 172 * This function returns a printable string for a given FBF user command <cmd_type>. … … 177 177 *****************************************************************************************/ 178 178 char * dev_fbf_cmd_str( uint32_t cmd_type ); 179 180 /****************************************************************************************** 181 * This function checks that the calling process is the owner of the window identified 182 * by the <wid> argument, and returns an extended pointer on the window descriptor. 183 * It can be called by a thread running in any cluster. 184 ****************************************************************************************** 185 * @ wid : FBF window kernel identifier. 186 * @ returns XPTR on the window if success / return XPT_NULL if not owner or undefined. 187 *****************************************************************************************/ 188 xptr_t dev_fbf_get_xptr_from_wid( uint32_t wid ); 179 189 180 190 /****************************************************************************************** … … 208 218 * The window index <wid> is dynamically allocated. The owner is the calling process. 209 219 * The FBF window is defined by the <nlines>, <npixels>, <l_min>, <p_min> arguments. 210 * It can be called by any thread running in any cluster. As th isvseg is not directly220 * It can be called by any thread running in any cluster. As the vseg is not directly 211 221 * mapped to the frame buffer, the owner process can access this private buffer without 212 222 * syscall. As for any vseg, the physical memory is allocated on demand at each page fault. 213 * The created vseg base address in user space is returned in the <user_base> argument. 214 * 215 * Implementation note: 216 * 1. it allocates memory in the local cluster for the window, 223 * The created vseg base address in user space is returned in the <user_base> argument. 224 * The created window is set in "hidden" mode. 225 ****************************************************************************************** 226 * Implementation note: 227 * 1. it allocates memory in the local cluster for the window descriptor, 217 228 * 2. it creates in the associated vseg, 218 229 * 3. it initializes the window descriptor, … … 220 231 * 5. it allocates a new <wid>, 221 232 * 6. it registers the window in the window_tbl[] array, 222 * 7. it registers the window in the windows list,233 * 7. it registers the window in the FBF rooted windows list, 223 234 * 8. it releases the lock protecting windows. 224 * It does not call the FBF driver.225 235 ****************************************************************************************** 226 236 * @ nlines : [in] number of lines in window. 227 237 * @ npixels : [in] number of pixels per line in window. 228 * @ l_min : [in] first pixel index in FBF .229 * @ p_min : [in] first line index in FBF .238 * @ l_min : [in] first pixel index in FBF reference. 239 * @ p_min : [in] first line index in FBF reference. 230 240 * @ user_base : [out] pointer on allocated buffer base in user space. 231 241 * @ return the <wid> index if success / returns -1 if failure … … 237 247 intptr_t * user_base ); 238 248 249 250 /****************************************************************************************** 251 * This function implements the fbf_active_wiindow syscall. It set or reset the "hidden" 252 * flag for the window identified by the <wid> argument as specified by <active> argument. 253 ****************************************************************************************** 254 * @ wid : [in] window index in window_tbl[]. 255 * @ active : [in] set hidden flag if zero / rest hidden flag if non zero. 256 * @ returns 0 if success / returns -1 if wid not registered. 257 *****************************************************************************************/ 258 error_t dev_fbf_active_window( uint32_t wid, 259 uint32_t active ); 260 239 261 /****************************************************************************************** 240 262 * This function implements the fbf_delete_window() syscall to delete a FBF window, … … 242 264 * releases the memory allocated for the window buffer and for the window descriptor. 243 265 * It can be called by any thread running in any cluster. 244 * 245 * Implementation note: 246 * 1. it takes the lock protecting windows in write mode,247 * 2. it set the hidden flag in deleted window descriptor,248 * 3. it refresh the FBF window,266 ****************************************************************************************** 267 * Implementation note: 268 * 1. it set the "hidden" flag in the window descriptor, 269 * 2. it refresh the window in FBF, 270 * 3. it takes the lock protecting windows in write mode, 249 271 * 4. it removes the window from windows_tbl[] array, 250 272 * 5. it removes the window from xlist, 251 273 * 6. it releases the wid to bitmap, 252 * 7. it releases the lock protecting windows ,274 * 7. it releases the lock protecting windows from write mode, 253 275 * 8. it releases the memory allocated for window descriptor, 254 276 * 9. it deletes the associated vseg in all clusters 255 * It does not call directly the FBF driver.256 277 ****************************************************************************************** 257 278 * @ wid : [in] window index in window_tbl[]. … … 265 286 * defined by the <l_min> and <p_min> arguments. 266 287 * It can be called by any thread running in any cluster. 267 * 268 * Implementation note: 269 * 1. it takes the lock protecting windows in write mode,270 * 2. it gives the modified window the lowest priority,271 * 3. it set the "hidden" flag in window descriptor,272 * 4. it refresh the FBF for the current window position,273 * 5. it set the new coordinates in the window descriptor,274 * 6. it gives the modified window the highest priority,288 ****************************************************************************************** 289 * Implementation note: 290 * 1. it set the "hidden" flag in window descriptor, 291 * 2. it refresh the FBF for the current window position, 292 * 3. it takes the lock protecting windows in write mode, 293 * 4. it set the new coordinates in the window descriptor, 294 * 5. it gives the modified window the highest priority, 295 * 6. it releases the lock protecting windows, 275 296 * 7. it reset the "hidden" flag in window descriptor, 276 297 * 8. it refresh the FBF for the new window position, 277 * 9. it releases the lock protecting windows,278 * It does not call directly the FBF driver.279 298 ****************************************************************************************** 280 299 * @ wid : [in] window index in window_tbl[]. 281 * @ l_min : [in] new first pixel index in FBF .282 * @ p_min : [in] new first line index in FBF .300 * @ l_min : [in] new first pixel index in FBF reference. 301 * @ p_min : [in] new first line index in FBF reference. 283 302 * @ returns 0 if success / returns -1 if illegal arguments. 284 303 *****************************************************************************************/ … … 293 312 * When the new window buffer is larger than the existing one, it is 0 filled. 294 313 * It can be called by any thread running in any cluster. 295 * 296 * Implementation note: 297 * 1. it takes the lock protecting windows in write mode,298 * 2. it gives the modified window the lowest priority,299 * 3. it set the "hidden" flag in window descriptor,300 * 4. it refresh the FBF for the current window,301 * 5. it set the new size in the window descriptor,302 * 6. it resizes the associated vsegif required,303 * 7. i f fill the window buffer extension with 0 if required,304 * 8. it gives the modified window the highest priority,314 ****************************************************************************************** 315 * Implementation note: 316 * 1. it set the "hidden" flag in window descriptor, 317 * 2. it refresh the FBF for the current window, 318 * 3. it takes the lock protecting windows in write mode, 319 * 4. it set the new size in the window descriptor, 320 * 5. it resizes the associated vseg if required, 321 * 6. it fill the user buffer with zero if required, 322 * 7. it gives the modified window the highest priority, 323 * 8. it releases the lock protecting windows, 305 324 * 9. it reset the "hidden" flag in window descriptor, 306 325 * 10. it refresh the FBF for the new window, 307 * 11. it releases the lock protecting windows,308 * It does not call directly the FBF driver.309 326 ****************************************************************************************** 310 327 * @ wid : [in] window index in window_tbl[]. … … 321 338 * It allows an owner process to signal the windows manager that some lines of a window 322 339 * identified by the <wid>, <line_min>, and <line_max> argument have been modified, and 323 * must be refreshed in the FBF. It scans all the registered FBF windows to respect the 324 * overlap order defined by the windows xlist. 325 * It can be called by any thread running in any cluster. 326 * 327 * Implementation note: 328 * 1. it takes the lock protecting windows in read mode, 329 * 2. it refresh the FBF, 330 * 3. it releases the lock protecting windows, 331 * It does not call directly the FBF driver. 340 * must be refreshed in the FBF. 341 * It can be called by any thread running in any cluster. 342 ****************************************************************************************** 343 * Implementation note: 344 * it simply checks the arguments, and calls the fbf_update() function. 332 345 ****************************************************************************************** 333 346 * @ wid : [in] window index in window_tbl[] 334 * @ line_ first : [in] first line index in window.335 * @ line_ last : [in] last line index(excluded).347 * @ line_min : [in] first line index in window in window referencd. 348 * @ line_max : [in] last line index in window in window reference (excluded). 336 349 * @ returns 0 if success / returns -1 if wid not registered. 337 350 *****************************************************************************************/ 338 351 error_t dev_fbf_refresh_window( uint32_t wid, 339 uint32_t line_first, 340 uint32_t line_last ); 341 342 /****************************************************************************************** 343 * WARNING : This function is deprecated ( january 2020 [AG] ). It was defined 352 uint32_t line_min, 353 uint32_t line_max ); 354 355 /****************************************************************************************** 356 * This function implements the fbf_front_window() syscall. 357 * It gives the highest priority to the window identified by the <wid> argument, 358 * and refresh the FBF accordingly. 359 * It can be called by any thread running in any cluster. 360 ****************************************************************************************** 361 * Implementation note: 362 * 1. it takes the lock protecting windows in write mode, 363 * 2. it modify the xlist of windows rooted in FBF, 364 * 3. it releases the lock from write mode, 365 * 4. it refresh the window in FBF, 366 ****************************************************************************************** 367 * @ wid : [in] window index in window_tbl[] 368 * @ returns 0 if success / returns -1 if wid not registered. 369 *****************************************************************************************/ 370 error_t dev_fbf_front_window( uint32_t wid ); 371 372 /****************************************************************************************** 373 * This function displays on the TXT0 kernel terminal the list of registered FBF windows 374 * rooted in the FBF device - in decreasing priority order - owned by the process 375 * identified by the <pid> argument. It displays all windows when pid value is 0. 376 * It can be called by any thread running in any cluster. 377 ****************************************************************************************** 378 * @ pid : [in] target process identifier / all processes when pid == 0 379 *****************************************************************************************/ 380 void dev_fbf_display_windows( pid_t pid ); 381 382 /****************************************************************************************** 383 * This function deletes all FBF windows owned by the process identified by 384 * the <pid> argument. It can be called by any thread running in any cluster. 385 ****************************************************************************************** 386 * @ pid : [in] target process identifier. 387 *****************************************************************************************/ 388 void dev_fbf_cleanup( pid_t pid ); 389 390 391 392 393 394 395 396 /****************************************************************************************** 397 * TODO : This function is deprecated ( january 2020 [AG] ). It was defined 344 398 * to implement the fbf_read() and fbf_write() deprecated syscalls. 345 * 399 ****************************************************************************************** 346 400 * It moves <length> bytes between the frame buffer, starting from pixel defined 347 401 * by the <offset> argument, and an user buffer defined by the <user_buffer> argument. -
trunk/kernel/devices/dev_ioc.c
r663 r674 54 54 55 55 // set chdev name 56 snprint f( ioc->name , 16 , "ioc%d" , channel );56 snprintk( ioc->name , 16 , "ioc%d" , channel ); 57 57 58 58 // call driver init function … … 78 78 lid ); 79 79 80 assert( (error == 0) , "cannot create server thread" );80 assert( __FUNCTION__, (error == 0) , "cannot create server thread" ); 81 81 82 82 // set "server" field in chdev descriptor … … 108 108 109 109 // check dev_xp 110 assert( (ioc_xp != XPTR_NULL) , "undefined IOC chdev descriptor" );110 assert( __FUNCTION__, (ioc_xp != XPTR_NULL) , "undefined IOC chdev descriptor" ); 111 111 112 112 // register command in client thread … … 141 141 142 142 // check dev_xp 143 assert( (ioc_xp != XPTR_NULL) , "undefined IOC chdev descriptor" );143 assert( __FUNCTION__, (ioc_xp != XPTR_NULL) , "undefined IOC chdev descriptor" ); 144 144 145 145 // register command in calling thread descriptor -
trunk/kernel/devices/dev_mmc.c
r657 r674 41 41 { 42 42 // set mmc name 43 snprint f( mmc->name , 16 , "mmc_%x" , local_cxy );43 snprintk( mmc->name , 16 , "mmc_%x" , local_cxy ); 44 44 45 45 // call driver init function … … 65 65 xptr_t dev_xp = this->mmc_cmd.dev_xp; 66 66 67 assert( (dev_xp != XPTR_NULL) , "target MMC device undefined" );67 assert( __FUNCTION__, (dev_xp != XPTR_NULL) , "target MMC device undefined" ); 68 68 69 69 // get MMC device cluster identifier & local pointer -
trunk/kernel/devices/dev_nic.c
r668 r674 54 54 55 55 // set chdev name 56 if( is_rx ) snprint f( chdev->name , 16 , "nic%d_rx" , channel );57 else snprint f( chdev->name , 16 , "nic%d_tx" , channel );56 if( is_rx ) snprintk( chdev->name , 16 , "nic%d_rx" , channel ); 57 else snprintk( chdev->name , 16 , "nic%d_tx" , channel ); 58 58 59 59 // initialize the root of the listening sockets list … … 360 360 361 361 /////////////////////////////////////////////////////////////////////////////////////////// 362 // This static function can becalled by the NIC_TX or NIC_RX server threads to unblock362 // This static function is called by the NIC_TX or NIC_RX server threads to unblock 363 363 // the TX client thread after completion (success or error) of a TX command registered 364 364 // in a socket identified by the <socket_xp> argument. The <status> argument defines … … 401 401 402 402 /////////////////////////////////////////////////////////////////////////////////////////// 403 // This static function can becalled by the NIC_TX or NIC_RX server threads to unblock403 // This static function is called by the NIC_TX or NIC_RX server threads to unblock 404 404 // the RX client thread after completion (success or error) of an RX command registered 405 405 // in a socket identified by the <socket_xp> argument. The <status> argument defines … … 440 440 441 441 } // end dev_nic_unblock_rx_client() 442 443 444 442 445 443 /////////////////////////////////////////////////////////////////////////////////////////// … … 680 678 // get status & space from rx_buf 681 679 status = remote_buf_status( socket_rbuf_xp ); 682 space = NIC_RX_BUF_SIZE - status;680 space = CONFIG_SOCK_RX_BUF_SIZE - status; 683 681 684 682 // get client thread … … 1268 1266 1269 1267 // compute empty space in rx_buf 1270 uint32_t space = NIC_RX_BUF_SIZE - status;1268 uint32_t space = CONFIG_SOCK_RX_BUF_SIZE - status; 1271 1269 1272 1270 // compute number of bytes to move : min (space , seg_data_len) … … 1406 1404 // update socket.state 1407 1405 hal_remote_s32( XPTR( socket_cxy , &socket_ptr->state ), 1408 TCP_STATE_CLOSED ); // TODO change to TIME_WAIT1406 TCP_STATE_CLOSED ); 1409 1407 1410 1408 // make an ACK request to R2T queue … … 1415 1413 // report success to TX client thread 1416 1414 dev_nic_unblock_tx_client( socket_xp , CMD_STS_SUCCESS ); 1417 1418 // TODO start the MSL timer / turn off others timers1419 1420 1415 } 1421 1416 } … … 1424 1419 // update socket.state 1425 1420 hal_remote_s32( XPTR( socket_cxy , &socket_ptr->state ), 1426 TCP_STATE_CLOSED ); // todo change to TIME_WAIT 1427 1428 // TODO start the MSL timer / turn off others timers 1429 1430 } 1431 else if( socket_state == TCP_STATE_TIME_WAIT ) 1432 { 1433 // TODO wait msl_time_out before unblocking TX thread 1434 1435 // update socket.state when ACK received 1436 hal_remote_s32( XPTR( socket_cxy , &socket_ptr->state ), 1437 TCP_STATE_CLOSED ); 1438 1439 // unblock TX client thead for success 1421 TCP_STATE_CLOSED ); 1422 1423 // report success to TX client thread 1440 1424 dev_nic_unblock_tx_client( socket_xp , CMD_STS_SUCCESS ); 1425 1441 1426 } 1442 1427 else if( socket_state == TCP_STATE_CLOSE_WAIT ) … … 1491 1476 1492 1477 // check socket type and state 1493 assert( (socket_type == SOCK_STREAM ) , "illegal socket type" );1494 assert( (socket_state == TCP_STATE_LISTEN ) , "illegal socket state" );1478 assert( __FUNCTION__, (socket_type == SOCK_STREAM ) , "illegal socket type" ); 1479 assert( __FUNCTION__, (socket_state == TCP_STATE_LISTEN ) , "illegal socket state" ); 1495 1480 1496 1481 // get relevant socket infos for matching … … 1638 1623 1639 1624 // check chdev direction and type 1640 assert( (chdev->func == DEV_FUNC_NIC) && (chdev->is_rx == true) ,1625 assert( __FUNCTION__, (chdev->func == DEV_FUNC_NIC) && (chdev->is_rx == true) , 1641 1626 "illegal chdev type or direction" ); 1642 1627 … … 2374 2359 // initialize socket tx_nxt, and rx_wnd 2375 2360 hal_remote_s32(XPTR(socket_cxy , &socket_ptr->tx_nxt), TCP_ISS_SERVER ); 2376 hal_remote_s32(XPTR(socket_cxy , &socket_ptr->rx_wnd), NIC_RX_BUF_SIZE);2361 hal_remote_s32(XPTR(socket_cxy , &socket_ptr->rx_wnd), CONFIG_SOCK_RX_BUF_SIZE); 2377 2362 2378 2363 // build TCP ACK-SYN segment … … 2624 2609 void dev_nic_tx_server( chdev_t * chdev ) 2625 2610 { 2626 uint8_t k_buf[ NIC_KERNEL_BUF_SIZE]; // buffer for one packet2611 uint8_t k_buf[CONFIG_SOCK_PKT_BUF_SIZE]; // buffer for one packet 2627 2612 2628 2613 xptr_t queue_root_xp; // extended pointer on sockets list root … … 2650 2635 2651 2636 // check chdev direction and type 2652 assert( (chdev->func == DEV_FUNC_NIC) && (chdev->is_rx == false) ,2637 assert( __FUNCTION__, (chdev->func == DEV_FUNC_NIC) && (chdev->is_rx == false) , 2653 2638 "illegal chdev type or direction" ); 2654 2639 -
trunk/kernel/devices/dev_nic.h
r668 r674 153 153 #define TCP_FLAG_URG 0x20 154 154 155 #define NIC_RX_BUF_SIZE 0x100000 // 1 Mbytes 156 #define NIC_R2T_QUEUE_SIZE 0x64 // smallest KCM size 157 #define NIC_CRQ_QUEUE_SIZE 0x8 // actual size is 8 * sizeof(sockaddr_t) 158 #define NIC_KERNEL_BUF_SIZE 0x800 // 2 Kbytes for one ETH/IP/TCP packet 159 160 #define CMD_ 155 #define TCP_RETRANSMISSION_TIMEOUT 10000000 161 156 162 157 /***************************************************************************************** -
trunk/kernel/devices/dev_txt.c
r663 r674 74 74 bool_t is_rx = txt->is_rx; 75 75 76 assert( (pic_xp != XPTR_NULL) || (channel == 0) ,76 assert( __FUNCTION__, ((pic_xp != XPTR_NULL) || (channel == 0)) , 77 77 "PIC not initialised before TXT" ); 78 78 79 79 // set chdev name 80 if( is_rx ) snprint f( txt->name , 16 , "txt%d_rx" , channel );81 else snprint f( txt->name , 16 , "txt%d_tx" , channel );80 if( is_rx ) snprintk( txt->name , 16 , "txt%d_rx" , channel ); 81 else snprintk( txt->name , 16 , "txt%d_tx" , channel ); 82 82 83 83 // set TXT chdev extension … … 120 120 lid ); 121 121 122 assert( (error == 0) , "cannot create server thread" );122 assert( __FUNCTION__, (error == 0) , "cannot create server thread" ); 123 123 124 124 // set "server" field in chdev descriptor … … 154 154 155 155 // check channel argument 156 assert( (channel < CONFIG_MAX_TXT_CHANNELS) , "illegal channel index" );156 assert( __FUNCTION__, (channel < CONFIG_MAX_TXT_CHANNELS) , "illegal channel index" ); 157 157 158 158 // get pointers on chdev … … 162 162 163 163 // check dev_xp 164 assert( (dev_xp != XPTR_NULL) , "undefined TXT chdev descriptor" );164 assert( __FUNCTION__, (dev_xp != XPTR_NULL) , "undefined TXT chdev descriptor" ); 165 165 166 166 // If we use MTTY (vci_multi_tty), we do a synchronous write on TXT[0] … … 243 243 244 244 // check channel argument 245 assert( (channel < CONFIG_MAX_TXT_CHANNELS) , "illegal channel index" );245 assert( __FUNCTION__, (channel < CONFIG_MAX_TXT_CHANNELS) , "illegal channel index" ); 246 246 247 247 // get pointers on chdev … … 249 249 250 250 // check dev_xp 251 assert( (dev_xp != XPTR_NULL) , "undefined TXT chdev descriptor" );251 assert( __FUNCTION__, (dev_xp != XPTR_NULL) , "undefined TXT chdev descriptor" ); 252 252 253 253 // register command in calling thread descriptor … … 290 290 uint32_t count ) 291 291 { 292 // get extended pointer on TXT[0] chdev 293 xptr_t dev_xp = chdev_dir.txt_tx[0]; 294 295 assert( (dev_xp != XPTR_NULL) , 296 "undefined TXT0 chdev descriptor" ); 297 298 // get TXTO chdev cluster and local pointer 299 cxy_t dev_cxy = GET_CXY( dev_xp ); 292 // get extended pointers on TXT[0] chdev 293 xptr_t dev_xp = chdev_dir.txt_tx[0]; 294 cxy_t dev_cxy = GET_CXY( dev_xp ); 300 295 chdev_t * dev_ptr = GET_PTR( dev_xp ); 301 296 302 // get driver command function 303 dev_aux_t * aux = (dev_aux_t *)hal_remote_lpt( XPTR( dev_cxy , &dev_ptr->aux ) ); 304 305 // build arguments structure 306 txt_sync_args_t args; 307 args.dev_xp = dev_xp; 308 args.buffer = buffer; 309 args.count = count; 310 args.channel = 0; 311 312 // call driver function 313 aux( &args ); 314 315 return 0; 316 } 317 297 if( dev_xp != XPTR_NULL) 298 { 299 // get driver command function 300 dev_aux_t * aux = (dev_aux_t *)hal_remote_lpt( XPTR( dev_cxy , &dev_ptr->aux ) ); 301 302 // build arguments structure 303 txt_sync_args_t args; 304 args.dev_xp = dev_xp; 305 args.buffer = buffer; 306 args.count = count; 307 args.channel = 0; 308 309 // call driver function 310 aux( &args ); 311 312 return 0; 313 } 314 else 315 { 316 return -1; 317 } 318 } // end dev_txt_sync_write() 319
Note: See TracChangeset
for help on using the changeset viewer.