Changeset 518


Ignore:
Timestamp:
Mar 10, 2015, 2:58:59 PM (9 years ago)
Author:
alain
Message:

Redefinition of the driver for the vci_mwmr_dma component.

Location:
soft/giet_vm/giet_drivers
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/giet_drivers/dma_driver.h

    r437 r518  
    1 ///////////////////////////////////////////////////////////////////////////////////
     1//////////////////////////////////////////////////////////////////////////////////
    22// File     : dma_driver.h
    33// Date     : 01/11/2013
    44// Author   : alain greiner
    55// Copyright (c) UPMC-LIP6
    6 ///////////////////////////////////////////////////////////////////////////////////
     6//////////////////////////////////////////////////////////////////////////////////
    77// The dma_driver.c and dma_driver.h files are part ot the GIET-VM nano-kernel.
    88// This driver supports the SoCLib vci_multi_dma component.
     
    2424//
    2525// The SEG_DMA_BASE virtual address mus be defined in the hard_config.h file.
    26 ////////////////////////////////////////////////////////////////////////////////////
     26//////////////////////////////////////////////////////////////////////////////////
    2727
    2828#ifndef _GIET_DMA_DRIVER_H_
    2929#define _GIET_DMA_DRIVER_H_
    3030
    31 ///////////////////////////////////////////////////////////////////////////////////
     31//////////////////////////////////////////////////////////////////////////////////
    3232// Multi DMA registers offset
    33 ///////////////////////////////////////////////////////////////////////////////////
     33//////////////////////////////////////////////////////////////////////////////////
    3434
    3535enum DMA_registers
     
    5757
    5858
    59 ///////////////////////////////////////////////////////////////////////////////
     59//////////////////////////////////////////////////////////////////////////////////
    6060//                  low-level access functions 
    61 ///////////////////////////////////////////////////////////////////////////////
     61//////////////////////////////////////////////////////////////////////////////////
    6262
    6363//////////////////////////////////////////////////////////////////////////////////
     
    9898//////////////////////////////////////////////////////////////////////////////////
    9999
    100 ///////////////////////////////////////////////////////////////////////////////////
     100//////////////////////////////////////////////////////////////////////////////////
    101101// This function copies a source memory buffer to a destination memory buffer,
    102102// using directly physical addresses.
     
    108108// In case of error (buffer unmapped, unaligned, or DMA_STATUS error), an error
    109109// message is displayed on TTY0, and system crash.
    110 ///////////////////////////////////////////////////////////////////////////////////
     110//////////////////////////////////////////////////////////////////////////////////
    111111extern void _dma_physical_copy( unsigned int       cluster_xy,
    112112                                unsigned int       channel_id,
     
    115115                                unsigned int       size );
    116116
    117 ///////////////////////////////////////////////////////////////////////////////////
     117//////////////////////////////////////////////////////////////////////////////////
    118118// This function copies a source memory buffer to a destination memory buffer,
    119119// making virtual to physical address translation: the MMU should be activated.
     
    125125// In case of error (buffer unmapped, unaligned, or DMA_STATUS error), an error
    126126// message is displayed on TTY0, and system crash.
    127 ///////////////////////////////////////////////////////////////////////////////////
     127//////////////////////////////////////////////////////////////////////////////////
    128128extern void _dma_copy(  unsigned int cluster_xy,
    129129                        unsigned int channel_id,
     
    133133                        unsigned int size );
    134134
    135 ///////////////////////////////////////////////////////////////////////////////
     135//////////////////////////////////////////////////////////////////////////////////
    136136// This ISR should not be used by the GIET_VM, because the DMA is only
    137137// used by the kernel in the boot phase, with a polling strategy.
    138 ///////////////////////////////////////////////////////////////////////////////
     138//////////////////////////////////////////////////////////////////////////////////
    139139extern void _dma_isr( unsigned int irq_type,
    140140                      unsigned int irq_id,
  • soft/giet_vm/giet_drivers/mwr_driver.c

    r456 r518  
    11///////////////////////////////////////////////////////////////////////////////////
    22// File     : mwr_driver.c
    3 // Date     : 23/05/2013
     3// Date     : 27/02/2015
    44// Author   : alain greiner
    55// Copyright (c) UPMC-LIP6
    66///////////////////////////////////////////////////////////////////////////////////
    7 // The mwmr_driver.c and mwmr_driver.h files are part ot the GIET-VM nano-kernel.
    8 // This driver supports the SoClib vci_mwmr_controller component.
    9 //
    10 // This peripheral can be replicated (at most one component per cluster).
    11 //
    12 // The (virtual) base address of the associated segment is:
    13 //       SEG_MWR_BASE + cluster_xy * PERI_CLUSTER_INCREMENT
    14 //
    15 // SEG_MWR_BASE and PERI_CLUSTER_INCREMENT must be defined in hard_config.h
    16 ////////////////////////////////////////////////////////////////////////////////
    177
    188#include <giet_config.h>
    199#include <hard_config.h>
     10#include <mapping_info.h>
    2011#include <mwr_driver.h>
    2112#include <utils.h>
    2213#include <tty0.h>
     14#include <io.h>
    2315
    2416#if !defined(X_SIZE)
     
    4638#endif
    4739
    48 //////////////////////////////////////////////////////////////////////////////////
    49 //    _mwr_hw_init()
    50 // This function initializes one MWMR controller channel (i.e. one coprocessor
    51 // port) in a given cluster.
    52 // - cluster_xy    : cluster index
    53 // _ port_id       : port index
    54 // - way           : direction (to_coproc/from_coproc)
    55 // - channel_pbase : physical base address of the MWMR channel
    56 // TODO : The MWMR controler should be modified to support 40 bits addresses...
    57 //        Introduce a MWMR_CONFIG_PADDR_EXT register in the MWMR coprocessor
    58 //////////////////////////////////////////////////////////////////////////////////
    59 // Returns 0 if success, returns > 0 if error.
    60 //////////////////////////////////////////////////////////////////////////////////
    61 unsigned int _mwr_hw_init( unsigned int           cluster_xy,
    62                            unsigned int           port_id,
    63                            unsigned int           from_coproc,
    64                            paddr_t                channel_pbase )
     40extern unsigned int _coproc_done[X_SIZE*Y_SIZE];
     41
     42/////////////////////////////////////////////////////////////////////////////
     43// This function returns the value contained in a private register
     44// of the coprocessor contained in cluster "cluster_xy".
     45/////////////////////////////////////////////////////////////////////////////
     46unsigned int _mwr_get_coproc_register( unsigned int cluster_xy, // cluster
     47                                       unsigned int index )     // register
    6548{
    66     _puts(" [GIET_ERROR] _mwr_hw_init() function not supported yet\n");
    67     _exit();
     49    unsigned int vaddr =
     50        SEG_MWR_BASE +
     51        (cluster_xy * PERI_CLUSTER_INCREMENT) +
     52        (index << 2);
    6853
    69 /*
    70     // parameters checking
    71     unsigned int x = cluster_xy >> Y_WIDTH;
    72     unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
    73     if (x >= X_SIZE)                    return 1;
    74     if (y >= Y_SIZE)                    return 1;
     54    return ioread32( (void*)vaddr );
     55}
    7556
    76     // compute base address
    77     unsigned int* mwr_address = (unsigned int*) ( SEG_MWR_BASE +
    78                                  (cluster_xy * PERI_CLUSTER_INCREMENT) );
     57/////////////////////////////////////////////////////////////////////////////
     58// This function sets a new value in a private register
     59// of the coprocessor contained in cluster "clustenr_xy".
     60/////////////////////////////////////////////////////////////////////////////
     61void _mwr_set_coproc_register( unsigned int cluster_xy,   // cluster index
     62                               unsigned int index,        // register index
     63                               unsigned int value )       // writte value
     64{
     65    unsigned int vaddr =
     66        SEG_MWR_BASE +
     67        (cluster_xy * PERI_CLUSTER_INCREMENT) +
     68        (index << 2);
     69       
     70    iowrite32( (void*)vaddr, value );
     71}
    7972
    80     unsigned int lsb = (unsigned int)channel_pbase;
    81     unsigned int msb = (unsigned int)(channel_pbase>>32);
     73/////////////////////////////////////////////////////////////////////////////
     74// This function returns the value contained in a channel register
     75// defined by the "index" and "channel" arguments, in the MWMR_DMA component
     76// contained in cluster "cluster_xy".
     77/////////////////////////////////////////////////////////////////////////////
     78unsigned int _mwr_get_channel_register( unsigned int cluster_xy, // cluster
     79                                        unsigned int channel,    // channel
     80                                        unsigned int index )     // register
     81{
     82    unsigned int vaddr =
     83        SEG_MWR_BASE +
     84        (cluster_xy * PERI_CLUSTER_INCREMENT) +
     85        ((channel + 1) * (CHANNEL_SPAN << 2)) +
     86        (index << 2);
    8287
    83     // get depth and width from channel itself
    84     unsigned int depth = _physical_read( channel_pbase + 16 );
    85     unsigned int width = _physical_read( channel_pbase + 20 );
     88    return ioread32( (void*)vaddr );
     89}
    8690
    87     // initializes and launches mwmr controler
    88     mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_FIFO_WAY]  = from_coproc;
    89     mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_FIFO_NO]   = port_id;
    90     mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_WIDTH]     = width;
    91     mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_DEPTH]     = depth;
    92     mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_STATUS]    = lsb;
    93     mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_DATA]      = lsb + 24;
    94     mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_EXT]       = msb;
    95     mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_RUNNING]   = 1;
    96 */
    97     return 0;
     91/////////////////////////////////////////////////////////////////////////////
     92// This function sets a new value in a channel register
     93// defined by the "index" and "channel") arguments, in the MWMR_DMA component
     94// contained in cluster "cluster_xy".
     95/////////////////////////////////////////////////////////////////////////////
     96void _mwr_set_channel_register( unsigned int cluster_xy,  // cluster index
     97                                unsigned int channel,     // channel index
     98                                unsigned int index,       // register index
     99                                unsigned int value )      // written value
     100{
     101    unsigned int vaddr =
     102        SEG_MWR_BASE +
     103        (cluster_xy * PERI_CLUSTER_INCREMENT) +
     104        ((channel + 1) * (CHANNEL_SPAN << 2)) +
     105        (index << 2);
     106       
     107    iowrite32( (void*)vaddr, value );
    98108}
     109
     110///////////////////////////////////////////////////////
     111void _mwr_isr( unsigned int irq_type,  // should be HWI
     112               unsigned int irq_id,    // index returned by XCU
     113               unsigned int channel )  // MWMR_DMA channel
     114{
     115    unsigned int gpid       = _get_procid();
     116    unsigned int cluster_xy = gpid >> P_WIDTH;
     117    unsigned int x          = cluster_xy >> Y_WIDTH;
     118    unsigned int y          = cluster_xy & ((1<<Y_WIDTH)-1);
     119
     120    // acknowledge IRQ
     121    _mwr_set_channel_register( cluster_xy, channel, CHANNEL_RUNNING, 0 );
     122
     123    // compute coproc_id from cluster coordinates
     124    unsigned int coproc_id = x * Y_SIZE + y;
     125
     126    // set synchronisation variable
     127    _coproc_done[coproc_id] = 1;
     128}
     129
    99130
    100131
  • soft/giet_vm/giet_drivers/mwr_driver.h

    r263 r518  
    44// Author   : alain greiner
    55// Copyright (c) UPMC-LIP6
    6 ///////////////////////////////////////////////////////////////////////////////////
     6///////////////////////////////////////////////////////////////////////////////
     7// The mwr_driver.c and mwr_driver.h files are part ot the GIET-VM OS.
     8// This driver supports the SoCLib vci_mwmr_dma component.
     9//
     10// It can exist several MWMR_DMA controlers in the architecture
     11// (one per cluster), and each controller can contain several ports.
     12// Each port defines a TO_COPROC or FROM_COPROC communication channel.
     13// Each channel can be configured to run in one of three predefined modes
     14// (MWMR / DMA_IRQ / DMA_NO_IRQ).
     15// The MWMR_DMA controler is a private ressource, allocated to a given task.
     16//
     17// The virtual base address of the segment associated to the coprocessor
     18// addressable registers is:
     19//   SEG_MWR_BASE + cluster_xy*PERI_CLUSTER_INCREMENT
     20//
     21// The virtual base address of the segments associated to a channel is:
     22//   SEG_MWR_BASE +
     23//   cluster_xy * PERI_CLUSTER_INCREMENT +
     24//   4 * CHANNEL_SPAN * (channel+1)
     25//
     26// The SEG_MWR_BASE virtual address mus be defined in the hard_config.h file.
     27///////////////////////////////////////////////////////////////////////////////
    728
    829#ifndef _GIET_MWR_DRIVERS_H_
    930#define _GIET_MWR_DRIVERS_H_
    1031
    11 ///////////////////////////////////////////////////////////////////////////////////
     32///////////////////////////////////////////////////////////////////////////////
    1233// MWMR controler registers offsets
    13 ///////////////////////////////////////////////////////////////////////////////////
     34///////////////////////////////////////////////////////////////////////////////
    1435
    15 enum SoclibMwmrRegisters
     36enum MwmrDmaRegisters
    1637{
    17     MWMR_IOREG_MAX = 16,
    18     MWMR_RESET = MWMR_IOREG_MAX,
    19     MWMR_CONFIG_FIFO_WAY,
    20     MWMR_CONFIG_FIFO_NO,
    21     MWMR_CONFIG_STATUS,
    22     MWMR_CONFIG_DEPTH,
    23     MWMR_CONFIG_BUFFER_ADDR,
    24     MWMR_CONFIG_RUNNING,
    25     MWMR_CONFIG_WIDTH,
    26     MWMR_CONFIG_DATA,
    27     MWMR_CONFIG_EXT,
    28     /***/
    29     MWMR_SPAN,
     38    CHANNEL_BUFFER_LSB   = 0,     // Data buffer paddr 32 LSB bits
     39    CHANNEL_BUFFER_MSB   = 1,     // Data buffer paddr extension
     40    CHANNEL_MWMR_LSB     = 2,     // MWMR descriptor paddr 32 LSB bits
     41    CHANNEL_MWMR_MSB     = 3,     // MWMR descriptor paddr extension
     42    CHANNEL_LOCK_LSB     = 4,     // MWMR lock paddr 32 LSB bits
     43    CHANNEL_LOCK_MSB     = 5,     // MWMR lock paddr extension
     44    CHANNEL_WAY          = 6,     // TO_COPROC / FROMCOPROC         (Read-only)
     45    CHANNEL_MODE         = 7,     // MWMR / DMA / DMA_IRQ
     46    CHANNEL_SIZE         = 8,     // Data Buffer size (bytes)
     47    CHANNEL_RUNNING      = 9,     // channel running   
     48    CHANNEL_STATUS       = 10,    // channel FSM state              (Read-Only)
     49    CHANNEL_INFO         = 11,    // STS | CFG | FROM | TO          (Read-Only)
     50    //
     51    CHANNEL_SPAN         = 16,
    3052};
    3153
    32 enum SoclibMwmrWay
    33 {
    34     MWMR_TO_COPROC,
    35     MWMR_FROM_COPROC,
    36 };
     54///////////////////////////////////////////////////////////////////////////////
     55//           Low-level access functions
     56///////////////////////////////////////////////////////////////////////////////
    3757
    38 ///////////////////////////////////////////////////////////////////////////////////
    39 // MWMR controller access functions
    40 ///////////////////////////////////////////////////////////////////////////////////
     58extern void _mwr_set_channel_register( unsigned int cluster_xy,
     59                                       unsigned int channel,
     60                                       unsigned int index,
     61                                       unsigned int value );
    4162
    42 extern unsigned int _mwr_hw_init( unsigned int           cluster_xy,
    43                                   unsigned int           port_id,
    44                                   unsigned int           from_coproc,
    45                                   unsigned long long     channel_pbase);
     63extern unsigned int _mwr_get_channel_register( unsigned int cluster_xy,
     64                                               unsigned int channel,
     65                                               unsigned int index );
    4666
    47 ///////////////////////////////////////////////////////////////////////////////////
     67extern void _mwr_set_coproc_register( unsigned int cluster_xy,
     68                                      unsigned int index,
     69                                      unsigned int value );
    4870
     71extern unsigned int _mwr_get_coproc_register( unsigned int cluster_xy,
     72                                              unsigned int index );
    4973
     74///////////////////////////////////////////////////////////////////////////////
     75//            Interrupt Service Routine
     76///////////////////////////////////////////////////////////////////////////////
     77
     78extern void _mwr_isr( unsigned int irq_type,
     79                      unsigned int irq_id,
     80                      unsigned int channel );
    5081#endif
    5182
Note: See TracChangeset for help on using the changeset viewer.