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

    r333 r345  
    2121#include <tty_driver.h>
    2222#include <utils.h>
     23#include <io.h>
    2324
    2425#if !defined(X_SIZE)
     
    4647#endif
    4748
     49///////////////////////////////////////////////////////////////////////////////
     50// This low level function returns the value contained in register "index"
     51// in the MMC component contained in cluster "cluster_xy"
     52///////////////////////////////////////////////////////////////////////////////
     53static
     54unsigned int _mmc_get_register( unsigned int cluster_xy, // cluster index
     55                                unsigned int func,       // function index
     56                                unsigned int index )     // register index
     57{
     58    unsigned int vaddr =
     59        SEG_MMC_BASE +
     60        (cluster_xy * PERI_CLUSTER_INCREMENT) +
     61        (MMC_REG(func, index) << 2);
     62
     63    return ioread32( (void*)vaddr );
     64}
     65
     66///////////////////////////////////////////////////////////////////////////////
     67// This low level function sets a new value in register "index"
     68// in the MMC component contained in cluster "cluster_xy"
     69///////////////////////////////////////////////////////////////////////////////
     70static
     71void _mmc_set_register( unsigned int cluster_xy,       // cluster index
     72                        unsigned int func,             // func index
     73                        unsigned int index,            // register index
     74                        unsigned int value )           // value to be written
     75{
     76    unsigned int vaddr =
     77        SEG_MMC_BASE +
     78        (cluster_xy * PERI_CLUSTER_INCREMENT) +
     79        (MMC_REG(func, index) << 2);
     80       
     81    iowrite32( (void*)vaddr, value );
     82}
     83
    4884///////////////////////////////////////////////////////////////////////////////////
    4985// This function invalidates all cache lines covering a memory buffer defined
     
    67103    }
    68104
    69     unsigned int* mmc_address = (unsigned int*)( SEG_MMC_BASE +
    70                                 (cluster_xy * PERI_CLUSTER_INCREMENT) );
    71 
    72105    // get the hard lock protecting exclusive access to MEMC
    73     while ( mmc_address[MEMC_LOCK] ) { asm volatile("nop"); }
     106    while ( _mmc_get_register(cluster_xy, 0, MEMC_LOCK) );
    74107
    75108    // write inval arguments
    76     mmc_address[MEMC_ADDR_LO]    = (unsigned int)buf_paddr;
    77     mmc_address[MEMC_ADDR_HI]    = (unsigned int)(buf_paddr>>32);
    78     mmc_address[MEMC_BUF_LENGTH] = buf_length;
    79     mmc_address[MEMC_CMD_TYPE]   = MEMC_CMD_INVAL;
     109    _mmc_set_register(cluster_xy, 0, MEMC_ADDR_LO   , (unsigned int)buf_paddr);
     110    _mmc_set_register(cluster_xy, 0, MEMC_ADDR_HI   , (unsigned int)(buf_paddr>>32));
     111    _mmc_set_register(cluster_xy, 0, MEMC_BUF_LENGTH, buf_length);
     112    _mmc_set_register(cluster_xy, 0, MEMC_CMD_TYPE  , MEMC_CMD_INVAL);
    80113
    81114    // release the lock
    82     mmc_address[MEMC_LOCK] = 0;
     115    _mmc_set_register(cluster_xy, 0, MEMC_LOCK, 0);
    83116}
    84117///////////////////////////////////////////////////////////////////////////////////
     
    103136    }
    104137
    105     unsigned int* mmc_address = (unsigned int*)( SEG_MMC_BASE +
    106                                 (cluster_xy * PERI_CLUSTER_INCREMENT) );
    107 
    108138    // get the hard lock protecting exclusive access to MEMC
    109     while ( mmc_address[MEMC_LOCK] ) { asm volatile("nop"); }
     139    while ( _mmc_get_register(cluster_xy, 0, MEMC_LOCK) );
    110140
    111141    // write inval arguments
    112     mmc_address[MEMC_ADDR_LO]    = (unsigned int)buf_paddr;
    113     mmc_address[MEMC_ADDR_HI]    = (unsigned int)(buf_paddr>>32);
    114     mmc_address[MEMC_BUF_LENGTH] = buf_length;
    115     mmc_address[MEMC_CMD_TYPE]   = MEMC_CMD_SYNC;
     142    _mmc_set_register(cluster_xy, 0, MEMC_ADDR_LO   , (unsigned int)buf_paddr);
     143    _mmc_set_register(cluster_xy, 0, MEMC_ADDR_HI   , (unsigned int)(buf_paddr>>32));
     144    _mmc_set_register(cluster_xy, 0, MEMC_BUF_LENGTH, buf_length);
     145    _mmc_set_register(cluster_xy, 0, MEMC_CMD_TYPE  , MEMC_CMD_SYNC);
    116146
    117     // release the lock protecting MEMC
    118     mmc_address[MEMC_LOCK] = 0;
     147    // release the lock
     148    _mmc_set_register(cluster_xy, 0, MEMC_LOCK, 0);
    119149}
    120150
Note: See TracChangeset for help on using the changeset viewer.