1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 #include <asm/export.h>
33
34 #define EX(x,y...) \
35 99: x,##y; \
36 .section __ex_table,"a"; \
37 .long 99b - .; \
38 lda $31, $exception-99b($31); \
39 .previous
40
41 .set noat
42 .set noreorder
43 .align 4
44
45 .globl __clear_user
46 .ent __clear_user
47 .frame $30, 0, $26
48 .prologue 0
49
50
51 __clear_user:
52 and $17, $17, $0
53 and $16, 7, $4 # .. E .. .. : find dest head misalignment
54 beq $0, $zerolength # U .. .. .. : U L U L
55
56 addq $0, $4, $1 # .. .. .. E : bias counter
57 and $1, 7, $2 # .. .. E .. : number of misaligned bytes in tail
58
59
60 srl $1, 3, $1 # .. E .. .. : number of quadwords to clear
61 beq $4, $headalign # U .. .. .. : U L U L
62
63
64
65
66
67 EX( ldq_u $5, 0($16) ) # .. .. .. L : load dst word to mask back in
68 beq $1, $onebyte # .. .. U .. : sub-word store?
69 mskql $5, $16, $5 # .. U .. .. : take care of misaligned head
70 addq $16, 8, $16 # E .. .. .. : L U U L
71
72 EX( stq_u $5, -8($16) ) # .. .. .. L :
73 subq $1, 1, $1 # .. .. E .. :
74 addq $0, $4, $0 # .. E .. .. : bytes left -= 8 - misalignment
75 subq $0, 8, $0 # E .. .. .. : U L U L
76
77 .align 4
78
79
80
81
82
83
84
85 $headalign:
86 subq $1, 16, $4 # .. .. .. E : If < 16, we can not use the huge loop
87 and $16, 0x3f, $2 # .. .. E .. : Forward work for huge loop
88 subq $2, 0x40, $3 # .. E .. .. : bias counter (huge loop)
89 blt $4, $trailquad # U .. .. .. : U L U L
90
91
92
93
94
95
96
97
98 nop # .. .. .. E
99 nop # .. .. E ..
100 nop # .. E .. ..
101 beq $3, $bigalign # U .. .. .. : U L U L : Aligned 0mod64
102
103 $alignmod64:
104 EX( stq_u $31, 0($16) ) # .. .. .. L
105 addq $3, 8, $3 # .. .. E ..
106 subq $0, 8, $0 # .. E .. ..
107 nop # E .. .. .. : U L U L
108
109 nop # .. .. .. E
110 subq $1, 1, $1 # .. .. E ..
111 addq $16, 8, $16 # .. E .. ..
112 blt $3, $alignmod64 # U .. .. .. : U L U L
113
114 $bigalign:
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132 nop # E :
133 nop # E :
134 nop # E :
135 bis $16,$16,$3 # E : U L U L : Initial wh64 address is dest
136
137
138 $do_wh64:
139 wh64 ($3) # .. .. .. L1 : memory subsystem hint
140 subq $1, 16, $4 # .. .. E .. : Forward calculation - repeat the loop?
141 EX( stq_u $31, 0($16) ) # .. L .. ..
142 subq $0, 8, $0 # E .. .. .. : U L U L
143
144 addq $16, 128, $3 # E : Target address of wh64
145 EX( stq_u $31, 8($16) ) # L :
146 EX( stq_u $31, 16($16) ) # L :
147 subq $0, 16, $0 # E : U L L U
148
149 nop # E :
150 EX( stq_u $31, 24($16) ) # L :
151 EX( stq_u $31, 32($16) ) # L :
152 subq $0, 168, $5 # E : U L L U : two trips through the loop left?
153
154
155 subq $0, 16, $0 # E :
156 EX( stq_u $31, 40($16) ) # L :
157 EX( stq_u $31, 48($16) ) # L :
158 cmovlt $5, $16, $3 # E : U L L U : Latency 2, extra mapping cycle
159
160 subq $1, 8, $1 # E :
161 subq $0, 16, $0 # E :
162 EX( stq_u $31, 56($16) ) # L :
163 nop # E : U L U L
164
165 nop # E :
166 subq $0, 8, $0 # E :
167 addq $16, 64, $16 # E :
168 bge $4, $do_wh64 # U : U L U L
169
170 $trailquad:
171
172 # $1 is the number of quadwords left to go.
173 #
174 nop # .. .. .. E
175 nop # .. .. E ..
176 nop # .. E .. ..
177 beq $1, $trailbytes # U .. .. .. : U L U L : Only 0..7 bytes to go
178
179 $onequad:
180 EX( stq_u $31, 0($16) ) # .. .. .. L
181 subq $1, 1, $1 # .. .. E ..
182 subq $0, 8, $0 # .. E .. ..
183 nop # E .. .. .. : U L U L
184
185 nop # .. .. .. E
186 nop # .. .. E ..
187 addq $16, 8, $16 # .. E .. ..
188 bgt $1, $onequad # U .. .. .. : U L U L
189
190
191 $trailbytes:
192 nop # .. .. .. E
193 nop # .. .. E ..
194 nop # .. E .. ..
195 beq $0, $zerolength # U .. .. .. : U L U L
196
197 # $0 contains the number of bytes left to copy (0..31)
198
199
200 $onebyte:
201 EX( stb $31, 0($16) ) # .. .. .. L
202 subq $0, 1, $0 # .. .. E .. :
203 addq $16, 1, $16 # .. E .. .. :
204 bgt $0, $onebyte # U .. .. .. : U L U L
205
206 $zerolength:
207 $exception: # Destination for exception recovery(?)
208 nop # .. .. .. E :
209 nop # .. .. E .. :
210 nop # .. E .. .. :
211 ret $31, ($26), 1 # L0 .. .. .. : L U L U
212 .end __clear_user
213 EXPORT_SYMBOL(__clear_user)