source: branches/fault_tolerance/softs/test_llsc/scripts/functions.c @ 728

Last change on this file since 728 was 724, checked in by cfuguet, 10 years ago

branches/fault_tolerance:

  • Recreating fault_tolerance branch with all new modifications from trunk.
  • Introducing distributed boot rom in the tsar_generic_iob platform
File size: 791 bytes
Line 
1
2#include "functions.h"
3
4void take_lock(volatile int * plock) {
5   volatile int * _plock = plock;
6   __asm__ __volatile__ (
7      "move $16, %0                   \n"
8      "giet_lock_try :                \n"
9      "lw   $2,    0($16)             \n"
10      "ll   $2,    0($16)             \n"
11      "bnez $2,    giet_lock_try      \n"
12      "li   $3,    1                  \n"
13      "sc   $3,    0($16)             \n"
14      "beqz $3,    giet_lock_try      \n"
15      "nop                            \n"
16      "giet_lock_ok:                  \n"
17      "nop                            \n"
18      :                               
19      :"r" (_plock)                 
20      :"$2", "$3", "$4", "$16");
21}
22
23
24void release_lock(volatile int * plock) {
25   asm volatile("\tsync\n");
26   *plock = 0;
27}
28
29
Note: See TracBrowser for help on using the repository browser.