ia64/xen-unstable

view linux-2.4.29-xen-sparse/include/asm-xen/synch_bitops.h @ 3887:4385894c52ae

bitkeeper revision 1.1230.2.4 (421a95cepOZORm0EbZfqBeZ6PZ8MwA)

Merge freefall.cl.cam.ac.uk:/auto/groups/xeno/users/cl349/BK/xen-unstable.bk
into freefall.cl.cam.ac.uk:/auto/groups/xeno-xenod/BK/xen-unstable.bk
author iap10@freefall.cl.cam.ac.uk
date Tue Feb 22 02:15:42 2005 +0000 (2005-02-22)
parents 0a4b76b6b5a0
children
line source
1 #ifndef __XEN_SYNCH_BITOPS_H__
2 #define __XEN_SYNCH_BITOPS_H__
4 /*
5 * Copyright 1992, Linus Torvalds.
6 * Heavily modified to provide guaranteed strong synchronisation
7 * when communicating with Xen or other guest OSes running on other CPUs.
8 */
10 #include <linux/config.h>
12 #define ADDR (*(volatile long *) addr)
14 static __inline__ void synch_set_bit(int nr, volatile void * addr)
15 {
16 __asm__ __volatile__ (
17 "lock btsl %1,%0"
18 : "=m" (ADDR) : "Ir" (nr) : "memory" );
19 }
21 static __inline__ void synch_clear_bit(int nr, volatile void * addr)
22 {
23 __asm__ __volatile__ (
24 "lock btrl %1,%0"
25 : "=m" (ADDR) : "Ir" (nr) : "memory" );
26 }
28 static __inline__ void synch_change_bit(int nr, volatile void * addr)
29 {
30 __asm__ __volatile__ (
31 "lock btcl %1,%0"
32 : "=m" (ADDR) : "Ir" (nr) : "memory" );
33 }
35 static __inline__ int synch_test_and_set_bit(int nr, volatile void * addr)
36 {
37 int oldbit;
38 __asm__ __volatile__ (
39 "lock btsl %2,%1\n\tsbbl %0,%0"
40 : "=r" (oldbit), "=m" (ADDR) : "Ir" (nr) : "memory");
41 return oldbit;
42 }
44 static __inline__ int synch_test_and_clear_bit(int nr, volatile void * addr)
45 {
46 int oldbit;
47 __asm__ __volatile__ (
48 "lock btrl %2,%1\n\tsbbl %0,%0"
49 : "=r" (oldbit), "=m" (ADDR) : "Ir" (nr) : "memory");
50 return oldbit;
51 }
53 static __inline__ int synch_test_and_change_bit(int nr, volatile void * addr)
54 {
55 int oldbit;
57 __asm__ __volatile__ (
58 "lock btcl %2,%1\n\tsbbl %0,%0"
59 : "=r" (oldbit), "=m" (ADDR) : "Ir" (nr) : "memory");
60 return oldbit;
61 }
63 static __inline__ int synch_const_test_bit(int nr, const volatile void * addr)
64 {
65 return ((1UL << (nr & 31)) &
66 (((const volatile unsigned int *) addr)[nr >> 5])) != 0;
67 }
69 static __inline__ int synch_var_test_bit(int nr, volatile void * addr)
70 {
71 int oldbit;
72 __asm__ __volatile__ (
73 "btl %2,%1\n\tsbbl %0,%0"
74 : "=r" (oldbit) : "m" (ADDR), "Ir" (nr) );
75 return oldbit;
76 }
78 #define synch_test_bit(nr,addr) \
79 (__builtin_constant_p(nr) ? \
80 synch_const_test_bit((nr),(addr)) : \
81 synch_var_test_bit((nr),(addr)))
83 #endif /* __XEN_SYNCH_BITOPS_H__ */