| Line | |
|---|
| 1 | #ifndef __ASM_SPINLOCK_H |
|---|
| 2 | #define __ASM_SPINLOCK_H |
|---|
| 3 | |
|---|
| 4 | #include <lib.h> |
|---|
| 5 | |
|---|
| 6 | /* |
|---|
| 7 | * Your basic SMP spinlocks, allowing only a single CPU anywhere |
|---|
| 8 | */ |
|---|
| 9 | |
|---|
| 10 | typedef struct { |
|---|
| 11 | volatile unsigned int slock; |
|---|
| 12 | } spinlock_t; |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | #include "arch_spinlock.h" |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | #define SPINLOCK_MAGIC 0xdead4ead |
|---|
| 19 | |
|---|
| 20 | #define SPIN_LOCK_UNLOCKED ARCH_SPIN_LOCK_UNLOCKED |
|---|
| 21 | |
|---|
| 22 | #define spin_lock_init(x) do { *(x) = SPIN_LOCK_UNLOCKED; } while(0) |
|---|
| 23 | |
|---|
| 24 | /* |
|---|
| 25 | * Simple spin lock operations. There are two variants, one clears IRQ's |
|---|
| 26 | * on the local processor, one does not. |
|---|
| 27 | * |
|---|
| 28 | * We make no fairness assumptions. They have a cost. |
|---|
| 29 | */ |
|---|
| 30 | |
|---|
| 31 | #define spin_is_locked(x) arch_spin_is_locked(x) |
|---|
| 32 | |
|---|
| 33 | #define spin_unlock_wait(x) do { barrier(); } while(spin_is_locked(x)) |
|---|
| 34 | |
|---|
| 35 | |
|---|
| 36 | #define _spin_trylock(lock) ({_raw_spin_trylock(lock) ? \ |
|---|
| 37 | 1 : ({ 0;});}) |
|---|
| 38 | |
|---|
| 39 | #define _spin_lock(lock) \ |
|---|
| 40 | do { \ |
|---|
| 41 | _raw_spin_lock(lock); \ |
|---|
| 42 | } while(0) |
|---|
| 43 | |
|---|
| 44 | #define _spin_unlock(lock) \ |
|---|
| 45 | do { \ |
|---|
| 46 | _raw_spin_unlock(lock); \ |
|---|
| 47 | } while (0) |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | #define spin_lock(lock) _spin_lock(lock) |
|---|
| 51 | #define spin_unlock(lock) _spin_unlock(lock) |
|---|
| 52 | |
|---|
| 53 | #define DEFINE_SPINLOCK(x) spinlock_t x = SPIN_LOCK_UNLOCKED |
|---|
| 54 | |
|---|
| 55 | #endif |
|---|
Note: See
TracBrowser
for help on using the repository browser.