aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc64/lib/rwsem.S
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/sparc64/lib/rwsem.S
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/sparc64/lib/rwsem.S')
-rw-r--r--arch/sparc64/lib/rwsem.S165
1 files changed, 165 insertions, 0 deletions
diff --git a/arch/sparc64/lib/rwsem.S b/arch/sparc64/lib/rwsem.S
new file mode 100644
index 000000000000..174ff7b9164c
--- /dev/null
+++ b/arch/sparc64/lib/rwsem.S
@@ -0,0 +1,165 @@
1/* rwsem.S: RW semaphore assembler.
2 *
3 * Written by David S. Miller (davem@redhat.com), 2001.
4 * Derived from asm-i386/rwsem.h
5 */
6
7#include <asm/rwsem-const.h>
8
9 .section .sched.text
10
11 .globl __down_read
12__down_read:
131: lduw [%o0], %g1
14 add %g1, 1, %g7
15 cas [%o0], %g1, %g7
16 cmp %g1, %g7
17 bne,pn %icc, 1b
18 add %g7, 1, %g7
19 cmp %g7, 0
20 bl,pn %icc, 3f
21 membar #StoreLoad | #StoreStore
222:
23 retl
24 nop
253:
26 save %sp, -192, %sp
27 call rwsem_down_read_failed
28 mov %i0, %o0
29 ret
30 restore
31 .size __down_read, .-__down_read
32
33 .globl __down_read_trylock
34__down_read_trylock:
351: lduw [%o0], %g1
36 add %g1, 1, %g7
37 cmp %g7, 0
38 bl,pn %icc, 2f
39 mov 0, %o1
40 cas [%o0], %g1, %g7
41 cmp %g1, %g7
42 bne,pn %icc, 1b
43 mov 1, %o1
44 membar #StoreLoad | #StoreStore
452: retl
46 mov %o1, %o0
47 .size __down_read_trylock, .-__down_read_trylock
48
49 .globl __down_write
50__down_write:
51 sethi %hi(RWSEM_ACTIVE_WRITE_BIAS), %g1
52 or %g1, %lo(RWSEM_ACTIVE_WRITE_BIAS), %g1
531:
54 lduw [%o0], %g3
55 add %g3, %g1, %g7
56 cas [%o0], %g3, %g7
57 cmp %g3, %g7
58 bne,pn %icc, 1b
59 cmp %g7, 0
60 bne,pn %icc, 3f
61 membar #StoreLoad | #StoreStore
622: retl
63 nop
643:
65 save %sp, -192, %sp
66 call rwsem_down_write_failed
67 mov %i0, %o0
68 ret
69 restore
70 .size __down_write, .-__down_write
71
72 .globl __down_write_trylock
73__down_write_trylock:
74 sethi %hi(RWSEM_ACTIVE_WRITE_BIAS), %g1
75 or %g1, %lo(RWSEM_ACTIVE_WRITE_BIAS), %g1
761:
77 lduw [%o0], %g3
78 cmp %g3, 0
79 bne,pn %icc, 2f
80 mov 0, %o1
81 add %g3, %g1, %g7
82 cas [%o0], %g3, %g7
83 cmp %g3, %g7
84 bne,pn %icc, 1b
85 mov 1, %o1
86 membar #StoreLoad | #StoreStore
872: retl
88 mov %o1, %o0
89 .size __down_write_trylock, .-__down_write_trylock
90
91 .globl __up_read
92__up_read:
931:
94 lduw [%o0], %g1
95 sub %g1, 1, %g7
96 cas [%o0], %g1, %g7
97 cmp %g1, %g7
98 bne,pn %icc, 1b
99 cmp %g7, 0
100 bl,pn %icc, 3f
101 membar #StoreLoad | #StoreStore
1022: retl
103 nop
1043: sethi %hi(RWSEM_ACTIVE_MASK), %g1
105 sub %g7, 1, %g7
106 or %g1, %lo(RWSEM_ACTIVE_MASK), %g1
107 andcc %g7, %g1, %g0
108 bne,pn %icc, 2b
109 nop
110 save %sp, -192, %sp
111 call rwsem_wake
112 mov %i0, %o0
113 ret
114 restore
115 .size __up_read, .-__up_read
116
117 .globl __up_write
118__up_write:
119 sethi %hi(RWSEM_ACTIVE_WRITE_BIAS), %g1
120 or %g1, %lo(RWSEM_ACTIVE_WRITE_BIAS), %g1
1211:
122 lduw [%o0], %g3
123 sub %g3, %g1, %g7
124 cas [%o0], %g3, %g7
125 cmp %g3, %g7
126 bne,pn %icc, 1b
127 sub %g7, %g1, %g7
128 cmp %g7, 0
129 bl,pn %icc, 3f
130 membar #StoreLoad | #StoreStore
1312:
132 retl
133 nop
1343:
135 save %sp, -192, %sp
136 call rwsem_wake
137 mov %i0, %o0
138 ret
139 restore
140 .size __up_write, .-__up_write
141
142 .globl __downgrade_write
143__downgrade_write:
144 sethi %hi(RWSEM_WAITING_BIAS), %g1
145 or %g1, %lo(RWSEM_WAITING_BIAS), %g1
1461:
147 lduw [%o0], %g3
148 sub %g3, %g1, %g7
149 cas [%o0], %g3, %g7
150 cmp %g3, %g7
151 bne,pn %icc, 1b
152 sub %g7, %g1, %g7
153 cmp %g7, 0
154 bl,pn %icc, 3f
155 membar #StoreLoad | #StoreStore
1562:
157 retl
158 nop
1593:
160 save %sp, -192, %sp
161 call rwsem_downgrade_wake
162 mov %i0, %o0
163 ret
164 restore
165 .size __downgrade_write, .-__downgrade_write