Changeset 647 for trunk/kernel


Ignore:
Timestamp:
Oct 22, 2019, 1:48:51 PM (4 years ago)
Author:
alain
Message:

...miscelaneous...

Location:
trunk/kernel
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/Makefile

    r641 r647  
    1919                 $(HAL_ARCH)/build/drivers/soclib_nic.o  \
    2020                 $(HAL_ARCH)/build/drivers/soclib_dma.o  \
     21                 $(HAL_ARCH)/build/drivers/soclib_fbf.o  \
    2122                 $(HAL_ARCH)/build/drivers/soclib_iob.o
    2223
     
    190191              build/syscalls/sys_get_best_core.o   \
    191192              build/syscalls/sys_get_nb_cores.o    \
    192               build/syscalls/sys_get_thread_info.o
     193              build/syscalls/sys_get_thread_info.o \
     194              build/syscalls/sys_fbf.o
    193195
    194196VFS_OBJS    = build/fs/vfs.o              \
     
    231233
    232234
    233 ##############################
     235######################################
    234236# rules to compile the drivers and hal
    235237$(HAL_ARCH)/build/%:
  • trunk/kernel/devices/dev_dma.c

    r637 r647  
    4141void dev_dma_init( chdev_t * dma )
    4242{
    43     // get implementation & channel from DMA dma descriptor
    44     uint32_t impl    = dma->impl;
     43    // get channel from chdev descriptor
    4544    uint32_t channel = dma->channel;
    4645
     
    4948
    5049    // call driver init function
    51     hal_drivers_dma_init( dma, impl );
     50    hal_drivers_dma_init( dma );
    5251
    5352    // bind IRQ to the core defined by the DMA channel
     
    104103    xptr_t  dev_xp = chdev_dir.dma[channel];
    105104
    106     assert( (dev_xp != XPTR_NULL) , "undefined DMA chdev descriptor" );
     105// check DMA chdev definition
     106assert( (dev_xp != XPTR_NULL) , "undefined DMA chdev descriptor" );
    107107
    108108    // register command in calling thread descriptor
  • trunk/kernel/devices/dev_dma.h

    r565 r647  
    3636 * to/from remote clusters. The burst size is defined by the cache line size.
    3737 * Each DMA channel is described by a specific chdev descriptor, handling its private
    38  * waiting threads queue.
    39  * It implement one single command : move data from a (remote) source buffer
    40  * to a (remote) destination buffer.
     38 * waiting threads queue. It implement one single command : move data from a (remote)
     39 * source buffer to a (remote) destination buffer.
    4140 ****************************************************************************************/
    4241 
  • trunk/kernel/devices/dev_fbf.c

    r565 r647  
    11/*
    2  * dev_fbf.c - FBF (Block Device Controler) generic device API implementation.
     2 * dev_fbf.c - FBF (Frame Buffer) generic device API implementation.
    33 *
    4  * Author  Alain Greiner    (2016,2017,2018)
     4 * Author  Alain Greiner    (2016,2017,2018,2019)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    2525#include <hal_kernel_types.h>
    2626#include <hal_gpt.h>
     27#include <hal_drivers.h>
    2728#include <thread.h>
    2829#include <printk.h>
     
    3738extern chdev_directory_t  chdev_dir;         // allocated in kernel_init.c
    3839
     40///////////////////////////////////////////
     41char * dev_fbf_cmd_str( uint32_t cmd_type )
     42{
     43    if     ( cmd_type == FBF_READ       )  return "READ";
     44    else if( cmd_type == FBF_WRITE      )  return "WRITE";
     45    else if( cmd_type == FBF_GET_CONFIG )  return "GET_CONFIG";
     46    else                                   return "undefined";
     47}
     48
    3949////////////////////////////////////
    40 void dev_fbf_init( chdev_t  * chdev )
     50void dev_fbf_init( chdev_t  * fbf )
    4151{
    42     // set FBF chdev extension fields
    43     // TODO this should be done in the implementation
    44     // TODO specific part, as these parameters must be obtained from the hardware.
    45     chdev->ext.fbf.width  = CONFIG_FBF_WIDTH;
    46     chdev->ext.fbf.height = CONFIG_FBF_HEIGHT;
    47 
    48     // get implementation
    49     uint32_t  impl = chdev->impl;
    50 
    5152    // set chdev name
    52     strcpy( chdev->name, "fbf" );
     53    strcpy( fbf->name, "fbf" );
    5354
    5455    // call driver init function
    55     if( impl == IMPL_FBF_SCL )
    56     {
    57         printk("\n[WARNING] Soclib FBF driver not implemented yet\n");
    58     }
    59     else
    60     {
    61         assert( false , "undefined FBF device implementation" );
    62     }
     56    hal_drivers_fbf_init( fbf );
    6357
    6458}  // end dev_fbf_init()
    6559
    66 /////////////////////////////////////////
    67 void dev_fbf_get_size( uint32_t  * width,
    68                        uint32_t  * height )
     60//////////////////////////////////////////
     61void dev_fbf_get_config( uint32_t * width,
     62                         uint32_t * height,
     63                         uint32_t * type )
    6964{
    7065    // get extended pointer on FBF chdev descriptor
     
    8075    *width  = hal_remote_l32( XPTR( dev_cxy , &dev_ptr->ext.fbf.width ) );
    8176    *height = hal_remote_l32( XPTR( dev_cxy , &dev_ptr->ext.fbf.height ) );
     77    *type   = hal_remote_l32( XPTR( dev_cxy , &dev_ptr->ext.fbf.subsampling ) );
    8278
    83 }  // end dev_fbf_get_size()
     79}  // end dev_fbf_get_config()
    8480
    85 /////////////////////////////
    86 error_t dev_fbf_alloc( void )
     81/////////////////////////////////////////////////////
     82error_t dev_fbf_move_data( uint32_t   cmd_type,
     83                           void     * user_buffer,
     84                           uint32_t   length,
     85                           uint32_t   offset )
    8786{
    88     // get extended pointer on FBF chdev descriptor
    89     // xptr_t  dev_xp = chdev_dir.fbf[0];
     87    // get pointer on calling thread
     88    thread_t * this = CURRENT_THREAD;
    9089
    91     // assert( (dev_xp != XPTR_NULL) , "undefined FBF chdev descriptor" );
     90#if DEBUG_DEV_FBF
     91uint32_t   cycle = (uint32_t)hal_get_cycles();
     92if( DEBUG_DEV_FBF < cycle )
     93printk("\n[%s] thread[%x,%x] : %s / buffer %x / length %d / offset %x / cycle %d\n",
     94__FUNCTION__ , this->process->pid, this->trdid, 
     95dev_fbf_cmd_str(cmd_type), user_buffer, length, offset, cycle );
     96#endif
    9297
    93     // get FBF chdev cluster and local pointer
    94     // cxy_t     dev_cxy = GET_CXY( dev_xp );
    95     // chdev_t * dev_ptr = GET_PTR( dev_xp );
     98    // get pointers on FBF chdev
     99    xptr_t      fbf_xp  = chdev_dir.fbf[0];
     100    cxy_t       fbf_cxy = GET_CXY( fbf_xp );
     101    chdev_t   * fbf_ptr = GET_PTR( fbf_xp );
    96102
    97     // try to get FBF ownership
     103// check fbf_xp definition
     104assert( (fbf_xp != XPTR_NULL) , "undefined FBF chdev descriptor" );
    98105
    99 assert( false , "not implemented yet" );
    100 
    101 }  // end dev_fbf_alloc()
    102 
    103 /////////////////////////
    104 void dev_fbf_free( void )
    105 {
    106     // get extended pointer on FBF chdev descriptor
    107     // xptr_t  dev_xp = chdev_dir.fbf[0];
    108 
    109     // assert( (dev_xp != XPTR_NULL) , "undefined FBF chdev descriptor" );
    110 
    111     // get FBF chdev cluster and local pointer
    112     // cxy_t     dev_cxy = GET_CXY( dev_xp );
    113     // chdev_t * dev_ptr = (GET_PTR( dev_xp );
    114 
    115     // release FBF ownership
    116 
    117 assert( false , "not implemented yet" );
    118 
    119 }  // end dev_fbf_free()
    120 
    121 //////////////////////////////////////////////////////////////////////////////////
    122 // This static function is called by dev_fbf_read() & dev_fbf_write() functions.
    123 // It builds and registers the command in the calling thread descriptor.
    124 // Then, it registers the calling thread in the relevant DMA chdev waiting queue.
    125 // Finally it blocks on the THREAD_BLOCKED_DEV condition and deschedule.
    126 ////////////////////////////////////i/////////////////////////////////////////////
    127 static error_t dev_fbf_access( bool_t    to_fbf,
    128                                char    * buffer,
    129                                uint32_t  length,
    130                                uint32_t  offset )
    131 {
    132 
    133     // get extended pointer on FBF chdev descriptor
    134     xptr_t  fbf_xp = chdev_dir.fbf[0];
    135 
    136     assert( (fbf_xp != XPTR_NULL) , "undefined FBF chdev descriptor" );
    137 
    138     // get FBF chdev cluster and local pointer
    139     cxy_t     fbf_cxy = GET_CXY( fbf_xp );
    140     chdev_t * fbf_ptr = (chdev_t *)GET_PTR( fbf_xp );
    141 
    142     // get frame buffer base address, width and height
    143     xptr_t   base   = hal_remote_l64( XPTR( fbf_cxy , &fbf_ptr->base ) );
     106    // get frame buffer width and height
    144107    uint32_t width  = hal_remote_l32 ( XPTR( fbf_cxy , &fbf_ptr->ext.fbf.width ) );
    145108    uint32_t height = hal_remote_l32 ( XPTR( fbf_cxy , &fbf_ptr->ext.fbf.height ) );
    146109
    147     // check offset and length versus FBF size
    148     assert( ((offset + length) <= (width * height)) ,
    149     "offset %d / length %d / width %d / height %d\n", offset, length, width, height );
     110// check offset and length versus FBF size
     111assert( ((offset + length) <= (width * height)) ,
     112"offset %d / length %d / width %d / height %d\n", offset, length, width, height );
    150113
    151     // compute extended pointers on frame buffer and memory buffer
    152     xptr_t  mem_buf_xp = XPTR( local_cxy , buffer );
    153     xptr_t  fbf_buf_xp = base + offset;
     114    // register command in calling thread descriptor
     115    this->fbf_cmd.dev_xp    = fbf_xp;
     116    this->fbf_cmd.type      = cmd_type;
     117    this->fbf_cmd.buffer    = user_buffer;
     118    this->fbf_cmd.offset    = offset;
     119    this->fbf_cmd.length    = length;
    154120
    155     // register command in DMA chdev
    156     if( to_fbf )  dev_dma_remote_memcpy( fbf_buf_xp , mem_buf_xp , length );
    157     else          dev_dma_remote_memcpy( mem_buf_xp , fbf_buf_xp , length );
     121    // get driver command function
     122    dev_cmd_t * cmd = (dev_cmd_t *)hal_remote_lpt( XPTR( fbf_cxy , &fbf_ptr->cmd ) );
    158123
    159     return 0;
     124    // call driver
     125    cmd( XPTR( local_cxy , this ) );
    160126
    161 }  // end dev_fbf_access()
     127    error_t error = this->fbf_cmd.error;
    162128
    163 ////////////////////////////////////////////
    164 error_t dev_fbf_read( char         * buffer,
    165                       uint32_t       length,
    166                       uint32_t       offset )
    167 {
    168 
    169 #if DEBUG_DEV_FBF_RX
    170 uint32_t cycle = (uint32_t)hal_get_cycles();
    171 if( DEBUG_DEV_FBF_RX < cycle )
    172 printk("\n[DBG] %s : thread %x enter / process %x / vaddr %x / size %x\n",
    173 __FUNCTION__ , this, this->process->pid , buffer , buf_paddr );
     129#if DEBUG_DEV_FBF
     130cycle = (uint32_t)hal_get_cycles();
     131if( DEBUG_DEV_FBF < cycle )
     132printk("\n[%s] thread[%x,%x] completes %s / error = %d / cycle %d\n",
     133__FUNCTION__ , this->process->pid, this->trdid, 
     134dev_fbf_cmd_str(cmd_type), error , cycle );
    174135#endif
    175136
    176     return dev_fbf_access( false , buffer , length , offset );
     137    // return I/O operation status
     138    return error;
    177139
    178 #if DEBUG_DEV_FBF_RX
    179 cycle = (uint32_t)hal_get_cycles();
    180 if( DEBUG_DEV_FBF_RX < cycle )
    181 printk("\n[DBG] %s : thread %x exit / process %x / vaddr %x / size %x\n",
    182 __FUNCTION__ , this, this->process->pid , buffer , buf_paddr );
    183 #endif
    184 
    185 
    186 
    187 ////////////////////////////////////////////
    188 error_t dev_fbf_write( char         * buffer,
    189                        uint32_t       length,
    190                        uint32_t       offset )
    191 {
    192 
    193 #if DEBUG_DEV_FBF_TX
    194 uint32_t cycle = (uint32_t)hal_get_cycles();
    195 if( DEBUG_DEV_FBF_TX < cycle )
    196 printk("\n[DBG] %s : thread %x enter / process %x / vaddr %x / size %x\n",
    197 __FUNCTION__ , this, this->process->pid , buffer , buf_paddr );
    198 #endif
    199 
    200     return dev_fbf_access( true , buffer , length , offset );
    201 
    202 #if DEBUG_DEV_FBF_RX
    203 cycle = (uint32_t)hal_get_cycles();
    204 if( DEBUG_DEV_FBF_RX < cycle )
    205 printk("\n[DBG] %s : thread %x exit / process %x / vaddr %x / size %x\n",
    206 __FUNCTION__ , this, this->process->pid , buffer , buf_paddr );
    207 #endif
    208 
    209 }
     140}  // end dev_fbf_move_data()
  • trunk/kernel/devices/dev_fbf.h

    r483 r647  
    22 * dev_fbf.h - FBF (Block Device Controler) generic device API definition.
    33 *
    4  * Author  Alain Greiner    (2016)
     4 * Author  Alain Greiner    (2016,2017,2018,2019)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    2626
    2727#include <hal_kernel_types.h>
     28#include <shared_fbf.h>
    2829
    2930/****  Forward declarations  ****/
     
    3637 * This device provide access to an external graphic display, that is seen
    3738 * as a fixed size frame buffer, mapped in the kernel address space.
    38  * Each pixel takes one byte defining 256 levels of gray.
     39 * The supported  pixel encoding types are defined in the <shared_fbf.h> file.
    3940 *
    40  * It supports five command types:
    41  * - SIZE  : return the Frame buffer width and height.
    42  * - ALLOC : give exclusive ownership of the frame buffer to the requesting process.
    43  * - FREE  : release the exclusive ownership to the kernel.
    44  * - READ  : move a given number of bytes from the frame buffer to a memory buffer.
    45  * - WRITE : move a given number of bytes from a memory buffer to the frame buffer.
     41 * It supports three command types:
     42 * GET_CONFIG : return frame buffer size and type.
     43 * READ       : move bytes from frame buffer to memory / deschedule the calling thread.
     44 * WRITE      : move bytes from memory to frame buffer / deschedule the calling thread.
    4645 *
    47  * It does not creates the associated server thread.
    48  * - The SIZE, ALLOC, FREE commands are directly handled by the FBF device.
    49  * - The READ & WRITE commands are actually registered in the DMA device waiting queue,
    50  *   using the local DMA channel defined by the calling core lid.
     46 * The READ and WRITE operations do not use the FBF device waiting queue,
     47 * the server thread, and the IOC IRQ. The client thread does not deschedule:
     48 * it registers the command in the thread descriptor, and calls directly the FBF driver.
     49 * that makes a (user <-> kernel) memcpy.
     50 *
     51 * Note: As we don't use any external DMA to move data, but a purely software approach,
     52 * there is no L2/L3 coherence issue.
    5153 *****************************************************************************************/
    5254
     
    5759typedef struct fbf_extend_s
    5860{
    59     uint32_t           width;     /*! number of pixels per line.                         */
    60     uint32_t           height;    /*! total number of lines.                             */
     61    uint32_t           width;         /*! number of pixels per line.                     */
     62    uint32_t           height;        /*! total number of lines.                         */
     63    uint32_t           subsampling;   /*! pixel encoding type.                           */
    6164}
    6265fbf_extend_t;
     
    7174    IMPL_FBF_SCL =   0,     
    7275    IMPL_FBF_I86 =   1, 
    73 }
     76} 
    7477fbf_impl_t;
    75 
    76 /******************************************************************************************
    77  * This defines the (implementation independant)  command passed to the driver.
    78  *****************************************************************************************/
    7978
    8079typedef struct fbf_command_s
    8180{
    82     xptr_t      dev_xp;     /*! extended pointer on device descriptor                    */
    83     uint32_t    to_fbf;     /*! requested operation type.                                */
    84     uint32_t    length;     /*! number of bytes.                                         */
    85     uint32_t    offset;     /*! offset in frame buffer (bytes)                           */
    86     xptr_t      buf_xp;     /*! extended pointer on memory buffer                        */
    87     uint32_t    error;      /*! operation status (0 if success)                          */
     81    xptr_t      dev_xp;        /*! extended pointer on device descriptor                 */
     82    uint32_t    type;          /*! requested operation type.                             */
     83    uint32_t    length;        /*! number of bytes.                                      */
     84    uint32_t    offset;        /*! offset in frame buffer (bytes)                        */
     85    void      * buffer;        /*! pointer on memory buffer in user space                */
     86    uint32_t    error;         /*! operation status (0 if success)                       */
    8887}
    8988fbf_command_t;
     89
     90
     91/******************************************************************************************
     92 * This function returns a printable string for a given FBF command  <cmd_type>.
     93 ******************************************************************************************
     94 * @ cmd_type   :  FBF command type (defined in shared_fbf.h file).
     95 * @ returns a string pointer.
     96 *****************************************************************************************/
     97char * dev_fbf_cmd_str( uint32_t cmd_type );
    9098
    9199/******************************************************************************************
    92100 * This function completes the FBF chdev descriptor initialisation.
    93101 * It calls the specific driver initialisation function, to initialise the hardware
    94  * device and the specific data structures when required by the implementation.
    95  * It must be called by a local thread.
    96  *
    97  * TODO In this first approach, the "width" and "height" parameters are defined
    98  * by the CONFIG_FBF_WIDTH & CONFIG_FBF_HEIGHT in the kernel_config.h file.
    99  * These parameters should be provided by the driver, accessing dedicated
    100  * adressable registers in the FBF controler.
     102 * device and the chdev extension. It must be called by a local thread.
    101103 ******************************************************************************************
    102104 * @ chdev      : pointer on FBF chdev descriptor.
     
    105107
    106108/******************************************************************************************
    107  * This function returns the fixed size frame buffer features.
     109 * This function returns the frame buffer size and type.
     110 * It does NOT access the hardware, as the size and type have been registered
     111 * in the chdev descriptor extension.
    108112 ******************************************************************************************
    109  * @ width     : number of pixels (bytes) per line.
    110  * @ heigth    : total number of lines.
     113 * @ width     : [out] number of pixels per line.
     114 * @ height    : [out] total number of lines.
     115 * @ type      : [out] pixel encoding type.
    111116 *****************************************************************************************/
    112 void dev_fbf_get_size( uint32_t  * width,
    113                        uint32_t  * height );
     117void dev_fbf_get_config( uint32_t  * width,
     118                         uint32_t  * height,
     119                         uint32_t  * type );
    114120
    115121/******************************************************************************************
    116  * This function try to get the exclusive ownership of the frame buffer.
     122 * This blocking function moves <length> bytes between the frame buffer, starting from
     123 * byte defined by <offset>, and an user buffer defined by the <user_buffer> argument.
     124 * It can be called by a client thread running in any cluster.
     125 * The transfer direction are defined by the <cmd_type> argument.
     126 * The request is registered in the client thread descriptor, but the client thread is
     127 * not descheduled, and calls directly the FBF driver.
    117128 ******************************************************************************************
    118  * @ return 0 if success / return EINVAL if frame buffer already allocated.
    119  *****************************************************************************************/
    120 error_t dev_fbf_alloc( void );
    121 
    122 /******************************************************************************************
    123  * This function releases the exclusive ownership of the frame buffer.
    124  *****************************************************************************************/
    125 void dev_fbf_free( void );
    126 
    127 /******************************************************************************************
    128  * This blocking function try to tranfer <length> bytes from the frame buffer, starting
    129  * from <offset>, to the memory buffer defined by <buffer> argument.
    130  * The corresponding request is actually registered in the local DMA device waiting
    131  * queue that has the same index as the calling core. The calling thread is descheduled,
    132  * waiting on transfer completion. It will be resumed by the DMA IRQ signaling completion.
    133  ******************************************************************************************
    134  * @ buffer    : local pointer on target buffer in memory.
    135  * @ length    : number of bytes.
    136  * @ offset    : first byte in frame buffer.   
     129 * @ cmd_type    : FBF_READ / FBF_WRITE / FBF_SYNC_READ / FBF_SYN_WRITE.
     130 * @ user_buffer : pointer on memory buffer in user space.
     131 * @ length      : number of bytes.
     132 * @ offset      : first byte in frame buffer.   
    137133 * @ returns 0 if success / returns EINVAL if error.
    138134 *****************************************************************************************/
    139 error_t dev_fbf_read( char         * buffer,
    140                       uint32_t       length,
    141                       uint32_t       offset );
    142 
    143 /******************************************************************************************
    144  * This blocking function try to tranfer <length> bytes from a memory buffer defined
    145  * by <buffer> argument, to the frame buffer, starting from <offset>.
    146  * The corresponding request is actually registered in the local DMA device waiting
    147  * queue, that has the same index as the calling core. The calling thread is descheduled,
    148  * waiting on transfer completion. It will be resumed by the DMA IRQ signaling completion.
    149  ******************************************************************************************
    150  * @ buffer    : local pointer on source buffer in memory.
    151  * @ length    : number of bytes.
    152  * @ offset    : first byte in frame buffer.   
    153  * @ returns 0 if success / returns EINVAL if error.
    154  *****************************************************************************************/
    155 error_t dev_fbf_write( char         * buffer,
    156                        uint32_t       length,
    157                        uint32_t       offset );
     135error_t dev_fbf_move_data( uint32_t   cmd_type,
     136                           void     * user_buffer,
     137                           uint32_t   length,
     138                           uint32_t   offset );
    158139
    159140#endif  /* _DEV_FBF_H */
  • trunk/kernel/devices/dev_iob.c

    r565 r647  
    3535void dev_iob_init( chdev_t * chdev )
    3636{
    37     // get implementation
    38     uint32_t  impl = chdev->impl;
    39 
    4037    // set chdev name
    4138    strcpy( chdev->name , "iob" );
    4239
    4340    // call driver init function
    44     hal_drivers_iob_init( chdev , impl );
     41    hal_drivers_iob_init( chdev );
    4542}
    4643
  • trunk/kernel/devices/dev_ioc.c

    r637 r647  
    5050void dev_ioc_init( chdev_t * ioc )
    5151{
    52     // the PIC chdev must be initialized before the IOC chdev, because
    53     // the IOC chdev initialisation requires the routing of an external IRQ
    54     xptr_t  pic_xp  = chdev_dir.pic;
    55 
    56     assert( (pic_xp != XPTR_NULL) , "PIC not initialised before IOC" );
    57 
    58     // get implementation and channel from chdev descriptor
    59     uint32_t  impl    = ioc->impl;
     52    // get channel from chdev descriptor
    6053    uint32_t  channel = ioc->channel;
    6154
     
    6457
    6558    // call driver init function
    66     hal_drivers_ioc_init( ioc, impl );
     59    hal_drivers_ioc_init( ioc );
    6760
    6861    // select a core to execute the IOC server thread
     
    9083    ioc->server = new_thread;
    9184
    92     // set "chdev field in thread descriptor
     85    // set "chdev" field in thread descriptor
    9386    new_thread->chdev = ioc;
    9487
     
    9891}  // end dev_ioc_init()
    9992
    100 //////////////////////////////////////////////////////////////////////////////////
    101 // This static function is called by dev_ioc_read() & dev_ioc_write() functions.
    102 // It builds and registers the command in the calling thread descriptor.
    103 // Then, it registers the calling thead in IOC chdev waiting queue.
    104 // Finally it blocks on the THREAD_BLOCKED_IO condition and deschedule.
    105 ////////////////////////////////////i/////////////////////////////////////////////
    106 static error_t dev_ioc_access( uint32_t   cmd_type,
    107                                uint8_t  * buffer,
    108                                uint32_t   lba,
    109                                uint32_t   count )
     93///////////////////////////////////////////////
     94error_t dev_ioc_move_data( uint32_t   cmd_type,
     95                           xptr_t     buffer_xp,
     96                           uint32_t   lba,
     97                           uint32_t   count )
    11098{
    11199    thread_t * this = CURRENT_THREAD;              // pointer on client thread
    112100
    113 #if ( DEV_IOC_RX  || DEV_IOC_TX )
     101#if ( DEBUG_DEV_IOC_RX  || DEBUG_DEV_IOC_TX )
    114102uint32_t   cycle = (uint32_t)hal_get_cycles();
    115103#endif
     
    118106    if( chdev_dir.iob )
    119107    {
    120         if (cmd_type == IOC_READ) dev_mmc_inval( XPTR( local_cxy , buffer ) , count<<9 );
    121         else                      dev_mmc_sync ( XPTR( local_cxy , buffer ) , count<<9 );
     108        if( (cmd_type == IOC_SYNC_READ) || (cmd_type == IOC_READ) )
     109        {
     110            dev_mmc_inval( buffer_xp , count<<9 );
     111        }
     112        else  // (cmd_type == IOC_SYNC_WRITE) or (cmd_type == IOC_WRITE)
     113        {
     114            dev_mmc_sync ( buffer_xp , count<<9 );
     115        }
    122116    }
    123117
    124118    // get extended pointer on IOC chdev descriptor
    125     xptr_t  dev_xp = chdev_dir.ioc[0];
     119    xptr_t      ioc_xp = chdev_dir.ioc[0];
    126120
    127121// check dev_xp
    128 assert( (dev_xp != XPTR_NULL) , "undefined IOC chdev descriptor" );
    129 
    130     // register command in calling thread descriptor
    131     this->ioc_cmd.dev_xp    = dev_xp;
    132     this->ioc_cmd.type      = cmd_type;
    133     this->ioc_cmd.buf_xp    = XPTR( local_cxy , buffer );
    134     this->ioc_cmd.lba       = lba;
    135     this->ioc_cmd.count     = count;
    136 
    137     // register client thread in IOC chdev waiting queue, activate server thread,
    138     // block client thread on THREAD_BLOCKED_IO and deschedule.
    139     // it is re-activated by the ISR signaling IO operation completion.
    140     chdev_register_command( dev_xp );
    141 
    142 #if(DEV_IOC_RX & 1)
    143 if( (DEV_IOC_RX < cycle) && (cmd_type != IOC_WRITE) )
    144 printk("\n[%s] thread[%x,%x] resumes for RX\n",
    145 __FUNCTION__, this->process->pid , this->trdid )
    146 #endif
    147 
    148 #if(DEV_IOC_TX & 1)
    149 if( (DEV_IOC_RX < cycle) && (cmd_type == IOC_WRITE) )
    150 printk("\n[%s] thread[%x,%x] resumes for TX\n",
    151 __FUNCTION__, this->process->pid , this->trdid )
    152 #endif
    153 
    154     // return I/O operation status
    155     return this->ioc_cmd.error;
    156 
    157 }  // end dev_ioc_access()
    158 
    159 ////////////////////////////////////////////
    160 error_t dev_ioc_read( uint8_t      * buffer,
    161                       uint32_t       lba,
    162                       uint32_t       count )
    163 {
    164 
    165 #if DEBUG_DEV_IOC_RX
    166 uint32_t   cycle = (uint32_t)hal_get_cycles();
    167 thread_t * this  = CURRENT_THREAD;
    168 if( DEBUG_DEV_IOC_RX < cycle )
    169 printk("\n[%s] thread[%x,%x] enters / lba  %x / buffer %x / cycle %d\n",
    170 __FUNCTION__ , this->process->pid, this->trdid, lba, buffer, cycle );
    171 #endif
    172 
    173     return dev_ioc_access( IOC_READ , buffer , lba , count );
    174 }
    175 
    176 ////////////////////////////////////////////
    177 error_t dev_ioc_write( uint8_t     * buffer,
    178                        uint32_t      lba,
    179                        uint32_t      count )
    180 {
    181 
    182 #if DEBUG_DEV_IOC_TX
    183 uint32_t   cycle = (uint32_t)hal_get_cycles();
    184 thread_t * this  = CURRENT_THREAD;
    185 if( DEBUG_DEV_IOC_TX < cycle )
    186 printk("\n[%s] thread[%x,%x] enters / lba  %x / buffer %x / cycle %d\n",
    187 __FUNCTION__ , this->process->pid, this->trdid, lba, buffer, cycle );
    188 #endif
    189 
    190     return dev_ioc_access( IOC_WRITE , buffer , lba , count );
    191 }
    192 
    193 
    194 
    195 
    196 
    197 //////////////////////////////////////////////////////////////////////////////////
    198 // This static function is called by dev_ioc_sync_read() & dev_ioc_sync_write().
    199 // It builds and registers the command in the calling thread descriptor, and
    200 // calls directly the blocking IOC driver command, that returns only when the
    201 // IO operation is completed.
    202 ////////////////////////////////////i/////////////////////////////////////////////
    203 error_t dev_ioc_sync_access( uint32_t   cmd_type,
    204                              xptr_t     buffer_xp,
    205                              uint32_t   lba,
    206                              uint32_t   count )
    207 {
    208     // get pointer on calling thread
    209     thread_t * this = CURRENT_THREAD;
    210 
    211     // software L2/L3 cache coherence for memory buffer
    212     if( chdev_dir.iob )
    213     {
    214         if (cmd_type == IOC_SYNC_READ) dev_mmc_inval( buffer_xp , count<<9 );
    215         else                           dev_mmc_sync ( buffer_xp , count<<9 );
    216     }
    217 
    218     // get extended pointer on IOC[0] chdev
    219     xptr_t  ioc_xp = chdev_dir.ioc[0];
    220 
    221 // check ioc_xp
    222122assert( (ioc_xp != XPTR_NULL) , "undefined IOC chdev descriptor" );
    223123
     
    229129    this->ioc_cmd.count     = count;
    230130
    231     // get driver command function
    232     cxy_t       ioc_cxy = GET_CXY( ioc_xp );
    233     chdev_t   * ioc_ptr = GET_PTR( ioc_xp );
    234     dev_cmd_t * cmd = (dev_cmd_t *)hal_remote_lpt( XPTR( ioc_cxy , &ioc_ptr->cmd ) );
    235 
    236     // get core local index for the core handling the IOC IRQ
    237     thread_t * server = (thread_t *)hal_remote_lpt( XPTR( ioc_cxy , &ioc_ptr->server ) );
    238     core_t   * core   = (core_t *)hal_remote_lpt( XPTR( ioc_cxy , &server->core ) );
    239     lid_t      lid    = (lid_t)hal_remote_l32( XPTR( ioc_cxy , &core->lid ) );
    240 
    241     // mask the IRQ
    242     dev_pic_disable_irq( lid , ioc_xp );
    243 
    244     // call driver function
    245     cmd( XPTR( local_cxy , this ) );
    246 
    247     // unmask the IRQ
    248     dev_pic_enable_irq( lid , ioc_xp );
    249 
    250     // return I/O operation status from calling thread descriptor
     131    // for a synchronous acces, the driver is directly called by the client thread
     132    if( (cmd_type == IOC_SYNC_READ) || (cmd_type == IOC_SYNC_WRITE) )
     133    {
     134
     135#if DEBUG_DEV_IOC_RX
     136uint32_t   cycle = (uint32_t)hal_get_cycles();
     137if( (DEBUG_DEV_IOC_RX < cycle) && (cmd_type == IOC_SYNC_READ) )
     138printk("\n[%s] thread[%x,%x] enters for SYNC_READ / lba  %x / buffer[%x,%x] / cycle %d\n",
     139__FUNCTION__ , this->process->pid, this->trdid, lba,
     140GET_CXY(buffer_xp), GET_PTR(buffer_xp), cycle );
     141#endif
     142
     143#if DEBUG_DEV_IOC_TX
     144uint32_t   cycle = (uint32_t)hal_get_cycles();
     145if( (DEBUG_DEV_IOC_TX < cycle) && (cmd_type == IOC_SYNC_WRITE) )
     146printk("\n[%s] thread[%x,%x] enters for SYNC_WRITE / lba  %x / buffer[%x,%x] / cycle %d\n",
     147__FUNCTION__ , this->process->pid, this->trdid, lba,
     148GET_CXY(buffer_xp), GET_PTR(buffer_xp), cycle );
     149#endif
     150        // get driver command function
     151        cxy_t       ioc_cxy = GET_CXY( ioc_xp );
     152        chdev_t   * ioc_ptr = GET_PTR( ioc_xp );
     153        dev_cmd_t * cmd = (dev_cmd_t *)hal_remote_lpt( XPTR( ioc_cxy , &ioc_ptr->cmd ) );
     154
     155        // call driver function
     156        cmd( XPTR( local_cxy , this ) );
     157
     158#if DEBUG_DEV_IOC_RX
     159if( (DEBUG_DEV_IOC_RX < cycle) && (cmd_type == IOC_SYNC_READ) )
     160printk("\n[%s] thread[%x,%x] resumes for IOC_SYNC_READ\n",
     161__FUNCTION__, this->process->pid , this->trdid )
     162#endif
     163
     164#if DEBUG_DEV_IOC_TX
     165if( (DEBUG_DEV_IOC_RX < cycle) && (cmd_type == IOC_SYNC_WRITE) )
     166printk("\n[%s] thread[%x,%x] resumes for IOC_SYNC_WRITE\n",
     167__FUNCTION__, this->process->pid , this->trdid )
     168#endif
     169
     170    }
     171    // for an asynchronous access, the client thread registers in the chdev waiting queue,
     172    // activates server thread, blocks on THREAD_BLOCKED_IO and deschedules.
     173    // It is re-activated by the server thread after IO operation completion.
     174    else  // (cmd_type == IOC_READ) || (cmd_type == IOC_WRITE)
     175    {
     176
     177#if DEBUG_DEV_IOC_RX
     178uint32_t   cycle = (uint32_t)hal_get_cycles();
     179if( (DEBUG_DEV_IOC_RX < cycle) && (cmd_type == IOC_READ) )
     180printk("\n[%s] thread[%x,%x] enters for READ / lba  %x / buffer[%x,%x] / cycle %d\n",
     181__FUNCTION__ , this->process->pid, this->trdid, lba,
     182GET_CXY(buffer_xp), GET_PTR(buffer_xp), cycle );
     183#endif
     184
     185#if DEBUG_DEV_IOC_TX
     186uint32_t   cycle = (uint32_t)hal_get_cycles();
     187if( (DEBUG_DEV_IOC_TX < cycle) && (cmd_type == IOC_WRITE) )
     188printk("\n[%s] thread[%x,%x] enters for WRITE / lba  %x / buffer[%x,%x] / cycle %d\n",
     189__FUNCTION__ , this->process->pid, this->trdid, lba,
     190GET_CXY(buffer_xp), GET_PTR(buffer_xp), cycle );
     191#endif
     192        chdev_register_command( ioc_xp );
     193
     194#if(DEBUG_DEV_IOC_RX )
     195if( (DEBUG_DEV_IOC_RX < cycle) && (cmd_type == IOC_READ) )
     196printk("\n[%s] thread[%x,%x] resumes for IOC_READ\n",
     197__FUNCTION__, this->process->pid , this->trdid )
     198#endif
     199
     200#if(DEBUG_DEV_IOC_TX & 1)
     201if( (DEBUG_DEV_IOC_RX < cycle) && (cmd_type == IOC_WRITE) )
     202printk("\n[%s] thread[%x,%x] resumes for IOC_WRITE\n",
     203__FUNCTION__, this->process->pid , this->trdid )
     204#endif
     205
     206    }
     207
     208    // return I/O operation status
    251209    return this->ioc_cmd.error;
    252210
    253 }  // end dev_ioc_sync_access()
    254 
    255 ////////////////////////////////////////////////
    256 error_t dev_ioc_sync_read( xptr_t     buffer_xp,
    257                            uint32_t   lba,
    258                            uint32_t   count )
    259 {
    260 
    261 #if DEBUG_DEV_IOC_RX
    262 thread_t * this  = CURRENT_THREAD;
    263 uint32_t   cycle = (uint32_t)hal_get_cycles();
    264 if( DEBUG_DEV_IOC_RX < cycle )
    265 printk("\n[%s] thread[%x,%x] : lba  %x / buffer(%x,%x) / count %d / cycle %d\n",
    266 __FUNCTION__ , this->process->pid, this->trdid,
    267 lba, GET_CXY(buffer_xp), GET_PTR(buffer_xp), count, cycle );
    268 #endif
    269 
    270     return dev_ioc_sync_access( IOC_SYNC_READ , buffer_xp , lba , count );
    271 }
    272 
    273 /////////////////////////////////////////////////
    274 error_t dev_ioc_sync_write( xptr_t     buffer_xp,
    275                             uint32_t   lba,
    276                             uint32_t   count )
    277 {
    278 
    279 #if DEBUG_DEV_IOC_TX
    280 thread_t * this  = CURRENT_THREAD;
    281 uint32_t   cycle = (uint32_t)hal_get_cycles();
    282 if( DEBUG_DEV_IOC_TX < cycle )
    283 printk("\n[%s] thread[%x,%x] : lba  %x / buffer(%x,%x) / count %d / cycle %d\n",
    284 __FUNCTION__ , this->process->pid, this->trdid,
    285 lba, GET_CXY(buffer_xp), GET_PTR(buffer_xp), count, cycle );
    286 #endif
    287 
    288     return dev_ioc_sync_access( IOC_SYNC_WRITE , buffer_xp , lba , count );
    289 }
    290 
     211}  // end dev_ioc_move_data()
     212
     213
  • trunk/kernel/devices/dev_ioc.h

    r627 r647  
    3838 * magnetic hard disk or a SD card, that can store blocks of data in a linear array
    3939 * of sectors indexed by a simple lba (logic block address).
     40 *
    4041 * It supports four command types:
    4142 * - READ       : move blocks from device to memory, with a descheduling policy.
     
    4344 * - SYNC_READ  : move blocks from device to memory, with a busy waiting policy.
    4445 * - SYNC_WRITE : move blocks from memory to device, with a busy waiting policy.
    45 
    46  * The READ or WRITE operations require dynamic ressource allocation. The calling thread
    47  * is descheduled, and the work is done by the server thread associated to IOC device.
    48  * The general scenario is detailed below.
    49  * A) the client thread start the I/O operation, by calling the dev_ioc_read()
    50  *    or the dev_ioc_write() kernel functions that perform the following actions:
    51  *    1) it get a free WTI mailbox from the client cluster WTI allocator.
    52  *    2) it enables the WTI IRQ on the client cluster ICU and update interrupt vector.
    53  *    3) it access the PIC to link the WTI mailbox to the IOC IRQ.
    54  *    4) it builds the command descriptor.
    55  *    5) it registers in the IOC device waiting queue.
    56  *    6) itblock on the THREAD_BLOCKED_IO condition and deschedule.
    57  * B) The server thread attached to the IOC device descriptor handles the commands
    58  *    registered in the waiting queue, calling the IOC driver function.
    59  *    Most hardware implementation have a DMA capability, but some implementations,
    60  *    such as the RDK (Ram Disk) implementation does not use DMA.
    61  * C) The ISR signaling the I/O operation completion reactivates the client thread,
    62  *    that releases the allocated resources:
    63  *    1) access the PIC to unlink the IOC IRQ.
    64  *    2) disable the WTI IRQ in the client cluster ICU and update interrupt vector.
    65  *    3) release the WTI mailbox to the client cluster WTI allocator.
     46 *
     47 * For the he READ or WRITE operations, the client thread is descheduled, and the work
     48 * is done by the server thread associated to the IOC device:
     49 * The client thread calls the dev_ioc_move_data() kernel functions that (i) registers
     50 * the command in the client thread descriptor, (ii) registers the client thread
     51 * in the IOC device waiting queue, and (iii) blocks on the THREAD_BLOCKED_IO condition
     52 * and deschedules.
     53 * The server thread attached to the IOC device descriptor handles the commands
     54 * registered in the waiting queue, calling the IOC driver function.
     55 * Most IOC device implementations have a DMA capability, but some implementations,
     56 * such as the RDK (Ram Disk) implementation does not use DMA.
     57 * When the server thread completes an I/O operation, it reactivates the client thread.
    6658 *
    6759 * The SYNC_READ and SYNC_WRITE operations are used by the kernel in the initialisation
    6860 * phase, to update the FAT (both the FAT mapper and the FAT on IOC device), or to update
    6961 * a directory on IOC device when a new file is created.
    70  * - These synchronous operations do not not use the IOC device waiting queue,
    71  *   the server thread, and the IOC IRQ, but implement a busy-waiting policy
    72  *   for the calling thread.
    73  * - As the work
     62 * These synchronous operations do not not use the IOC device waiting queue,
     63 * the server thread, and the IOC IRQ. The client thread does not deschedules:
     64 * it registers the command in the thread descriptor, calls directly the IOC driver,
     65 * and uses a busy-waiting policy to poll the IOC device status.
    7466 *****************************************************************************************/
    7567
     
    116108{
    117109    xptr_t      dev_xp;     /*! extended pointer on IOC device descriptor                */
    118     uint32_t    type;       /*! IOC_READ / IOC_WRITE / IOC_SYNC_READ                     */
     110    uint32_t    type;       /*! command type above                                       */
    119111    uint32_t    lba;        /*! first block index                                        */
    120112    uint32_t    count;      /*! number of blocks                                         */
     
    146138
    147139/******************************************************************************************
    148  * This blocking function moves one or several contiguous blocks of data
    149  * from the block device to a local memory buffer. The corresponding request is actually
    150  * registered in the device pending request queue, and the calling thread is descheduled,
    151  * waiting on transfer completion. It will be resumed by the IRQ signaling completion.
    152  * It must be called by a local thread.
     140 * This blocking function moves <count> contiguous blocks of data between the block device
     141 * starting from block defined by the <lba> argument and a kernel memory buffer, defined
     142 * by the <buffer_xp> argument. The transfer direction and mode are defined by the
     143 * <cmd_type> argument. The request is always registered in the calling thread descriptor.
     144 * - In synchronous mode, the calling thread is not descheduled, and directly calls the
     145 *   IOC driver, polling the IOC status to detect transfer completion.
     146 * - In asynchronous mode, the calling thread blocks and deschedules, and the IOC driver
     147 *   is called by the server thread associated to the IOC device.
    153148 ******************************************************************************************
    154  * @ buffer    : local pointer on target buffer in memory (must be block aligned).
     149 * @ cmd_type  : IOC_READ / IOC_WRITE / IOC_SYNC_READ / IOC_SYN_WRITE.
     150 * @ buffer_xp : extended pointer on kernel buffer in memory (must be block aligned).
    155151 * @ lba       : first block index on device.
    156152 * @ count     : number of blocks to transfer.
    157153 * @ returns 0 if success / returns -1 if error.
    158154 *****************************************************************************************/
    159 error_t dev_ioc_read( uint8_t      * buffer,
    160                       uint32_t       lba,
    161                       uint32_t       count );
    162 
    163 /******************************************************************************************
    164  * This blocking function moves one or several contiguous blocks of data
    165  * from a local memory buffer to the block device. The corresponding request is actually
    166  * registered in the device pending request queue, and the calling thread is descheduled,
    167  * waiting on transfer completion. It will be resumed by the IRQ signaling completion.
    168  * It must be called by a local thread.
    169  ******************************************************************************************
    170  * @ buffer    : local pointer on source buffer in memory (must be block aligned).
    171  * @ lba       : first block index on device.
    172  * @ count     : number of blocks to transfer.
    173  * @ returns 0 if success / returns -1 if error.
    174  *****************************************************************************************/
    175 error_t dev_ioc_write( uint8_t      * buffer,
    176                        uint32_t       lba,
    177                        uint32_t       count );
    178 
    179 /******************************************************************************************
    180  * This blocking function moves one or several contiguous blocks of data
    181  * from the block device to a - possibly remote - memory buffer.
    182  * It uses an extended pointer, because the target buffer is generally a remote mapper.
    183  * It does  not uses the IOC device waiting queue and server thread, and does not use
    184  * the IOC IRQ, but call directly the relevant IOC driver, implementing a busy-waiting
    185  * policy for the calling thread.
    186  * It can be called by a thread running in any cluster.
    187  ******************************************************************************************
    188  * @ buffer_xp : extended pointer on target buffer in memory (must be block aligned).
    189  * @ lba       : first block index on device.
    190  * @ count     : number of blocks to transfer.
    191  * @ returns 0 if success / returns -1 if error.
    192  *****************************************************************************************/
    193 error_t dev_ioc_sync_read( xptr_t         buffer_xp,
    194                            uint32_t       lba,
    195                            uint32_t       count );
    196 
    197 /******************************************************************************************
    198  * This blocking function moves one or several contiguous blocks of data
    199  * from a - possibly remote - memory buffer to the block device.
    200  * It uses an extended pointer, because the target buffer is generally a remote mapper.
    201  * It does  not uses the IOC device waiting queue and server thread, and does not use
    202  * the IOC IRQ, but call directly the relevant IOC driver, implementing a busy-waiting
    203  * policy for the calling thread.
    204  * It can be called by a thread running in any cluster.
    205  ******************************************************************************************
    206  * @ buffer_xp : extended pointer on source buffer in memory (must be block aligned).
    207  * @ lba       : first block index on device.
    208  * @ count     : number of blocks to transfer.
    209  * @ returns 0 if success / returns -1 if error.
    210  *****************************************************************************************/
    211 error_t dev_ioc_sync_write( xptr_t         buffer_xp,
    212                             uint32_t       lba,
    213                             uint32_t       count );
     155error_t dev_ioc_move_data( uint32_t  cmd_type,
     156                           xptr_t    buffer_xp,
     157                           uint32_t  lba,
     158                           uint32_t  count );
    214159
    215160#endif  /* _DEV_IOC_H */
  • trunk/kernel/devices/dev_mmc.c

    r626 r647  
    4040void dev_mmc_init( chdev_t * mmc )
    4141{
    42     // get implementation from device descriptor
    43     uint32_t  impl = mmc->impl;
    44 
    4542    // set mmc name
    4643    snprintf( mmc->name , 16 , "mmc_%x" , local_cxy );
    4744
    4845    // call driver init function
    49     hal_drivers_mmc_init( mmc , impl );
     46    hal_drivers_mmc_init( mmc );
    5047
    5148    // bind IRQ to CP0
  • trunk/kernel/devices/dev_nic.c

    r637 r647  
    3939void dev_nic_init( chdev_t * nic )
    4040{
    41     // the PIC chdev must be initialized before the NIC chdev, because
    42     // the NIC chdev initialisation requires the routing of an external IRQ.
    43     xptr_t  pic_xp  = chdev_dir.pic;
    44 
    45     assert( (pic_xp != XPTR_NULL) , "ICU not initialised before NIC" );
    46 
    47     // get "impl" , "channel" , "is_rx" fields from chdev descriptor
    48     uint32_t  impl    = nic->impl;
     41    // get "channel" & "is_rx" fields from chdev descriptor
    4942    uint32_t  channel = nic->channel;
    5043    bool_t    is_rx   = nic->is_rx;
     
    5548
    5649    // call driver init function
    57     hal_drivers_nic_init( nic , impl );
     50    hal_drivers_nic_init( nic );
    5851
    5952    // select a core to execute the NIC server thread
  • trunk/kernel/devices/dev_pic.c

    r565 r647  
    4343void dev_pic_init( chdev_t  * pic )
    4444{
    45     // get implementation
    46     uint32_t impl = pic->impl;
    47 
    4845    // set chdev name
    4946    strcpy( pic->name , "pic" );
    5047
    5148    // call the implementation-specific PIC driver
    52     hal_drivers_pic_init(pic, impl);
     49    hal_drivers_pic_init( pic );
    5350}
    5451
  • trunk/kernel/devices/dev_txt.c

    r637 r647  
    8787   
    8888    // call driver init function
    89     hal_drivers_txt_init(txt, impl);
     89    hal_drivers_txt_init( txt );
    9090
    9191    // no server thread and no IRQ routing for TXT0
  • trunk/kernel/fs/fatfs.c

    r635 r647  
    575575   
    576576    // update the FS_INFO sector on IOC device
    577     return dev_ioc_sync_write( fs_info_buffer_xp , fs_info_lba , 1 );
     577    return dev_ioc_move_data( IOC_SYNC_WRITE , fs_info_buffer_xp , fs_info_lba , 1 );
    578578 
    579579}  // end fatfs_update_ioc_fsinfo()
     
    11151115
    11161116    // load the BOOT record from device
    1117     error = dev_ioc_sync_read( buffer_xp , 0 , 1 );
     1117    error = dev_ioc_move_data( IOC_SYNC_READ , buffer_xp , 0 , 1 );
    11181118
    11191119    if ( error )
     
    11751175
    11761176    // load the FS_INFO record from device
    1177     error = dev_ioc_sync_read( buffer_xp , fs_info_lba , 1 );
     1177    error = dev_ioc_move_data( IOC_SYNC_READ , buffer_xp , fs_info_lba , 1 );
    11781178
    11791179    if ( error )
     
    23942394
    23952395    // copy FS_INFO sector from IOC to local buffer
    2396     error = dev_ioc_sync_read( tmp_buf_xp , fs_info_lba , 1 );
     2396    error = dev_ioc_move_data( IOC_SYNC_READ , tmp_buf_xp , fs_info_lba , 1 );
    23972397
    23982398    if ( error )
     
    24312431
    24322432        // update the FS_INFO sector on IOC device
    2433         error = dev_ioc_sync_write( fs_info_buffer_xp , fs_info_lba , 1 );
     2433        error = dev_ioc_move_data( IOC_SYNC_WRITE , fs_info_buffer_xp , fs_info_lba , 1 );
    24342434
    24352435        if ( error )
     
    27502750    // get page base address
    27512751    xptr_t    buffer_xp  = ppm_page2base( page_xp );
    2752     uint8_t * buffer_ptr = (uint8_t *)GET_PTR( buffer_xp );
    27532752 
    27542753    // get inode pointer from mapper
     
    27592758printk("\n[%s] thread[%x,%x] enters : %s / cxy %x / mapper %x / inode %x / page %x\n",
    27602759__FUNCTION__, this->process->pid, this->trdid,
    2761 dev_ioc_cmd_str( cmd_type ), page_cxy, mapper_ptr, inode_ptr, buffer_ptr );
     2760dev_ioc_cmd_str( cmd_type ), page_cxy, mapper_ptr, inode_ptr, GET_PTR(buffer_xp) );
    27622761#endif
    27632762
     
    27682767        uint32_t      lba = fatfs_ctx->fat_begin_lba + (page_id << 3);
    27692768 
    2770         // access device
    2771         if     (cmd_type == IOC_SYNC_READ ) error = dev_ioc_sync_read ( buffer_xp  , lba , 8 );
    2772         else if(cmd_type == IOC_SYNC_WRITE) error = dev_ioc_sync_write( buffer_xp  , lba , 8 );
    2773         else if(cmd_type == IOC_READ      ) error = dev_ioc_read      ( buffer_ptr , lba , 8 );
    2774         else if(cmd_type == IOC_WRITE     ) error = dev_ioc_write     ( buffer_ptr , lba , 8 );
    2775         else                                error = -1;
     2769        // access IOC device
     2770        error = dev_ioc_move_data( cmd_type , buffer_xp , lba , 8 );
    27762771
    27772772        if( error )
     
    28312826        uint32_t lba = fatfs_lba_from_cluster( fatfs_ctx , searched_cluster );
    28322827
    2833         // access device
    2834         if     (cmd_type == IOC_SYNC_READ ) error = dev_ioc_sync_read ( buffer_xp  , lba , 8 );
    2835         else if(cmd_type == IOC_SYNC_WRITE) error = dev_ioc_sync_write( buffer_xp  , lba , 8 );
    2836         else if(cmd_type == IOC_READ      ) error = dev_ioc_read      ( buffer_ptr , lba , 8 );
    2837         else if(cmd_type == IOC_WRITE     ) error = dev_ioc_write     ( buffer_ptr , lba , 8 );
    2838         else                                error = -1;
     2828        // access IOC device
     2829        error = dev_ioc_move_data( cmd_type , buffer_xp , lba , 8 );
    28392830
    28402831        if( error )
  • trunk/kernel/fs/vfs.c

    r635 r647  
    681681    process_t * process = this->process;
    682682
    683 #if DEBUG_VFS_OPEN
    684 uint32_t cycle = (uint32_t)hal_get_cycles();
    685 if( DEBUG_VFS_OPEN < cycle )
    686 printk("\n[%s] thread[%x,%x] enter for <%s> / root_inode (%x,%x) / cycle %d\n",
    687 __FUNCTION__, process->pid, this->trdid, path, GET_CXY(root_xp), GET_PTR(root_xp), cycle );
    688 #endif
    689 
    690683    // compute lookup working mode
    691684    lookup_mode = VFS_LOOKUP_OPEN;
     
    694687    if( (flags & O_EXCL   )      )  lookup_mode |= VFS_LOOKUP_EXCL;
    695688 
     689#if DEBUG_VFS_OPEN
     690uint32_t cycle = (uint32_t)hal_get_cycles();
     691if( DEBUG_VFS_OPEN < cycle )
     692printk("\n[%s] thread[%x,%x] enter for <%s> / root_inode (%x,%x) / cycle %d\n",
     693__FUNCTION__, process->pid, this->trdid, path, GET_CXY(root_xp), GET_PTR(root_xp), cycle );
     694#endif
     695
    696696    // compute attributes for the created file
    697697    file_attr = 0;
  • trunk/kernel/kern/do_syscall.c

    r641 r647  
    111111    sys_get_nb_cores,       // 54
    112112    sys_get_thread_info,    // 55
     113    sys_fbf,                // 56
    113114};
    114115
     
    179180    case SYS_GET_NB_CORES:                 return "GET_NB_CORES";     // 54
    180181    case SYS_GET_THREAD_INFO:              return "GET_THREAD_INFO";  // 55
     182    case SYS_FBF:                          return "FBF";              // 56
    181183
    182184    default:                               return "undefined";
  • trunk/kernel/kern/kernel_init.c

    r640 r647  
    561561                if( target_cxy == local_cxy )
    562562                {
     563
     564#if( DEBUG_KERNEL_INIT & 0x3 )
     565if( hal_time_stamp() > DEBUG_KERNEL_INIT )
     566printk("\n[%s] : found chdev %s / channel = %d / rx = %d / cluster %x\n",
     567__FUNCTION__ , chdev_func_str( func ), channel , rx , local_cxy );
     568#endif
    563569                    chdev = chdev_create( func,
    564570                                          impl,
     
    608614                    }
    609615
    610 #if( DEBUG_KERNEL_INIT & 0x1 )
     616#if( DEBUG_KERNEL_INIT & 0x3 )
    611617if( hal_time_stamp() > DEBUG_KERNEL_INIT )
    612 printk("\n[%s] : create chdev %s / channel = %d / rx = %d / cluster %x / chdev = %x\n",
     618printk("\n[%s] : created chdev %s / channel = %d / rx = %d / cluster %x / chdev = %x\n",
    613619__FUNCTION__ , chdev_func_str( func ), channel , rx , local_cxy , chdev );
    614620#endif
  • trunk/kernel/kern/thread.c

    r641 r647  
    942942uint32_t global_one  = global_nr ? (global_cost / global_nr) : 0;
    943943
    944 printk("\n***** thread[%x,%x] page-faults\n"
     944printk("\n***** thread[%x,%x] page faults\n"
    945945       " - false  : %d events / cost %d cycles / max %d cycles\n"
    946946       " - local  : %d events / cost %d cycles / max %d cycles\n"
  • trunk/kernel/kern/thread.h

    r641 r647  
    183183    mmc_command_t       mmc_cmd;         /*! MMC device generic command               */
    184184    dma_command_t       dma_cmd;         /*! DMA device generic command               */
     185    fbf_command_t       fbf_cmd;         /*! FBF device generic command               */
    185186
    186187        xptr_t              rpc_client_xp;   /*! client thread (for a RPC thread only)    */
  • trunk/kernel/kernel_config.h

    r641 r647  
    5656#define DEBUG_DEV_NIC_RX                  0
    5757#define DEBUG_DEV_NIC_RX                  0
    58 #define DEBUG_DEV_FBF_RX                  0
    59 #define DEBUG_DEV_FBF_TX                  0
     58#define DEBUG_DEV_FBF                        1
    6059#define DEBUG_DEV_DMA                     0
    6160#define DEBUG_DEV_MMC                     0
     
    105104#define DEBUG_HAL_TXT_RX                  0
    106105#define DEBUG_HAL_TXT_TX                  0
     106#define DEBUG_HAL_FBF                        1
    107107#define DEBUG_HAL_USPACE                  0
    108108#define DEBUG_HAL_VMM                     0
     
    134134#define DEBUG_PROCESS_GET_LOCAL_COPY      0
    135135#define DEBUG_PROCESS_INIT_CREATE         0
    136 #define DEBUG_PROCESS_MAKE_EXEC           0
    137 #define DEBUG_PROCESS_MAKE_FORK           0
     136#define DEBUG_PROCESS_MAKE_EXEC              1
     137#define DEBUG_PROCESS_MAKE_FORK              1
    138138#define DEBUG_PROCESS_REFERENCE_INIT      0
    139139#define DEBUG_PROCESS_SIGACTION           0
     
    184184#define DEBUG_SYS_CONDVAR                 0
    185185#define DEBUG_SYS_DISPLAY                 0
    186 #define DEBUG_SYS_EXEC                    0
     186#define DEBUG_SYS_EXEC                       2
    187187#define DEBUG_SYS_EXIT                    0
     188#define DEBUG_SYS_FBF                     0
    188189#define DEBUG_SYS_FG                      0
    189 #define DEBUG_SYS_FORK                    0
     190#define DEBUG_SYS_FORK                       2
    190191#define DEBUG_SYS_GET_CONFIG              0
    191192#define DEBUG_SYS_GETCWD                  0
  • trunk/kernel/syscalls/sys_fbf.c

    r642 r647  
    173173#if DEBUG_SYS_FBF
    174174if( DEBUG_SYS_FBF < tm_end )
    175 printk("\n[DBG] %s : thread %x in process %x exit for %s / cost = %d / cycle %d\n",
    176 __FUNCTION__, this->trdid, process->pid, dev_fbf_cmd_str( operation ),
     175printk("\n[%s] thread[%x,%x] exit for %s / cost = %d / cycle %d\n",
     176__FUNCTION__, process->pid, this->trdid, dev_fbf_cmd_str( operation ),
    177177(uint32_t)(tm_end - tm_start), (uint32_t)tm_end );
    178178#endif
Note: See TracChangeset for help on using the changeset viewer.