Print this page
de-linting of .s files
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/sun4u/ml/mach_copy.s
+++ new/usr/src/uts/sun4u/ml/mach_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, Version 1.0 only
6 6 * (the "License"). You may not use this file except in compliance
7 7 * with the License.
8 8 *
9 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 * or http://www.opensolaris.org/os/licensing.
11 11 * See the License for the specific language governing permissions
12 12 * and limitations under the License.
13 13 *
14 14 * When distributing Covered Code, include this CDDL HEADER in each
15 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 * If applicable, add the following below this CDDL HEADER, with the
↓ open down ↓ |
16 lines elided |
↑ open up ↑ |
17 17 * fields enclosed by brackets "[]" replaced with your own identifying
18 18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 19 *
20 20 * CDDL HEADER END
21 21 */
22 22 /*
23 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 26
27 -#pragma ident "%Z%%M% %I% %E% SMI"
28 -
29 27 #include <sys/param.h>
30 28 #include <sys/errno.h>
31 29 #include <sys/asm_linkage.h>
32 30 #include <sys/vtrace.h>
33 31 #include <sys/machthread.h>
34 32 #include <sys/clock.h>
35 33 #include <sys/asi.h>
36 34 #include <sys/fsr.h>
37 35 #include <sys/privregs.h>
38 36
39 -#if !defined(lint)
40 37 #include "assym.h"
41 -#endif /* lint */
42 38
43 39 #define FP_USED 1
44 40 #define LOFAULT_SET 2
45 41
46 42 /*
47 43 * Error barrier:
48 44 * We use membar sync to establish an error barrier for
49 45 * deferred errors. Membar syncs are added before any update
50 46 * to t_lofault to ensure that deferred errors from earlier
51 47 * accesses will not be reported after the membar. This error
52 48 * isolation is important when we try to recover from async
↓ open down ↓ |
1 lines elided |
↑ open up ↑ |
53 49 * errors which tries to distinguish kernel accesses to user
54 50 * data.
55 51 */
56 52
57 53 /*
58 54 * Zero a block of storage.
59 55 *
60 56 * uzero is used by the kernel to zero a block in user address space.
61 57 */
62 58
63 -#if defined(lint)
64 -
65 -/* ARGSUSED */
66 -int
67 -kzero(void *addr, size_t count)
68 -{ return(0); }
69 -
70 -/* ARGSUSED */
71 -void
72 -uzero(void *addr, size_t count)
73 -{}
74 -
75 -#else /* lint */
76 -
77 59 ENTRY(uzero)
78 60 !
79 61 ! Set a new lo_fault handler only if we came in with one
80 62 ! already specified.
81 63 !
82 64 wr %g0, ASI_USER, %asi
83 65 ldn [THREAD_REG + T_LOFAULT], %o5
84 66 tst %o5
85 67 bz,pt %ncc, .do_zero
86 68 sethi %hi(.zeroerr), %o2
87 69 or %o2, %lo(.zeroerr), %o2
88 70 membar #Sync
89 71 ba,pt %ncc, .do_zero
90 72 stn %o2, [THREAD_REG + T_LOFAULT]
91 73
92 74 ENTRY(kzero)
93 75 !
94 76 ! Always set a lo_fault handler
95 77 !
96 78 wr %g0, ASI_P, %asi
97 79 ldn [THREAD_REG + T_LOFAULT], %o5
98 80 sethi %hi(.zeroerr), %o2
99 81 or %o5, LOFAULT_SET, %o5
100 82 or %o2, %lo(.zeroerr), %o2
101 83 membar #Sync
102 84 ba,pt %ncc, .do_zero
103 85 stn %o2, [THREAD_REG + T_LOFAULT]
104 86
105 87 /*
106 88 * We got here because of a fault during kzero or if
107 89 * uzero or bzero was called with t_lofault non-zero.
108 90 * Otherwise we've already run screaming from the room.
109 91 * Errno value is in %g1. Note that we're here iff
110 92 * we did set t_lofault.
111 93 */
112 94 .zeroerr:
113 95 !
114 96 ! Undo asi register setting. Just set it to be the
115 97 ! kernel default without checking.
116 98 !
117 99 wr %g0, ASI_P, %asi
118 100 !
119 101 ! If saved t_lofault has FP_USED set, clear the %fprs register
120 102 !
121 103 btst FP_USED, %o5
122 104 bz,pt %ncc, 1f ! skip if not used
123 105 nop
124 106 membar #Sync
125 107 wr %g0, %g0, %fprs ! clear fprs
126 108 andn %o5, FP_USED, %o5 ! turn off flag bit
127 109 !
128 110 ! We did set t_lofault. It may well have been zero coming in.
129 111 !
130 112 1:
131 113 tst %o5
132 114 membar #Sync
133 115 bne,pn %ncc, 3f
134 116 andncc %o5, LOFAULT_SET, %o5
135 117 2:
136 118 !
137 119 ! Old handler was zero. Just return the error.
138 120 !
139 121 retl ! return
140 122 mov %g1, %o0 ! error code from %g1
141 123 3:
142 124 !
143 125 ! We're here because %o5 was non-zero. It was non-zero
144 126 ! because either LOFAULT_SET was present, a previous fault
145 127 ! handler was present or both. In all cases we need to reset
146 128 ! T_LOFAULT to the value of %o5 after clearing LOFAULT_SET
↓ open down ↓ |
60 lines elided |
↑ open up ↑ |
147 129 ! before we either simply return the error or we invoke the
148 130 ! previously specified handler.
149 131 !
150 132 be %ncc, 2b
151 133 stn %o5, [THREAD_REG + T_LOFAULT]
152 134 jmp %o5 ! goto real handler
153 135 nop
154 136 SET_SIZE(kzero)
155 137 SET_SIZE(uzero)
156 138
157 -#endif /* lint */
158 -
159 139 /*
160 140 * Zero a block of storage.
161 141 */
162 142
163 -#if defined(lint)
164 -
165 -/* ARGSUSED */
166 -void
167 -bzero(void *addr, size_t count)
168 -{}
169 -
170 -#else /* lint */
171 -
172 143 ENTRY(bzero)
173 144 wr %g0, ASI_P, %asi
174 145
175 146 ldn [THREAD_REG + T_LOFAULT], %o5 ! save old vector
176 147 tst %o5
177 148 bz,pt %ncc, .do_zero
178 149 sethi %hi(.zeroerr), %o2
179 150 or %o2, %lo(.zeroerr), %o2
180 151 membar #Sync ! sync error barrier
181 152 stn %o2, [THREAD_REG + T_LOFAULT] ! install new vector
182 153
183 154 .do_zero:
184 155 cmp %o1, 15 ! check for small counts
185 156 blu,pn %ncc, .byteclr ! just clear bytes
186 157 nop
187 158
188 159 cmp %o1, 192 ! check for large counts
189 160 blu %ncc, .bzero_small
190 161 nop
191 162
192 163 sethi %hi(use_hw_bzero), %o2
193 164 ld [%o2 + %lo(use_hw_bzero)], %o2
194 165 tst %o2
195 166 bz %icc, .bzero_small
196 167 nop
197 168
198 169 rd %fprs, %o2 ! check for unused fp
199 170 btst FPRS_FEF, %o2
200 171 bnz %icc, .bzero_small
201 172 nop
202 173
203 174 ldn [THREAD_REG + T_LWP], %o2
204 175 tst %o2
205 176 bz,pn %ncc, .bzero_small
206 177 nop
207 178
208 179 ! Check for block alignment
209 180 btst (64-1), %o0
210 181 bz %icc, .bzl_block
211 182 nop
212 183
213 184 ! Check for double-word alignment
214 185 btst (8-1), %o0
215 186 bz %icc, .bzl_dword
216 187 nop
217 188
218 189 ! Check for word alignment
219 190 btst (4-1), %o0
220 191 bz %icc, .bzl_word
221 192 nop
222 193
223 194 ! Clear bytes until word aligned
224 195 .bzl_byte:
225 196 stba %g0, [%o0]%asi
226 197 add %o0, 1, %o0
227 198 btst (4-1), %o0
228 199 bnz %icc, .bzl_byte
229 200 sub %o1, 1, %o1
230 201
231 202 ! Check for dword-aligned
232 203 btst (8-1), %o0
233 204 bz %icc, .bzl_dword
234 205 nop
235 206
236 207 ! Clear words until double-word aligned
237 208 .bzl_word:
238 209 sta %g0, [%o0]%asi
239 210 add %o0, 4, %o0
240 211 btst (8-1), %o0
241 212 bnz %icc, .bzl_word
242 213 sub %o1, 4, %o1
243 214
244 215 .bzl_dword:
245 216 ! Clear dwords until block aligned
246 217 stxa %g0, [%o0]%asi
247 218 add %o0, 8, %o0
248 219 btst (64-1), %o0
249 220 bnz %icc, .bzl_dword
250 221 sub %o1, 8, %o1
251 222
252 223 .bzl_block:
253 224 membar #StoreStore|#StoreLoad|#LoadStore
254 225 wr %g0, FPRS_FEF, %fprs
255 226
256 227 ! Set the lower bit in the saved t_lofault to indicate
257 228 ! that we need to clear the %fprs register on the way
258 229 ! out
259 230 or %o5, FP_USED, %o5
260 231
261 232 ! Clear block
262 233 fzero %d0
263 234 fzero %d2
264 235 fzero %d4
265 236 fzero %d6
266 237 fzero %d8
267 238 fzero %d10
268 239 fzero %d12
269 240 fzero %d14
270 241 rd %asi, %o3
271 242 wr %g0, ASI_BLK_P, %asi
272 243 cmp %o3, ASI_P
273 244 bne,a %icc, 1f
274 245 wr %g0, ASI_BLK_AIUS, %asi
275 246 1:
276 247 mov 256, %o3
277 248 ba,pt %ncc, .bzl_doblock
278 249 nop
279 250
280 251 .bzl_blkstart:
281 252 ! stda %d0, [%o0+192]%asi ! in dly slot of branch that got us here
282 253 stda %d0, [%o0+128]%asi
283 254 stda %d0, [%o0+64]%asi
284 255 stda %d0, [%o0]%asi
285 256 .bzl_zinst:
286 257 add %o0, %o3, %o0
287 258 sub %o1, %o3, %o1
288 259 .bzl_doblock:
289 260 cmp %o1, 256
290 261 bgeu,a %ncc, .bzl_blkstart
291 262 stda %d0, [%o0+192]%asi
292 263
293 264 cmp %o1, 64
294 265 blu %ncc, .bzl_finish
295 266
296 267 andn %o1, (64-1), %o3
297 268 srl %o3, 4, %o2 ! using blocks, 1 instr / 16 words
298 269 set .bzl_zinst, %o4
299 270 sub %o4, %o2, %o4
300 271 jmp %o4
301 272 nop
302 273
303 274 .bzl_finish:
304 275 membar #StoreLoad|#StoreStore
305 276 wr %g0, %g0, %fprs
306 277 andn %o5, FP_USED, %o5
307 278
308 279 rd %asi, %o4
309 280 wr %g0, ASI_P, %asi
310 281 cmp %o4, ASI_BLK_P
311 282 bne,a %icc, 1f
312 283 wr %g0, ASI_USER, %asi
313 284 1:
314 285
315 286 .bzlf_dword:
316 287 ! double words
317 288 cmp %o1, 8
318 289 blu %ncc, .bzlf_word
319 290 nop
320 291 stxa %g0, [%o0]%asi
321 292 add %o0, 8, %o0
322 293 sub %o1, 8, %o1
323 294 ba,pt %ncc, .bzlf_dword
324 295 nop
325 296
326 297 .bzlf_word:
327 298 ! words
328 299 cmp %o1, 4
329 300 blu %ncc, .bzlf_byte
330 301 nop
331 302 sta %g0, [%o0]%asi
332 303 add %o0, 4, %o0
333 304 sub %o1, 4, %o1
334 305 ba,pt %ncc, .bzlf_word
335 306 nop
336 307
337 308 1:
338 309 add %o0, 1, %o0 ! increment address
339 310 .bzlf_byte:
340 311 subcc %o1, 1, %o1 ! decrement count
341 312 bgeu,a %ncc, 1b
342 313 stba %g0, [%o0]%asi ! zero a byte
343 314
344 315 !
345 316 ! If we used the FP registers, that bit was turned
346 317 ! off after we were finished. We're just concerned with
347 318 ! whether t_lofault was set when we came in. We end up
348 319 ! here from either kzero() or bzero(). kzero() *always*
349 320 ! sets a lofault handler. It ors LOFAULT_SET into %o5
350 321 ! to indicate it has done this even if the value of %o5
351 322 ! is otherwise zero. bzero() sets a lofault handler *only*
352 323 ! if one was previously set. Accordingly we need to examine
353 324 ! %o5 and if it is non-zero be sure to clear LOFAULT_SET
354 325 ! before resetting the error handler.
355 326 !
356 327 tst %o5
357 328 bz,pt %ncc, 1f
358 329 andn %o5, LOFAULT_SET, %o5
359 330 membar #Sync ! sync error barrier
360 331 stn %o5, [THREAD_REG + T_LOFAULT] ! restore old t_lofault
361 332 1:
362 333 retl
363 334 clr %o0 ! return (0)
364 335
365 336 .bzero_small:
366 337
367 338 !
368 339 ! Check for word alignment.
369 340 !
370 341 btst 3, %o0
371 342 bz .bzero_probe
372 343 mov 0x100, %o3 ! constant size of main loop
373 344 !
374 345 !
375 346 ! clear bytes until word aligned
376 347 !
377 348 1: stba %g0,[%o0]%asi
378 349 add %o0, 1, %o0
379 350 btst 3, %o0
380 351 bnz 1b
381 352 sub %o1, 1, %o1
382 353 .bzero_probe:
383 354
384 355 !
385 356 ! if needed move a word to become double-word aligned.
386 357 !
387 358 btst 7, %o0 ! is double aligned?
388 359 bz %icc, .bzero_nobuf
389 360 nop
390 361 sta %g0, [%o0]%asi ! clr to double boundry
391 362 sub %o1, 4, %o1
392 363 ba,pt %ncc, .bzero_nobuf
393 364 add %o0, 4, %o0
394 365
395 366 !stxa %g0, [%o0+0xf8]%asi
396 367 .bzero_blk:
397 368 stxa %g0, [%o0+0xf0]%asi
398 369 stxa %g0, [%o0+0xe8]%asi
399 370 stxa %g0, [%o0+0xe0]%asi
400 371 stxa %g0, [%o0+0xd8]%asi
401 372 stxa %g0, [%o0+0xd0]%asi
402 373 stxa %g0, [%o0+0xc8]%asi
403 374 stxa %g0, [%o0+0xc0]%asi
404 375 stxa %g0, [%o0+0xb8]%asi
405 376 stxa %g0, [%o0+0xb0]%asi
406 377 stxa %g0, [%o0+0xa8]%asi
407 378 stxa %g0, [%o0+0xa0]%asi
408 379 stxa %g0, [%o0+0x98]%asi
409 380 stxa %g0, [%o0+0x90]%asi
410 381 stxa %g0, [%o0+0x88]%asi
411 382 stxa %g0, [%o0+0x80]%asi
412 383 stxa %g0, [%o0+0x78]%asi
413 384 stxa %g0, [%o0+0x70]%asi
414 385 stxa %g0, [%o0+0x68]%asi
415 386 stxa %g0, [%o0+0x60]%asi
416 387 stxa %g0, [%o0+0x58]%asi
417 388 stxa %g0, [%o0+0x50]%asi
418 389 stxa %g0, [%o0+0x48]%asi
419 390 stxa %g0, [%o0+0x40]%asi
420 391 stxa %g0, [%o0+0x38]%asi
421 392 stxa %g0, [%o0+0x30]%asi
422 393 stxa %g0, [%o0+0x28]%asi
423 394 stxa %g0, [%o0+0x20]%asi
424 395 stxa %g0, [%o0+0x18]%asi
425 396 stxa %g0, [%o0+0x10]%asi
426 397 stxa %g0, [%o0+0x08]%asi
427 398 stxa %g0, [%o0]%asi
428 399 .zinst:
429 400 add %o0, %o3, %o0 ! increment source address
430 401 sub %o1, %o3, %o1 ! decrement count
431 402 .bzero_nobuf:
432 403 cmp %o1, 0x100 ! can we do whole chunk?
433 404 bgeu,a %ncc, .bzero_blk
434 405 stxa %g0, [%o0+0xf8]%asi ! do first double of chunk
435 406
436 407 cmp %o1, 7 ! can we zero any more double words
437 408 bleu %ncc, .byteclr ! too small go zero bytes
438 409
439 410 andn %o1, 7, %o3 ! %o3 bytes left, double-word aligned
440 411 srl %o3, 1, %o2 ! using doubles, need 1 instr / 2 words
441 412 set .zinst, %o4 ! address of clr instructions
442 413 sub %o4, %o2, %o4 ! jmp address relative to instr
443 414 jmp %o4
444 415 nop
445 416 !
446 417 ! do leftover bytes
447 418 !
448 419 3:
449 420 add %o0, 1, %o0 ! increment address
450 421 .byteclr:
451 422 subcc %o1, 1, %o1 ! decrement count
452 423 bgeu,a %ncc, 3b
453 424 stba %g0, [%o0]%asi ! zero a byte
454 425
455 426 .bzero_finished:
456 427 !
457 428 ! We're just concerned with whether t_lofault was set
458 429 ! when we came in. We end up here from either kzero()
459 430 ! or bzero(). kzero() *always* sets a lofault handler.
460 431 ! It ors LOFAULT_SET into %o5 to indicate it has done
461 432 ! this even if the value of %o5 is otherwise zero.
462 433 ! bzero() sets a lofault handler *only* if one was
463 434 ! previously set. Accordingly we need to examine
464 435 ! %o5 and if it is non-zero be sure to clear LOFAULT_SET
465 436 ! before resetting the error handler.
466 437 !
↓ open down ↓ |
285 lines elided |
↑ open up ↑ |
467 438 tst %o5
468 439 bz %ncc, 1f
469 440 andn %o5, LOFAULT_SET, %o5
470 441 membar #Sync ! sync error barrier
471 442 stn %o5, [THREAD_REG + T_LOFAULT] ! restore old t_lofault
472 443 1:
473 444 retl
474 445 clr %o0 ! return (0)
475 446
476 447 SET_SIZE(bzero)
477 -#endif /* lint */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX