Ignore:
Timestamp:
Dec 19, 2013, 9:36:48 AM (11 years ago)
Author:
alain
Message:

Introducing support for TSAR fixed format cluster index (cluster_xy)
We have now 4 parameters defined in map.xml:

  • X_WIDTH, Y_WIDTH define the fixed format (typically X_WIDTH = 4 / Y_WIDTH = 4)
  • X_SIZE, Y_SIZE define the actual TSAR 2D mesh variable size (from 1 to 16)
Location:
soft/giet_vm/giet_drivers
Files:
13 edited

Legend:

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

    r258 r263  
    1212//
    1313// There is  (NB_CLUSTERS * NB_DMA_CHANNELS) channels, indexed by a global index:
    14 //        dma_id = cluster_id * NB_DMA_CHANNELS + loc_id
     14//        dma_id = cluster_xy * NB_DMA_CHANNELS + loc_id
    1515//
    1616// A DMA channel is a private ressource allocated to a given processor.
     
    2222// The virtual base address of the segment associated to a channel is:
    2323//
    24 //    seg_dma_base + cluster_id * vseg_cluster_increment + DMA_SPAN * channel_id
     24//    seg_dma_base + cluster_xy * vseg_cluster_increment + DMA_SPAN * channel_id
    2525//
    2626////////////////////////////////////////////////////////////////////////////////////
     
    3232#include <vmem.h>
    3333
    34 #if !defined(NB_CLUSTERS)
    35 # error: You must define NB_CLUSTERS in the hard_config.h file
    36 #endif
    37 
    38 #if (NB_CLUSTERS > 256)
    39 # error: NB_CLUSTERS cannot be larger than 256!
    40 #endif
    41 
    42 #if !defined(NB_PROCS_MAX)
    43 # error: You must define NB_PROCS_MAX in the hard_config.h file
    44 #endif
    45 
    46 #if (NB_PROCS_MAX > 8)
    47 # error: NB_PROCS_MAX cannot be larger than 8!
    48 #endif
    49 
    50 #if (NB_DMA_CHANNELS > 8)
    51 # error: NB_DMA_CHANNELS cannot be larger than 8!
     34#if !defined(X_SIZE)
     35# error: You must define X_SIZE in the hard_config.h file
     36#endif
     37
     38#if !defined(Y_SIZE)
     39# error: You must define X_SIZE in the hard_config.h file
     40#endif
     41
     42#if !defined(X_WIDTH)
     43# error: You must define X_WIDTH in the hard_config.h file
     44#endif
     45
     46#if !defined(Y_WIDTH)
     47# error: You must define X_WIDTH in the hard_config.h file
     48#endif
     49
     50#if !defined(NB_DMA_CHANNELS)
     51# error: You must define NB_DMA_CHANNELS in the hard_config.h file
    5252#endif
    5353
     
    6060// Returns 0 if success, returns > 0 if error.
    6161//////////////////////////////////////////////////////////////////////////////////
    62 unsigned int _dma_init( unsigned int cluster_id,
     62unsigned int _dma_init( unsigned int cluster_xy,
    6363                        unsigned int channel_id )
    6464{
    6565#if NB_DMA_CHANNELS > 0
     66
    6667    // parameters checking
    67     if (cluster_id >= NB_CLUSTERS)      return 1;
     68    unsigned int x = cluster_xy >> Y_WIDTH;
     69    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
     70    if (x >= X_SIZE)                    return 1;
     71    if (y >= Y_SIZE)                    return 1;
    6872    if (channel_id >= NB_DMA_CHANNELS)  return 1;
    6973
    7074    // compute DMA base address
    7175    unsigned int* dma_address = (unsigned int*) ((unsigned int)&seg_dma_base +
    72                                 (cluster_id * (unsigned int)&vseg_cluster_increment));
     76                                (cluster_xy * (unsigned int)&vseg_cluster_increment));
    7377
    7478    // disable interrupt for selected channel
     
    8488// completion. It actually forces the channel to return in iDLE state.
    8589//////////////////////////////////////////////////////////////////////////////////
    86 unsigned int _dma_reset( unsigned int cluster_id,
     90unsigned int _dma_reset( unsigned int cluster_xy,
    8791                         unsigned int channel_id )
    8892{
    8993#if NB_DMA_CHANNELS > 0
     94
    9095    // parameters checking
    91     if (cluster_id >= NB_CLUSTERS)      return 1;
     96    unsigned int x = cluster_xy >> Y_WIDTH;
     97    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
     98    if (x >= X_SIZE)                    return 1;
     99    if (y >= Y_SIZE)                    return 1;
    92100    if (channel_id >= NB_DMA_CHANNELS)  return 1;
    93101
    94102    // compute DMA base address
    95103    unsigned int* dma_address = (unsigned int*) ((unsigned int)&seg_dma_base +
    96                                 (cluster_id * (unsigned int)&vseg_cluster_increment));
     104                                (cluster_xy * (unsigned int)&vseg_cluster_increment));
    97105
    98106    // reset selected channel
     
    107115// This function returns the status of a DMA channel in a given cluster
    108116//////////////////////////////////////////////////////////////////////////////////
    109 unsigned int _dma_get_status( unsigned int cluster_id,
     117unsigned int _dma_get_status( unsigned int cluster_xy,
    110118                              unsigned int channel_id )
    111119{
    112120#if NB_DMA_CHANNELS > 0
     121
    113122    // parameters checking
    114     if (cluster_id >= NB_CLUSTERS)      return 1;
     123    unsigned int x = cluster_xy >> Y_WIDTH;
     124    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
     125    if (x >= X_SIZE)                    return 1;
     126    if (y >= Y_SIZE)                    return 1;
    115127    if (channel_id >= NB_DMA_CHANNELS)  return 1;
    116128
    117129    // compute DMA base address
    118130    unsigned int * dma_address = (unsigned int *) ((unsigned int)&seg_dma_base +
    119                                  (cluster_id * (unsigned int)&vseg_cluster_increment));
     131                                 (cluster_xy * (unsigned int)&vseg_cluster_increment));
    120132
    121133    // get selected channel status
     
    131143// and sets the transfer size to lauch the transfer.
    132144//////////////////////////////////////////////////////////////////////////////////
    133 unsigned int _dma_start_transfer( unsigned int       cluster_id,
     145unsigned int _dma_start_transfer( unsigned int       cluster_xy,
    134146                                  unsigned int       channel_id,
    135147                                  unsigned long long dst_paddr,   // physical address
     
    138150{
    139151#if NB_DMA_CHANNELS > 0
     152
    140153    // parameters checking
    141     if (cluster_id >= NB_CLUSTERS)      return 1;
     154    unsigned int x = cluster_xy >> Y_WIDTH;
     155    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
     156    if (x >= X_SIZE)                    return 1;
     157    if (y >= Y_SIZE)                    return 1;
    142158    if (channel_id >= NB_DMA_CHANNELS)  return 1;
    143159
    144160    // compute DMA base address
    145161    unsigned int * dma_address = (unsigned int *) ((unsigned int)&seg_dma_base +
    146                                  (cluster_id * (unsigned int)&vseg_cluster_increment));
     162                                 (cluster_xy * (unsigned int)&vseg_cluster_increment));
    147163
    148164    // selected channel configuration and lauching
     
    179195
    180196    unsigned int procid    = _get_procid();
    181     unsigned int cluster_id = procid/NB_PROCS_MAX;
     197    unsigned int cluster_xy = procid/NB_PROCS_MAX;
    182198    unsigned int channel_id = procid%NB_PROCS_MAX;
    183199
     
    192208_puts("\n - vspace_id  = ");
    193209_putx( vspace_id );
    194 _puts("\n - cluster_id = ");
    195 _putx( cluster_id );
     210_puts("\n - cluster_xy = ");
     211_putx( cluster_xy );
    196212_puts("\n - channel_id = ");
    197213_putx( channel_id );
     
    263279
    264280    // dma channel configuration & lauching
    265     ko = _dma_start_transfer(  cluster_id, channel_id, dst_paddr, src_paddr, size );
     281    ko = _dma_start_transfer(  cluster_xy, channel_id, dst_paddr, src_paddr, size );
    266282    if ( ko )
    267283    {
     
    273289
    274290    // scan dma channel status
    275     unsigned int status = _dma_get_status( cluster_id, channel_id );
     291    unsigned int status = _dma_get_status( cluster_xy, channel_id );
    276292    while( (status != DMA_SUCCESS) &&
    277293           (status != DMA_READ_ERROR) &&
    278294           (status != DMA_WRITE_ERROR) )
    279295    {
    280         status = _dma_get_status( cluster_id, channel_id );
     296        status = _dma_get_status( cluster_xy, channel_id );
    281297
    282298#if GIET_DEBUG_DMA_DRIVER
     
    299315    }
    300316    // reset dma channel
    301     _dma_reset( cluster_id, channel_id );
     317    _dma_reset( cluster_xy, channel_id );
    302318
    303319#if GIET_DEBUG_DMA_DRIVER
  • soft/giet_vm/giet_drivers/dma_driver.h

    r258 r263  
    4242
    4343// low level access functions
    44 extern unsigned int _dma_init( unsigned int cluster_id,
     44extern unsigned int _dma_init( unsigned int cluster_xy,
    4545                               unsigned int channel_id );
    4646
    47 extern unsigned int _dma_reset( unsigned int  cluster_id,
     47extern unsigned int _dma_reset( unsigned int  cluster_xy,
    4848                                unsigned int  channel_id );
    4949
    50 extern unsigned int _dma_get_status( unsigned int  cluster_id,
     50extern unsigned int _dma_get_status( unsigned int  cluster_xy,
    5151                                     unsigned int  channel_id );
    5252
    53 extern unsigned int _dma_start_transfer( unsigned int       cluster_id,
     53extern unsigned int _dma_start_transfer( unsigned int       cluster_xy,
    5454                                         unsigned int       channel_id,
    5555                                         unsigned long long dst_paddr,
  • soft/giet_vm/giet_drivers/fbf_driver.c

    r258 r263  
    9696} fb_cma_channel_t;
    9797
     98// array of FB_CMA channels descriptors (32 bytes per entry)
     99// each entry contains one SRC and one DST chbuf descriptors.
    98100in_unckdata volatile fb_cma_channel_t
    99101_fb_cma_channel[NB_CMA_CHANNELS] __attribute__((aligned(64)));
    100102
     103// array of physical addresses for the FB_CMA channels descriptors
    101104in_unckdata volatile paddr_t         
    102105_fb_cma_desc_paddr[NB_CMA_CHANNELS];
     
    105108// _fb_cma_init()
    106109// This function uses the _fb_cma_channel[] and _fb_cma_desc_paddr[] arrays,
    107 // that are both indexed by the channel index.
    108 // where each entry contains one fb_cma_channel structure (defining two
    109 // SRC and DST chbuf descriptors), and does four things:
     110// (that are both indexed by the channel index), and does four things:
    110111//
    111112// 1) computes the physical addresses for the two source user buffers, for
    112113//    the destination frame buffer. It initialises the channel descriptor
    113114//    _fb_cma_channel[i], containing the SRC chbuf descriptor (two buffers),
    114 //    the DST chbuf descriptor (one single frame buffer), and the buffer length.
     115//    the DST chbuf descriptor (one single buffer), and the buffer length.
    115116//
    116117// 2) computes the physical address for the channel descriptor and register it
     
    138139    unsigned int  flags;               // protection flags
    139140    unsigned int  ppn;                 // physical page number
    140     paddr_t       channel_pbase;       // physical address of channel descriptor
     141    paddr_t       desc_paddr;          // physical address of channel descriptor
    141142
    142143    // get CMA channel index
     
    255256        return 1;
    256257    }
    257     channel_pbase = (((paddr_t)ppn) << 12) | (vaddr & 0x00000FFF);
    258     _fb_cma_desc_paddr[channel_id] = channel_pbase;
    259 
    260 #if GIET_DEBUG_CMA_DRIVER
     258    _fb_cma_desc_paddr[channel_id] = (((paddr_t)ppn) << 12) | (vaddr & 0x00000FFF);
     259
     260    desc_paddr                     = (((paddr_t)ppn) << 12) | (vaddr & 0x00000FFF);
     261   
     262
     263#if GIET_DEBUG_FBF_DRIVER
     264_tty_get_lock( 0 );
     265_puts("\n[CMA DEBUG] fb_cma_init()");
     266_puts("\n - fbf       pbase = ");
     267_putl( _fb_cma_channel[channel_id].fbf );
     268_puts("\n - buf0      pbase = ");
     269_putl( _fb_cma_channel[channel_id].buf0 );
     270_puts("\n - buf1      pbase = ");
     271_putl( _fb_cma_channel[channel_id].buf1 );
     272_puts("\n - channel   pbase = ");
     273_putl( _fb_cma_desc_paddr[channel_id] );
    261274_puts("\n");
    262 _puts("- fbf       pbase = ");
    263 _putl( _fb_cma_channel[channel_id].fbf );
    264 _puts("\n");
    265 _puts("- buf0      pbase = ");
    266 _putl( _fb_cma_channel[channel_id].buf0 );
    267 _puts("\n");
    268 _puts("- buf1      pbase = ");
    269 _putl( _fb_cma_channel[channel_id].buf1 );
    270 _puts("\n");
    271 _puts("- channel   pbase = ");
    272 _putl( channel_pbase );
    273 _puts("\n");
     275_tty_release_lock( 0 );
    274276#endif
    275277
    276278    // SYNC request for channel descriptor
    277     _memc_sync( channel_pbase, 32 );
     279    _memc_sync( desc_paddr, 32 );
    278280
    279281    // CMA channel activation
    280282    unsigned int* cma_vbase = (unsigned int *)&seg_cma_base;
    281     unsigned int  offset     = channel_id * CHBUF_CHANNEL_SPAN;
    282 
    283     cma_vbase[offset + CHBUF_SRC_DESC]  = (unsigned int)(channel_pbase & 0xFFFFFFFF);
    284     cma_vbase[offset + CHBUF_SRC_EXT]   = (unsigned int)(channel_pbase >> 32);
     283    unsigned int  offset    = channel_id * CHBUF_CHANNEL_SPAN;
     284
     285    cma_vbase[offset + CHBUF_SRC_DESC]  = (unsigned int)(desc_paddr & 0xFFFFFFFF);
     286    cma_vbase[offset + CHBUF_SRC_EXT]   = (unsigned int)(desc_paddr >> 32);
    285287    cma_vbase[offset + CHBUF_SRC_NBUFS] = 2;
    286     cma_vbase[offset + CHBUF_DST_DESC]  = (unsigned int)(channel_pbase & 0xFFFFFFFF) + 16;
    287     cma_vbase[offset + CHBUF_DST_EXT]   = (unsigned int)(channel_pbase >> 32);
     288    cma_vbase[offset + CHBUF_DST_DESC]  = (unsigned int)(desc_paddr & 0xFFFFFFFF) + 16;
     289    cma_vbase[offset + CHBUF_DST_EXT]   = (unsigned int)(desc_paddr >> 32);
    288290    cma_vbase[offset + CHBUF_DST_NBUFS] = 1;
    289291    cma_vbase[offset + CHBUF_BUF_SIZE]  = length;
     
    302304#endif
    303305}
    304 //////////////////////////////////////////////////////////////////////////////////
     306////////////////////////////////////////////////////////////////////////////////////
    305307// _fb_cma_write()
    306 // This function makes a SYNC request for the source user buffer.
    307 // Then it updates the status of the SRC and DST chbuf descriptors, to allow
    308 // the CMA component to transfer the source user buffer buffer to the destination
    309 // frame buffer, and makes a SYNC request for the channel descriptor.
    310 //
    311 // - buffer_id : user buffer index (0 => buf0 / not 0 => buf1)
     308//
     309// It updates the status of the SRC and DST chbuf descriptors, to allow the CMA
     310// component to transfer the source user buffer to the frame buffer.
     311//
     312// If the IO Bridge component is used:
     313// 1) it makes an INVAL request for the channel descriptor, before testing the
     314//    source buffer status, because it is modified in XRAM by the CMA component.
     315// 2) it makes a SYNC request for the source user buffer before activating the CMA
     316//    transfer, because the data will be read from XRAM by the CMA component.
     317// 3) it makes a SYNC request for the channel descriptor after modification
     318//    of the SRC and DST status, because these descriptors will be read from XRAM
     319//    by the CMA component.
     320//
     321// The buffer_id argument is the user buffer index (0 => buf0 / not 0 => buf1)
    312322// Returns 0 if success, > 0 if error
    313 //////////////////////////////////////////////////////////////////////////////////
     323////////////////////////////////////////////////////////////////////////////////////
    314324unsigned int _fb_cma_write( unsigned int buffer_id )
    315325{
    316326#if NB_CMA_CHANNELS > 0
    317327
    318     paddr_t         buf_paddr;
    319     unsigned int    buf_length;
     328    volatile paddr_t buf_paddr;
     329    unsigned int     buf_length;
     330    unsigned int     full = 1;
     331
     332    unsigned int     count = 0;
    320333
    321334    // get CMA channel index
    322335    unsigned int channel_id = _get_context_slot(CTX_CMA_ID);
    323336
    324     // SYNC request for the source user buffer
    325     if ( buffer_id == 0 )  buf_paddr = _fb_cma_channel[channel_id].buf0;
    326     else                   buf_paddr = _fb_cma_channel[channel_id].buf1;
    327     buf_length = _fb_cma_channel[channel_id].length;
    328     _memc_sync( buf_paddr, buf_length );
     337#if GIET_DEBUG_FBF_DRIVER
     338_tty_get_lock( 0 );
     339_puts("\n[CMA DEBUG] fb_cma_write() for CMA channel ");
     340_putd( channel_id );
     341_puts(" / buf_id = ");
     342_putd( buffer_id );
     343_puts("\n");
     344_tty_release_lock( 0 );
     345#endif
     346
     347    // waiting buffer empty
     348    while ( full )
     349    { 
     350        if ( USE_IOB )
     351        {
     352            // INVAL L2 cache for the channel descriptor,
     353            _memc_inval( _fb_cma_desc_paddr[channel_id], 32 );
     354
     355            // INVAL L1 cache for the channel descriptor,
     356            _dcache_buf_invalidate( &_fb_cma_channel[channel_id], 32 );
     357        }
     358
     359        // read SRC buffer descriptor
     360        if ( buffer_id == 0 ) buf_paddr = _fb_cma_channel[channel_id].buf0;
     361        else                  buf_paddr = _fb_cma_channel[channel_id].buf1;
     362        full = ( (unsigned int)(buf_paddr>>63) );
     363
     364        count++;
     365        if ( count == 10 ) _exit();
     366
     367#if GIET_DEBUG_FBF_DRIVER
     368_tty_get_lock( 0 );
     369_puts(" - buffer descriptor = ");
     370_putl( buf_paddr );
     371_puts(" at cycle ");
     372_putd( _get_proctime() );
     373_puts("\n");
     374_tty_release_lock( 0 );
     375#endif
     376
     377    }
     378
     379    if ( USE_IOB )
     380    {
     381        // SYNC request for the user buffer because
     382        // this buffer will be read from XRAM by the CMA component
     383        _memc_sync( buf_paddr, _fb_cma_channel[channel_id].length );
     384    }
    329385
    330386    // set SRC full
     
    338394                                       & 0x7FFFFFFFFFFFFFFFULL;
    339395
    340     // SYNC request for the channel descriptor
    341     buf_paddr  = _fb_cma_desc_paddr[channel_id];
    342     buf_length = 32;
    343     _memc_sync( buf_paddr, buf_length );
     396    if ( USE_IOB )
     397    {
     398        // SYNC request for the channel descriptor, because
     399        // it will be read in XRAM by the CMA component
     400        _memc_sync( _fb_cma_desc_paddr[channel_id], 32 );
     401    }
    344402
    345403    return 0;
  • soft/giet_vm/giet_drivers/icu_driver.c

    r258 r263  
    1616// The virtual base address of the segment associated to the component is:
    1717//
    18 //      seg_icu_base + cluster_id * vseg_cluster_increment
     18//      seg_icu_base + cluster_xy * vseg_cluster_increment
    1919//
    2020// The seg_icu_base and vseg_cluster_increment values must be defined
     
    2424#include <giet_config.h>
    2525#include <icu_driver.h>
     26#include <tty_driver.h>
    2627#include <utils.h>
    2728
    28 #if !defined(NB_CLUSTERS)
    29 # error: You must define NB_CLUSTERS in the hard_config.h file
     29#if !defined(X_SIZE)
     30# error: You must define X_SIZE in the hard_config.h file
    3031#endif
    3132
    32 #if (NB_CLUSTERS > 256)
    33 # error: NB_CLUSTERS cannot be larger than 256!
     33#if !defined(Y_SIZE)
     34# error: You must define X_SIZE in the hard_config.h file
     35#endif
     36
     37#if !defined(X_WIDTH)
     38# error: You must define X_WIDTH in the hard_config.h file
     39#endif
     40
     41#if !defined(Y_WIDTH)
     42# error: You must define X_WIDTH in the hard_config.h file
    3443#endif
    3544
    3645#if !defined(NB_PROCS_MAX)
    3746# error: You must define NB_PROCS_MAX in the hard_config.h file
    38 #endif
    39 
    40 #if (NB_PROCS_MAX > 8)
    41 # error: NB_PROCS_MAX cannot be larger than 8!
    4247#endif
    4348
     
    5358// Returns 0 if success, > 0 if error.
    5459////////////////////////////////////////////////////////////////////////////////
    55 unsigned int _icu_set_mask( unsigned int cluster_id,
     60unsigned int _icu_set_mask( unsigned int cluster_xy,
    5661                            unsigned int proc_id,
    5762                            unsigned int value )
    5863{
    5964    // parameters checking
    60     if (cluster_id >= NB_CLUSTERS) return 1;
    61     if (proc_id >= NB_PROCS_MAX)   return 1;
     65    unsigned int x = cluster_xy >> Y_WIDTH;
     66    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
     67    if (x >= X_SIZE)             return 1;
     68    if (y >= Y_SIZE)             return 1;
     69    if (proc_id >= NB_PROCS_MAX) return 1;
    6270
    6371#if USE_XICU
    64     _puts("[GIET ERROR] _icu_set_mask should not be used if USE_XICU is set\n");
     72    _puts("[GIET ERROR] _icu_set_mask() should not be used if USE_XICU is set\n");
    6573    return 1;
    6674#else
    6775    unsigned int * icu_address = (unsigned int *) ((unsigned int)&seg_icu_base +
    68                                  (cluster_id * (unsigned int)&vseg_cluster_increment));
     76                                 (cluster_xy * (unsigned int)&vseg_cluster_increment));
    6977    icu_address[proc_id * ICU_SPAN + ICU_MASK_SET] = value;
    7078    return 0;
     
    7886// Returns 0 if success, > 0 if error.
    7987////////////////////////////////////////////////////////////////////////////////
    80 unsigned int _icu_get_index( unsigned int cluster_id,
     88unsigned int _icu_get_index( unsigned int cluster_xy,
    8189                             unsigned int proc_id,
    8290                             unsigned int * buffer)
    8391{
    8492    // parameters checking
    85     if (cluster_id >= NB_CLUSTERS)  return 1;
    86     if (proc_id >= NB_PROCS_MAX)    return 1;
     93    unsigned int x = cluster_xy >> Y_WIDTH;
     94    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
     95    if (x >= X_SIZE)             return 1;
     96    if (y >= Y_SIZE)             return 1;
     97    if (proc_id >= NB_PROCS_MAX) return 1;
    8798
    8899#if USE_XICU
    89     _puts("[GIET ERROR] _icu_get_index should not be used if USE_XICU is set\n");
     100    _puts("[GIET ERROR] _icu_get_index() should not be used if USE_XICU is set\n");
    90101    return 1;
    91102#else
    92103    unsigned int* icu_address = (unsigned int *) ((unsigned int)&seg_icu_base +
    93                                  (cluster_id * (unsigned int)&vseg_cluster_increment));
     104                                 (cluster_xy * (unsigned int)&vseg_cluster_increment));
    94105    *buffer = icu_address[proc_id * ICU_SPAN + ICU_IT_VECTOR];
    95106    return 0;
  • soft/giet_vm/giet_drivers/icu_driver.h

    r258 r263  
    2929///////////////////////////////////////////////////////////////////////////////////
    3030
    31 extern unsigned int _icu_get_index( unsigned int cluster_id,
     31extern unsigned int _icu_get_index( unsigned int cluster_xy,
    3232                                    unsigned int proc_id,
    3333                                    unsigned int * buffer );
    3434
    35 extern unsigned int _icu_set_mask( unsigned int cluster_id,
     35extern unsigned int _icu_set_mask( unsigned int cluster_xy,
    3636                                   unsigned int proc_id,
    3737                                   unsigned int value );
  • soft/giet_vm/giet_drivers/ioc_driver.c

    r258 r263  
    285285_puts("\n");
    286286_puts(" - lba       = ");
    287 _putd( lba );
     287_putx( lba );
    288288_puts("\n");
    289289_tty_release_lock( 0 );
     
    379379_puts(" for processor ");
    380380_putd( _get_procid() );
     381_puts(" : error = ");
     382_putd( (unsigned int)error );
    381383_puts("\n");
    382384_tty_release_lock( 0 );
  • soft/giet_vm/giet_drivers/mmc_driver.c

    r258 r263  
    2121#include <giet_config.h>
    2222#include <mmc_driver.h>
     23#include <tty_driver.h>
    2324#include <utils.h>
    2425
    25 #if !defined(NB_CLUSTERS)
    26 # error: You must define NB_CLUSTERS in the hard_config.h file
     26#if !defined(X_SIZE)
     27# error: You must define X_SIZE in the hard_config.h file
    2728#endif
    2829
    29 #if (NB_CLUSTERS > 256)
    30 # error: NB_CLUSTERS cannot be larger than 256!
     30#if !defined(Y_SIZE)
     31# error: You must define X_SIZE in the hard_config.h file
     32#endif
     33
     34#if !defined(X_WIDTH)
     35# error: You must define X_WIDTH in the hard_config.h file
     36#endif
     37
     38#if !defined(Y_WIDTH)
     39# error: You must define X_WIDTH in the hard_config.h file
    3140#endif
    3241
     
    4049                  unsigned int buf_length )
    4150{
    42     unsigned int cluster_id    = (unsigned int)((buf_paddr>>32)/(256/NB_CLUSTERS));
     51    // compute cluster coordinates
     52    unsigned int cluster_xy = (unsigned int)(buf_paddr>>(40-X_WIDTH-Y_WIDTH));
     53    unsigned int x          = cluster_xy >> Y_WIDTH;
     54    unsigned int y          = cluster_xy & ((1<<Y_WIDTH)-1);
     55
     56    // parameters checking
     57    if ( (x >= X_SIZE) || (y >= Y_SIZE) )
     58    {
     59        _puts("\n[GIET ERROR] in _memc_inval() : illegal cluster index[");
     60        _putd( x );
     61        _puts(",");
     62        _putd( y );
     63        _puts("]\n");
     64        _puts("   - paddr      = ");
     65        _putl( buf_paddr );
     66        _puts("\n   - cluster_xy = ");
     67        _putx( cluster_xy );
     68        _puts("\n");
     69        _exit();
     70    }
    4371
    4472    unsigned int* mmc_address = (unsigned int*)((unsigned int)&seg_mmc_base +
    45                                 (cluster_id * (unsigned int)&vseg_cluster_increment));
     73                                (cluster_xy * (unsigned int)&vseg_cluster_increment));
    4674
    4775    // get the hard lock protecting exclusive access to MEMC
     
    6694                 unsigned int buf_length )
    6795{
    68     unsigned int cluster_id    = (unsigned int)((buf_paddr>>32)/(256/NB_CLUSTERS));
     96    // compute cluster coordinates
     97    unsigned int cluster_xy = (unsigned int)(buf_paddr>>(40-X_WIDTH-Y_WIDTH));
     98    unsigned int x          = cluster_xy >> Y_WIDTH;
     99    unsigned int y          = cluster_xy & ((1<<Y_WIDTH)-1);
     100
     101    // parameters checking
     102    if ( (x >= X_SIZE) || (y >= Y_SIZE) )
     103    {
     104        _puts("\n[GIET ERROR] in _memc_sync() : illegal cluster index[");
     105        _putd( x );
     106        _puts(",");
     107        _putd( y );
     108        _puts("]\n");
     109        _puts("   - paddr      = ");
     110        _putl( buf_paddr );
     111        _puts("\n   - cluster_xy = ");
     112        _putx( cluster_xy );
     113        _puts("\n");
     114        _exit();
     115    }
    69116
    70117    unsigned int * mmc_address = (unsigned int *) ((unsigned int)&seg_mmc_base +
    71                                  (cluster_id * (unsigned int)&vseg_cluster_increment));
     118                                 (cluster_xy * (unsigned int)&vseg_cluster_increment));
    72119
    73120    // get the hard lock protecting exclusive access to MEMC
  • soft/giet_vm/giet_drivers/mwr_driver.c

    r258 r263  
    1212// The (virtual) base address of the associated segment is:
    1313//
    14 //       seg_mwr_base + cluster_id * vseg_cluster_increment
     14//       seg_mwr_base + cluster_xy * vseg_cluster_increment
    1515//
    1616// The seg_mwr_base and vseg_cluster_increment values must be defined
     
    2222#include <utils.h>
    2323
    24 #if !defined(NB_CLUSTERS)
    25 # error: You must define NB_CLUSTERS in the hard_config.h file
     24#if !defined(X_SIZE)
     25# error: You must define X_SIZE in the hard_config.h file
    2626#endif
    2727
    28 #if (NB_CLUSTERS > 256)
    29 # error: NB_CLUSTERS cannot be larger than 256!
     28#if !defined(Y_SIZE)
     29# error: You must define X_SIZE in the hard_config.h file
     30#endif
     31
     32#if !defined(X_WIDTH)
     33# error: You must define X_WIDTH in the hard_config.h file
     34#endif
     35
     36#if !defined(Y_WIDTH)
     37# error: You must define X_WIDTH in the hard_config.h file
    3038#endif
    3139
    3240//////////////////////////////////////////////////////////////////////////////////
    33 //    _mwmr_hw_init()
     41//    _mwr_hw_init()
    3442// This function initializes one MWMR controller channel (i.e. one coprocessor
    3543// port) in a given cluster.
    36 // - cluster_id    : cluster index
     44// - cluster_xy    : cluster index
    3745// _ port_id       : port index
    3846// - way           : direction (to_coproc/from_coproc)
     
    4048// TODO : The MWMR controler should be modified to support 40 bits addresses...
    4149//        Introduce a MWMR_CONFIG_PADDR_EXT register in the MWMR coprocessor
    42 //        To support addresses > 32 bits and remove this limitation...
    4350//////////////////////////////////////////////////////////////////////////////////
    4451// Returns 0 if success, returns > 0 if error.
    4552//////////////////////////////////////////////////////////////////////////////////
    46 unsigned int _mwmr_hw_init( unsigned int           cluster_id,
    47                             unsigned int           port_id,
    48                             unsigned int           from_coproc,
    49                             paddr_t                channel_pbase )
     53unsigned int _mwr_hw_init( unsigned int           cluster_xy,
     54                           unsigned int           port_id,
     55                           unsigned int           from_coproc,
     56                           paddr_t                channel_pbase )
    5057{
    51     _puts(" [GIET_ERROR] _mwmr_hw_init() function not implemented yet\n");
     58    _puts(" [GIET_ERROR] _mwr_hw_init() function not supported yet\n");
    5259    _exit();
    5360
    5461/*
    5562    // parameters checking
    56     if (cluster_id >= NB_CLUSTERS)      return 1;
     63    unsigned int x = cluster_xy >> Y_WIDTH;
     64    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
     65    if (x >= X_SIZE)                    return 1;
     66    if (y >= Y_SIZE)                    return 1;
    5767
    58     // compute MWMR base address
    59     unsigned int* mwmr_address = (unsigned int*) ((unsigned int)&seg_mwmr_base +
    60                                  (cluster_id * (unsigned int)&vseg_cluster_increment));
     68    // compute base address
     69    unsigned int* mwr_address = (unsigned int*) ((unsigned int)&seg_mwr_base +
     70                                 (cluster_xy * (unsigned int)&vseg_cluster_increment));
    6171
    6272    unsigned int lsb = (unsigned int)channel_pbase;
     
    6878
    6979    // initializes and launches mwmr controler
    70     mwmr_address[port_id * MWMR_SPAN + MWMR_CONFIG_FIFO_WAY]  = from_coproc;
    71     mwmr_address[port_id * MWMR_SPAN + MWMR_CONFIG_FIFO_NO]   = port_id;
    72     mwmr_address[port_id * MWMR_SPAN + MWMR_CONFIG_WIDTH]     = width;
    73     mwmr_address[port_id * MWMR_SPAN + MWMR_CONFIG_DEPTH]     = depth;
    74     mwmr_address[port_id * MWMR_SPAN + MWMR_CONFIG_STATUS]    = lsb;
    75     mwmr_address[port_id * MWMR_SPAN + MWMR_CONFIG_DATA]      = lsb + 24;
    76     mwmr_address[port_id * MWMR_SPAN + MWMR_CONFIG_EXT]       = msb;
    77     mwmr_address[port_id * MWMR_SPAN + MWMR_CONFIG_RUNNING]   = 1;
     80    mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_FIFO_WAY]  = from_coproc;
     81    mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_FIFO_NO]   = port_id;
     82    mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_WIDTH]     = width;
     83    mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_DEPTH]     = depth;
     84    mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_STATUS]    = lsb;
     85    mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_DATA]      = lsb + 24;
     86    mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_EXT]       = msb;
     87    mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_RUNNING]   = 1;
    7888*/
    7989    return 0;
  • soft/giet_vm/giet_drivers/mwr_driver.h

    r258 r263  
    1919    MWMR_CONFIG_FIFO_WAY,
    2020    MWMR_CONFIG_FIFO_NO,
    21     MWMR_CONFIG_STATUS_ADDR,
     21    MWMR_CONFIG_STATUS,
    2222    MWMR_CONFIG_DEPTH,
    2323    MWMR_CONFIG_BUFFER_ADDR,
    2424    MWMR_CONFIG_RUNNING,
    2525    MWMR_CONFIG_WIDTH,
    26     MWMR_FIFO_FILL_STATUS,
     26    MWMR_CONFIG_DATA,
     27    MWMR_CONFIG_EXT,
     28    /***/
     29    MWMR_SPAN,
    2730};
    2831
     
    3740///////////////////////////////////////////////////////////////////////////////////
    3841
    39 extern unsigned int _mwmr_hw_init( unsigned int           cluster_id,
    40                                    unsigned int           port_id,
    41                                    unsigned int           from_coproc,
    42                                    unsigned long long     channel_pbase);
     42extern 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);
    4346
    4447///////////////////////////////////////////////////////////////////////////////////
  • soft/giet_vm/giet_drivers/tim_driver.c

    r258 r263  
    1616// - "user" timers : requested by the task in the mapping_info data structure.
    1717//   For each user timer, the timer_id is stored in the context of the task.
    18 // The global index is cluster_id * (NB_PROCS_MAX + NB_TIM_CHANNELS) + local_id
     18// The global index is cluster_xy * (NB_PROCS_MAX + NB_TIM_CHANNELS) + local_id
    1919//
    2020// The NB_PROCS_MAX and NB_TIM_CHANNELS values must be defined in the
     
    2525// The virtual base address of the segment associated to a channel is:
    2626//
    27 //     seg_tim_base + cluster_id * vseg_cluster_increment + TIMER_SPAN * timer_id
     27//     seg_tim_base + cluster_xy * vseg_cluster_increment + TIMER_SPAN * timer_id
    2828//
    2929// The seg_tim_base and vseg_cluster_increment values must be defined
     
    3535#include <utils.h>
    3636
    37 #if !defined(NB_CLUSTERS)
    38 # error: You must define NB_CLUSTERS in the hard_config.h file
     37#if !defined(X_SIZE)
     38# error: You must define X_SIZE in the hard_config.h file
    3939#endif
    4040
    41 #if (NB_CLUSTERS > 256)
    42 # error: NB_CLUSTERS cannot be larger than 256!
     41#if !defined(Y_SIZE)
     42# error: You must define X_SIZE in the hard_config.h file
     43#endif
     44
     45#if !defined(X_WIDTH)
     46# error: You must define X_WIDTH in the hard_config.h file
     47#endif
     48
     49#if !defined(Y_WIDTH)
     50# error: You must define X_WIDTH in the hard_config.h file
    4351#endif
    4452
    4553#if !defined(NB_PROCS_MAX)
    4654# error: You must define NB_PROCS_MAX in the hard_config.h file
    47 #endif
    48 
    49 #if (NB_PROCS_MAX > 8)
    50 # error: NB_PROCS_MAX cannot be larger than 8!
    5155#endif
    5256
     
    5963#endif
    6064
    61 #if !defined( USE_XICU )
    62 # error: You must define USE_XICU in the hard_config.h file
    63 #endif
    64 
    6565///////////////////  Timer global variables ////////////////////////////////////////
    6666
     
    6868
    6969#if (NB_TIM_CHANNELS > 0)
    70 in_unckdata volatile unsigned char _user_timer_event[NB_CLUSTERS * NB_TIM_CHANNELS]
    71                             = { [0 ... ((NB_CLUSTERS * NB_TIM_CHANNELS) - 1)] = 0 };
     70in_unckdata volatile unsigned char _user_timer_event[X_SIZE*Y_SIZE*NB_TIM_CHANNELS]
     71                            = { [0 ... ((X_SIZE*Y_SIZE*NB_TIM_CHANNELS) - 1)] = 0 };
    7272#endif
    7373
     
    8080// Returns 0 if success, > 0 if error.
    8181//////////////////////////////////////////////////////////////////////////////
    82 unsigned int _timer_start( unsigned int cluster_id,
     82unsigned int _timer_start( unsigned int cluster_xy,
    8383                           unsigned int local_id,
    8484                           unsigned int period)
    8585{
    8686    // parameters checking
    87     if (cluster_id >= NB_CLUSTERS)    return 1;
     87    unsigned int x = cluster_xy >> Y_WIDTH;
     88    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
     89    if (x >= X_SIZE)                  return 1;
     90    if (y >= Y_SIZE)                  return 1;
    8891    if (local_id >= NB_TIM_CHANNELS)  return 1;
    8992
    9093    unsigned int* timer_address = (unsigned int *) ((unsigned int)&seg_tim_base +
    91                                   (cluster_id * (unsigned int)&vseg_cluster_increment));
     94                                  (cluster_xy * (unsigned int)&vseg_cluster_increment));
    9295
    9396    timer_address[local_id * TIMER_SPAN + TIMER_PERIOD] = period;
     
    102105// Returns 0 if success, > 0 if error.
    103106//////////////////////////////////////////////////////////////////////////////
    104 unsigned int _timer_stop( unsigned int cluster_id,
     107unsigned int _timer_stop( unsigned int cluster_xy,
    105108                          unsigned int local_id)
    106109{
    107110    // parameters checking
    108     if (cluster_id >= NB_CLUSTERS)    return 1;
     111    unsigned int x = cluster_xy >> Y_WIDTH;
     112    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
     113    if (x >= X_SIZE)                  return 1;
     114    if (y >= Y_SIZE)                  return 1;
    109115    if (local_id >= NB_TIM_CHANNELS)  return 1;
    110116
    111117    unsigned int* timer_address = (unsigned int *) ((unsigned int)&seg_tim_base +
    112                                   (cluster_id * (unsigned int)&vseg_cluster_increment));
     118                                  (cluster_xy * (unsigned int)&vseg_cluster_increment));
    113119
    114120    timer_address[local_id * TIMER_SPAN + TIMER_MODE] = 0;
     
    124130// Returns 0 if success, > 0 if error.
    125131//////////////////////////////////////////////////////////////////////////////
    126 unsigned int _timer_reset_irq( unsigned int cluster_id,
     132unsigned int _timer_reset_irq( unsigned int cluster_xy,
    127133                               unsigned int local_id )
    128134{
    129135    // parameters checking
    130     if (cluster_id >= NB_CLUSTERS)    return 1;
     136    unsigned int x = cluster_xy >> Y_WIDTH;
     137    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
     138    if (x >= X_SIZE)                  return 1;
     139    if (y >= Y_SIZE)                  return 1;
    131140    if (local_id >= NB_TIM_CHANNELS)  return 1;
    132141
    133142    unsigned int * timer_address = (unsigned int *) ((unsigned int)&seg_tim_base +
    134                                    (cluster_id * (unsigned int)&vseg_cluster_increment));
     143                                   (cluster_xy * (unsigned int)&vseg_cluster_increment));
    135144
    136145    timer_address[local_id * TIMER_SPAN + TIMER_RESETIRQ] = 0;
     
    147156// This function is called during a context switch (user or preemptive)
    148157//////////////////////////////////////////////////////////////////////i//////
    149 unsigned int _timer_reset_cpt( unsigned int cluster_id,
     158unsigned int _timer_reset_cpt( unsigned int cluster_xy,
    150159                               unsigned int local_id)
    151160{
    152161    // parameters checking
    153     if (cluster_id >= NB_CLUSTERS)    return 1;
     162    unsigned int x = cluster_xy >> Y_WIDTH;
     163    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
     164    if (x >= X_SIZE)                  return 1;
     165    if (y >= Y_SIZE)                  return 1;
    154166    if (local_id >= NB_TIM_CHANNELS)  return 1;
    155167
    156168    // We suppose that the TIMER_MODE register value is 0x3
    157169    unsigned int * timer_address = (unsigned int *) ((unsigned int)&seg_tim_base +
    158                                    (cluster_id * (unsigned int)&vseg_cluster_increment));
     170                                   (cluster_xy * (unsigned int)&vseg_cluster_increment));
    159171
    160172    unsigned int period = timer_address[local_id * TIMER_SPAN + TIMER_PERIOD];
  • soft/giet_vm/giet_drivers/tim_driver.h

    r258 r263  
    2929extern volatile unsigned char _timer_event[];
    3030
    31 extern unsigned int _timer_start( unsigned int cluster_id,
     31extern unsigned int _timer_start( unsigned int cluster_xy,
    3232                                  unsigned int local_id,
    3333                                  unsigned int period );
    3434
    35 extern unsigned int _timer_stop( unsigned int cluster_id,
     35extern unsigned int _timer_stop( unsigned int cluster_xy,
    3636                                 unsigned int local_id );
    3737
    38 extern unsigned int _timer_reset_irq( unsigned int cluster_id,
     38extern unsigned int _timer_reset_irq( unsigned int cluster_xy,
    3939                                      unsigned int local_id );
    4040
    41 extern unsigned int _timer_reset_cpt( unsigned int cluster_id,
     41extern unsigned int _timer_reset_cpt( unsigned int cluster_xy,
    4242                                      unsigned int local_id);
    4343
  • soft/giet_vm/giet_drivers/xcu_driver.c

    r258 r263  
    1616// The virtual base address of the segment associated to the component is:
    1717//
    18 //      seg_xcu_base + cluster_id * vseg_cluster_increment
     18//      seg_xcu_base + cluster_xy * vseg_cluster_increment
    1919//
    2020// The seg_xcu_base and vseg_cluster_increment values must be defined
     
    2424#include <giet_config.h>
    2525#include <xcu_driver.h>
     26#include <tty_driver.h>
     27#include <mapping_info.h>
    2628#include <utils.h>
    2729
    28 #if !defined(NB_CLUSTERS)
    29 # error: You must define NB_CLUSTERS in the hard_config.h file
    30 #endif
    31 
    32 #if (NB_CLUSTERS > 256)
    33 # error: NB_CLUSTERS cannot be larger than 256!
     30#if !defined(X_SIZE)
     31# error: You must define X_SIZE in the hard_config.h file
     32#endif
     33
     34#if !defined(Y_SIZE)
     35# error: You must define X_SIZE in the hard_config.h file
     36#endif
     37
     38#if !defined(X_WIDTH)
     39# error: You must define X_WIDTH in the hard_config.h file
     40#endif
     41
     42#if !defined(Y_WIDTH)
     43# error: You must define X_WIDTH in the hard_config.h file
    3444#endif
    3545
    3646#if !defined(NB_PROCS_MAX)
    3747# error: You must define NB_PROCS_MAX in the hard_config.h file
    38 #endif
    39 
    40 #if (NB_PROCS_MAX > 8)
    41 # error: NB_PROCS_MAX cannot be larger than 8!
    4248#endif
    4349
     
    5359// Returns 0 if success, > 0 if error.
    5460////////////////////////////////////////////////////////////////////////////////
    55 unsigned int _xcu_set_mask( unsigned int cluster_id, unsigned int proc_id,
     61unsigned int _xcu_set_mask( unsigned int cluster_xy,
     62                            unsigned int proc_id,
    5663                            unsigned int value,
    57                             unsigned int is_PTI)
    58 {
    59     // parameters checking
    60     if (cluster_id >= NB_CLUSTERS) return 1;
    61     if (proc_id >= NB_PROCS_MAX)   return 1;
     64                            unsigned int irq_type )
     65{
     66    // parameters checking
     67    unsigned int x = cluster_xy >> Y_WIDTH;
     68    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
     69    if (x >= X_SIZE)             return 1;
     70    if (y >= Y_SIZE)             return 1;
     71    if (proc_id >= NB_PROCS_MAX) return 1;
    6272
    6373#if USE_XICU
    6474    unsigned int* xcu_address = (unsigned int *) ((unsigned int)&seg_xcu_base +
    65                                 (cluster_id * (unsigned int)&vseg_cluster_increment));
    66     if (is_PTI)
    67         xcu_address[XICU_REG(XICU_MSK_PTI_ENABLE, proc_id)] = value;
    68     else
    69         xcu_address[XICU_REG(XICU_MSK_HWI_ENABLE, proc_id)] = value;
     75                                (cluster_xy * (unsigned int)&vseg_cluster_increment));
     76    unsigned int func;
     77    if      (irq_type == IRQ_TYPE_PTI) func = XICU_MSK_PTI_ENABLE;
     78    else if (irq_type == IRQ_TYPE_SWI) func = XICU_MSK_WTI_ENABLE;
     79    else                               func = XICU_MSK_HWI_ENABLE;
     80    xcu_address[XICU_REG(func,proc_id)] = value;
    7081    return 0;
    7182#else
     
    8697// Returns 0 if success, > 0 if error.
    8798////////////////////////////////////////////////////////////////////////////////
    88 unsigned int _xcu_get_index( unsigned int cluster_id,
     99unsigned int _xcu_get_index( unsigned int cluster_xy,
    89100                             unsigned int proc_id,
    90101                             unsigned int * buffer)
    91102{
    92103    // parameters checking
    93     if (cluster_id >= NB_CLUSTERS)  return 1;
    94     if (proc_id >= NB_PROCS_MAX)    return 1;
     104    unsigned int x = cluster_xy >> Y_WIDTH;
     105    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
     106    if (x >= X_SIZE)             return 1;
     107    if (y >= Y_SIZE)             return 1;
     108    if (proc_id >= NB_PROCS_MAX) return 1;
    95109
    96110#if USE_XICU
    97111    unsigned int* xcu_address = (unsigned int *) ((unsigned int)&seg_xcu_base +
    98                                 (cluster_id * (unsigned int)&vseg_cluster_increment));
     112                                (cluster_xy * (unsigned int)&vseg_cluster_increment));
    99113
    100114    unsigned int prio = xcu_address[XICU_REG(XICU_PRIO, proc_id)];
     
    125139// Returns 0 if success, > 0 if error.
    126140////////////////////////////////////////////////////////////////////////////////
    127 unsigned int _xcu_send_ipi( unsigned int cluster_id,
     141unsigned int _xcu_send_ipi( unsigned int cluster_xy,
    128142                            unsigned int proc_id,
    129143                            unsigned int wdata )
    130144{
    131145    // parameters checking
    132     if (cluster_id >= NB_CLUSTERS)  return 1;
    133     if (proc_id >= NB_PROCS_MAX)    return 1;
     146    unsigned int x = cluster_xy >> Y_WIDTH;
     147    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
     148    if (x >= X_SIZE)             return 1;
     149    if (y >= Y_SIZE)             return 1;
     150    if (proc_id >= NB_PROCS_MAX) return 1;
    134151
    135152#if USE_XICU
    136153    unsigned int* xcu_address = (unsigned int *) ((unsigned int)&seg_xcu_base +
    137                                  (cluster_id * (unsigned int)&vseg_cluster_increment));
     154                                 (cluster_xy * (unsigned int)&vseg_cluster_increment));
    138155    xcu_address[XICU_REG(XICU_WTI_REG, proc_id)] = wdata;
    139156    return 0;
     
    152169// Returns 0 if success, > 0 if error.
    153170////////////////////////////////////////////////////////////////////////////////
    154 unsigned int _xcu_timer_start( unsigned int cluster_id,
    155                                unsigned int local_id,
     171unsigned int _xcu_timer_start( unsigned int cluster_xy,
     172                               unsigned int proc_id,
    156173                               unsigned int period )
    157174{
    158175    // parameters checking
    159     if (cluster_id >= NB_CLUSTERS)    return 1;
    160     if (local_id >= NB_TIM_CHANNELS)  return 1;
     176    unsigned int x = cluster_xy >> Y_WIDTH;
     177    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
     178    if (x >= X_SIZE)             return 1;
     179    if (y >= Y_SIZE)             return 1;
     180    if (proc_id >= NB_PROCS_MAX) return 1;
    161181
    162182#if USE_XICU
    163183    unsigned int* xcu_address = (unsigned int *) ((unsigned int)&seg_xcu_base +
    164                                 (cluster_id * (unsigned int)&vseg_cluster_increment));
    165     xcu_address[XICU_REG(XICU_PTI_PER, local_id)] = period;
     184                                (cluster_xy * (unsigned int)&vseg_cluster_increment));
     185    xcu_address[XICU_REG(XICU_PTI_PER, proc_id)] = period;
    166186    return 0;
    167187#else
     
    179199// Returns 0 if success, > 0 if error.
    180200//////////////////////////////////////////////////////////////////////////////
    181 unsigned int _xcu_timer_stop( unsigned int cluster_id,
    182                               unsigned int local_id)
    183 {
    184     // parameters checking
    185     if (cluster_id >= NB_CLUSTERS)    return 1;
    186     if (local_id >= NB_TIM_CHANNELS)  return 1;
     201unsigned int _xcu_timer_stop( unsigned int cluster_xy,
     202                              unsigned int proc_id)
     203{
     204    // parameters checking
     205    unsigned int x = cluster_xy >> Y_WIDTH;
     206    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
     207    if (x >= X_SIZE)             return 1;
     208    if (y >= Y_SIZE)             return 1;
     209    if (proc_id >= NB_PROCS_MAX) return 1;
    187210
    188211#if USE_XICU
    189212    unsigned int * xcu_address = (unsigned int *) ((unsigned int)&seg_xcu_base +
    190                                  (cluster_id * (unsigned int)&vseg_cluster_increment));
    191     xcu_address[XICU_REG(XICU_PTI_PER, local_id)] = 0;
     213                                 (cluster_xy * (unsigned int)&vseg_cluster_increment));
     214    xcu_address[XICU_REG(XICU_PTI_PER, proc_id)] = 0;
    192215    return 0;
    193216#else
     
    207230// Returns 0 if success, > 0 if error.
    208231//////////////////////////////////////////////////////////////////////////////
    209 unsigned int _xcu_timer_reset_irq( unsigned int cluster_id,
    210                                    unsigned int local_id )
    211 {
    212     // parameters checking
    213     if (cluster_id >= NB_CLUSTERS)    return 1;
    214     if (local_id >= NB_TIM_CHANNELS)  return 1;
     232unsigned int _xcu_timer_reset_irq( unsigned int cluster_xy,
     233                                   unsigned int proc_id )
     234{
     235    // parameters checking
     236    unsigned int x = cluster_xy >> Y_WIDTH;
     237    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
     238    if (x >= X_SIZE)             return 1;
     239    if (y >= Y_SIZE)             return 1;
     240    if (proc_id >= NB_PROCS_MAX) return 1;
    215241
    216242#if USE_XICU
    217243    unsigned int * xcu_address = (unsigned int *) ((unsigned int)&seg_xcu_base +
    218                                  (cluster_id * (unsigned int)&vseg_cluster_increment));
    219 
    220     unsigned int bloup = xcu_address[XICU_REG(XICU_PTI_ACK, local_id)];
     244                                 (cluster_xy * (unsigned int)&vseg_cluster_increment));
     245
     246    unsigned int bloup = xcu_address[XICU_REG(XICU_PTI_ACK, proc_id)];
    221247    bloup++; // to avoid a warning
    222248    return 0;
     
    238264// This function is called during a context switch (user or preemptive)
    239265/////////////////////////////////////////////////////////////////////////////
    240 unsigned int _xcu_timer_reset_cpt( unsigned int cluster_id,
    241                                    unsigned int local_id )
    242 {
    243     // parameters checking
    244     if (cluster_id >= NB_CLUSTERS)   return 1;
    245     if (local_id >= NB_TIM_CHANNELS) return 1;
     266unsigned int _xcu_timer_reset_cpt( unsigned int cluster_xy,
     267                                   unsigned int proc_id )
     268{
     269    // parameters checking
     270    unsigned int x = cluster_xy >> Y_WIDTH;
     271    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
     272    if (x >= X_SIZE)             return 1;
     273    if (y >= Y_SIZE)             return 1;
     274    if (proc_id >= NB_PROCS_MAX) return 1;
    246275
    247276#if USE_XICU
    248277    unsigned int * xcu_address = (unsigned int *) ((unsigned int) &seg_xcu_base +
    249                                  (cluster_id * (unsigned int)&vseg_cluster_increment));
    250 
    251     unsigned int period = xcu_address[XICU_REG(XICU_PTI_PER, local_id)];
     278                                 (cluster_xy * (unsigned int)&vseg_cluster_increment));
     279
     280    unsigned int period = xcu_address[XICU_REG(XICU_PTI_PER, proc_id)];
    252281
    253282    // we write 0 first because if the timer is currently running,
    254283    // the corresponding timer counter is not reset
    255     xcu_address[XICU_REG(XICU_PTI_PER, local_id)] = 0;
    256     xcu_address[XICU_REG(XICU_PTI_PER, local_id)] = period;
     284    xcu_address[XICU_REG(XICU_PTI_PER, proc_id)] = 0;
     285    xcu_address[XICU_REG(XICU_PTI_PER, proc_id)] = period;
    257286    return 0;
    258287#else
  • soft/giet_vm/giet_drivers/xcu_driver.h

    r258 r263  
    3939
    4040#define XICU_REG(func, index) (((func)<<5)|(index))
    41 
     41 
    4242///////////////////////////////////////////////////////////////////////////////////
    4343// XICU access functions
    4444///////////////////////////////////////////////////////////////////////////////////
    4545
    46 extern unsigned int _xcu_get_index( unsigned int cluster_id,
     46extern unsigned int _xcu_get_index( unsigned int cluster_xy,
    4747                                    unsigned int proc_id,
    4848                                    unsigned int * buffer );
    4949
    50 extern unsigned int _xcu_set_mask( unsigned int cluster_id,
     50extern unsigned int _xcu_set_mask( unsigned int cluster_xy,
    5151                                   unsigned int proc_id,
    5252                                   unsigned int mask,
    5353                                   unsigned int is_timer );
    5454
    55 extern unsigned int _xcu_send_ipi( unsigned int cluster_id,
     55extern unsigned int _xcu_send_ipi( unsigned int cluster_xy,
    5656                                   unsigned int proc_id,
    5757                                   unsigned int wdata );
    5858
    59 extern unsigned int _xcu_timer_start( unsigned int cluster_id,
    60                                       unsigned int local_id,
     59extern unsigned int _xcu_timer_start( unsigned int cluster_xy,
     60                                      unsigned int proc_id,
    6161                                      unsigned int period );
    6262
    63 extern unsigned int _xcu_timer_stop( unsigned int cluster_id,
    64                                      unsigned int local_id );
     63extern unsigned int _xcu_timer_stop( unsigned int cluster_xy,
     64                                     unsigned int proc_id );
    6565
    66 extern unsigned int _xcu_timer_reset_irq( unsigned int cluster_id,
    67                                           unsigned int local_id );
     66extern unsigned int _xcu_timer_reset_irq( unsigned int cluster_xy,
     67                                          unsigned int proc_id );
    6868
    69 extern unsigned int _xcu_timer_reset_cpt( unsigned int cluster_id,
    70                                           unsigned int local_id );
     69extern unsigned int _xcu_timer_reset_cpt( unsigned int cluster_xy,
     70                                          unsigned int proc_id );
    7171
    7272///////////////////////////////////////////////////////////////////////////////////
Note: See TracChangeset for help on using the changeset viewer.