Ignore:
Timestamp:
Aug 7, 2012, 6:37:49 PM (12 years ago)
Author:
alain
Message:

Introducing a new release where all initialisation
is done in the boot code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/libs/spin_lock.c

    r178 r189  
    1010// It is a simple binary lock, without waiting queue.
    1111//
    12 // The lock_acquire(), lock_try_acquire() and lock_release() functions do
    13 // not require a system call.
     12// The lock_acquire() and lock_release() functions do not require a system call.
     13// The barrier itself must have been allocated in a non cacheable segment,
     14// if the platform does not provide hardwate cache coherence.
    1415//
    1516// ALL locks must be defined in the mapping_info data structure,
    1617// to be initialised by the GIET in the boot phase.
    1718// The vobj_get_vbase() system call (defined in stdio.c and stdio.h files)
    18 // can be used to get the virtual base address of the lock from it's name.
     19// can be used to get the virtual base address of the lock fro it's name.
    1920///////////////////////////////////////////////////////////////////////////////////
    2021
     
    6465}
    6566
    66 //////////////////////////////////////////////////////////////////////////////
    67 // lock_try_acquire()
    68 //////////////////////////////////////////////////////////////////////////////
    69 int lock_try_acquire( giet_lock_t* lock )
    70 {
    71         register int ret = 0;   
    72     register unsigned int*      plock = &lock->value;
    73 
    74         asm volatile ("ll   $2,    0(%1)                    \n" // $2 <= _locks_lock
    75                   "bnez $2,    _lock_done           \n" // exitif busy
    76                   "li   $3,    1                            \n" // prepare argument for sc 
    77                   "sc   $3,    0(%1)                \n" // try to set _locks_busy
    78                   "xori %0, $3, 1                   \n" // ret = !$3
    79                   "_lock_done:                          \n"
    80                   :"=r"(ret)
    81                   :"r"(plock)
    82                   :"$2","$3");
    83     return ret;
    84 }
Note: See TracChangeset for help on using the changeset viewer.