Ignore:
Timestamp:
Mar 18, 2020, 11:16:59 PM (22 months ago)
Author:
alain
Message:

Introduce remote_buf.c/.h & socket.c/.h files.
Update dev_nic.c/.h files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/hal/tsar_mips32/drivers/soclib_fbf.c

    r654 r657  
    22 * soclib_fbf.c - soclib frame-buffer driver implementation.
    33 *
    4  * Author Alain greiner (2016,2017,2018,2019)
     4 * Author Alain greiner (2016,2017,2018,2019,2020)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    5959void __attribute__((noinline)) soclib_fbf_cmd( xptr_t thread_xp )
    6060{
    61     uint32_t   cmd_type;    // READ / WRITE / SYNC_READ / SYNC_WRITE
    62     uint32_t   offset;
    63     uint32_t   length;
    64     void     * buffer;      // pointer on memory buffer in user space
    65     xptr_t     fbf_xp;
     61    uint32_t   type;        // USER_WRITE / USER_READ / KERNEL_WRITE / KERNEL_READ
     62    uint32_t   offset;      // offset in FBF (in pixels)
     63    uint32_t   npixels;     // number of pixels to move
     64    xptr_t     fbf_xp;      // extended pointer on FBF chdev descriptor
    6665    uint32_t   status;      // I/0 operation status (from BDV)
     66    void     * buffer;      // pointer on kernel or user buffer
    6767
    6868    // get client thread cluster and local pointer
     
    7878
    7979    // get command arguments
    80     cmd_type =         hal_remote_l32( XPTR( th_cxy , &th_ptr->fbf_cmd.type   ) );
    81     offset   =         hal_remote_l32( XPTR( th_cxy , &th_ptr->fbf_cmd.offset ) );
    82     length   =         hal_remote_l32( XPTR( th_cxy , &th_ptr->fbf_cmd.length ) );
    83     buffer   =         hal_remote_lpt( XPTR( th_cxy , &th_ptr->fbf_cmd.buffer ) );
    84     fbf_xp   = (xptr_t)hal_remote_l64( XPTR( th_cxy , &th_ptr->fbf_cmd.dev_xp ) );
     80    type     = hal_remote_l32( XPTR( th_cxy , &th_ptr->fbf_cmd.type    ) );
     81    offset   = hal_remote_l32( XPTR( th_cxy , &th_ptr->fbf_cmd.offset ) );
     82    npixels  = hal_remote_l32( XPTR( th_cxy , &th_ptr->fbf_cmd.npixels ) );
     83    fbf_xp   = hal_remote_l64( XPTR( th_cxy , &th_ptr->fbf_cmd.dev_xp ) );
     84    buffer   = hal_remote_lpt( XPTR( th_cxy , &th_ptr->fbf_cmd.buffer ) );
    8585
    8686    // get cluster and local pointer on FBF chdev
     
    9292
    9393    // execute command
    94     if( cmd_type == FBF_READ )     // use a (kernel -> user) memcpy
     94    if( type == FBF_DRIVER_USER_WRITE )     // user_buffer => FBF
    9595    {
    9696
    9797#if DEBUG_HAL_FBF
    9898if( DEBUG_HAL_FBF < cycle )
    99 printk("\n[%s] client thread[%x,%x] / READ / offset %d / length %d / buffer %x / fbf (%x,%x)\n",
    100 __FUNCTION__ , client_pid, client_trdid,
    101 offset, length, buffer, GET_CXY(base_xp), GET_PTR(base_xp) );
     99printk("\n[%s] client thread[%x,%x] / USER_WRITE / offset %d / npixels %d / buf %x\n",
     100__FUNCTION__ , client_pid, client_trdid, offset, npixels, buffer );
    102101#endif
    103         hal_copy_to_uspace( buffer,
    104                             base_xp + offset,
    105                             length );
    106 #if DEBUG_HAL_FBF
    107 if( DEBUG_HAL_FBF < cycle )
    108 printk("\n[%s] client thread[%x,%x] / READ successful / cycle %d\n",
    109 __FUNCTION__ , client_pid, client_trdid , cycle );
    110 #endif
    111 
     102        hal_copy_from_uspace( base_xp + offset,
     103                              buffer,
     104                              npixels );
    112105    }
    113     else  // cmd_type == FBF_WRITE => use a (user -> kernel)  memcpy
     106    else if( type == FBF_DRIVER_USER_READ )  // FBF => user_buffer
    114107    {
    115108
    116109#if DEBUG_HAL_FBF
    117110if( DEBUG_HAL_FBF < cycle )
    118 printk("\n[%s] client thread[%x,%x] / WRITE / offset %d / length %d / buffer %x / fbf (%x,%x)\n",
    119 __FUNCTION__ , client_pid, client_trdid,
    120 offset, length, buffer, GET_CXY(base_xp), GET_PTR(base_xp) );
     111printk("\n[%s] client thread[%x,%x] / USER_READ / offset %d / npixels %d / buf %x\n",
     112__FUNCTION__ , client_pid, client_trdid, offset, npixels, buffer );
    121113#endif
    122         hal_copy_from_uspace( base_xp + offset,
    123                               buffer,
    124                               length );
     114        hal_copy_to_uspace( buffer,
     115                            base_xp + offset,
     116                            npixels );
     117    }
     118    else if( type == FBF_DRIVER_KERNEL_WRITE )  // kernel_buffer => FBF
     119    {
     120
    125121#if DEBUG_HAL_FBF
    126122if( DEBUG_HAL_FBF < cycle )
    127 printk("\n[%s] client thread[%x,%x] / WRITE successful / cycle %d\n",
    128 __FUNCTION__ , client_pid, client_trdid , cycle );
     123printk("\n[%s] client thread[%x,%x] / KERNEL_WRITE / offset %d / npixels %d / buf %x\n",
     124__FUNCTION__ , client_pid, client_trdid, offset, npixels, buffer );
    129125#endif
     126        hal_remote_memcpy( base_xp + offset,
     127                           XPTR( local_cxy , buffer ),
     128                           npixels );
     129    }
     130    else if( type == FBF_DRIVER_KERNEL_READ )  // FBF => kernel_buffer
     131    {
    130132
     133#if DEBUG_HAL_FBF
     134if( DEBUG_HAL_FBF < cycle )
     135printk("\n[%s] client thread[%x,%x] / KERNEL_READ / offset %d / npixels %d / buf %x\n",
     136__FUNCTION__ , client_pid, client_trdid, offset, npixels, buffer );
     137#endif
     138        hal_remote_memcpy( XPTR( local_cxy , buffer ),
     139                           base_xp + offset,
     140                           npixels );
    131141    }
    132142
    133143    // set success in command
    134144    hal_remote_s32( XPTR( th_cxy , &th_ptr->fbf_cmd.error ) , 0 );
     145
     146#if DEBUG_HAL_FBF
     147if( DEBUG_HAL_FBF < cycle )
     148printk("\n[%s] client thread[%x,%x] / successful move / cycle %d\n",
     149__FUNCTION__ , client_pid, client_trdid , cycle );
     150#endif
    135151           
    136152}  // end soclib_fbf_cmd()
Note: See TracChangeset for help on using the changeset viewer.