This source file includes following definitions.
- ldstub
- lock_kernel
- unlock_kernel
1
2
3
4
5
6 #ifndef __SPARC_SMPLOCK_H
7 #define __SPARC_SMPLOCK_H
8
9 #ifdef __SMP__
10
11 extern _inline_ unsigned char ldstub(klock_t *lock)
12 {
13 klock_t retval;
14
15 __asm__ __volatile__("ldstub [%1], %0\n\t" :
16 "=r" (retval) :
17 "r" (lock));
18 return retval;
19 }
20
21
22 extern _inline_ void lock_kernel(void)
23 {
24 unsigned long flags;
25 int proc = smp_processor_id();
26
27 save_flags(flags); cli();
28 while(ldstub(&kernel_lock)) {
29 if(proc == active_kernel_processor)
30 break;
31 if(test_bit(proc, (unsigned long *)&smp_invalidate_needed))
32 if(clear_bit(proc, (unsigned long *)&smp_invalidate_needed))
33 local_invalidate();
34 }
35 active_kernel_processor = proc;
36 kernel_counter++;
37 restore_flags(flags);
38 }
39
40
41 extern _inline_ void unlock_kernel(void)
42 {
43 unsigned long flags;
44
45 save_flags(flags); cli();
46 if(kernel_counter == 0)
47 panic("Bogus kernel counter.\n");
48 if(!--kernel_counter) {
49 active_kernel_processor = NO_PROC_ID;
50 kernel_lock = KLOCK_CLEAR;
51 }
52 restore_flag(flags);
53 }
54
55 #endif
56
57 #endif