aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc/lib/rwsem.S
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sparc/lib/rwsem.S')
-rw-r--r--arch/sparc/lib/rwsem.S205
1 files changed, 205 insertions, 0 deletions
diff --git a/arch/sparc/lib/rwsem.S b/arch/sparc/lib/rwsem.S
new file mode 100644
index 000000000000..e7578dc600b8
--- /dev/null
+++ b/arch/sparc/lib/rwsem.S
@@ -0,0 +1,205 @@
1/* $Id: rwsem.S,v 1.5 2000/05/09 17:40:13 davem Exp $
2 * Assembly part of rw semaphores.
3 *
4 * Copyright (C) 1999 Jakub Jelinek (jakub@redhat.com)
5 */
6
7#include <linux/config.h>
8#include <asm/ptrace.h>
9#include <asm/psr.h>
10
11 .section .sched.text
12 .align 4
13
14 .globl ___down_read
15___down_read:
16 rd %psr, %g3
17 nop
18 nop
19 nop
20 or %g3, PSR_PIL, %g7
21 wr %g7, 0, %psr
22 nop
23 nop
24 nop
25#ifdef CONFIG_SMP
261: ldstub [%g1 + 4], %g7
27 tst %g7
28 bne 1b
29 ld [%g1], %g7
30 sub %g7, 1, %g7
31 st %g7, [%g1]
32 stb %g0, [%g1 + 4]
33#else
34 ld [%g1], %g7
35 sub %g7, 1, %g7
36 st %g7, [%g1]
37#endif
38 wr %g3, 0, %psr
39 add %g7, 1, %g7
40 nop
41 nop
42 subcc %g7, 1, %g7
43 bneg 3f
44 nop
452: jmpl %o7, %g0
46 mov %g4, %o7
473: save %sp, -64, %sp
48 mov %g1, %l1
49 mov %g4, %l4
50 bcs 4f
51 mov %g5, %l5
52 call down_read_failed
53 mov %l1, %o0
54 mov %l1, %g1
55 mov %l4, %g4
56 ba ___down_read
57 restore %l5, %g0, %g5
584: call down_read_failed_biased
59 mov %l1, %o0
60 mov %l1, %g1
61 mov %l4, %g4
62 ba 2b
63 restore %l5, %g0, %g5
64
65 .globl ___down_write
66___down_write:
67 rd %psr, %g3
68 nop
69 nop
70 nop
71 or %g3, PSR_PIL, %g7
72 wr %g7, 0, %psr
73 sethi %hi(0x01000000), %g2
74 nop
75 nop
76#ifdef CONFIG_SMP
771: ldstub [%g1 + 4], %g7
78 tst %g7
79 bne 1b
80 ld [%g1], %g7
81 sub %g7, %g2, %g7
82 st %g7, [%g1]
83 stb %g0, [%g1 + 4]
84#else
85 ld [%g1], %g7
86 sub %g7, %g2, %g7
87 st %g7, [%g1]
88#endif
89 wr %g3, 0, %psr
90 add %g7, %g2, %g7
91 nop
92 nop
93 subcc %g7, %g2, %g7
94 bne 3f
95 nop
962: jmpl %o7, %g0
97 mov %g4, %o7
983: save %sp, -64, %sp
99 mov %g1, %l1
100 mov %g4, %l4
101 bcs 4f
102 mov %g5, %l5
103 call down_write_failed
104 mov %l1, %o0
105 mov %l1, %g1
106 mov %l4, %g4
107 ba ___down_write
108 restore %l5, %g0, %g5
1094: call down_write_failed_biased
110 mov %l1, %o0
111 mov %l1, %g1
112 mov %l4, %g4
113 ba 2b
114 restore %l5, %g0, %g5
115
116 .text
117 .globl ___up_read
118___up_read:
119 rd %psr, %g3
120 nop
121 nop
122 nop
123 or %g3, PSR_PIL, %g7
124 wr %g7, 0, %psr
125 nop
126 nop
127 nop
128#ifdef CONFIG_SMP
1291: ldstub [%g1 + 4], %g7
130 tst %g7
131 bne 1b
132 ld [%g1], %g7
133 add %g7, 1, %g7
134 st %g7, [%g1]
135 stb %g0, [%g1 + 4]
136#else
137 ld [%g1], %g7
138 add %g7, 1, %g7
139 st %g7, [%g1]
140#endif
141 wr %g3, 0, %psr
142 nop
143 nop
144 nop
145 cmp %g7, 0
146 be 3f
147 nop
1482: jmpl %o7, %g0
149 mov %g4, %o7
1503: save %sp, -64, %sp
151 mov %g1, %l1
152 mov %g4, %l4
153 mov %g5, %l5
154 clr %o1
155 call __rwsem_wake
156 mov %l1, %o0
157 mov %l1, %g1
158 mov %l4, %g4
159 ba 2b
160 restore %l5, %g0, %g5
161
162 .globl ___up_write
163___up_write:
164 rd %psr, %g3
165 nop
166 nop
167 nop
168 or %g3, PSR_PIL, %g7
169 wr %g7, 0, %psr
170 sethi %hi(0x01000000), %g2
171 nop
172 nop
173#ifdef CONFIG_SMP
1741: ldstub [%g1 + 4], %g7
175 tst %g7
176 bne 1b
177 ld [%g1], %g7
178 add %g7, %g2, %g7
179 st %g7, [%g1]
180 stb %g0, [%g1 + 4]
181#else
182 ld [%g1], %g7
183 add %g7, %g2, %g7
184 st %g7, [%g1]
185#endif
186 wr %g3, 0, %psr
187 sub %g7, %g2, %g7
188 nop
189 nop
190 addcc %g7, %g2, %g7
191 bcs 3f
192 nop
1932: jmpl %o7, %g0
194 mov %g4, %o7
1953: save %sp, -64, %sp
196 mov %g1, %l1
197 mov %g4, %l4
198 mov %g5, %l5
199 mov %g7, %o1
200 call __rwsem_wake
201 mov %l1, %o0
202 mov %l1, %g1
203 mov %l4, %g4
204 ba 2b
205 restore %l5, %g0, %g5