Ignore:
Timestamp:
Nov 20, 2020, 12:04:01 AM (3 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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///////////////////////////////////////////////
Note: See TracChangeset for help on using the changeset viewer.