]> bbs.cooldavid.org Git - net-next-2.6.git/blame - arch/sparc/lib/bitops.S
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[net-next-2.6.git] / arch / sparc / lib / bitops.S
CommitLineData
24f287e4 1/* bitops.S: Sparc64 atomic bit operations.
1da177e4 2 *
24f287e4 3 * Copyright (C) 2000, 2007 David S. Miller (davem@davemloft.net)
1da177e4
LT
4 */
5
1da177e4 6#include <asm/asi.h>
24f287e4 7#include <asm/backoff.h>
1da177e4 8
b445e26c
DM
9 .text
10
1da177e4
LT
11 .globl test_and_set_bit
12 .type test_and_set_bit,#function
13test_and_set_bit: /* %o0=nr, %o1=addr */
24f287e4 14 BACKOFF_SETUP(%o3)
1da177e4
LT
15 srlx %o0, 6, %g1
16 mov 1, %o2
17 sllx %g1, 3, %g3
18 and %o0, 63, %g2
19 sllx %o2, %g2, %o2
20 add %o1, %g3, %o1
211: ldx [%o1], %g7
22 or %g7, %o2, %g1
23 casx [%o1], %g7, %g1
24 cmp %g7, %g1
0f58189d 25 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
1da177e4 26 and %g7, %o2, %g2
1da177e4 27 clr %o0
b445e26c 28 movrne %g2, 1, %o0
1da177e4 29 retl
b445e26c 30 nop
24f287e4 312: BACKOFF_SPIN(%o3, %o4, 1b)
1da177e4
LT
32 .size test_and_set_bit, .-test_and_set_bit
33
34 .globl test_and_clear_bit
35 .type test_and_clear_bit,#function
36test_and_clear_bit: /* %o0=nr, %o1=addr */
24f287e4 37 BACKOFF_SETUP(%o3)
1da177e4
LT
38 srlx %o0, 6, %g1
39 mov 1, %o2
40 sllx %g1, 3, %g3
41 and %o0, 63, %g2
42 sllx %o2, %g2, %o2
43 add %o1, %g3, %o1
441: ldx [%o1], %g7
45 andn %g7, %o2, %g1
46 casx [%o1], %g7, %g1
47 cmp %g7, %g1
0f58189d 48 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
1da177e4 49 and %g7, %o2, %g2
1da177e4 50 clr %o0
b445e26c 51 movrne %g2, 1, %o0
1da177e4 52 retl
b445e26c 53 nop
24f287e4 542: BACKOFF_SPIN(%o3, %o4, 1b)
1da177e4
LT
55 .size test_and_clear_bit, .-test_and_clear_bit
56
57 .globl test_and_change_bit
58 .type test_and_change_bit,#function
59test_and_change_bit: /* %o0=nr, %o1=addr */
24f287e4 60 BACKOFF_SETUP(%o3)
1da177e4
LT
61 srlx %o0, 6, %g1
62 mov 1, %o2
63 sllx %g1, 3, %g3
64 and %o0, 63, %g2
65 sllx %o2, %g2, %o2
66 add %o1, %g3, %o1
671: ldx [%o1], %g7
68 xor %g7, %o2, %g1
69 casx [%o1], %g7, %g1
70 cmp %g7, %g1
0f58189d 71 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
1da177e4 72 and %g7, %o2, %g2
1da177e4 73 clr %o0
b445e26c 74 movrne %g2, 1, %o0
1da177e4 75 retl
b445e26c 76 nop
24f287e4 772: BACKOFF_SPIN(%o3, %o4, 1b)
1da177e4
LT
78 .size test_and_change_bit, .-test_and_change_bit
79
80 .globl set_bit
81 .type set_bit,#function
82set_bit: /* %o0=nr, %o1=addr */
24f287e4 83 BACKOFF_SETUP(%o3)
1da177e4
LT
84 srlx %o0, 6, %g1
85 mov 1, %o2
86 sllx %g1, 3, %g3
87 and %o0, 63, %g2
88 sllx %o2, %g2, %o2
89 add %o1, %g3, %o1
901: ldx [%o1], %g7
91 or %g7, %o2, %g1
92 casx [%o1], %g7, %g1
93 cmp %g7, %g1
0f58189d 94 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
1da177e4
LT
95 nop
96 retl
97 nop
24f287e4 982: BACKOFF_SPIN(%o3, %o4, 1b)
1da177e4
LT
99 .size set_bit, .-set_bit
100
101 .globl clear_bit
102 .type clear_bit,#function
103clear_bit: /* %o0=nr, %o1=addr */
24f287e4 104 BACKOFF_SETUP(%o3)
1da177e4
LT
105 srlx %o0, 6, %g1
106 mov 1, %o2
107 sllx %g1, 3, %g3
108 and %o0, 63, %g2
109 sllx %o2, %g2, %o2
110 add %o1, %g3, %o1
1111: ldx [%o1], %g7
112 andn %g7, %o2, %g1
113 casx [%o1], %g7, %g1
114 cmp %g7, %g1
0f58189d 115 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
1da177e4
LT
116 nop
117 retl
118 nop
24f287e4 1192: BACKOFF_SPIN(%o3, %o4, 1b)
1da177e4
LT
120 .size clear_bit, .-clear_bit
121
122 .globl change_bit
123 .type change_bit,#function
124change_bit: /* %o0=nr, %o1=addr */
24f287e4 125 BACKOFF_SETUP(%o3)
1da177e4
LT
126 srlx %o0, 6, %g1
127 mov 1, %o2
128 sllx %g1, 3, %g3
129 and %o0, 63, %g2
130 sllx %o2, %g2, %o2
131 add %o1, %g3, %o1
1321: ldx [%o1], %g7
133 xor %g7, %o2, %g1
134 casx [%o1], %g7, %g1
135 cmp %g7, %g1
0f58189d 136 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
1da177e4
LT
137 nop
138 retl
139 nop
24f287e4 1402: BACKOFF_SPIN(%o3, %o4, 1b)
1da177e4 141 .size change_bit, .-change_bit