2005-07-28 02:44:44 +08:00
|
|
|
#ifndef __ASM_CRIS_ARCH_ATOMIC__
|
|
|
|
#define __ASM_CRIS_ARCH_ATOMIC__
|
|
|
|
|
2008-01-28 23:53:19 +08:00
|
|
|
#include <linux/spinlock_types.h>
|
2005-07-28 02:44:44 +08:00
|
|
|
|
|
|
|
extern void cris_spin_unlock(void *l, int val);
|
|
|
|
extern void cris_spin_lock(void *l);
|
|
|
|
extern int cris_spin_trylock(void* l);
|
|
|
|
|
|
|
|
#ifndef CONFIG_SMP
|
|
|
|
#define cris_atomic_save(addr, flags) local_irq_save(flags);
|
|
|
|
#define cris_atomic_restore(addr, flags) local_irq_restore(flags);
|
|
|
|
#else
|
|
|
|
|
|
|
|
extern spinlock_t cris_atomic_locks[];
|
|
|
|
#define LOCK_COUNT 128
|
|
|
|
#define HASH_ADDR(a) (((int)a) & 127)
|
|
|
|
|
|
|
|
#define cris_atomic_save(addr, flags) \
|
|
|
|
local_irq_save(flags); \
|
2008-01-28 23:53:19 +08:00
|
|
|
cris_spin_lock((void *)&cris_atomic_locks[HASH_ADDR(addr)].raw_lock.slock);
|
2005-07-28 02:44:44 +08:00
|
|
|
|
|
|
|
#define cris_atomic_restore(addr, flags) \
|
|
|
|
{ \
|
|
|
|
spinlock_t *lock = (void*)&cris_atomic_locks[HASH_ADDR(addr)]; \
|
|
|
|
__asm__ volatile ("move.d %1,%0" \
|
2008-01-28 23:53:19 +08:00
|
|
|
: "=m" (lock->raw_lock.slock) \
|
|
|
|
: "r" (1) \
|
|
|
|
: "memory"); \
|
2005-07-28 02:44:44 +08:00
|
|
|
local_irq_restore(flags); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|