1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License.  See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Default SMP lock implementation
7 */
8#include <linux/interrupt.h>
9#include <linux/spinlock.h>
10
11extern spinlock_t kernel_flag;
12
13#define kernel_locked()		spin_is_locked(&kernel_flag)
14
15/*
16 * Release global kernel lock and global interrupt lock
17 */
18#define release_kernel_lock(task, cpu) \
19do { \
20	if (task->lock_depth >= 0) \
21		spin_unlock(&kernel_flag); \
22	release_irqlock(cpu); \
23	__sti(); \
24} while (0)
25
26/*
27 * Re-acquire the kernel lock
28 */
29#define reacquire_kernel_lock(task) \
30do { \
31	if (task->lock_depth >= 0) \
32		spin_lock(&kernel_flag); \
33} while (0)
34
35
36/*
37 * Getting the big kernel lock.
38 *
39 * This cannot happen asynchronously,
40 * so we only need to worry about other
41 * CPU's.
42 */
43extern __inline__ void lock_kernel(void)
44{
45	if (!++current->lock_depth)
46		spin_lock(&kernel_flag);
47}
48
49extern __inline__ void unlock_kernel(void)
50{
51	if (--current->lock_depth < 0)
52		spin_unlock(&kernel_flag);
53}
54