Changeset 810 for trunk/softs/giet_tsar


Ignore:
Timestamp:
Sep 19, 2014, 2:53:18 PM (10 years ago)
Author:
cfuguet
Message:

giet_tsar: updating giet_tsar to use new hard_config format

Other optimizations:

  • Using a memory lock instead of the hard lock for the TTY
  • Each tty channel data is aligned to a cacheline (lock and buffers).
  • The applications' ldscript is generated from a template which includes the hard_config.h file.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/softs/giet_tsar/stdio.c

    r744 r810  
    7272#define in_drivers __attribute__((section (".drivers")))
    7373#define in_unckdata __attribute__((section (".unckdata")))
     74#define cacheline_aligned __attribute__((aligned(64)))
    7475
    7576//////////////////////////////////////////////////////////////
     
    9293static in_unckdata int volatile  _ioc_status;
    9394
    94 static in_unckdata char volatile _tty_get_buf[NB_TTY_CHANNELS];
    95 static in_unckdata int volatile  _tty_get_full[NB_TTY_CHANNELS] = { [0 ... NB_TTY_CHANNELS-1] = 0 };
     95static volatile in_unckdata struct cacheline_aligned {
     96    int  lock;
     97    int  get_full;
     98    char get_buf;
     99    char __padding[55];
     100} _tty_channel[NB_TTY_CHANNELS];
    96101
    97102////////////////////////////////////////////////////////////////////////////////////////
     
    141146in_drivers void  _extended_memcpy( unsigned int dst_cluster,
    142147                                   unsigned int dst_address,
     148                                   unsigned int src_cluster,
    143149                                   unsigned int src_address,
    144150                                   unsigned int length )
     
    157163    for ( i = 0 ; i < length ; i = i+4 )
    158164    {
    159         word = _word_extended_read( src_cluster, (src_address + i) );
    160         _word_extended_write( dst_cluster, (dst_address + i), word );
     165        word = _word_extended_read( src_cluster, src_address + i );
     166        _word_extended_write( dst_cluster, dst_address + i, word );
    161167    }
    162168}
     
    545551in_drivers void _tty_get_lock( unsigned int channel )
    546552{
    547     unsigned int base = (unsigned int)&seg_tty_base;
    548     unsigned int offset = (TTY_CONFIG + channel*TTY_SPAN) << 2;
    549     while ( _word_extended_read( CLUSTER_IO, base + offset ) );
     553    register unsigned int* plock = (unsigned int*)&_tty_channel[channel].lock;
     554
     555    asm volatile (
     556            "1:                         \n"
     557            "ll     $2,     0(%0)       \n" // $2 <= _tty_lock
     558            "bnez   $2,     1b          \n" // retry  if busy
     559            "li     $3,     1           \n" // prepare argument for sc
     560            "sc     $3,     0(%0)       \n" // try to set _tty_busy
     561            "beqz   $3,     1b          \n" // retry if not atomic
     562            ::"r"(plock) :"$2","$3");
    550563}
    551564
     
    556569in_drivers void _tty_release_lock( unsigned int channel )
    557570{
    558     unsigned int base    = (unsigned int)&seg_tty_base;
    559     unsigned int offset  = (TTY_CONFIG + channel*TTY_SPAN) << 2;
    560     _word_extended_write( CLUSTER_IO, base + offset, 0 );
     571    _tty_channel[channel].lock = 0;
    561572}
    562573
     
    813824    unsigned int offset = (index*TTY_SPAN + TTY_READ) << 2;
    814825
    815     _tty_get_buf[index] = _byte_extended_read(CLUSTER_IO, base + offset);
    816     _tty_get_full[index] = 1;               // signals character available
     826    _tty_channel[index].get_buf = _byte_extended_read(CLUSTER_IO, base + offset);
     827    _tty_channel[index].get_full = 1;               // signals character available
    817828}
    818829
     
    872883// reset the _ioc_done variable to zero, and releases the _ioc_lock variable.
    873884///////////////////////////////////////////////////////////////////////////////////////
    874 //  If USE_RAMDISK is set, we access a "virtual" block device controler implemented
     885//  If USE_IOC_RDK is set, we access a "virtual" block device controler implemented
    875886//  as a memory-mapped segment in cluster [0,0] at address seg_ramdisk_base.
    876887//  The tranfer being fully synchronous, the IOC interrupt is not activated.
     
    910921    _ioc_get_lock();
    911922
    912     if ( USE_RAMDISK )  // we use an extended_memcpy
     923    if ( USE_IOC_RDK )  // we use an extended_memcpy
    913924    {
    914925        unsigned int  src_address = (unsigned int)buffer;
     
    953964    _ioc_get_lock();
    954965
    955     if ( USE_RAMDISK )  // we use an extended_memcpy
     966    if ( USE_IOC_RDK )  // we use an extended_memcpy
    956967    {
    957968        unsigned int  dst_address = (unsigned int)buffer;
Note: See TracChangeset for help on using the changeset viewer.