#ifndef KERNEL_LOCKS_H_ #define KERNEL_LOCKS_H_ #include #include #ifdef __cplusplus extern "C" { #endif typedef __aligned(8) ml_hwlock_t spin_lock_t; #define SPIN_LOCK_INIT ML_HWLOCK_INIT #define spin_lock(lck) ml_hwlock_lock(lck); #define spin_unlock(lck) ml_hwlock_unlock(lck); #define spin_lock_irq(lck) ml_hwlock_lock_irq(lck); #define spin_unlock_irq(lck) ml_hwlock_unlock_irq(lck); #define spin_lock_irqsave(lck, flags) ml_hwlock_lock_irqsave(lck, flags); #define spin_unlock_irqrestore(lck, flags) \ ml_hwlock_unlock_irqrestore(lck, flags); static inline void spin_lock_pair_irqsave( spin_lock_t *a, spin_lock_t *b, unsigned long *flags) { if (a == b) { spin_lock_irqsave(a, flags); } else if (a < b) { spin_lock_irqsave(a, flags); spin_lock(b); } else { spin_lock_irqsave(b, flags); spin_lock(a); } } static inline void spin_unlock_pair_irqrestore( spin_lock_t *a, spin_lock_t *b, unsigned long flags) { if (a == b) { spin_unlock_irqrestore(a, flags); } else if (a < b) { spin_unlock(b); spin_unlock_irqrestore(a, flags); } else { spin_unlock(a); spin_unlock_irqrestore(b, flags); } } #ifdef __cplusplus } #endif #endif