Changeset 647 for trunk


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

...miscelaneous...

Location:
trunk
Files:
38 edited

Legend:

Unmodified
Added
Removed
  • trunk/Makefile

    r633 r647  
    4646                user/idbg/build/idbg.elf           \
    4747                user/sort/build/sort.elf           \
    48         user/fft/build/fft.elf
     48        user/fft/build/fft.elf             \
     49        user/display/build/display.elf     \
     50        user/convol/build/convol.elf       \
     51        user/transpose/build/transpose.elf
     52 
    4953
    5054# Virtual disk path
     
    6165# when the corresponding sources files have been modified or destroyed.
    6266# The "home" directory on the virtual disk is not modified
    63 compile: dirs                              \
    64          hard_config.h                     \
    65          build_libs                        \
    66          $(BOOTLOADER_PATH)/build/boot.elf \
    67          kernel/build/kernel.elf           \
    68          user/init/build/init.elf          \
    69          user/ksh/build/ksh.elf            \
    70          user/pgcd/build/pgcd.elf          \
    71          user/idbg/build/idbg.elf          \
    72          user/sort/build/sort.elf          \
    73          user/fft/build/fft.elf            \
     67compile: dirs                                \
     68         hard_config.h                       \
     69         build_libs                          \
     70         $(BOOTLOADER_PATH)/build/boot.elf   \
     71         kernel/build/kernel.elf             \
     72         user/init/build/init.elf            \
     73         user/ksh/build/ksh.elf              \
     74         user/pgcd/build/pgcd.elf            \
     75         user/idbg/build/idbg.elf            \
     76         user/sort/build/sort.elf            \
     77         user/fft/build/fft.elf              \
     78         user/display/build/display.elf      \
     79         user/convol/build/convol.elf        \
     80         user/transpose/build/transpose.elf  \
    7481         list
    7582
     
    107114        $(MAKE) -C user/idbg clean
    108115        $(MAKE) -C user/fft clean
     116        $(MAKE) -C user/display clean
     117        $(MAKE) -C user/convol clean
     118        $(MAKE) -C user/transpose clean
    109119        $(MAKE) -C $(HAL_ARCH) clean
    110120
     
    119129        dd              if=$(DISK_IMAGE) of=temp.dmg count=65536
    120130        mv              temp.dmg $(DISK_IMAGE)
    121         mmd             -o -i $(DISK_IMAGE) ::/bin            || true
    122         mmd             -o -i $(DISK_IMAGE) ::/bin/kernel     || true
    123         mmd             -o -i $(DISK_IMAGE) ::/bin/user       || true
    124         mmd             -o -i $(DISK_IMAGE) ::/home           || true
     131        mmd             -o -i $(DISK_IMAGE) ::/bin                          || true
     132        mmd             -o -i $(DISK_IMAGE) ::/bin/kernel                   || true
     133        mmd             -o -i $(DISK_IMAGE) ::/bin/user                     || true
     134        mmd             -o -i $(DISK_IMAGE) ::/home                         || true
     135        mmd             -o -i $(DISK_IMAGE) ::/misc                         || true
     136        mcopy           -o -i $(DISK_IMAGE) images/lena_256.raw ::/misc     || true             
     137        mcopy           -o -i $(DISK_IMAGE) images/images_128.raw ::/misc   || true             
     138        mcopy           -o -i $(DISK_IMAGE) images/philips_1024.raw ::/misc || true             
    125139        mdir                -/ -b -i $(DISK_IMAGE) ::/
    126140
     
    194208        $(MAKE) -C user/fft
    195209        mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user
     210user/display/build/display.elf: build_libs
     211        $(MAKE) -C user/display
     212        mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user
     213user/convol/build/convol.elf: build_libs
     214        $(MAKE) -C user/convol
     215        mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user
     216user/transpose/build/transpose.elf: build_libs
     217        $(MAKE) -C user/transpose
     218        mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user
  • trunk/hal/generic/hal_drivers.h

    r346 r647  
    2525#include <chdev.h>
    2626
    27 void hal_drivers_txt_init(chdev_t *txt, uint32_t impl);
     27void hal_drivers_txt_init( chdev_t * txt );
    2828
    29 void hal_drivers_pic_init(chdev_t *pic, uint32_t impl);
     29void hal_drivers_pic_init( chdev_t * pic );
    3030
    31 void hal_drivers_iob_init(chdev_t *iob, uint32_t impl);
     31void hal_drivers_iob_init( chdev_t * iob );
    3232
    33 void hal_drivers_ioc_init(chdev_t *ioc, uint32_t impl);
     33void hal_drivers_ioc_init( chdev_t * ioc );
    3434
    35 void hal_drivers_mmc_init(chdev_t *mmc, uint32_t impl);
     35void hal_drivers_mmc_init( chdev_t * mmc );
    3636
    37 void hal_drivers_nic_init(chdev_t *nic, uint32_t impl);
     37void hal_drivers_nic_init( chdev_t * nic );
    3838
    39 void hal_drivers_dma_init(chdev_t *dma, uint32_t impl);
     39void hal_drivers_dma_init( chdev_t * dma );
     40
     41void hal_drivers_fbf_init( chdev_t * fbf );
    4042
    4143#endif  /* HAL_DRIVERS_H_ */
  • trunk/hal/tsar_mips32/Makefile

    r570 r647  
    2424               $(HAL_ARCH)/build/drivers/soclib_dma.o  \
    2525               $(HAL_ARCH)/build/drivers/soclib_mmc.o  \
     26               $(HAL_ARCH)/build/drivers/soclib_fbf.o  \
    2627               $(HAL_ARCH)/build/drivers/soclib_iob.o
    2728
  • trunk/hal/tsar_mips32/core/hal_context.c

    r640 r647  
    221221
    222222    // get base and ppn of remote child process GPT PT1
    223     child_gpt_ptr = hal_remote_l32( XPTR(child_cxy , &child_process->vmm.gpt.ptr) );
     223    child_gpt_ptr = hal_remote_lpt( XPTR(child_cxy , &child_process->vmm.gpt.ptr) );
    224224    child_gpt_ppn = ppm_base2ppn( XPTR( child_cxy , child_gpt_ptr ) );   
    225225
  • trunk/hal/tsar_mips32/core/hal_drivers.c

    r570 r647  
    3434#include <soclib_nic.h>
    3535#include <soclib_dma.h>
     36#include <soclib_fbf.h>
    3637
    3738#include <dev_txt.h>
     
    4647///////////////////////////////////////////////////////////////////////////////
    4748
    48 //////////////////////////////////////////
    49 void hal_drivers_txt_init( chdev_t  * txt,
    50                            uint32_t   impl )
     49///////////////////////////////////////////
     50void hal_drivers_txt_init( chdev_t  * txt )
    5151{
     52    uint32_t   impl = txt->impl;
     53
    5254    if( impl ==  IMPL_TXT_TTY )
    5355    {
     
    6870///////////////////////////////////////////////////////////////////////////////
    6971
    70 //////////////////////////////////////////
    71 void hal_drivers_pic_init( chdev_t  * pic,
    72                            uint32_t   impl )
     72///////////////////////////////////////////
     73void hal_drivers_pic_init( chdev_t  * pic )
    7374{
     75    uint32_t   impl = pic->impl;
     76
    7477    assert( (impl == IMPL_PIC_SCL), "undefined implementation" );
    7578
     
    9194///////////////////////////////////////////////////////////////////////////////
    9295
    93 //////////////////////////////////////////
    94 void hal_drivers_iob_init( chdev_t  * iob,
    95                            uint32_t   impl )
     96///////////////////////////////////////////
     97void hal_drivers_iob_init( chdev_t  * iob )
    9698{
     99    uint32_t   impl = iob->impl;
     100
    97101        assert( (impl == IMPL_IOB_TSR), "undefined implementation" );
    98102
     
    112116///////////////////////////////////////////////////////////////////////////////
    113117
    114 //////////////////////////////////////////
    115 void hal_drivers_ioc_init( chdev_t  * ioc,
    116                            uint32_t   impl )
     118///////////////////////////////////////////
     119void hal_drivers_ioc_init( chdev_t  * ioc )
    117120{
     121    uint32_t   impl = ioc->impl;
     122
    118123        if (impl == IMPL_IOC_BDV)
    119124    {
     
    138143///////////////////////////////////////////////////////////////////////////////
    139144
    140 //////////////////////////////////////////
    141 void hal_drivers_mmc_init( chdev_t  * mmc,
    142                            uint32_t   impl )
     145///////////////////////////////////////////
     146void hal_drivers_mmc_init( chdev_t  * mmc )
    143147{
     148    uint32_t   impl = mmc->impl;
     149
    144150        assert( (impl == IMPL_MMC_TSR), "undefined implementation" );
    145151 
     
    151157///////////////////////////////////////////////////////////////////////////////
    152158
    153 //////////////////////////////////////////
    154 void hal_drivers_nic_init( chdev_t  * nic,
    155                            uint32_t   impl )
     159///////////////////////////////////////////
     160void hal_drivers_nic_init( chdev_t  * nic )
    156161{
     162    uint32_t   impl = nic->impl;
     163
    157164        assert( (impl == IMPL_NIC_CBF), "undefined implementation" );
    158165 
     
    164171///////////////////////////////////////////////////////////////////////////////
    165172
    166 //////////////////////////////////////////
    167 void hal_drivers_dma_init( chdev_t  * dma,
    168                            uint32_t   impl )
     173///////////////////////////////////////////
     174void hal_drivers_dma_init( chdev_t  * dma )
    169175{
     176    uint32_t   impl = dma->impl;
     177
    170178        assert( (impl == IMPL_DMA_SCL), "undefined implementation" );
    171179 
     
    173181}
    174182
     183///////////////////////////////////////////////////////////////////////////////
     184//    FBF
     185///////////////////////////////////////////////////////////////////////////////
     186
     187///////////////////////////////////////////
     188void hal_drivers_fbf_init( chdev_t  * fbf )
     189{
     190    uint32_t   impl = fbf->impl;
     191
     192        assert( (impl == IMPL_FBF_SCL), "undefined implementation" );
     193 
     194    soclib_fbf_init( fbf );
     195}
     196
  • trunk/hal/tsar_mips32/core/hal_gpt.c

    r640 r647  
    2424#include <hal_kernel_types.h>
    2525#include <hal_gpt.h>
     26#include <hal_vmm.h>
    2627#include <hal_special.h>
    2728#include <hal_irqmask.h>
     
    291292uint32_t   cycle = (uint32_t)hal_get_cycles();
    292293// if( DEBUG_HAL_GPT_LOCK_PTE < cycle )
    293 if( (vpn == 0x3600) && (gpt_cxy == 0x11) )
     294if( (vpn == 0xc1fff) && (gpt_cxy == 0x1) )
    294295printk("\n[%s] thread[%x,%x] enters / vpn %x in cluster %x / cycle %d\n",
    295296__FUNCTION__, this->process->pid, this->trdid, vpn, gpt_cxy, cycle );
     
    360361#if DEBUG_HAL_GPT_LOCK_PTE
    361362// if( DEBUG_HAL_GPT_LOCK_PTE < cycle )
    362 if( (vpn == 0x3600) && (gpt_cxy == 0x11) )
     363if( (vpn == 0xc1fff) && (gpt_cxy == 0x1) )
    363364printk("\n[%s] PTE1 unmapped : winner thread[%x,%x] allocates a PT2 for vpn %x in cluster %x\n",
    364365__FUNCTION__, this->process->pid, this->trdid, vpn, gpt_cxy );
     
    371372#if DEBUG_HAL_GPT_LOCK_PTE
    372373// if( DEBUG_HAL_GPT_LOCK_PTE < cycle )
    373 if( (vpn == 0x3600) && (gpt_cxy == 0x11) )
     374if( (vpn == 0xc1fff) && (gpt_cxy == 0x1) )
    374375printk("\n[%s] PTE1 unmapped : loser thread[%x,%x] wait PTE1 for vpn %x in cluster %x\n",
    375376__FUNCTION__, this->process->pid, this->trdid, vpn, gpt_cxy );
     
    412413#if DEBUG_HAL_GPT_LOCK_PTE
    413414// if( DEBUG_HAL_GPT_LOCK_PTE < cycle )
    414 if( (vpn == 0x3600) && (gpt_cxy == 0x11) )
     415if( (vpn == 0xc1fff) && (gpt_cxy == 0x1) )
    415416printk("\n[%s] PTE1 unmapped : loser thread[%x,%x] get PTE1 for vpn %x in cluster %x\n",
    416417__FUNCTION__, this->process->pid, this->trdid, vpn, gpt_cxy );
     
    426427#if DEBUG_HAL_GPT_LOCK_PTE
    427428// if( DEBUG_HAL_GPT_LOCK_PTE < cycle )
    428 if( (vpn == 0x3600) && (gpt_cxy == 0x11) )
     429if( (vpn == 0xc1fff) && (gpt_cxy == 0x1) )
    429430printk("\n[%s] thread[%x,%x] get pte1 %x for vpn %x in cluster %x\n",
    430431__FUNCTION__, this->process->pid, this->trdid, pte1, vpn, gpt_cxy );
     
    494495cycle = (uint32_t)hal_get_cycles();
    495496// if( DEBUG_HAL_GPT_LOCK_PTE < cycle )
    496 if( (vpn == 0x3600) && (gpt_cxy == 0x11) )
     497if( (vpn == 0xc1fff) && (gpt_cxy == 0x1) )
    497498printk("\n[%s] thread[%x,%x] success / vpn %x in cluster %x / attr %x / ppn %x / cycle %d\n",
    498499__FUNCTION__, this->process->pid, this->trdid, vpn, gpt_cxy, pte2_attr, pte2_ppn, cycle );
  • trunk/hal/tsar_mips32/core/hal_remote.c

    r625 r647  
    220220        "mtc2   %4,     $24          \n"  /* PADDR_EXT <= cxy   */   
    221221        "or     $8,     $0,    %3    \n"  /* $8 <= new          */
    222         "ll     $3,    0(%1)         \n"  /* $3 <= *paddr       */
     222        "ll     $3,    0(%1)         \n"  /* $3 <= *ptr         */
    223223        "bne    $3,     %2,    1f    \n"  /* if ($3 != old)     */
    224224        "li     $7,     0            \n"  /* $7 <= 0            */
    225         "sc     $8,     (%1)         \n"  /* *paddr <= new      */
     225        "sc     $8,     (%1)         \n"  /* *ptr <= new        */
    226226        "or     $7,     $8,    $0    \n"  /* $7 <= atomic       */
    227227        "sync                        \n"
  • trunk/hal/tsar_mips32/core/hal_uspace.c

    r637 r647  
    142142// If the two buffers are aligned on a word boundary, it moves the data word per word
    143143// in a first loop, and moves byte per byte the remaining bytes in a second loop.
    144 // If the buffers are not aligned, it moves all data byte per byte.
     144// If the buffers are not word aligned, it moves all data byte per byte.
    145145///////////////////////////////////////////////////////////////////////////////////////
    146146// @ u_dst_ptr : pointer on destination user buffer
  • trunk/hal/tsar_mips32/drivers/soclib_bdv.c

    r626 r647  
    3333void soclib_bdv_init( chdev_t * chdev )
    3434{
    35     // get extended pointer on SOCLIB_BDV peripheral base
    36         xptr_t  bdv_xp = chdev->base;
    37 
    38     // set driver specific fields
     35    // set driver specific fields in IOC chdev
    3936    chdev->cmd = &soclib_bdv_cmd;
    4037    chdev->isr = &soclib_bdv_isr;
    4138
     39    // get extended pointer on SOCLIB_BDV peripheral base
     40        xptr_t  base_xp = chdev->base;
     41
    4242    // get hardware device cluster and local pointer
    43     cxy_t      bdv_cxy  = GET_CXY( bdv_xp );
    44     uint32_t * bdv_ptr  = (uint32_t *)GET_PTR( bdv_xp );
     43    cxy_t      base_cxy  = GET_CXY( base_xp );
     44    uint32_t * base_ptr  = GET_PTR( base_xp );
    4545
    4646    // get block_size and block_count 
    47         uint32_t block_size = hal_remote_l32( XPTR( bdv_cxy , bdv_ptr + BDV_BLOCK_SIZE_REG ) );
    48         uint32_t block_count = hal_remote_l32( XPTR( bdv_cxy , bdv_ptr + BDV_SIZE_REG ) );
    49 
    50     // set IOC device descriptor extension
     47        uint32_t block_size  = hal_remote_l32( XPTR( base_cxy , base_ptr + BDV_BLOCK_SIZE_REG ) );
     48        uint32_t block_count = hal_remote_l32( XPTR( base_cxy , base_ptr + BDV_SIZE_REG ) );
     49
     50    // set IOC chdev extension fields
    5151    chdev->ext.ioc.size  = block_size;
    5252    chdev->ext.ioc.count = block_count;
     
    9191    else     assert( false , "illegal command" );
    9292
    93     // get IOC device cluster and local pointer
     93    // get cluster and local pointer on IOC chdev
    9494    cxy_t      ioc_cxy = GET_CXY( ioc_xp );
    9595    chdev_t  * ioc_ptr = GET_PTR( ioc_xp );
     
    131131    // waiting policy  depends on the command type
    132132    // - for IOC_READ / IOC_WRITE commands, this function is called by the server thread
    133     //   that blocks and deschedules after launching the I/O transfer.
    134     //   The I/O operation status is reported in the command by the ISR.
    135     // - for IOC_SYNC_READ / IOC_SYNC_WRITE command, this function is called by the client
    136     //   thread that polls the BDV status register until I/O transfer completion.
     133    //   => block and deschedule after launching the I/O transfer.
     134    //   The I/O operation status is reported in the command by the ISR, and the
     135    //   server thread is re-activated by the ISR.
     136    // - for IOC_SYNC_READ / IOC_SYNC_WRITE, this function is called by the client thread
     137    //   => mask the IOC IRQ and poll the BDV status register until I/O transfer completion,
     138    //   and report status in the command.
    137139
    138140    if( (cmd_type == IOC_SYNC_READ) || (cmd_type == IOC_SYNC_WRITE) )  // polling policy
    139141    {
     142        // get core handling the IOC IRQ
     143        thread_t * server = (thread_t *)hal_remote_lpt( XPTR( ioc_cxy , &ioc_ptr->server ) );
     144        core_t   * core   = (core_t *)hal_remote_lpt( XPTR( ioc_cxy , &server->core ) );
     145        lid_t      lid    = (lid_t)hal_remote_l32( XPTR( ioc_cxy , &core->lid ) );
     146
     147        // mask the IOC IRQ
     148        dev_pic_disable_irq( lid , ioc_xp );
     149
    140150        // launch I/O operation on BDV device
    141151        hal_remote_s32( XPTR( seg_cxy , seg_ptr + BDV_OP_REG ) , op );
     
    149159                (status == BDV_WRITE_SUCCESS) ) // successfully completed
    150160            {
     161                // unmask IOC IRQ
     162                dev_pic_enable_irq( lid , ioc_xp );
     163
     164                // report success in command
    151165                hal_remote_s32( XPTR( th_cxy , &th_ptr->ioc_cmd.error ) , 0 );
    152166
     
    154168cycle = (uint32_t)hal_get_cycles();
    155169if( (DEBUG_HAL_IOC_RX < cycle) && (cmd_type == IOC_SYNC_READ) )
    156 printk("\n[%s] thread[%x,%x] exit after SYNC_READ for client thread[%x,%x] / cycle %d\n",
     170printk("\n[%s] thread[%x,%x] SYNC_READ success for client thread[%x,%x] / cycle %d\n",
    157171__FUNCTION__, this->process->pid, this->trdid, client_pid, client_trdid, cycle );
    158172#endif
     
    161175cycle = (uint32_t)hal_get_cycles();
    162176if( (DEBUG_HAL_IOC_TX < cycle) && (cmd_type == IOC_SYNC_WRITE) )
    163 printk("\n[%s] thread[%x,%x] exit after SYNC_WRITE for client thread[%x,%x] / cycle %d\n",
     177printk("\n[%s] thread[%x,%x] SYNC_WRITE success for client thread[%x,%x] / cycle %d\n",
    164178__FUNCTION__, this->process->pid, this->trdid, client_pid, client_trdid, cycle );
    165179#endif
     
    172186            else                               // error reported
    173187            {
     188                // unmask IOC IRQ
     189                dev_pic_enable_irq( lid , ioc_xp );
     190
     191                // report failure in command
    174192                hal_remote_s32( XPTR( th_cxy , &th_ptr->ioc_cmd.error ) , 1 );
     193
     194#if DEBUG_HAL_IOC_RX
     195cycle = (uint32_t)hal_get_cycles();
     196if( (DEBUG_HAL_IOC_RX < cycle) && (cmd_type == IOC_SYNC_READ) )
     197printk("\n[%s] thread[%x,%x] SYNC_READ failure for client thread[%x,%x] / cycle %d\n",
     198__FUNCTION__, this->process->pid, this->trdid, client_pid, client_trdid, cycle );
     199#endif
     200
     201#if DEBUG_HAL_IOC_TX
     202cycle = (uint32_t)hal_get_cycles();
     203if( (DEBUG_HAL_IOC_TX < cycle) && (cmd_type == IOC_SYNC_WRITE) )
     204printk("\n[%s] thread[%x,%x] SYNC_WRITE failure for client thread[%x,%x] / cycle %d\n",
     205__FUNCTION__, this->process->pid, this->trdid, client_pid, client_trdid, cycle );
     206#endif
    175207                break;
    176208            }
  • trunk/hal/tsar_mips32/drivers/soclib_fbf.c

    r75 r647  
    22 * soclib_fbf.c - soclib frame-buffer driver implementation.
    33 *
    4  * Author Alain greiner (2016)
     4 * Author Alain greiner (2016,2017,2018,2019)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    2222 */
    2323
     24#include <soclib_fbf.h>
     25#include <hal_kernel_types.h>
     26#include <hal_uspace.h>
     27#include <chdev.h>
     28#include <dev_fbf.h>
     29#include <printk.h>
     30#include <thread.h>
     31
     32///////////////////////////////////////
     33void soclib_fbf_init( chdev_t * chdev )
     34{
     35    // set driver specific fields in FBF chdev
     36    chdev->cmd = &soclib_fbf_cmd;
     37    chdev->isr = NULL;
     38
     39    // get extended pointer on SOCLIB_FBF peripheral segment base
     40        xptr_t  base_xp = chdev->base;
     41
     42    // get cluster and local pointer for the SOCLIB_FBF peripheral segment
     43    cxy_t      base_cxy  = GET_CXY( base_xp );
     44    uint32_t * base_ptr  = GET_PTR( base_xp );
     45
     46    // get frame buffer width, height, and type 
     47        uint32_t width  = hal_remote_l32( XPTR( base_cxy , base_ptr + FBF_WIDTH_REG ) );
     48        uint32_t height = hal_remote_l32( XPTR( base_cxy , base_ptr + FBF_HEIGHT_REG ) );
     49    uint32_t type   = hal_remote_l32( XPTR( base_cxy , base_ptr + FBF_SUBSAMPLING_REG ) );
     50
     51    // set FBF chdev extension fields
     52    chdev->ext.fbf.width       = width;
     53    chdev->ext.fbf.height      = height;
     54    chdev->ext.fbf.subsampling = type;
     55
     56}  // end soclib_fbf_init()
     57
     58/////////////////////////////////////////////////////////////////
     59void __attribute__((noinline)) soclib_fbf_cmd( xptr_t thread_xp )
     60{
     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;
     66    uint32_t   status;      // I/0 operation status (from BDV)
     67
     68    // get client thread cluster and local pointer
     69    cxy_t      th_cxy = GET_CXY( thread_xp );
     70    thread_t * th_ptr = GET_PTR( thread_xp );
     71
     72#if (DEBUG_HAL_FBF|| DEBUG_HAL_FBF)
     73uint32_t    cycle        = (uint32_t)hal_get_cycles();
     74thread_t  * this         = CURRENT_THREAD;
     75process_t * process      = hal_remote_lpt( XPTR( th_cxy , &th_ptr->process ) );
     76pid_t       client_pid   = hal_remote_l32( XPTR( th_cxy , &process->pid ) );
     77trdid_t     client_trdid = hal_remote_l32( XPTR( th_cxy , &th_ptr->trdid ) );
     78#endif
     79
     80    // get command arguments
     81    cmd_type =         hal_remote_l32( XPTR( th_cxy , &th_ptr->fbf_cmd.type   ) );
     82    offset   =         hal_remote_l32( XPTR( th_cxy , &th_ptr->fbf_cmd.offset ) );
     83    length   =         hal_remote_l32( XPTR( th_cxy , &th_ptr->fbf_cmd.length ) );
     84    buffer   =         hal_remote_lpt( XPTR( th_cxy , &th_ptr->fbf_cmd.buffer ) );
     85    fbf_xp   = (xptr_t)hal_remote_l64( XPTR( th_cxy , &th_ptr->fbf_cmd.dev_xp ) );
     86
     87    // get cluster and local pointer on FBF chdev
     88    cxy_t     fbf_cxy = GET_CXY( fbf_xp );
     89    chdev_t * fbf_ptr = GET_PTR( fbf_xp );
     90
     91    // get extended pointer on SOCLIB_FBF peripheral segment base
     92        xptr_t  base_xp = (xptr_t)hal_remote_l64( XPTR( fbf_cxy , &fbf_ptr->base ) );
     93
     94    // execute command
     95    if( cmd_type == FBF_READ )     // use a (kernel -> user) memcpy
     96    {
     97
     98#if DEBUG_HAL_FBF
     99if( DEBUG_HAL_FBF < cycle )
     100printk("\n[%s] thread[%x,%x] / client[%x,%x] / READ / offset / length / buffer %x / cycle %d\n",
     101__FUNCTION__ , this->process->pid, this->trdid,  client_pid, client_trdid,
     102offset, length, buffer, cycle );
     103#endif
     104        hal_copy_to_uspace( buffer,
     105                            base_xp + offset,
     106                            length );
     107
     108    }
     109    else  // cmd_type == FBF_WRITE => use a (user -> kernel)  memcpy
     110    {
     111
     112#if DEBUG_HAL_FBF
     113if( DEBUG_HAL_FBF < cycle )
     114printk("\n[%s] thread[%x,%x] / client[%x,%x] / WRITE / offset / length / buffer %x / cycle %d\n",
     115__FUNCTION__ , this->process->pid, this->trdid, client_pid, client_trdid,
     116offset, length, buffer, cycle );
     117#endif
     118        hal_copy_from_uspace( base_xp + offset,
     119                              buffer,
     120                              length );
     121    }
     122
     123    // set success in command
     124    hal_remote_s32( XPTR( th_cxy , &th_ptr->fbf_cmd.error ) , 0 );
     125           
     126}  // end soclib_fbf_cmd()
     127
  • trunk/hal/tsar_mips32/drivers/soclib_fbf.h

    r75 r647  
    11/*
    2  * soclib_fbf.h - soclib frame-buffer driver definition.
     2 * soclib_fbf.h - soclib frame-buffer driver definition (used in TSAR_IOB architecture).
    33 *
    4  * Author Alain greiner (2016)
     4 * Author Alain greiner (2016,2017,2018,2019)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    2222 */
    2323
    24 #ifndef _SOCLIB_FB_H_
    25 #define _SOCLIB_FB_H_
     24#ifndef _SOCLIB_FBF_H_
     25#define _SOCLIB_FBF_H_
    2626
     27#include <chdev.h>
     28#include <hal_kernel_types.h>
     29
     30/****************************************************************************************
     31 * This driver supports the vci_fbf_tsar component.
     32 *
     33 * This hardware component supports both a frame buffer, and a set of addressable
     34 * configuration status registers.
     35 ***************************************************************************************/
     36
     37/****************************************************************************************
     38 *                    SOCLIB_FBF registers offsets
     39 * The three addressables registers are on top  of the 4 Mbytes allocated
     40 * to the frame buffer itself.
     41 ***************************************************************************************/
     42
     43enum SoclibFrameBufferRegisters
     44{
     45    FBF_WIDTH_REG        = 0x100000,
     46    FBF_HEIGHT_REG       = 0x100001,
     47    FBF_SUBSAMPLING_REG  = 0x100002,
     48};
     49
     50/****************************************************************************************
     51 * This function access the SOCLIB_FBF hardware registers, to get the frame buffer
     52 * size and type, and update the FBF device extension.
     53 ****************************************************************************************
     54 * @ chdev     : pointer on the FBF chdev descriptor.
     55 ***************************************************************************************/
     56void soclib_fbf_init( chdev_t * chdev );
     57
     58/****************************************************************************************
     59 * This function implements the FBF_READ and FBF_WRITE commands registered in the client
     60 * thread descriptor identified by the <thread_xp> argument.
     61 * It is called directly by the client thread.
     62 * **************************************************************************************
     63 * @ thread_xp : extended pointer on client thread descriptor.
     64 ***************************************************************************************/
     65extern void soclib_fbf_cmd( xptr_t thread_xp );
    2766
    2867#endif
  • 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
  • trunk/libs/libalmosmkh/almosmkh.c

    r643 r647  
    14561456/////////////////////////////////////////////////////////////////////////////////////////
    14571457
    1458 /////////////////////////////////
    1459 int fbf_get_config( int * width,
    1460                     int * height,
    1461                     int * type )
     1458/////////////////////////////////////////
     1459int fbf_get_config( unsigned int * width,
     1460                    unsigned int * height,
     1461                    unsigned int * type )
    14621462{
    14631463    return hal_user_syscall( SYS_FBF,
     
    14681468}
    14691469
    1470 ////////////////////////////
    1471 int fbf_read( void * buffer,
    1472               int    length,
    1473               int    offset )
     1470////////////////////////////////////
     1471int fbf_read( void         * buffer,
     1472              unsigned int   length,
     1473              unsigned int   offset )
    14741474{
    14751475    return hal_user_syscall( SYS_FBF,
     
    14801480}
    14811481
    1482 ////////////////////////////
    1483 int fbf_write( void * buffer,
    1484                int    length,
    1485                int    offset )
     1482/////////////////////////////////////
     1483int fbf_write( void         * buffer,
     1484               unsigned int   length,
     1485               unsigned int   offset )
    14861486{
    14871487    return hal_user_syscall( SYS_FBF,
  • trunk/libs/libalmosmkh/almosmkh.h

    r643 r647  
    538538 * @ returns 0 if success / returns -1 if error.
    539539 ****************************************************************************************/
    540 int fbf_get_config( int * width,
    541                     int * height,
    542                     int * type );
     540int fbf_get_config( unsigned int * width,
     541                    unsigned int * height,
     542                    unsigned int * type );
    543543
    544544/*****************************************************************************************
     
    551551 * @ returns 0 if success / returns -1 if error.
    552552 ****************************************************************************************/
    553 int fbf_read( void * buffer,
    554               int    length,
    555               int    offset );
     553int fbf_read( void         * buffer,
     554              unsigned int   length,
     555              unsigned int   offset );
    556556
    557557/*****************************************************************************************
     
    564564 * @ returns 0 if success / returns -1 if error.
    565565 ****************************************************************************************/
    566 int fbf_write( void * buffer,
    567                int    length,
    568                int    offset );
     566int fbf_write( void         * buffer,
     567               unsigned int   length,
     568               unsigned int   offset );
    569569
    570570#endif /* _LIBALMOSMKH_H_ */
  • trunk/libs/libpthread/pthread.h

    r640 r647  
    3232
    3333/*********************************************************************************************
    34  * This function creates a new user thread. The <user_attr> argument is a pointer
     34 * This function creates a new user thread. The <attr> argument is a pointer
    3535 * on a structure containing the thread attributes, defined in the shared_pthread.h file.
     36 * The thread entry point is defined by the <start_func> and <start_args> arguments.
    3637 *********************************************************************************************
    3738 * @ trdid       : [out] buffer for created thread identifier in process.
  • trunk/libs/mini-libc/stdio.c

    r643 r647  
    412412
    413413    // compute nbytes
    414     unsigned int nbytes = size * nitems;
     414    int nbytes = size * nitems;
    415415
    416416    if( hal_user_syscall( SYS_READ,
     
    435435
    436436    // compute nbytes
    437     unsigned int nbytes = size * nitems;
     437    int nbytes = size * nitems;
    438438
    439439    if( hal_user_syscall( SYS_WRITE,
     
    444444
    445445}  // end fwrite()
     446
     447//////////////////////////////////////////
     448unsigned int fseek( FILE         * stream,
     449                    unsigned int   offset,
     450                    int            whence )
     451{
     452    // check stream valid
     453    if( stream->key != VALID_OPEN_FILE ) return -1;
     454
     455    // get file descriptor from stream pointer
     456    int fd = stream->fd;
     457
     458    return( hal_user_syscall( SYS_LSEEK,
     459                              (reg_t)fd,
     460                              (reg_t)offset,
     461                              (reg_t)whence, 0 ) );
     462}  // end fseek()
    446463
    447464/////////////////////////////////
  • trunk/libs/mini-libc/stdio.h

    r643 r647  
    146146 * It can be a regular file or a character oriented input device.
    147147 *********************************************************************************************
     148 * @ buffer    : pointer on user buffer.
     149 * @ size      : item size in bytes.
     150 * @ nitems    : number of items.
    148151 * @ stream    : pointer on a stream.
    149  * @ format    : formated string.
    150152 * @ returns actual number of items read if success / returns 0 if failure.
    151153 ********************************************************************************************/
     
    160162 * It can be a  regular file or a character oriented input device.
    161163 *********************************************************************************************
     164 * @ buffer    : pointer on user buffer.
     165 * @ size      : item size in bytes.
     166 * @ nitems    : number of items.
    162167 * @ stream    : pointer on a stream.
    163  * @ format    : formated string.
    164168 * @ returns actual number of written items if success / returns 0 if failure.
    165169 ********************************************************************************************/
     
    169173                     FILE         * stream ); 
    170174
     175/*********************************************************************************************
     176 * This function moves <nitems> oblects, each <size> bytes long, from an input stream
     177 * identified by <stream>, to the user buffer identified by the <buffer> argument.
     178 * It can be a regular file or a character oriented input device.
     179 *********************************************************************************************
     180 * @ stream    : pointer on a stream.
     181 * @ offset    : used to compute new offset value.
     182 * @ whence    : operation type (SEEK_SET / SEEK_CUR / SEEK_END)
     183 * @ return 0 if success / returns -1 if failure.
     184 ********************************************************************************************/
     185unsigned int fseek( FILE        * stream,
     186                    unsigned int  offset,
     187                    int           whence );
     188
     189
    171190#endif  // _STDIO_H_
  • trunk/params-hard.mk

    r641 r647  
    22
    33ARCH      = /Users/alain/soc/tsar-trunk-svn-2013/platforms/tsar_generic_iob
    4 X_SIZE    = 4
    5 Y_SIZE    = 2
    6 NB_PROCS  = 4
     4X_SIZE    = 1
     5Y_SIZE    = 1
     6NB_PROCS  = 1
    77NB_TTYS   = 2
    88IOC_TYPE  = IOC_BDV
  • trunk/user/ksh/ksh.c

    r644 r647  
    12261226
    12271227
    1228 // 1. first direct command
     1228/* 1. first direct command
    12291229if( sem_wait( &semaphore ) )
    12301230{
     
    12381238    execute( cmd );
    12391239}
    1240 //
     1240*/
    12411241
    12421242
Note: See TracChangeset for help on using the changeset viewer.