Ignore:
Timestamp:
Jun 25, 2014, 2:19:37 PM (10 years ago)
Author:
cfuguet
Message:

giet_vm optimizations:

  • Several modifications in GIET_VM in order to support compilation with GCC optimizations (-O2) activated.
  • Adding missing volatile in some global variables.
  • Using ioread and iowrite utility functions in peripheral drivers which prevent GCC to remove writes or reads in hardware memory mapped registers.
  • Code refactoring of stdio printf functions. Now, shr_printf and tty_printf function reuse the same function body. The only difference is that shr_printf wraps printf function call with TTY get lock and release lock.
File:
1 edited

Legend:

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

    r343 r345  
    3232#include <vmem.h>
    3333#include <utils.h>
     34#include <io.h>
    3435
    3536#if !defined(X_SIZE)
     
    6162#endif
    6263
    63 extern unsigned int _ptabs_vaddr[];
     64extern volatile unsigned int _ptabs_vaddr[];
     65
     66///////////////////////////////////////////////////////////////////////////////
     67// This low level function returns the value contained in register "index"
     68// in the DMA component contained in cluster "cluster_xy"
     69///////////////////////////////////////////////////////////////////////////////
     70static
     71unsigned int _dma_get_register( unsigned int cluster_xy, // cluster index
     72                                unsigned int channel_id, // channel index
     73                                unsigned int index )     // register index
     74{
     75    unsigned int vaddr =
     76        SEG_DMA_BASE +
     77        (cluster_xy * PERI_CLUSTER_INCREMENT) +
     78        (channel_id * DMA_SPAN) +
     79        (index << 2);
     80
     81    return ioread32( (void*)vaddr );
     82}
     83
     84///////////////////////////////////////////////////////////////////////////////
     85// This low level function sets a new value in register "index"
     86// in the DMA component contained in cluster "cluster_xy"
     87///////////////////////////////////////////////////////////////////////////////
     88static
     89void _dma_set_register( unsigned int cluster_xy,       // cluster index
     90                        unsigned int channel_id,       // channel index
     91                        unsigned int index,            // register index
     92                        unsigned int value )           // value to be written
     93{
     94    unsigned int vaddr =
     95        SEG_DMA_BASE +
     96        (cluster_xy * PERI_CLUSTER_INCREMENT) +
     97        (channel_id * DMA_SPAN) +
     98        (index << 2);
     99
     100    iowrite32( (void*)vaddr, value );
     101}
    64102
    65103//////////////////////////////////////////////////////////////////////////////////
     
    81119    if (channel_id >= NB_DMA_CHANNELS)  return 1;
    82120
    83     // compute DMA base address
    84     unsigned int* dma_address = (unsigned int*) ( SEG_DMA_BASE +
    85                                 (cluster_xy * PERI_CLUSTER_INCREMENT) );
    86 
    87121    // disable interrupt for selected channel
    88     dma_address[channel_id * DMA_SPAN + DMA_IRQ_DISABLE] = 1;           
     122    _dma_set_register(cluster_xy, channel_id, DMA_IRQ_DISABLE, 1);
    89123    return 0;
    90124#else
     
    109143    if (channel_id >= NB_DMA_CHANNELS)  return 1;
    110144
    111     // compute DMA base address
    112     unsigned int* dma_address = (unsigned int*) ( SEG_DMA_BASE +
    113                                 (cluster_xy * PERI_CLUSTER_INCREMENT) );
    114 
    115145    // reset selected channel
    116     dma_address[channel_id * DMA_SPAN + DMA_RESET] = 0;           
     146    _dma_set_register(cluster_xy, channel_id, DMA_RESET, 0);
    117147    return 0;
    118148#else
     
    136166    if (channel_id >= NB_DMA_CHANNELS)  return 1;
    137167
    138     // compute DMA base address
    139     unsigned int * dma_address = (unsigned int *) ( SEG_DMA_BASE +
    140                                  (cluster_xy * PERI_CLUSTER_INCREMENT) );
    141 
    142168    // get selected channel status
    143     return dma_address[channel_id * DMA_SPAN + DMA_LEN];
     169    return _dma_get_register(cluster_xy, channel_id, DMA_LEN);
    144170#else
    145171    return DMA_IDLE;
     
    160186#if NB_DMA_CHANNELS > 0
    161187
    162     // compute DMA base address
    163     unsigned int * dma_address = (unsigned int *) ( SEG_DMA_BASE +
    164                                  (cluster_xy * PERI_CLUSTER_INCREMENT) );
    165 
    166188    // selected channel configuration and lauching
    167     dma_address[channel_id * DMA_SPAN + DMA_SRC]     = (unsigned int)(src_paddr);
    168     dma_address[channel_id * DMA_SPAN + DMA_SRC_EXT] = (unsigned int)(src_paddr>>32);
    169     dma_address[channel_id * DMA_SPAN + DMA_DST]     = (unsigned int)(dst_paddr);
    170     dma_address[channel_id * DMA_SPAN + DMA_DST_EXT] = (unsigned int)(dst_paddr>>32);
    171     dma_address[channel_id * DMA_SPAN + DMA_LEN]     = (unsigned int)size;
     189    _dma_set_register(cluster_xy, channel_id, DMA_SRC,
     190            (unsigned int)(src_paddr));
     191    _dma_set_register(cluster_xy, channel_id, DMA_SRC_EXT,
     192            (unsigned int)(src_paddr>>32));
     193    _dma_set_register(cluster_xy, channel_id, DMA_DST,
     194            (unsigned int)(dst_paddr));
     195    _dma_set_register(cluster_xy, channel_id, DMA_DST_EXT,
     196            (unsigned int)(dst_paddr>>32));
     197    _dma_set_register(cluster_xy, channel_id, DMA_LEN,
     198            (unsigned int)size);
    172199
    173200#endif
     
    312339
    313340    // get vspace page table pointer
    314     unsigned int pt =  _ptabs_vaddr[vspace_id];
     341    unsigned int pt = _ptabs_vaddr[vspace_id];
    315342
    316343    // get src_paddr buffer physical addresse
Note: See TracChangeset for help on using the changeset viewer.