Changeset 674


Ignore:
Timestamp:
Nov 20, 2020, 12:04:01 AM (4 years ago)
Author:
alain
Message:

1) Introduce up to 4 command lines arguments in the KSH "load" command.
These arguments are transfered to the user process through the
argc/argv mechanism, using the user space "args" vseg.

2) Introduce the named and anonymous "pipes", for inter-process communication
through the pipe() and mkfifo() syscalls.

3) Introduce the "chat" application to validate the two above mechanisms.

4) Improve printk() and assert() fonctions in printk.c.

Location:
trunk/kernel/devices
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/devices/dev_dma.c

    r657 r674  
    4545
    4646    // set dma name
    47     snprintf( dma->name , 16 , "dma%d_%x" , channel , local_cxy );
     47    snprintk( dma->name , 16 , "dma%d_%x" , channel , local_cxy );
    4848
    4949    // call driver init function
     
    6969    if( error )
    7070    {
    71         assert( false , "cannot create server thread" );
     71        assert( __FUNCTION__, false , "cannot create server thread" );
    7272    }
    7373
     
    104104
    105105// check DMA chdev definition
    106 assert( (dev_xp != XPTR_NULL) , "undefined DMA chdev descriptor" );
     106assert( __FUNCTION__, (dev_xp != XPTR_NULL) , "undefined DMA chdev descriptor" );
    107107
    108108    // register command in calling thread descriptor
     
    151151
    152152// check DMA chdev definition
    153 assert( (dev_xp != XPTR_NULL) , "undefined DMA chdev descriptor" );
     153assert( __FUNCTION__, (dev_xp != XPTR_NULL) , "undefined DMA chdev descriptor" );
    154154
    155155    // register command in calling thread descriptor
  • trunk/kernel/devices/dev_fbf.c

    r657 r674  
    4848    if     ( cmd_type == FBF_GET_CONFIG     )  return "GET_CONFIG";
    4949    else if( cmd_type == FBF_CREATE_WINDOW  )  return "CREATE_WINDOW";
     50    else if( cmd_type == FBF_ACTIVE_WINDOW  )  return "ACTIVE_WINDOW";
    5051    else if( cmd_type == FBF_DELETE_WINDOW  )  return "DELETE_WINDOW";
    5152    else if( cmd_type == FBF_MOVE_WINDOW    )  return "MOVE_WINDOW";
    5253    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
    5357    else if( cmd_type == FBF_DIRECT_WRITE   )  return "DIRECT_WRITE";
    5458    else if( cmd_type == FBF_DIRECT_READ    )  return "DIRECT_READ";
     
    5660}
    5761
     62////////////////////////////////////////////////
     63xptr_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
    58103////////////////////////////////////
    59104void dev_fbf_init( chdev_t  * fbf )
     
    94139    xptr_t  dev_xp = chdev_dir.fbf[0];
    95140
    96 assert( (dev_xp != XPTR_NULL) , "undefined FBF chdev descriptor" );
     141assert( __FUNCTION__, (dev_xp != XPTR_NULL) , "undefined FBF chdev descriptor" );
    97142
    98143    // get FBF chdev cluster and local pointer
     
    107152}  // end dev_fbf_get_config()
    108153
    109 ///////////////////////////////////////////////
     154/////////////////////////////////////////////////
    110155uint32_t dev_fbf_create_window( uint32_t   nlines,
    111156                                uint32_t   npixels,
     
    136181
    137182// check fbf_xp definition
    138 assert( (fbf_xp != XPTR_NULL) , "undefined FBF chdev descriptor" );
     183assert( __FUNCTION__, (fbf_xp != XPTR_NULL) , "undefined FBF chdev descriptor" );
    139184
    140185    // get FBF width and height
     
    249294    window->l_min   = l_min;
    250295    window->p_min   = p_min;
    251     window->hidden  = false;
     296    window->hidden  = true;
    252297    window->buffer  = (uint8_t *)vseg_base;
    253298
     
    271316#endif
    272317
    273 #if (DEBUG_DEV_FBF & 1)
    274 hal_vmm_display( ref_xp , true );
    275 #endif
    276 
    277318    // return pointer on allocated buffer
    278319    *user_buffer = vseg_base;
     
    282323}  // end dev_fbf_create_window()
    283324
    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/////////////////////////////////////////////
     326error_t dev_fbf_active_window( uint32_t  wid,
     327                               uint32_t  active )
     328{
     329
     330#if DEBUG_DEV_FBF
     331thread_t  * thi   = CURRENT_THREAD;
     332uint32_t    cycle = (uint32_t)hal_get_cycles();
     333if( DEBUG_DEV_FBF < cycle )
     334printk("\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
    307344    cxy_t          window_cxy = GET_CXY( window_xp );
    308345    fbf_window_t * window_ptr = GET_PTR( window_xp );
    309346
    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
     351cycle = (uint32_t)hal_get_cycles();
     352if( DEBUG_DEV_FBF < cycle )
     353printk("\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()
    347360
    348361////////////////////////////////////////////////////////////////////////////////////////
    349362// 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 the
    351 // 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 defined
    353 // by the windows xlist. It does not take the lock protecting the xlist, that must be
    354 // 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.
    355368////////////////////////////////////////////////////////////////////////////////////////
    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.
    359378////////////////////////////////////////////////////////////////////////////////////////
    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////////////////////////////////////////////////////////////////////////////////////////
     384error_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
    367392    error_t        error;
    368393
    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];
    372396
    373397    // get pointer on calling thread and core lid
    374398    thread_t  * this = CURRENT_THREAD;
    375399
    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
    383401uint32_t cycle = (uint32_t)hal_get_cycles();
    384402if( DEBUG_DEV_FBF < cycle )
    385 printk("\n[%s] core[%x,%d] enter / wid %d / cycle %d\n",
    386 __FUNCTION__, local_cxy, lid, wid, cycle );
     403printk("\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 );
    387405#endif
    388406
     
    392410    chdev_t   * fbf_ptr = GET_PTR( fbf_xp );
    393411
    394     // get frame buffer width
     412    // get frame buffer width and height
    395413    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
     417assert( __FUNCTION__, (p_min < fbf_width)  && (p_max <= fbf_width) &&
     418        (l_min < fbf_height) && (l_max <= fbf_height) , "illegal arguments" );
    396419
    397420    // get pointer on driver command function
    398421    dev_cmd_t * cmd = hal_remote_lpt( XPTR( fbf_cxy , &fbf_ptr->cmd ) );
    399422
    400     // build extended pointers on windows xlist root
     423    // build extended pointers on windows xlist root and lock
    401424    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 );
    407426
    408427    error = 0;
    409428
    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++ )
    412431    {
    413432        // 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
    417439        XLIST_FOREACH( windows_root_xp , iter_xp )
    418440        {
    419             // get pointers on remote window
     441            // get pointers on current target window
    420442            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 );
    432486        }  // end for windows
     487
     488        // release the lock
     489        remote_rwlock_rd_release( windows_lock_xp );
    433490
    434491        // compute offset in FBF
     
    439496        this->fbf_cmd.type      = FBF_DRIVER_KERNEL_WRITE;
    440497        this->fbf_cmd.buffer    = line_buffer;
    441         this->fbf_cmd.npixels   = w_pixels;
     498        this->fbf_cmd.npixels   = p_max - p_min;
    442499        this->fbf_cmd.offset    = fbf_offset;
    443500
     
    452509cycle = (uint32_t)hal_get_cycles();
    453510if( 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 );
     511printk("\n[%s] exit / cycle %d\n",
     512__FUNCTION__, cycle );
    456513#endif
    457514
     
    475532__FUNCTION__ , process->pid, this->trdid, wid, cycle );
    476533#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;
    477539
    478540    // get cluster and pointers on FBF chdev
     
    481543    chdev_t   * fbf_ptr = GET_PTR( fbf_xp );
    482544
    483     // build extended pointers on windows lock, and wid allocator
     545    // build extended pointers on windows lock, windows_tbl[wid] and wid allocator
    484546    xptr_t windows_lock_xp = XPTR( fbf_cxy , &fbf_ptr->ext.fbf.windows_lock );
    485547    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
    501551    cxy_t          window_cxy = GET_CXY( window_xp );
    502552    fbf_window_t * window_ptr = GET_PTR( window_xp );
    503553
    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
    520568    remote_rwlock_wr_acquire( windows_lock_xp );
    521569
    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
    526571    hal_remote_s64( windows_tbl_xp , XPTR_NULL );
    527572
    528     // 4. remove the window from xlist     
     573    // 5. remove the window from xlist     
    529574    xlist_unlink( XPTR( window_cxy , &window_ptr->xlist ) );
    530575
    531     // 5. release wid to bitmap
     576    // 6. release wid to bitmap
    532577    bitmap_remote_clear( wid_bitmap_xp , wid );
    533578
    534     // 6. release the lock protecting windows in write mode
     579    // 7. release the lock protecting windows in write mode
    535580    remote_rwlock_wr_release( windows_lock_xp );
    536581 
    537     // 7. release memory allocated for window descriptor
     582    // 8. release memory allocated for window descriptor
    538583    req.type = KMEM_KCM;
    539584    req.ptr  = window_ptr;
    540585    kmem_remote_free( window_cxy , &req );
    541586
    542     // 8. release the associated vseg
     587    // 9. release the associated vseg
    543588    vmm_global_delete_vseg( process , (intptr_t)buffer );
    544589   
     
    556601////////////////////////////////////////////
    557602error_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
     608thread_t  * this  = CURRENT_THREAD;
     609uint32_t    cycle = (uint32_t)hal_get_cycles();
     610if( DEBUG_DEV_FBF < cycle )
     611printk("\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;
    570619
    571620    // get cluster and pointers on FBF chdev
     
    578627    xptr_t windows_root_xp = XPTR( fbf_cxy , &fbf_ptr->ext.fbf.windows_root );
    579628
    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
    594631    cxy_t          window_cxy = GET_CXY( window_xp );
    595632    fbf_window_t * window_ptr = GET_PTR( window_xp );
    596633
    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 ) );
    601637    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 );
    610642
    611643    // 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 )
     650printk("\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 )
     657printk("\n[%s] refreshed old window\n", __FUNCTION__ );
     658#endif
     659
     660    // 3. take the lock protecting windows in write mode
    615661    remote_rwlock_wr_acquire( windows_lock_xp );
    616662
     
    619665#endif
    620666
    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 );
    647670
    648671#if ( DEBUG_DEV_FBF & 1 )
     
    650673#endif
    651674
    652     // 6. gives the window the highest priority
     675    // 5. gives the window the highest priority
    653676    xlist_unlink( xlist_entry_xp );
    654677    xlist_add_last( windows_root_xp , xlist_entry_xp );
     
    658681#endif
    659682
     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 )
     687printk("\n[%s] lock released\n", __FUNCTION__ );
     688#endif
     689
    660690    // 7. reset the "hidden" flag in window descriptor
    661691    hal_remote_s32( XPTR( window_cxy , &window_ptr->hidden ) , false );
     
    665695#endif
    666696
    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 )
     701printk("\n[%s] refresh new new window\n", __FUNCTION__ );
     702#endif
     703
    677704#if DEBUG_DEV_FBF
    678705cycle = (uint32_t)hal_get_cycles();
    679706if( DEBUG_DEV_FBF < cycle )
    680707printk("\n[%s] thread[%x,%x] exit / cycle %d\n",
    681 __FUNCTION__ , process->pid, this->trdid, cycle );
     708__FUNCTION__ , this->process->pid, this->trdid, cycle );
    682709#endif
    683710
     
    695722
    696723#if DEBUG_DEV_FBF
    697 uint32_t   cycle = (uint32_t)hal_get_cycles();
     724uint32_t    cycle = (uint32_t)hal_get_cycles();
    698725if( DEBUG_DEV_FBF < cycle )
    699726printk("\n[%s] thread[%x,%x] enters : wid %d / width %d / height %d / cycle %d\n",
    700727__FUNCTION__ , process->pid , this->trdid , wid, width , height , cycle );
    701728#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;
    702734
    703735    // get cluster and pointers on FBF chdev
     
    710742    xptr_t windows_root_xp = XPTR( fbf_cxy , &fbf_ptr->ext.fbf.windows_root );
    711743
    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
    726745    cxy_t          window_cxy = GET_CXY( window_xp );
    727746    fbf_window_t * window_ptr = GET_PTR( window_xp );
    728747
    729748    // 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 );
    742757
    743758    // does nothing if no change
     
    748763    uint32_t new_size = width * height;
    749764
    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 )
     769printk("\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 )
     776printk("\n[%s] refreshed old window\n", __FUNCTION__ );
     777#endif
     778
     779    // 3. take the lock protecting windows in write mode
    751780    remote_rwlock_wr_acquire( windows_lock_xp );
    752781
     
    755784#endif
    756785
    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,
    781787    hal_remote_s32( XPTR( window_cxy , &window_ptr->width  ), width );
    782788    hal_remote_s32( XPTR( window_cxy , &window_ptr->height ), height );
     
    786792#endif
    787793
    788     // 6. resize vseg if required
     794    // 5. resize vseg if required
    789795    vmm_global_resize_vseg( process, (intptr_t)base, (intptr_t)base, width * height );
    790796
     
    793799#endif
    794800
    795     // 7. fill buffer extension if required
     801    // 6. fill buffer extension if required
    796802    if( new_size > old_size )  memset( base + old_size , 0 , new_size - old_size );
    797803
     
    800806#endif
    801807
    802     // 8. gives the window the highest priority
     808    // 7. gives the window the highest priority
    803809    xlist_unlink( xlist_entry_xp );
    804810    xlist_add_last( windows_root_xp , xlist_entry_xp );
     
    808814#endif
    809815
     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 )
     820printk("\n[%s] lock released\n", __FUNCTION__ );
     821#endif
     822
    810823    // 9. reset the "hidden" flag in window descriptor
    811824    hal_remote_s32( XPTR( window_cxy , &window_ptr->hidden ) , false );
     
    816829
    817830    // 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 )
     834printk("\n[%s] refreshed new window\n", __FUNCTION__ );
     835#endif
     836
    827837#if DEBUG_DEV_FBF
    828838cycle = (uint32_t)hal_get_cycles();
     
    836846}  // end dev_fbf_resize_window()
    837847
    838 ///////////////////////////////////////////////
     848//////////////////////////////////////////////
    839849error_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
     855thread_t  * thi   = CURRENT_THREAD;
     856uint32_t    cycle = (uint32_t)hal_get_cycles();
    849857if( DEBUG_DEV_FBF < cycle )
    850858printk("\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
     889cycle = (uint32_t)hal_get_cycles();
     890if( DEBUG_DEV_FBF < cycle )
     891printk("\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////////////////////////////////////////////
     900error_t dev_fbf_front_window( uint32_t wid )
     901{
     902
     903#if DEBUG_DEV_FBF
     904thread_t  * this  = CURRENT_THREAD;
     905uint32_t    cycle = (uint32_t)hal_get_cycles();
     906if( DEBUG_DEV_FBF < cycle )
     907printk("\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;
    853915
    854916    // get cluster and pointers on FBF chdev
     
    857919    chdev_t   * fbf_ptr = GET_PTR( fbf_xp );
    858920
    859     // build extended pointer on windows lock
     921    // build extended pointer on windows lock and root
    860922    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
    867926    cxy_t          window_cxy = GET_CXY( window_xp );
    868927    fbf_window_t * window_ptr = GET_PTR( window_xp );
    869928
    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 )
     943printk("\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 )
     951printk("\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 )
     958printk("\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 )
     965printk("\n[%s] refresh window in FBF\n", __FUNCTION__ );
     966#endif
     967
     968#if DEBUG_DEV_FBF
     969cycle = (uint32_t)hal_get_cycles();
     970if( DEBUG_DEV_FBF < cycle )
     971printk("\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/////////////////////////////////////////
     980void 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        }
    8761019    }
    8771020
    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/////////////////////////////////
     1027void 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 );
    8871055    }
    8881056
    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
    9191064
    9201065///////////////////////////////////////////////
  • trunk/kernel/devices/dev_fbf.h

    r657 r674  
    3939 * This device provide access to an external graphic display, that is seen
    4040 * 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 pixel
    42  * (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).
    4343 *
    4444 * It supports a first API, for the user syscalls, implementing a simple windows manager.
     
    7878 * - FBF_DIRECT_WRITE   : move synchronously pixels from an user buffer to the FBF.
    7979 * - FBF_DIRECT_READ    : move synchronously pixels from the FBF to an user buffer.
    80  *
    8180 * For these deprecated operations, the client thread calls
    8281 * directly the driver to move data between the user buffer and the FBF.
     
    105104    bitmap_t        windows_bitmap[CONFIG_FBF_WINDOWS_MAX_NR >> 5]; /*! wid allocator    */
    106105
    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.           */
    110109}
    111110fbf_extend_t;
     
    169168fbf_window_t;
    170169
     170
    171171/******************************************************************************************
    172172 * This function returns a printable string for a given FBF user command  <cmd_type>.
     
    177177 *****************************************************************************************/
    178178char * 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 *****************************************************************************************/
     188xptr_t dev_fbf_get_xptr_from_wid( uint32_t wid );
    179189
    180190/******************************************************************************************
     
    208218 * The window index <wid> is dynamically allocated. The owner is the calling process.
    209219 * 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 this vseg is not directly
     220 * It can be called by any thread running in any cluster. As the vseg is not directly
    211221 * mapped to the frame buffer, the owner process can access this private buffer without
    212222 * 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,
    217228 * 2. it creates in the associated vseg,
    218229 * 3. it initializes the window descriptor,
     
    220231 * 5. it allocates a new  <wid>,
    221232 * 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,
    223234 * 8. it releases the lock protecting windows.
    224  * It does not call the FBF driver.
    225235 ******************************************************************************************
    226236 * @ nlines      : [in]  number of lines in window.
    227237 * @ 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.
    230240 * @ user_base   : [out] pointer on allocated buffer base in user space.
    231241 * @ return the <wid> index if success / returns -1 if failure
     
    237247                                intptr_t * user_base );
    238248
     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 *****************************************************************************************/
     258error_t dev_fbf_active_window( uint32_t wid,
     259                               uint32_t active );
     260
    239261/******************************************************************************************
    240262 * This function implements the fbf_delete_window() syscall to delete a FBF window,
     
    242264 * releases the memory allocated for the window buffer and for the window descriptor.
    243265 * 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,
    249271 * 4. it removes the window from windows_tbl[] array,
    250272 * 5. it removes the window from xlist,     
    251273 * 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,
    253275 * 8. it releases the memory allocated for window descriptor,
    254276 * 9. it deletes the associated vseg in all clusters
    255  * It does not call directly the FBF driver.
    256277 ******************************************************************************************
    257278 * @ wid       : [in] window index in window_tbl[].
     
    265286 * defined by the <l_min> and <p_min> arguments.
    266287 * 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,
    275296 * 7. it reset the "hidden" flag in window descriptor,
    276297 * 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.
    279298 ******************************************************************************************
    280299 * @ 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.
    283302 * @ returns 0 if success / returns -1 if illegal arguments.
    284303 *****************************************************************************************/
     
    293312 * When the new window buffer is larger than the existing one, it is 0 filled.
    294313 * 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 vseg if required,
    303  * 7.  if 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,
    305324 * 9.  it reset the "hidden" flag in window descriptor,
    306325 * 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.
    309326 ******************************************************************************************
    310327 * @ wid       : [in] window index in window_tbl[].
     
    321338 * It allows an owner process to signal the windows manager that some lines of a window
    322339 * 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.
    332345 ******************************************************************************************
    333346 * @ 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).
    336349 * @ returns 0 if success / returns -1 if wid not registered.
    337350 *****************************************************************************************/
    338351error_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 *****************************************************************************************/
     370error_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 *****************************************************************************************/
     380void 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 *****************************************************************************************/
     388void 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
    344398 * to implement the fbf_read() and fbf_write() deprecated syscalls.
    345  *
     399 ******************************************************************************************
    346400 * It  moves <length> bytes between the frame buffer, starting from pixel defined
    347401 * by the <offset> argument, and an user buffer defined by the <user_buffer> argument.
  • trunk/kernel/devices/dev_ioc.c

    r663 r674  
    5454
    5555    // set chdev name
    56     snprintf( ioc->name , 16 , "ioc%d" , channel );
     56    snprintk( ioc->name , 16 , "ioc%d" , channel );
    5757
    5858    // call driver init function
     
    7878                                  lid );
    7979
    80 assert( (error == 0) , "cannot create server thread" );
     80assert( __FUNCTION__, (error == 0) , "cannot create server thread" );
    8181
    8282    // set "server" field in chdev descriptor
     
    108108
    109109// check dev_xp
    110 assert( (ioc_xp != XPTR_NULL) , "undefined IOC chdev descriptor" );
     110assert( __FUNCTION__, (ioc_xp != XPTR_NULL) , "undefined IOC chdev descriptor" );
    111111
    112112    // register command in client thread 
     
    141141
    142142// check dev_xp
    143 assert( (ioc_xp != XPTR_NULL) , "undefined IOC chdev descriptor" );
     143assert( __FUNCTION__, (ioc_xp != XPTR_NULL) , "undefined IOC chdev descriptor" );
    144144
    145145    // register command in calling thread descriptor
  • trunk/kernel/devices/dev_mmc.c

    r657 r674  
    4141{
    4242    // set mmc name
    43     snprintf( mmc->name , 16 , "mmc_%x" , local_cxy );
     43    snprintk( mmc->name , 16 , "mmc_%x" , local_cxy );
    4444
    4545    // call driver init function
     
    6565    xptr_t  dev_xp = this->mmc_cmd.dev_xp;
    6666
    67     assert( (dev_xp != XPTR_NULL) , "target MMC device undefined" );
     67    assert( __FUNCTION__, (dev_xp != XPTR_NULL) , "target MMC device undefined" );
    6868
    6969    // get MMC device cluster identifier & local pointer
  • trunk/kernel/devices/dev_nic.c

    r668 r674  
    5454
    5555    // set chdev name
    56     if( is_rx ) snprintf( chdev->name , 16 , "nic%d_rx" , channel );
    57     else        snprintf( 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 );
    5858
    5959    // initialize the root of the listening sockets list
     
    360360
    361361///////////////////////////////////////////////////////////////////////////////////////////
    362 // This static function can be called by the NIC_TX or NIC_RX server threads to unblock
     362// This static function is called by the NIC_TX or NIC_RX server threads to unblock
    363363// the TX client thread after completion (success or error) of a TX command registered
    364364// in a socket identified by the <socket_xp> argument. The <status> argument defines
     
    401401
    402402///////////////////////////////////////////////////////////////////////////////////////////
    403 // This static function can be called by the NIC_TX or NIC_RX server threads to unblock
     403// This static function is called by the NIC_TX or NIC_RX server threads to unblock
    404404// the RX client thread after completion (success or error) of an RX command registered
    405405// in a socket identified by the <socket_xp> argument. The <status> argument defines
     
    440440
    441441}  // end dev_nic_unblock_rx_client()
    442 
    443 
    444442
    445443///////////////////////////////////////////////////////////////////////////////////////////
     
    680678    // get status & space from rx_buf
    681679    status = remote_buf_status( socket_rbuf_xp );
    682     space  = NIC_RX_BUF_SIZE - status;
     680    space  = CONFIG_SOCK_RX_BUF_SIZE - status;
    683681
    684682    // get client thread
     
    12681266
    12691267                        // 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;
    12711269
    12721270                        // compute number of bytes to move : min (space , seg_data_len)
     
    14061404                        // update socket.state
    14071405                        hal_remote_s32( XPTR( socket_cxy , &socket_ptr->state ),
    1408                                         TCP_STATE_CLOSED );  // TODO change to TIME_WAIT
     1406                                        TCP_STATE_CLOSED );
    14091407
    14101408                        // make an ACK request to R2T queue
     
    14151413                        // report success to TX client thread
    14161414                        dev_nic_unblock_tx_client( socket_xp , CMD_STS_SUCCESS );
    1417 
    1418                         // TODO start the MSL timer / turn off others timers
    1419 
    14201415                    }
    14211416                }
     
    14241419                    // update socket.state
    14251420                    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
    14401424                    dev_nic_unblock_tx_client( socket_xp , CMD_STS_SUCCESS );
     1425
    14411426                }
    14421427                else if( socket_state == TCP_STATE_CLOSE_WAIT )
     
    14911476               
    14921477// check socket type and state
    1493 assert( (socket_type  == SOCK_STREAM ) , "illegal socket type" );
    1494 assert( (socket_state == TCP_STATE_LISTEN ) , "illegal socket state" );
     1478assert( __FUNCTION__, (socket_type  == SOCK_STREAM ) , "illegal socket type" );
     1479assert( __FUNCTION__, (socket_state == TCP_STATE_LISTEN ) , "illegal socket state" );
    14951480
    14961481        // get relevant socket infos for matching
     
    16381623
    16391624// check chdev direction and type
    1640 assert( (chdev->func == DEV_FUNC_NIC) && (chdev->is_rx == true) ,
     1625assert( __FUNCTION__, (chdev->func == DEV_FUNC_NIC) && (chdev->is_rx == true) ,
    16411626"illegal chdev type or direction" );
    16421627
     
    23742359                    // initialize socket tx_nxt, and rx_wnd
    23752360                    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);
    23772362               
    23782363                    // build TCP ACK-SYN segment
     
    26242609void dev_nic_tx_server( chdev_t * chdev )
    26252610{
    2626     uint8_t       k_buf[NIC_KERNEL_BUF_SIZE];  // buffer for one packet
     2611    uint8_t       k_buf[CONFIG_SOCK_PKT_BUF_SIZE];  // buffer for one packet
    26272612
    26282613    xptr_t        queue_root_xp;       // extended pointer on sockets list root
     
    26502635
    26512636// check chdev direction and type
    2652 assert( (chdev->func == DEV_FUNC_NIC) && (chdev->is_rx == false) ,
     2637assert( __FUNCTION__, (chdev->func == DEV_FUNC_NIC) && (chdev->is_rx == false) ,
    26532638"illegal chdev type or direction" );
    26542639
  • trunk/kernel/devices/dev_nic.h

    r668 r674  
    153153#define TCP_FLAG_URG           0x20
    154154
    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
    161156
    162157/*****************************************************************************************
  • trunk/kernel/devices/dev_txt.c

    r663 r674  
    7474    bool_t    is_rx   = txt->is_rx;
    7575
    76 assert( (pic_xp != XPTR_NULL) || (channel == 0) ,
     76assert( __FUNCTION__, ((pic_xp != XPTR_NULL) || (channel == 0)) ,
    7777"PIC not initialised before TXT" );
    7878
    7979    // set chdev name
    80     if( is_rx ) snprintf( txt->name , 16 , "txt%d_rx" , channel );
    81     else        snprintf( 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 );
    8282
    8383    // set TXT chdev extension
     
    120120                                      lid );
    121121
    122         assert( (error == 0) , "cannot create server thread" );
     122        assert( __FUNCTION__, (error == 0) , "cannot create server thread" );
    123123
    124124        // set "server" field in chdev descriptor
     
    154154
    155155// check channel argument
    156 assert( (channel < CONFIG_MAX_TXT_CHANNELS) , "illegal channel index" );
     156assert( __FUNCTION__, (channel < CONFIG_MAX_TXT_CHANNELS) , "illegal channel index" );
    157157
    158158    // get pointers on chdev
     
    162162
    163163// check dev_xp
    164 assert( (dev_xp != XPTR_NULL) , "undefined TXT chdev descriptor" );
     164assert( __FUNCTION__, (dev_xp != XPTR_NULL) , "undefined TXT chdev descriptor" );
    165165
    166166    // If we use MTTY (vci_multi_tty), we do a synchronous write on TXT[0]
     
    243243
    244244// check channel argument
    245 assert( (channel < CONFIG_MAX_TXT_CHANNELS) , "illegal channel index" );
     245assert( __FUNCTION__, (channel < CONFIG_MAX_TXT_CHANNELS) , "illegal channel index" );
    246246
    247247    // get pointers on chdev
     
    249249
    250250// check dev_xp
    251 assert( (dev_xp != XPTR_NULL) , "undefined TXT chdev descriptor" );
     251assert( __FUNCTION__, (dev_xp != XPTR_NULL) , "undefined TXT chdev descriptor" );
    252252
    253253    // register command in calling thread descriptor
     
    290290                            uint32_t     count )
    291291{
    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 );
    300295    chdev_t * dev_ptr = GET_PTR( dev_xp );
    301296
    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.