- Timestamp:
- Jul 18, 2015, 3:18:32 PM (9 years ago)
- Location:
- soft/giet_vm/giet_common
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_common/kernel_locks.c
r495 r632 26 26 "ll $12, 0($10) \n" /* $12 <= *ptr */ 27 27 "addu $13, $11, $12 \n" /* $13 <= *ptr + increment */ 28 "sc $13, 0($10) \n" /* M[ptr] <= new*/28 "sc $13, 0($10) \n" /* *ptr <= $12 */ 29 29 "beqz $13, 1234b \n" /* retry if failure */ 30 30 "move %0, $12 \n" /* value <= *ptr if success */ … … 34 34 35 35 return value; 36 } 37 38 //////////////////////////////////// 39 void _atomic_or( unsigned int* ptr, 40 unsigned int mask ) 41 { 42 asm volatile ( 43 "1789: \n" 44 "move $10, %0 \n" /* $10 <= ptr */ 45 "move $11, %1 \n" /* $11 <= mask */ 46 "ll $12, 0($10) \n" /* $12 <= *ptr */ 47 "or $12, $11, $12 \n" /* $12 <= *ptr | mask */ 48 "sc $12, 0($10) \n" /* *ptr <= $12 */ 49 "beqz $12, 1789b \n" /* retry if failure */ 50 "nop \n" 51 : 52 : "r" (ptr), "r" (mask) 53 : "$10", "$11", "$12", "memory" ); 54 } 55 56 //////////////////////////////////// 57 void _atomic_and( unsigned int* ptr, 58 unsigned int mask ) 59 { 60 asm volatile ( 61 "1945: \n" 62 "move $10, %0 \n" /* $10 <= ptr */ 63 "move $11, %1 \n" /* $11 <= mask */ 64 "ll $12, 0($10) \n" /* $12 <= *ptr */ 65 "and $12, $11, $12 \n" /* $13 <= *ptr & mask */ 66 "sc $12, 0($10) \n" /* *ptr <= new */ 67 "beqz $12, 1945b \n" /* retry if failure */ 68 "nop \n" 69 : 70 : "r" (ptr), "r" (mask) 71 : "$10", "$11", "$12", "memory" ); 36 72 } 37 73 -
soft/giet_vm/giet_common/kernel_locks.h
r523 r632 13 13 14 14 #include "hard_config.h" 15 16 17 ////////////////////////////////////////////////////////////////////////////// 18 // Atomic access functions using LL/SC instructions 19 ////////////////////////////////////////////////////////////////////////////// 20 21 extern unsigned int _atomic_increment( unsigned int* ptr, 22 int increment ); 23 24 extern void _atomic_or( unsigned int* ptr, 25 unsigned int mask ); 26 27 extern void _atomic_and( unsigned int* ptr, 28 unsigned int mask ); 15 29 16 30 ////////////////////////////////////////////////////////////////////////////// … … 38 52 unsigned int padding[14]; // for 64 bytes alignment 39 53 } spin_lock_t; 40 41 extern unsigned int _atomic_increment( unsigned int* ptr,42 int increment );43 54 44 55 extern void _spin_lock_init( spin_lock_t* lock );
Note: See TracChangeset
for help on using the changeset viewer.