diff options
author | kfraser@localhost.localdomain <kfraser@localhost.localdomain> | 2006-11-17 09:18:28 +0000 |
---|---|---|
committer | kfraser@localhost.localdomain <kfraser@localhost.localdomain> | 2006-11-17 09:18:28 +0000 |
commit | 4fa75a7c3b58f11b028905f6a1d3af3c871b4b7a (patch) | |
tree | dc131e6798a5409440ff08fae58e2baa205072c6 /extras | |
parent | 5d3a4a385800111da6ea0b6e607685c0c42a37fa (diff) | |
download | xen-4fa75a7c3b58f11b028905f6a1d3af3c871b4b7a.tar.gz xen-4fa75a7c3b58f11b028905f6a1d3af3c871b4b7a.tar.bz2 xen-4fa75a7c3b58f11b028905f6a1d3af3c871b4b7a.zip |
[MINIOS] Refactor spinlock header for multi-arch support.
I separated the spinlock parts special to the x86 architecture and
moved these to include/x86/arch_spinlock.h. The common code is now in
include/spinlock.h.
Signed-off-by: Dietmar Hahn <dietmar.hahn@fujitsu-siemens.com>
Diffstat (limited to 'extras')
-rw-r--r-- | extras/mini-os/include/spinlock.h | 55 | ||||
-rw-r--r-- | extras/mini-os/include/x86/arch_spinlock.h (renamed from extras/mini-os/include/x86/spinlock.h) | 38 |
2 files changed, 60 insertions, 33 deletions
diff --git a/extras/mini-os/include/spinlock.h b/extras/mini-os/include/spinlock.h new file mode 100644 index 0000000000..ecfe73627e --- /dev/null +++ b/extras/mini-os/include/spinlock.h @@ -0,0 +1,55 @@ +#ifndef __ASM_SPINLOCK_H +#define __ASM_SPINLOCK_H + +#include <lib.h> + +/* + * Your basic SMP spinlocks, allowing only a single CPU anywhere + */ + +typedef struct { + volatile unsigned int slock; +} spinlock_t; + + +#include "arch_spinlock.h" + + +#define SPINLOCK_MAGIC 0xdead4ead + +#define SPIN_LOCK_UNLOCKED ARCH_SPIN_LOCK_UNLOCKED + +#define spin_lock_init(x) do { *(x) = SPIN_LOCK_UNLOCKED; } while(0) + +/* + * Simple spin lock operations. There are two variants, one clears IRQ's + * on the local processor, one does not. + * + * We make no fairness assumptions. They have a cost. + */ + +#define spin_is_locked(x) arch_spin_is_locked(x) + +#define spin_unlock_wait(x) do { barrier(); } while(spin_is_locked(x)) + + +#define _spin_trylock(lock) ({_raw_spin_trylock(lock) ? \ + 1 : ({ 0;});}) + +#define _spin_lock(lock) \ +do { \ + _raw_spin_lock(lock); \ +} while(0) + +#define _spin_unlock(lock) \ +do { \ + _raw_spin_unlock(lock); \ +} while (0) + + +#define spin_lock(lock) _spin_lock(lock) +#define spin_unlock(lock) _spin_unlock(lock) + +#define DEFINE_SPINLOCK(x) spinlock_t x = SPIN_LOCK_UNLOCKED + +#endif diff --git a/extras/mini-os/include/x86/spinlock.h b/extras/mini-os/include/x86/arch_spinlock.h index 4274cd2869..a181ed3c92 100644 --- a/extras/mini-os/include/x86/spinlock.h +++ b/extras/mini-os/include/x86/arch_spinlock.h @@ -1,21 +1,12 @@ -#ifndef __ASM_SPINLOCK_H -#define __ASM_SPINLOCK_H -#include <lib.h> - -/* - * Your basic SMP spinlocks, allowing only a single CPU anywhere - */ -typedef struct { - volatile unsigned int slock; -} spinlock_t; +#ifndef __ARCH_ASM_SPINLOCK_H +#define __ARCH_ASM_SPINLOCK_H -#define SPINLOCK_MAGIC 0xdead4ead +#include <lib.h> -#define SPIN_LOCK_UNLOCKED (spinlock_t) { 1 } -#define spin_lock_init(x) do { *(x) = SPIN_LOCK_UNLOCKED; } while(0) +#define ARCH_SPIN_LOCK_UNLOCKED (spinlock_t) { 1 } /* * Simple spin lock operations. There are two variants, one clears IRQ's @@ -24,7 +15,7 @@ typedef struct { * We make no fairness assumptions. They have a cost. */ -#define spin_is_locked(x) (*(volatile signed char *)(&(x)->slock) <= 0) +#define arch_spin_is_locked(x) (*(volatile signed char *)(&(x)->slock) <= 0) #define spin_unlock_wait(x) do { barrier(); } while(spin_is_locked(x)) #define spin_lock_string \ @@ -99,23 +90,4 @@ static inline void _raw_spin_lock_flags (spinlock_t *lock, unsigned long flags) :"=m" (lock->slock) : "r" (flags) : "memory"); } -#define _spin_trylock(lock) ({_raw_spin_trylock(lock) ? \ - 1 : ({ 0;});}) - -#define _spin_lock(lock) \ -do { \ - _raw_spin_lock(lock); \ -} while(0) - -#define _spin_unlock(lock) \ -do { \ - _raw_spin_unlock(lock); \ -} while (0) - - -#define spin_lock(lock) _spin_lock(lock) -#define spin_unlock(lock) _spin_unlock(lock) - -#define DEFINE_SPINLOCK(x) spinlock_t x = SPIN_LOCK_UNLOCKED - #endif |