Ignore:
Timestamp:
Feb 8, 2015, 12:55:35 PM (10 years ago)
Author:
alain
Message:

Introduce quad tree for distributed locks and barriers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/giet_common/tty0.c

    r466 r495  
    1313#include <tty_driver.h>
    1414#include <utils.h>
    15 #include <locks.h>
     15#include <kernel_locks.h>
     16
     17/////////////////////////////////////////////////////////////////////////////
     18// The global variable tty0_boot_mode define the type of lock used,
     19// and must be defined in both kernel_init.c and boot.c files.
     20// - the boot code must use a spin_lock because the kernel heap is not set.
     21// - the kernel code can use a sqt_lock when the kernel heap is set.
     22/////////////////////////////////////////////////////////////////////////////
     23
     24extern unsigned int  _tty0_boot_mode;
     25
     26__attribute__((section(".kdata")))
     27sqt_lock_t           _tty0_sqt_lock  __attribute__((aligned(64))); 
     28
     29__attribute__((section(".kdata")))
     30spin_lock_t          _tty0_spin_lock  __attribute__((aligned(64)));
    1631
    1732//////////////////////////////////////////////
     
    2035{
    2136    unsigned int n;
     37    unsigned int k;
    2238
    2339    for ( n = 0 ; n < nbytes ; n++ )
    2440    {
    25         // return error if TTY_TX buffer full
    26         if ( (_tty_get_register( 0, TTY_STATUS ) & 0x2) ) return 1;
     41        // test TTY_TX buffer full
     42        if ( (_tty_get_register( 0, TTY_STATUS ) & 0x2) ) // buffer full
     43        {
     44            // retry if full
     45            for( k = 0 ; k < 10000 ; k++ )
     46            {
     47                if ( (_tty_get_register( 0, TTY_STATUS ) & 0x2) == 0) break;
     48            }
     49            // return error if full after 10000 retry
     50            return 1;
     51        }
    2752
    2853        // write one byte
     
    240265        unsigned int lpid       = procid & ((1<<P_WIDTH)-1);
    241266        _puts("\n\n[GIET ERROR] in _printf() for processor[");
    242         _putd( x );
     267        _putd( x ); 
    243268        _puts(",");
    244269        _putd( y );
     
    268293    // get TTY0 lock
    269294    _it_disable( &save_sr );
    270     _sbt_lock_acquire( &_tty_tx_lock[0] );
     295    if ( _tty0_boot_mode ) _spin_lock_acquire( &_tty0_spin_lock );
     296    else                   _sqt_lock_acquire( &_tty0_sqt_lock );
    271297
    272298    va_start( args , format );
     
    275301
    276302    // release TTY0 lock
    277     _sbt_lock_release( &_tty_tx_lock[0] );
     303    if ( _tty0_boot_mode ) _spin_lock_release( &_tty0_spin_lock );
     304    else                   _sqt_lock_release( &_tty0_sqt_lock );
    278305    _it_restore( &save_sr );
    279306}
Note: See TracChangeset for help on using the changeset viewer.