Print this page
de-linting of .s files
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/sun4/ml/copy.s
+++ new/usr/src/uts/sun4/ml/copy.s
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
↓ open down ↓ |
15 lines elided |
↑ open up ↑ |
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 25
26 -#pragma ident "%Z%%M% %I% %E% SMI"
27 -
28 26 #include <sys/param.h>
29 27 #include <sys/errno.h>
30 28 #include <sys/asm_linkage.h>
31 29 #include <sys/vtrace.h>
32 30 #include <sys/machthread.h>
33 31 #include <sys/clock.h>
34 32 #include <sys/asi.h>
35 33 #include <sys/fsr.h>
36 34 #include <sys/privregs.h>
37 35
38 -#if !defined(lint)
39 36 #include "assym.h"
40 -#endif /* lint */
41 37
42 38 /*
43 39 * Error barrier:
44 40 * We use membar sync to establish an error barrier for
45 41 * deferred errors. Membar syncs are added before any update
46 42 * to t_lofault to ensure that deferred errors from earlier
47 43 * accesses will not be reported after the membar. This error
48 44 * isolation is important when we try to recover from async
49 45 * errors which tries to distinguish kernel accesses to user
50 46 * data.
51 47 */
52 48
↓ open down ↓ |
2 lines elided |
↑ open up ↑ |
53 49 /*
54 50 * Copy a null terminated string from one point to another in
55 51 * the kernel address space.
56 52 * NOTE - don't use %o5 in this routine as copy{in,out}str uses it.
57 53 *
58 54 * copystr(from, to, maxlength, lencopied)
59 55 * caddr_t from, to;
60 56 * u_int maxlength, *lencopied;
61 57 */
62 58
63 -#if defined(lint)
64 -
65 -/* ARGSUSED */
66 -int
67 -copystr(const char *from, char *to, size_t maxlength, size_t *lencopied)
68 -{ return(0); }
69 -
70 -#else /* lint */
71 -
72 59 ENTRY(copystr)
73 60 orcc %o2, %g0, %o4 ! save original count
74 61 bg,a %ncc, 1f
75 62 sub %o0, %o1, %o0 ! o0 gets the difference of src and dst
76 63
77 64 !
78 65 ! maxlength <= 0
79 66 !
80 67 bz %ncc, .cs_out ! maxlength = 0
81 68 mov ENAMETOOLONG, %o0
82 69
83 70 b 2f ! maxlength < 0
84 71 mov EFAULT, %o0 ! return failure
85 72
86 73 !
87 74 ! Do a byte by byte loop.
88 75 ! We do this instead of a word by word copy because most strings
89 76 ! are small and this takes a small number of cache lines.
90 77 !
91 78 0:
92 79 stb %g1, [%o1] ! store byte
93 80 tst %g1
94 81 bnz,pt %icc, 1f
95 82 add %o1, 1, %o1 ! incr dst addr
96 83
97 84 ba,pt %ncc, .cs_out ! last byte in string
98 85 mov 0, %o0 ! ret code = 0
99 86 1:
100 87 subcc %o2, 1, %o2 ! test count
101 88 bgeu,a %ncc, 0b
102 89 ldub [%o0 + %o1], %g1 ! delay slot, get source byte
103 90
104 91 mov 0, %o2 ! max number of bytes moved
105 92 mov ENAMETOOLONG, %o0 ! ret code = ENAMETOOLONG
↓ open down ↓ |
24 lines elided |
↑ open up ↑ |
106 93 .cs_out:
107 94 tst %o3
108 95 bz %ncc, 2f
109 96 sub %o4, %o2, %o4 ! compute length and store it
110 97 stn %o4, [%o3]
111 98 2:
112 99 retl
113 100 nop
114 101 SET_SIZE(copystr)
115 102
116 -#endif /* lint */
117 103
118 -
119 104 /*
120 105 * Copy a null terminated string from the user address space into
121 106 * the kernel address space.
122 107 */
123 -#if defined(lint)
124 108
125 -/* ARGSUSED */
126 -int
127 -copyinstr(const char *uaddr, char *kaddr, size_t maxlength,
128 - size_t *lencopied)
129 -{ return (0); }
130 -
131 -#else /* lint */
132 -
133 109 ENTRY(copyinstr)
134 110 sethi %hi(.copyinstr_err), %o4
135 111 ldn [THREAD_REG + T_LOFAULT], %o5 ! catch faults
136 112 or %o4, %lo(.copyinstr_err), %o4
137 113 membar #Sync ! sync error barrier
138 114 stn %o4, [THREAD_REG + T_LOFAULT]
139 115
140 116 brz,a,pn %o2, .copyinstr_out
141 117 mov ENAMETOOLONG, %o0
142 118
143 119 mov %o2, %g3 ! g3 is the current count
144 120 mov %o1, %g4 ! g4 is the dest addr
145 121
146 122 b 1f
147 123 sub %o0, %o1, %g2 ! g2 gets the difference of src and dst
148 124
149 125 !
150 126 ! Do a byte by byte loop.
151 127 ! We do this instead of a word by word copy because most strings
152 128 ! are small and this takes a small number of cache lines.
153 129 !
154 130 0:
155 131 stb %g1, [%g4] ! store byte
156 132 tst %g1
157 133 bnz,pt %icc, 1f
158 134 add %g4, 1, %g4 ! incr dst addr
159 135
160 136 ba,pt %ncc, .copyinstr_out ! last byte in string
161 137 mov 0, %o0 ! ret code = 0
162 138 1:
163 139 subcc %g3, 1, %g3 ! test count
164 140 bgeu,a %ncc, 0b
165 141 lduba [%g2+%g4]ASI_USER, %g1 ! delay slot, get source byte
166 142
167 143 mov 0, %g3 ! max number of bytes moved
168 144 ba,pt %ncc, .copyinstr_out
169 145 mov ENAMETOOLONG, %o0 ! ret code = ENAMETOOLONG
170 146
171 147 /*
172 148 * Fault while trying to move from or to user space.
173 149 * Set and return error code.
174 150 */
175 151 .copyinstr_err:
176 152 membar #Sync ! sync error barrier
177 153 stn %o5, [THREAD_REG + T_LOFAULT]
178 154 ldn [THREAD_REG + T_COPYOPS], %o4
179 155 brz %o4, 1f
180 156 nop
181 157 ldn [%o4 + CP_COPYINSTR], %g1
182 158 jmp %g1
183 159 nop
184 160 1:
185 161 retl
186 162 mov EFAULT, %o0
↓ open down ↓ |
44 lines elided |
↑ open up ↑ |
187 163 .copyinstr_out:
188 164 tst %o3 ! want length?
189 165 bz %ncc, 2f
190 166 sub %o2, %g3, %o2 ! compute length and store it
191 167 stn %o2, [%o3]
192 168 2:
193 169 membar #Sync ! sync error barrier
194 170 retl
195 171 stn %o5, [THREAD_REG + T_LOFAULT] ! stop catching faults
196 172 SET_SIZE(copyinstr)
197 -#endif
198 173
199 -#if defined(lint)
200 -
201 -/* ARGSUSED */
202 -int
203 -copyinstr_noerr(const char *uaddr, char *kaddr, size_t maxlength,
204 - size_t *lencopied)
205 -{ return (0); }
206 -
207 -#else /* lint */
208 -
209 174 ENTRY(copyinstr_noerr)
210 175 mov %o2, %o4 ! save original count
211 176
212 177 ! maxlength is unsigned so the only error is if it's 0
213 178 brz,a,pn %o2, .copyinstr_noerr_out
214 179 mov ENAMETOOLONG, %o0
215 180
216 181 b 1f
217 182 sub %o0, %o1, %o0 ! o0 gets the difference of src and dst
218 183
219 184 !
220 185 ! Do a byte by byte loop.
221 186 ! We do this instead of a word by word copy because most strings
222 187 ! are small and this takes a small number of cache lines.
223 188 !
224 189 0:
225 190 stb %g1, [%o1] ! store byte
226 191 tst %g1 ! null byte?
227 192 bnz 1f
228 193 add %o1, 1, %o1 ! incr dst addr
229 194
230 195 ba,pt %ncc, .copyinstr_noerr_out ! last byte in string
231 196 mov 0, %o0 ! ret code = 0
232 197 1:
233 198 subcc %o2, 1, %o2 ! test count
234 199 bgeu,a %ncc, 0b
235 200 lduba [%o0 + %o1]ASI_USER, %g1 ! delay slot, get source byte
236 201
237 202 mov 0, %o2 ! max number of bytes moved
238 203 b .copyinstr_noerr_out
239 204 mov ENAMETOOLONG, %o0 ! ret code = ENAMETOOLONG
↓ open down ↓ |
21 lines elided |
↑ open up ↑ |
240 205 .copyinstr_noerr_out:
241 206 tst %o3 ! want length?
242 207 bz %ncc, 2f
243 208 sub %o4, %o2, %o4
244 209 stn %o4, [%o3]
245 210 2:
246 211 retl
247 212 nop
248 213 SET_SIZE(copyinstr_noerr)
249 214
250 -#endif /* lint */
251 -
252 215 /*
253 216 * Copy a null terminated string from the kernel
254 217 * address space to the user address space.
255 218 */
256 219
257 -#if defined(lint)
258 -
259 -/* ARGSUSED */
260 -int
261 -copyoutstr(const char *kaddr, char *uaddr, size_t maxlength,
262 - size_t *lencopied)
263 -{ return (0); }
264 -
265 -#else /* lint */
266 -
267 220 ENTRY(copyoutstr)
268 221 sethi %hi(.copyoutstr_err), %o5
269 222 ldn [THREAD_REG + T_LOFAULT], %o4 ! catch faults
270 223 or %o5, %lo(.copyoutstr_err), %o5
271 224 membar #Sync ! sync error barrier
272 225 stn %o5, [THREAD_REG + T_LOFAULT]
273 226 mov %o4, %o5
274 227
275 228 brz,a,pn %o2, .copyoutstr_out
276 229 mov ENAMETOOLONG, %o0
277 230
278 231 mov %o2, %g3 ! g3 is the current count
279 232 mov %o1, %g4 ! g4 is the dest addr
280 233
281 234 b 1f
282 235 sub %o0, %o1, %g2 ! g2 gets the difference of src and dst
283 236
284 237 !
285 238 ! Do a byte by byte loop.
286 239 ! We do this instead of a word by word copy because most strings
287 240 ! are small and this takes a small number of cache lines.
288 241 !
289 242 0:
290 243 stba %g1, [%g4]ASI_USER ! store byte
291 244 tst %g1
292 245 bnz,pt %icc, 1f
293 246 add %g4, 1, %g4 ! incr dst addr
294 247
295 248 ba,pt %ncc, .copyoutstr_out ! last byte in string
296 249 mov 0, %o0 ! ret code = 0
297 250 1:
298 251 subcc %g3, 1, %g3 ! test count
299 252 bgeu,a %ncc, 0b
300 253 ldub [%g2 + %g4], %g1 ! delay slot, get source byte
301 254
302 255 mov 0, %g3 ! max number of bytes moved
303 256 ba,pt %ncc, .copyoutstr_out
304 257 mov ENAMETOOLONG, %o0 ! ret code = ENAMETOOLONG
305 258
306 259 /*
307 260 * Fault while trying to move from or to user space.
308 261 * Set and return error code.
309 262 */
310 263 .copyoutstr_err:
311 264 membar #Sync ! sync error barrier
312 265 stn %o5, [THREAD_REG + T_LOFAULT]
313 266 ldn [THREAD_REG + T_COPYOPS], %o4
314 267 brz %o4, 1f
315 268 nop
316 269 ldn [%o4 + CP_COPYOUTSTR], %g1
317 270 jmp %g1
318 271 nop
319 272 1:
320 273 retl
321 274 mov EFAULT, %o0
322 275 .copyoutstr_out:
↓ open down ↓ |
46 lines elided |
↑ open up ↑ |
323 276 tst %o3 ! want length?
324 277 bz %ncc, 2f
325 278 sub %o2, %g3, %o2 ! compute length and store it
326 279 stn %o2, [%o3]
327 280 2:
328 281 membar #Sync ! sync error barrier
329 282 retl
330 283 stn %o5, [THREAD_REG + T_LOFAULT] ! stop catching faults
331 284 SET_SIZE(copyoutstr)
332 285
333 -#endif /* lint */
334 -
335 -#if defined(lint)
336 -
337 -/* ARGSUSED */
338 -int
339 -copyoutstr_noerr(const char *kaddr, char *uaddr, size_t maxlength,
340 - size_t *lencopied)
341 -{ return (0); }
342 -
343 -#else /* lint */
344 -
345 286 ENTRY(copyoutstr_noerr)
346 287 mov %o2, %o4 ! save original count
347 288
348 289 brz,a,pn %o2, .copyoutstr_noerr_out
349 290 mov ENAMETOOLONG, %o0
350 291
351 292 b 1f
352 293 sub %o0, %o1, %o0 ! o0 gets the difference of src and dst
353 294
354 295 !
355 296 ! Do a byte by byte loop.
356 297 ! We do this instead of a word by word copy because most strings
357 298 ! are small and this takes a small number of cache lines.
358 299 !
359 300 0:
360 301 stba %g1, [%o1]ASI_USER ! store byte
361 302 tst %g1 ! null byte?
362 303 bnz 1f
363 304 add %o1, 1, %o1 ! incr dst addr
364 305
365 306 b .copyoutstr_noerr_out ! last byte in string
366 307 mov 0, %o0 ! ret code = 0
367 308 1:
368 309 subcc %o2, 1, %o2 ! test count
369 310 bgeu,a %ncc, 0b
370 311 ldub [%o0+%o1], %g1 ! delay slot, get source byte
371 312
372 313 mov 0, %o2 ! max number of bytes moved
373 314 b .copyoutstr_noerr_out
374 315 mov ENAMETOOLONG, %o0 ! ret code = ENAMETOOLONG
↓ open down ↓ |
20 lines elided |
↑ open up ↑ |
375 316 .copyoutstr_noerr_out:
376 317 tst %o3 ! want length?
377 318 bz %ncc, 2f
378 319 sub %o4, %o2, %o4
379 320 stn %o4, [%o3]
380 321 2:
381 322 retl
382 323 nop
383 324 SET_SIZE(copyoutstr_noerr)
384 325
385 -#endif /* lint */
386 326
387 -
388 327 /*
389 328 * Copy a block of storage. If the source and target regions overlap,
390 329 * one or both of the regions will be silently corrupted.
391 330 * No fault handler installed (to be called under on_fault())
392 331 */
393 332
394 -#if defined(lint)
395 -
396 -/* ARGSUSED */
397 -void
398 -ucopy(const void *ufrom, void *uto, size_t ulength)
399 -{}
400 -
401 -#else /* lint */
402 -
403 333 ENTRY(ucopy)
404 334 save %sp, -SA(MINFRAME), %sp ! get another window
405 335
406 336 subcc %g0, %i2, %i3
407 337 add %i0, %i2, %i0
408 338 bz,pn %ncc, 5f
409 339 add %i1, %i2, %i1
410 340 lduba [%i0 + %i3]ASI_USER, %i4
411 341 4: stba %i4, [%i1 + %i3]ASI_USER
412 342 inccc %i3
413 343 bcc,a,pt %ncc, 4b
414 344 lduba [%i0 + %i3]ASI_USER, %i4
415 345 5:
416 346 ret
417 347 restore %g0, 0, %o0 ! return (0)
418 348
419 349 SET_SIZE(ucopy)
420 -#endif /* lint */
421 350
422 351 /*
423 352 * Copy a user-land string. If the source and target regions overlap,
424 353 * one or both of the regions will be silently corrupted.
425 354 * No fault handler installed (to be called under on_fault())
426 355 */
427 356
428 -#if defined(lint)
429 -
430 -/* ARGSUSED */
431 -void
432 -ucopystr(const char *ufrom, char *uto, size_t umaxlength, size_t *ulencopied)
433 -{}
434 -
435 -#else /* lint */
436 -
437 357 ENTRY(ucopystr)
438 358 save %sp, -SA(MINFRAME), %sp ! get another window
439 359
440 360 brz %i2, 5f
441 361 clr %i5
442 362
443 363 lduba [%i0 + %i5]ASI_USER, %i4
444 364 4: stba %i4, [%i1 + %i5]ASI_USER
445 365 brz,pn %i4, 5f
446 366 inc %i5
447 367 deccc %i2
↓ open down ↓ |
1 lines elided |
↑ open up ↑ |
448 368 bnz,a,pt %ncc, 4b
449 369 lduba [%i0 + %i5]ASI_USER, %i4
450 370 5:
451 371 brnz,a,pt %i3, 6f
452 372 stn %i5, [%i3]
453 373 6:
454 374 ret
455 375 restore %g0, 0, %o0 ! return (0)
456 376
457 377 SET_SIZE(ucopystr)
458 -#endif /* lint */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX