source: trunk/softs/test_llsc/scripts/functions.c @ 536

Last change on this file since 536 was 536, checked in by meunier, 11 years ago

Added a tool which generates tests for the LL/SC table, in the soft/ directory.

File size: 749 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      "ll   $2,    0($16)             \n"
10      "bnez $2,    giet_lock_try      \n"
11      "li   $3,    1                  \n"
12      "sc   $3,    0($16)             \n"
13      "beqz $3,    giet_lock_try      \n"
14      "nop                            \n"
15      "giet_lock_ok:                  \n"
16      "nop                            \n"
17      :                               
18      :"r" (_plock)                 
19      :"$2", "$3", "$4", "$16");
20}
21
22
23void release_lock(volatile int * plock) {
24   asm volatile("\tsync\n");
25   *plock = 0;
26}
27
28
Note: See TracBrowser for help on using the repository browser.