1/* 2 * <asm/smplock.h> 3 * 4 * Default SMP lock implementation 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version 9 * 2 of the License, or (at your option) any later version. 10 */ 11#include <linux/interrupt.h> 12#include <linux/spinlock.h> 13 14extern spinlock_t kernel_flag; 15 16#define kernel_locked() spin_is_locked(&kernel_flag) 17 18/* 19 * Release global kernel lock and global interrupt lock 20 */ 21#define release_kernel_lock(task, cpu) \ 22do { \ 23 if (task->lock_depth >= 0) \ 24 spin_unlock(&kernel_flag); \ 25 release_irqlock(cpu); \ 26 __sti(); \ 27} while (0) 28 29/* 30 * Re-acquire the kernel lock 31 */ 32#define reacquire_kernel_lock(task) \ 33do { \ 34 if (task->lock_depth >= 0) \ 35 spin_lock(&kernel_flag); \ 36} while (0) 37 38 39/* 40 * Getting the big kernel lock. 41 * 42 * This cannot happen asynchronously, 43 * so we only need to worry about other 44 * CPU's. 45 */ 46static inline void lock_kernel(void) 47{ 48 if (!++current->lock_depth) 49 spin_lock(&kernel_flag); 50} 51 52static inline void unlock_kernel(void) 53{ 54 if (--current->lock_depth < 0) 55 spin_unlock(&kernel_flag); 56} 57