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/xcu_driver.c

    r333 r345  
    1616#include <mapping_info.h>
    1717#include <utils.h>
     18#include <io.h>
    1819
    1920#if !defined(X_SIZE)
     
    4950#endif
    5051
     52///////////////////////////////////////////////////////////////////////////////
     53// This low level function returns the value contained in register "index"
     54// in the XCU component contained in cluster "cluster_xy"
     55///////////////////////////////////////////////////////////////////////////////
     56static
     57unsigned int _xcu_get_register( unsigned int cluster_xy, // cluster index
     58                                unsigned int func,       // function index
     59                                unsigned int index )     // register index
     60{
     61    unsigned int vaddr =
     62        SEG_XCU_BASE +
     63        (cluster_xy * PERI_CLUSTER_INCREMENT) +
     64        (XCU_REG(func, index) << 2);
     65
     66    return ioread32( (void*)vaddr );
     67}
     68
     69///////////////////////////////////////////////////////////////////////////////
     70// This low level function sets a new value in register "index"
     71// in the XCU component contained in cluster "cluster_xy"
     72///////////////////////////////////////////////////////////////////////////////
     73static
     74void _xcu_set_register( unsigned int cluster_xy,       // cluster index
     75                        unsigned int func,             // func index
     76                        unsigned int index,            // register index
     77                        unsigned int value )           // value to be written
     78{
     79    unsigned int vaddr =
     80        SEG_XCU_BASE +
     81        (cluster_xy * PERI_CLUSTER_INCREMENT) +
     82        (XCU_REG(func, index) << 2);
     83       
     84    iowrite32( (void*)vaddr, value );
     85}
    5186
    5287////////////////////////////////////////////////////////////////////////////////
     
    68103    if (channel >= (NB_PROCS_MAX * IRQ_PER_PROCESSOR)) _exit();
    69104
    70     unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE +
    71                                 (cluster_xy * PERI_CLUSTER_INCREMENT) );
    72 
    73     unsigned int func;
     105    unsigned int func = 0;
    74106    if      (irq_type == IRQ_TYPE_PTI) func = XCU_MSK_PTI_ENABLE;
    75107    else if (irq_type == IRQ_TYPE_WTI) func = XCU_MSK_WTI_ENABLE;
     
    81113    }
    82114
    83     xcu_address[XCU_REG(func,channel)] = value;
     115    _xcu_set_register(cluster_xy, func, channel, value);
    84116
    85117#else
     
    110142    if (channel >= (NB_PROCS_MAX * IRQ_PER_PROCESSOR)) _exit();
    111143
    112     unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE +
    113                                 (cluster_xy * PERI_CLUSTER_INCREMENT) );
    114 
    115     unsigned int prio = xcu_address[XCU_REG(XCU_PRIO,channel)];
     144    unsigned int prio = _xcu_get_register(cluster_xy, XCU_PRIO, channel);
    116145    unsigned int pti_ok = (prio & 0x00000001);
    117146    unsigned int hwi_ok = (prio & 0x00000002);
     
    162191    if (wti_index >= 32)           _exit();
    163192
    164     unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE +
    165                                 (cluster_xy * PERI_CLUSTER_INCREMENT) );
    166 
    167     xcu_address[XCU_REG(XCU_WTI_REG,wti_index)] = wdata;
     193    _xcu_set_register(cluster_xy, XCU_WTI_REG, wti_index, wdata);
    168194
    169195#else
     
    191217    if (wti_index >= 32)           _exit();
    192218 
    193     unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE +
    194                                 (cluster_xy * PERI_CLUSTER_INCREMENT) );
    195 
    196     *value = xcu_address[XCU_REG(XCU_WTI_REG, wti_index)];
     219    *value = _xcu_get_register(cluster_xy, XCU_WTI_REG, wti_index);
    197220
    198221#else
     
    215238    if (wti_index >= 32)           _exit();
    216239 
    217     unsigned int xcu_address = (unsigned int)SEG_XCU_BASE;
    218     *address = xcu_address + (XCU_REG(XCU_WTI_REG, wti_index)<<2);
     240    *address = SEG_XCU_BASE + (XCU_REG(XCU_WTI_REG, wti_index)<<2);
    219241
    220242#else
     
    239261    if (y >= Y_SIZE)             _exit();
    240262
    241     unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE +
    242                                 (cluster_xy * PERI_CLUSTER_INCREMENT) );
    243 
    244     xcu_address[XCU_REG(XCU_PTI_PER, pti_index)] = period;
     263    _xcu_set_register(cluster_xy, XCU_PTI_PER, pti_index, period);
    245264
    246265#else
     
    264283    if (y >= Y_SIZE)             _exit();
    265284
    266     unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE +
    267                                 (cluster_xy * PERI_CLUSTER_INCREMENT) );
    268 
    269     xcu_address[XCU_REG(XCU_PTI_PER, pti_index)] = 0;
     285    _xcu_set_register(cluster_xy, XCU_PTI_PER, pti_index, 0);
    270286
    271287#else
     
    291307    if (y >= Y_SIZE)             _exit();
    292308
    293     unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE +
    294                                 (cluster_xy * PERI_CLUSTER_INCREMENT) );
    295 
    296309    // This return value is not used / avoid a compilation warning.
    297     return xcu_address[XCU_REG(XCU_PTI_ACK, pti_index)];
     310    return _xcu_get_register(cluster_xy, XCU_PTI_ACK, pti_index);
    298311
    299312#else
     
    322335    if (y >= Y_SIZE)             _exit();
    323336
    324     unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE +
    325                                 (cluster_xy * PERI_CLUSTER_INCREMENT) );
    326 
    327     unsigned int period = xcu_address[XCU_REG(XCU_PTI_PER, pti_index)];
     337    unsigned int per = _xcu_get_register(cluster_xy, XCU_PTI_PER, pti_index);
    328338
    329339    // we write 0 first because if the timer is currently running,
    330340    // the corresponding timer counter is not reset
    331     xcu_address[XCU_REG(XCU_PTI_PER, pti_index)] = 0;
    332     xcu_address[XCU_REG(XCU_PTI_PER, pti_index)] = period;
     341    _xcu_set_register(cluster_xy, XCU_PTI_PER, pti_index, 0);
     342    _xcu_set_register(cluster_xy, XCU_PTI_PER, pti_index, per);
    333343
    334344#else
Note: See TracChangeset for help on using the changeset viewer.