Changeset 657 for trunk/hal


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

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

Location:
trunk/hal
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/hal/generic/hal_atomic.h

    r587 r657  
    22 * hal_atomic.h - Generic Atomic Operations API definition.
    33 *
    4  * Authors   Alain Greiner    (2016)
     4 * Authors   Alain Greiner    (2016,2017,2018,2019,2020)
    55 *
    66 * Copyright (c)  UPMC Sorbonne Universites
  • trunk/hal/generic/hal_remote.h

    r629 r657  
    22 * hal_remote.h - Generic Remote Access API definition.
    33 *
    4  * Authors    Alain Greiner (2016,2017,2018,2019)
     4 * Authors    Alain Greiner (2016,2017,2018,2019,2020)
    55 *
    66 * Copyright (c)  UPMC Sorbonne Universites
  • trunk/hal/generic/hal_uspace.h

    r637 r657  
    22 * hal_uspace.h - Generic User Space Access API definition
    33 *
    4  * Authors    Alain Greiner (2016,2017,2018,2019)
     4 * Authors    Alain Greiner (2016,2017,2018,2019,2020)
    55 *
    66 * Copyright (c)  UPMC Sorbonne Universites
  • trunk/hal/tsar_mips32/core/hal_macros.h

    r570 r657  
    2626
    2727//////////////////////////////////////////////////////////////////////////////////////////
    28 //     User-side, hardware dependant, macros definition.
     28//   Hardware dependant, macros definition.
    2929//
    3030//   Any architecture specific implementation must implement these macros.
  • trunk/hal/tsar_mips32/core/hal_remote.c

    r647 r657  
    33 *
    44 * Authors : Mohammed Karaoui (2015)
    5  *           Alain Greiner    (2016)
     5 *           Alain Greiner    (2016,2017,2018,2019)
    66 *
    77 * Copyright (c) UPMC Sorbonne Universites
  • trunk/hal/tsar_mips32/core/hal_uspace.c

    r654 r657  
    22 * hal_uspace.c - implementation of Generic User Space Access API for MIPS32
    33 *
    4  * Author        Alain Greiner   (2016,2017,2018,2019)
     4 * Author        Alain Greiner   (2016,2017,2018,2019,2020)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    5454    uint32_t dst = (uint32_t)GET_PTR( k_dst_xp );
    5555    uint32_t cxy = (uint32_t)GET_CXY( k_dst_xp );
    56    
    5756 
    5857#if DEBUG_HAL_USPACE
  • trunk/hal/tsar_mips32/drivers/soclib_bdv.c

    r647 r657  
    22 * soclib_bdv.c - soclib simple block device driver implementation.
    33 *
    4  * Author     Alain Greiner (2016,2017,2018)
     4 * Author     Alain Greiner (2016,2017,2018,2019,2020)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
  • trunk/hal/tsar_mips32/drivers/soclib_dma.c

    r570 r657  
    22 * soclib_dma.c - soclib Multi Channels DMA driver implementation
    33 *
    4  * Author     Alain Greiner (2017)
     4 * Author     Alain Greiner (2017,2018,2019,2020)
    55
    66 * Copyright (c) UPMC Sorbonne Universites
     
    3939    chdev->isr = &soclib_dma_isr;
    4040
    41     // enable interrupts
    42         hal_remote_s32( XPTR( dma_cxy , dma_ptr + DMA_IRQ_DISABLED ) , 0 );
     41    // disable interrupts
     42        hal_remote_s32( XPTR( dma_cxy , dma_ptr + DMA_IRQ_DISABLED ) , 1 );
    4343
    4444} // soclib_dma_init()
     
    4747void __attribute__ ((noinline)) soclib_dma_cmd( xptr_t thread_xp )
    4848{
     49    bool_t     sync;
    4950    xptr_t     dev_xp;       // extended pointer on DMA devive
    5051    xptr_t     dst_xp;       // extended pointer on destination buffer
    5152    xptr_t     src_xp;       // extended pointer on source buffer
    5253    uint32_t   size;         // buffer size
     54    uint32_t   status;       // DMA status
    5355
    5456    // get client thread cluster and local pointer
    55     cxy_t      thread_cxy = GET_CXY( thread_xp );
    56     thread_t * thread_ptr = (thread_t *)GET_PTR( thread_xp );
    57 
    58     // get command arguments and extended pointer on DMA device
    59     dev_xp = (xptr_t)hal_remote_l64( XPTR( thread_cxy , &thread_ptr->dma_cmd.dev_xp ) );
    60     dst_xp = (xptr_t)hal_remote_l64( XPTR( thread_cxy , &thread_ptr->dma_cmd.dst_xp ) );
    61     src_xp = (xptr_t)hal_remote_l64( XPTR( thread_cxy , &thread_ptr->dma_cmd.src_xp ) );
    62     size   =         hal_remote_l32 ( XPTR( thread_cxy , &thread_ptr->dma_cmd.size   ) );
     57    cxy_t      client_cxy = GET_CXY( thread_xp );
     58    thread_t * client_ptr = (thread_t *)GET_PTR( thread_xp );
     59
     60#if (DEBUG_HAL_IOC_RX || DEBUG_HAL_IOC_TX)
     61uint32_t    cycle        = (uint32_t)hal_get_cycles();
     62thread_t  * this         = CURRENT_THREAD;
     63process_t * process      = hal_remote_lpt( XPTR( th_cxy , &th_ptr->process ) );
     64pid_t       client_pid   = hal_remote_l32( XPTR( th_cxy , &process->pid ) );
     65trdid_t     client_trdid = hal_remote_l32( XPTR( th_cxy , &th_ptr->trdid ) );
     66#endif
     67
     68// TODO both the client and the server threads are allways local,
     69// we could replace all these remote accesses by local accesses !!!  [AG]
     70
     71    // get command arguments and extended pointer on DMA device descriptor
     72    sync   =         hal_remote_l32( XPTR( client_cxy , &client_ptr->dma_cmd.sync   ) );
     73    dev_xp = (xptr_t)hal_remote_l64( XPTR( client_cxy , &client_ptr->dma_cmd.dev_xp ) );
     74    dst_xp = (xptr_t)hal_remote_l64( XPTR( client_cxy , &client_ptr->dma_cmd.dst_xp ) );
     75    src_xp = (xptr_t)hal_remote_l64( XPTR( client_cxy , &client_ptr->dma_cmd.src_xp ) );
     76    size   =         hal_remote_l32( XPTR( client_cxy , &client_ptr->dma_cmd.size   ) );
    6377
    6478    // get DMA device cluster and local pointer
     
    6680    chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );
    6781
    68     // get extended pointer on SOCLIB-DMA peripheral
    69     xptr_t     dma_xp = hal_remote_l32( XPTR( dev_cxy , &dev_ptr->base ) );
    70 
    71     // get SOCLIB_DMA device cluster and local pointer
     82    // get pointers on DMA peripheral
     83    xptr_t     dma_xp  = hal_remote_l32( XPTR( dev_cxy , &dev_ptr->base ) );
    7284    cxy_t      dma_cxy = GET_CXY( dma_xp );
    73     uint32_t * dma_ptr = (uint32_t *)GET_PTR( dma_xp );
     85    uint32_t * dma_ptr = GET_PTR( dma_xp );
    7486
    7587    // get DMA channel index and channel base address
     
    8294    uint32_t   src_msb = (uint32_t)(src_xp>>32);
    8395
    84     // set SOCLIB_DMA registers to start tranfer operation
     96    // set SOCLIB_DMA registers and launch tranfer operation
    8597    hal_remote_s32( XPTR( dma_cxy , base + DMA_SRC     ) , src_lsb );
    8698    hal_remote_s32( XPTR( dma_cxy , base + DMA_SRC_EXT ) , src_msb );
    8799    hal_remote_s32( XPTR( dma_cxy , base + DMA_DST     ) , dst_lsb );
    88100    hal_remote_s32( XPTR( dma_cxy , base + DMA_DST_EXT ) , dst_msb );
    89     hal_remote_s32( XPTR( dma_cxy , base + DMA_LEN     ) , size    );
    90 
    91     // Block and deschedule server thread
    92     thread_block( XPTR( local_cxy , CURRENT_THREAD ) , THREAD_BLOCKED_ISR );
    93     sched_yield("blocked on ISR");
    94    
     101    hal_remote_s32( XPTR( dma_cxy , base + DMA_LEN_STS ) , size    );
     102
     103 #if DEBUG_HAL_DMA
     104if( DEBUG_HAL_DMA < cycle )
     105printk("\n[%s] thread[%x,%x] launched DMA for client thread[%x,%x] / cycle %d\n",
     106__FUNCTION__, this->process->pid, this->trdid, client_pid, client_trdid, cycle );
     107#endif
     108
     109    // waiting policy  depends on the command type
     110    // - for an asynchronous command, this function is called by the server thread
     111    //   => block and deschedule after launching the transfer.
     112    //   The operation status is reported in the command by the ISR, and the
     113    //   server thread is re-activated by the ISR.
     114    // - for a synchronous command, this function is called by the client thread
     115    //   => mask the DMA_IRQ and poll the DMA status register until transfer completion,
     116    //   and reports status in the command when the transfer is completed.
     117
     118    if( sync )                            // client thread poll status until completion
     119    {
     120        while( 1 )
     121        {
     122            status = hal_remote_l32( XPTR( dma_cxy , base + DMA_LEN_STS ) );
     123
     124            if( (status == DMA_SUCCESS) || (status == DMA_IDLE) )
     125            {
     126                // set operation status in command
     127                hal_remote_s32( XPTR( client_cxy , &client_ptr->dma_cmd.error ) , 0 );
     128
     129#if DEBUG_HAL_DMA
     130cycle = (uint32_t)hal_get_cycles();
     131if( DEBUG_HAL_DMA < cycle )
     132printk("\n[%s] thread[%x,%x] exit after SYNC success / cycle %d\n",
     133__FUNCTION__, this->process->pid, this->trdid, cycle );
     134#endif
     135                // exit while
     136                break;
     137            }
     138            else if( (status == DMA_ERROR_READ) || (status == DMA_ERROR_WRITE) )
     139            {
     140                // set operation status in command
     141                hal_remote_s32( XPTR( client_cxy , &client_ptr->dma_cmd.error ) , 1 );
     142
     143#if DEBUG_HAL_DMA
     144cycle = (uint32_t)hal_get_cycles();
     145if( DEBUG_HAL_DMA < cycle )
     146printk("\n[%s] thread[%x,%x] exit after SYNC failure / cycle %d\n",
     147__FUNCTION__, this->process->pid, this->trdid, cycle );
     148#endif
     149                // exit while
     150                break;
     151            }
     152        }
     153    }   
     154    else                                // server thread block and deschedule
     155    {
     156        // server thread blocks on ISR
     157        thread_block( XPTR( local_cxy , CURRENT_THREAD ) , THREAD_BLOCKED_ISR );
     158
     159        // enable DMA interrupts
     160            hal_remote_s32( XPTR( dma_cxy , dma_ptr + DMA_IRQ_DISABLED ) , 0 );
     161
     162        // server thread deschedules
     163        sched_yield("blocked on ISR");
     164
     165        // disable DMA interrupts
     166            hal_remote_s32( XPTR( dma_cxy , dma_ptr + DMA_IRQ_DISABLED ) , 1 );
     167
     168#if DEBUG_HAL_DMA
     169cycle = (uint32_t)hal_get_cycles();
     170if( DEBUG_HAL_DMA < cycle )
     171printk("\n[%s] thread[%x,%x] exit after ASYNC / client thread[%x,%x] / cycle %d\n",
     172__FUNCTION__ , this->process->pid, this->trdid, client_pid, client_trdid, cycle );
     173#endif
     174
     175    }
    95176} // soclib_dma_cmd()
    96177
     
    98179void __attribute__ ((noinline)) soclib_dma_isr( chdev_t * chdev )
    99180{
    100     // get extended pointer on client thread
     181    // get extended pointer on server thread
     182    xptr_t server_xp = XPTR( local_cxy , &chdev->server );
     183
     184   // get extended pointer on client thread
    101185    xptr_t root      = XPTR( local_cxy , &chdev->wait_root );
    102186    xptr_t client_xp = XLIST_FIRST( root , thread_t , wait_list );
    103 
    104     // get extended pointer on server thread
    105     xptr_t server_xp = XPTR( local_cxy , &chdev->server );
    106187
    107188    // get client thread cluster and local pointer
     
    113194    uint32_t * dma_ptr  = (uint32_t *)GET_PTR( chdev->base );
    114195
    115     // get DMA channel base address
     196    // build DMA channel base address
    116197    uint32_t * base = dma_ptr + (DMA_SPAN * chdev->channel);
    117198
    118199    // get DMA status register
    119         uint32_t status = hal_remote_l32( XPTR( dma_cxy , base + DMA_LEN ) );   
     200        uint32_t status = hal_remote_l32( XPTR( dma_cxy , base + DMA_LEN_STS ) );   
    120201
    121202    // acknowledge IRQ
     
    129210    thread_unblock( server_xp , THREAD_BLOCKED_ISR );
    130211
    131     // unblock client thread
    132     thread_unblock( client_xp , THREAD_BLOCKED_IO );
    133 
    134212} // soclib_dma_isr()
    135213
  • trunk/hal/tsar_mips32/drivers/soclib_dma.h

    r75 r657  
    3939    DMA_SRC                  = 0,    /*! source buffer 32 LSB address bits                         */
    4040    DMA_DST                  = 1,    /*! source buffer 32 LSB address bits                         */
    41     DMA_LEN                  = 2,    /*! number of bytes (on write) / transfer status (on read)    */
     41    DMA_LEN_STS      = 2,    /*! number of bytes (on write) / transfer status (on read)    */
    4242    DMA_RESET            = 3,    /*! desactivate channel (can be usde to acknowledge IRQ)      */
    4343    DMA_IRQ_DISABLED = 4,    /*! no IRQ generated if non zero                              */
     
    6060
    6161/********************************************************************************************
    62  * This function access the SOCLIB_DMA hardware register to enable interrupts.
     62 * This function access the SOCLIB_DMA hardware register to disable interrupts,
     63 * because the most frequent operations are supposed to be synchronous accesses.
    6364 ********************************************************************************************
    6465 * @ chdev     : pointer on DMA chdev descriptor.
     
    6768
    6869/********************************************************************************************
    69  * This function is called by the server thread associated to the DMA device.
    70  * It access the command embedded in the calling thread descriptor, (format defined in the
    71  * dev_dma.h file) and access the SOCLIB_DMA hardware registers to start command execution.
    72  * Then it blocks on the THREAD_BLOCKED_DEV_ISR and deschedules, because each DMA channel
    73  * can only execute one command at a given time.
    74  * It is re-activated by the ISR signaling the transfer completion.
     70 * This function can be called by the "server" thread associated to the DMA channel, for an
     71 * asynchronous access, or can be directly called by the "client" thread for a synchronous
     72 * access. In both cases, it get the command arguments from the calling thread descriptor,
     73 * and access the DMA registers to launch the DMA transfer.
     74 * Then, the waiting policy depends on the command type:
     75 * - for asynchronous access, it enables the DMA interrupts, blocks on THREAD_BLOCKED_ISR,
     76 *   and deschedules. It will be re-activated by the soclib_dma_isr() function.
     77 * - for a synchronous transfer, it polls the DMA status register until completion,
     78 *   and reports the transfer status in the command registered in the client thread. 
    7579 ********************************************************************************************
    7680 * @ thread_xp  : extended pointer on the client thread.
     
    8084/********************************************************************************************
    8185 * This Interrupt Service Routine is executed when the IRQ signaling the completion of
    82  * a DMA command is received by a core. It acknowledge the IRQ by accessing the proper
    83  * SOCLIB_DMA register, unblock the client thread, and unblock the server thread that
    84  * can starts execution of a new command if the waiting queue is not emppty.
     86 * an asynchronous DMA command is received by a core. It acknowledge the IRQ by accessing
     87 * the proper SOCLIB_DMA register, reports the transfer status in the command registered
     88 * in the client thread descriptor, and unblock the server thread.
    8589 ********************************************************************************************
    8690 * @ chdev     : pointer on DMA chdev descriptor.
  • trunk/hal/tsar_mips32/drivers/soclib_fbf.c

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

    r654 r657  
    22 * soclib_mmc.c - soclib L2 cache driver implementation.
    33 *
    4  * Author     Alain Greiner (2016,2017,2018,2019)
     4 * Author     Alain Greiner (2016,2017,2018,2019,2020)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    1818 *
    1919 * You should have received a copy of the GNU General Public License
    20  * along with ALMOS-MKH.; if not, write to the Free Software Foundation,
     20 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
    2121 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
    2222 */
    23 
    2423
    2524#include <hal_kernel_types.h>
     
    2928#include <thread.h>
    3029#include <printk.h>
    31 
    3230
    3331///////////////////////////////////////
     
    4442    *(base + (SOCLIB_MMC_ERROR_FUNC << 7) + SOCLIB_MMC_ERROR_IRQ_ENABLE) = 1;
    4543}
    46 
    4744
    4845//////////////////////////////////////////////////////////////
     
    8582
    8683        // set SOCLIB_MMC registers to start INVAL/SYNC operation
    87         hal_remote_s32( XPTR( seg_cxy , seg_ptr + SOCLIB_MMC_ADDR_LO    ) , (uint32_t)buf_ptr );
    88         hal_remote_s32( XPTR( seg_cxy , seg_ptr + SOCLIB_MMC_ADDR_HI    ) , (uint32_t)dev_cxy );
    89         hal_remote_s32( XPTR( seg_cxy , seg_ptr + SOCLIB_MMC_BUF_LENGTH ) , buf_size );
    90         hal_remote_s32( XPTR( seg_cxy , seg_ptr + SOCLIB_MMC_CMD_TYPE   ) , cc_cmd );
     84        hal_remote_s32( XPTR( seg_cxy , seg_ptr +
     85        MMC_REG( SOCLIB_MMC_CC_FUNC , SOCLIB_MMC_ADDR_LO) ) , (uint32_t)buf_ptr );
     86
     87        hal_remote_s32( XPTR( seg_cxy , seg_ptr +
     88        MMC_REG( SOCLIB_MMC_CC_FUNC , SOCLIB_MMC_ADDR_HI) ) , dev_cxy );
     89
     90        hal_remote_s32( XPTR( seg_cxy , seg_ptr +
     91        MMC_REG( SOCLIB_MMC_CC_FUNC , SOCLIB_MMC_BUF_LENGTH) ) , buf_size );
     92
     93        hal_remote_s32( XPTR( seg_cxy , seg_ptr +
     94        MMC_REG( SOCLIB_MMC_CC_FUNC , SOCLIB_MMC_CMD_TYPE) ) , cc_cmd );
    9195    }
    92     else  // (type == MMC_GET_ERROR) or (type == MMC_GET_ERROR) pr (type == MMC_GET_INSTRU )
     96    else if( (type == MMC_ERROR_GET) || (type == MMC_ERROR_SET) )
    9397    {
    9498        // get src/dst buffer local pointer and register index
    9599        reg_ptr   = (uint32_t *)hal_remote_lpt( XPTR( th_cxy , &th_ptr->mmc_cmd.reg_ptr ) );
    96         reg_index = hal_remote_l32( XPTR( th_cxy , &th_ptr->mmc_cmd.reg_index ) );
     100        reg_index =             hal_remote_l32( XPTR( th_cxy , &th_ptr->mmc_cmd.reg_index ) );
    97101
    98         // move register to/from local buffer
    99         if( (type == MMC_GET_ERROR) || (type == MMC_GET_INSTRU) )
    100         {
    101             *reg_ptr =  hal_remote_l32( XPTR( seg_cxy , seg_ptr + reg_index ) );
    102         }
    103         else  // type == MMC_SET_ERROR
    104         {
    105             hal_remote_s32( XPTR( seg_cxy , seg_ptr + reg_index ) , *reg_ptr );
    106         }
     102        // build extended pointer on relevant MMC register
     103        xptr_t mmc_reg_xp = XPTR( seg_cxy , seg_ptr +
     104                                  MMC_REG( SOCLIB_MMC_ERROR_FUNC , reg_index ) );
     105
     106        // move MMC register to/from local buffer
     107        if( type == MMC_ERROR_GET ) *reg_ptr = hal_remote_l32( mmc_reg_xp );
     108        else                        hal_remote_s32( mmc_reg_xp , *reg_ptr );
    107109    }
     110    else  // type == MMC_INSTRU_GET
     111    {
     112        // get dst buffer local pointer and register index
     113        reg_ptr   = (uint32_t *)hal_remote_lpt( XPTR( th_cxy , &th_ptr->mmc_cmd.reg_ptr ) );
     114        reg_index =             hal_remote_l32( XPTR( th_cxy , &th_ptr->mmc_cmd.reg_index ) );
     115
     116        // build extended pointer on relevant MMC register
     117        xptr_t mmc_reg_xp = XPTR( seg_cxy , seg_ptr +
     118                                  MMC_REG( SOCLIB_MMC_INSTR_FUNC , reg_index ) );
     119
     120        // move MMC register to local buffer 
     121        *reg_ptr = hal_remote_l32( mmc_reg_xp );
     122    }
     123
    108124} // end soclib_mmc_cmd()
    109125
     
    121137
    122138    // print an error message on kernel terminal
    123     printk("\n[ERROR] reported from MMC : cxy %x / cycle %d / bad address [%x,%x] / srcid %x\n",
    124     local_cxy , (uint32_t)hal_get_cycles() , paddr_hi , paddr_lo , srcid );
     139    printk("\n[ERROR] reported from MMC : bad address [%x,%x] / srcid %x / cycle %d\n",
     140    paddr_hi , paddr_lo , srcid , (uint32_t)hal_get_cycles() );
    125141
    126142    // reset MMC IRQ
     
    128144   
    129145} // end soclib_mmc_isr()
    130 
    131 
    132 
  • trunk/hal/tsar_mips32/drivers/soclib_mmc.h

    r626 r657  
    22 * soclib_mmc.h - TSAR L2 cache driver definition.
    33 *
    4  * Author    Alain Greiner (2016,2017,2018,2019)
     4 * Author    Alain Greiner (2016,2017,2018,2019),2020)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    4949};
    5050
     51enum SoclibMemCacheConfigCmd
     52{
     53    SOCLIB_MMC_CC_NOP     = 0,
     54    SOCLIB_MMC_CC_INVAL   = 1,
     55    SOCLIB_MMC_CC_SYNC    = 2,
     56};
     57
     58// CONFIG Registers indexes
    5159enum SoclibMemCacheCCRegs
    5260{
     
    5765};
    5866
    59 enum SoclibMemCacheConfigCmd
    60 {
    61     SOCLIB_MMC_CC_NOP     = 0,
    62     SOCLIB_MMC_CC_INVAL   = 1,
    63     SOCLIB_MMC_CC_SYNC    = 2,
    64 };
    65 
     67// INSTRU Registers indexes
    6668enum SoclibMemCacheInstrRegs
    6769{
     
    143145};
    144146
     147// ERROR registers indexes
    145148enum SoclibMemCacheRerrorRegs
    146149{
     
    157160
    158161/********************************************************************************************
    159  * This function initializes the SOCLIB_MMC peripheral hardware registers related
    160  * to error signaling. It enables the MMC peripheral IRQ.
     162 * This function initializes the SOCLIB_MMC peripheral hardware registers.
     163 * It enables the MMC peripheral IRQ.
    161164 ********************************************************************************************
    162165 * @ chdev      : local pointer on the MMC chdev descriptor.
     
    175178/********************************************************************************************
    176179 * This Interrupt Service Routine is executed when the MMC IRQ signals a faulty address.
    177  * The ISR should access the vci_mem_cache component to get the faulty physical address
     180 * The ISR should access the relevant MMC register to get the faulty physical address
    178181 * and the associated SRCID, and acknowledges the IRQ.
    179182 ********************************************************************************************
  • trunk/hal/tsar_mips32/drivers/soclib_nic.c

    r635 r657  
    22 * soclib_nic.c - SOCLIB_NIC (Network Interface Controler) driver implementation.
    33 *
    4  * Author     Alain Greiner (2016,2017,2018,2019)
     4 * Author     Alain Greiner (2016,2017,2018,2019,2020:)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    9393void __attribute__ ((noinline)) soclib_nic_cmd( xptr_t thread_xp )
    9494{
    95     uint32_t       cmd;          // command type   
     95    uint32_t       type;         // command type   
    9696    char         * buffer;       // pointer on command buffer   
    9797    uint32_t       length;       // Ethernet packet length
     
    109109
    110110    // get command arguments
    111     cmd    = thread_ptr->nic_cmd.cmd;
     111    type   = thread_ptr->nic_cmd.type;
    112112    buffer = thread_ptr->nic_cmd.buffer;
    113113    length = thread_ptr->nic_cmd.length;
     
    121121
    122122    // analyse command type
    123     switch( cmd )
     123    switch( type )
    124124    {
    125125        /////////////////////////////////////////////////////////////////////////////
     
    274274        break;  // end READABLE
    275275        default: {
    276             assert( false, "Unknown command <%x>\n", cmd );
     276            assert( false, "Unknown command <%x>\n", type );
    277277        }
    278278    }
Note: See TracChangeset for help on using the changeset viewer.