blob: ad919f4f4b37a8cc901df5207c2af6c1e54a1434 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* $Id: entry.S,v 1.144 2002/02/09 19:49:30 davem Exp $
2 * arch/sparc64/kernel/entry.S: Sparc64 trap low-level entry points.
3 *
4 * Copyright (C) 1995,1997 David S. Miller (davem@caip.rutgers.edu)
5 * Copyright (C) 1996 Eddie C. Dost (ecd@skynet.be)
6 * Copyright (C) 1996 Miguel de Icaza (miguel@nuclecu.unam.mx)
7 * Copyright (C) 1996,98,99 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
8 */
9
10#include <linux/config.h>
11#include <linux/errno.h>
12
13#include <asm/head.h>
14#include <asm/asi.h>
15#include <asm/smp.h>
16#include <asm/ptrace.h>
17#include <asm/page.h>
18#include <asm/signal.h>
19#include <asm/pgtable.h>
20#include <asm/processor.h>
21#include <asm/visasm.h>
22#include <asm/estate.h>
23#include <asm/auxio.h>
David S. Miller6c52a962005-08-29 12:45:11 -070024#include <asm/sfafsr.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#define curptr g6
27
David S. Miller1b9a4282006-02-07 18:11:24 -080028#define NR_SYSCALLS 300 /* Each OS is different... */
Linus Torvalds1da177e2005-04-16 15:20:36 -070029
30 .text
31 .align 32
32
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 /* This is trivial with the new code... */
34 .globl do_fpdis
35do_fpdis:
David S. Millerba6399332005-10-07 13:30:49 -070036 sethi %hi(TSTATE_PEF), %g4
Linus Torvalds1da177e2005-04-16 15:20:36 -070037 rdpr %tstate, %g5
38 andcc %g5, %g4, %g0
39 be,pt %xcc, 1f
40 nop
41 rd %fprs, %g5
42 andcc %g5, FPRS_FEF, %g0
43 be,pt %xcc, 1f
44 nop
45
46 /* Legal state when DCR_IFPOE is set in Cheetah %dcr. */
47 sethi %hi(109f), %g7
48 ba,pt %xcc, etrap
49109: or %g7, %lo(109b), %g7
50 add %g0, %g0, %g0
51 ba,a,pt %xcc, rtrap_clr_l6
52
David S. Miller56fb4df2006-02-26 23:24:22 -0800531: TRAP_LOAD_THREAD_REG
54 ldub [%g6 + TI_FPSAVED], %g5
David S. Millerba6399332005-10-07 13:30:49 -070055 wr %g0, FPRS_FEF, %fprs
56 andcc %g5, FPRS_FEF, %g0
57 be,a,pt %icc, 1f
58 clr %g7
59 ldx [%g6 + TI_GSR], %g7
601: andcc %g5, FPRS_DL, %g0
61 bne,pn %icc, 2f
62 fzero %f0
63 andcc %g5, FPRS_DU, %g0
64 bne,pn %icc, 1f
65 fzero %f2
Linus Torvalds1da177e2005-04-16 15:20:36 -070066 faddd %f0, %f2, %f4
67 fmuld %f0, %f2, %f6
68 faddd %f0, %f2, %f8
69 fmuld %f0, %f2, %f10
70 faddd %f0, %f2, %f12
71 fmuld %f0, %f2, %f14
72 faddd %f0, %f2, %f16
73 fmuld %f0, %f2, %f18
74 faddd %f0, %f2, %f20
75 fmuld %f0, %f2, %f22
76 faddd %f0, %f2, %f24
77 fmuld %f0, %f2, %f26
78 faddd %f0, %f2, %f28
79 fmuld %f0, %f2, %f30
80 faddd %f0, %f2, %f32
81 fmuld %f0, %f2, %f34
82 faddd %f0, %f2, %f36
83 fmuld %f0, %f2, %f38
84 faddd %f0, %f2, %f40
85 fmuld %f0, %f2, %f42
86 faddd %f0, %f2, %f44
87 fmuld %f0, %f2, %f46
88 faddd %f0, %f2, %f48
89 fmuld %f0, %f2, %f50
90 faddd %f0, %f2, %f52
91 fmuld %f0, %f2, %f54
92 faddd %f0, %f2, %f56
93 fmuld %f0, %f2, %f58
94 b,pt %xcc, fpdis_exit2
95 faddd %f0, %f2, %f60
961: mov SECONDARY_CONTEXT, %g3
97 add %g6, TI_FPREGS + 0x80, %g1
98 faddd %f0, %f2, %f4
99 fmuld %f0, %f2, %f6
100 ldxa [%g3] ASI_DMMU, %g5
David S. Miller0835ae02005-10-04 15:23:20 -0700101 sethi %hi(sparc64_kern_sec_context), %g2
102 ldx [%g2 + %lo(sparc64_kern_sec_context)], %g2
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 stxa %g2, [%g3] ASI_DMMU
104 membar #Sync
105 add %g6, TI_FPREGS + 0xc0, %g2
106 faddd %f0, %f2, %f8
107 fmuld %f0, %f2, %f10
David S. Millerba6399332005-10-07 13:30:49 -0700108 membar #Sync
109 ldda [%g1] ASI_BLK_S, %f32
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 ldda [%g2] ASI_BLK_S, %f48
David S. Millerba6399332005-10-07 13:30:49 -0700111 membar #Sync
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112 faddd %f0, %f2, %f12
113 fmuld %f0, %f2, %f14
114 faddd %f0, %f2, %f16
115 fmuld %f0, %f2, %f18
116 faddd %f0, %f2, %f20
117 fmuld %f0, %f2, %f22
118 faddd %f0, %f2, %f24
119 fmuld %f0, %f2, %f26
120 faddd %f0, %f2, %f28
121 fmuld %f0, %f2, %f30
122 b,pt %xcc, fpdis_exit
David S. Millerb445e262005-06-27 15:42:04 -0700123 nop
Linus Torvalds1da177e2005-04-16 15:20:36 -07001242: andcc %g5, FPRS_DU, %g0
125 bne,pt %icc, 3f
126 fzero %f32
127 mov SECONDARY_CONTEXT, %g3
128 fzero %f34
129 ldxa [%g3] ASI_DMMU, %g5
130 add %g6, TI_FPREGS, %g1
David S. Miller0835ae02005-10-04 15:23:20 -0700131 sethi %hi(sparc64_kern_sec_context), %g2
132 ldx [%g2 + %lo(sparc64_kern_sec_context)], %g2
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133 stxa %g2, [%g3] ASI_DMMU
134 membar #Sync
135 add %g6, TI_FPREGS + 0x40, %g2
136 faddd %f32, %f34, %f36
137 fmuld %f32, %f34, %f38
David S. Millerba6399332005-10-07 13:30:49 -0700138 membar #Sync
139 ldda [%g1] ASI_BLK_S, %f0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 ldda [%g2] ASI_BLK_S, %f16
David S. Millerba6399332005-10-07 13:30:49 -0700141 membar #Sync
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142 faddd %f32, %f34, %f40
143 fmuld %f32, %f34, %f42
144 faddd %f32, %f34, %f44
145 fmuld %f32, %f34, %f46
146 faddd %f32, %f34, %f48
147 fmuld %f32, %f34, %f50
148 faddd %f32, %f34, %f52
149 fmuld %f32, %f34, %f54
150 faddd %f32, %f34, %f56
151 fmuld %f32, %f34, %f58
152 faddd %f32, %f34, %f60
153 fmuld %f32, %f34, %f62
154 ba,pt %xcc, fpdis_exit
David S. Millerb445e262005-06-27 15:42:04 -0700155 nop
Linus Torvalds1da177e2005-04-16 15:20:36 -07001563: mov SECONDARY_CONTEXT, %g3
157 add %g6, TI_FPREGS, %g1
158 ldxa [%g3] ASI_DMMU, %g5
David S. Miller0835ae02005-10-04 15:23:20 -0700159 sethi %hi(sparc64_kern_sec_context), %g2
160 ldx [%g2 + %lo(sparc64_kern_sec_context)], %g2
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161 stxa %g2, [%g3] ASI_DMMU
162 membar #Sync
163 mov 0x40, %g2
David S. Millerba6399332005-10-07 13:30:49 -0700164 membar #Sync
165 ldda [%g1] ASI_BLK_S, %f0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166 ldda [%g1 + %g2] ASI_BLK_S, %f16
167 add %g1, 0x80, %g1
168 ldda [%g1] ASI_BLK_S, %f32
169 ldda [%g1 + %g2] ASI_BLK_S, %f48
170 membar #Sync
171fpdis_exit:
172 stxa %g5, [%g3] ASI_DMMU
173 membar #Sync
174fpdis_exit2:
175 wr %g7, 0, %gsr
176 ldx [%g6 + TI_XFSR], %fsr
177 rdpr %tstate, %g3
178 or %g3, %g4, %g3 ! anal...
179 wrpr %g3, %tstate
180 wr %g0, FPRS_FEF, %fprs ! clean DU/DL bits
181 retry
182
183 .align 32
184fp_other_bounce:
185 call do_fpother
186 add %sp, PTREGS_OFF, %o0
187 ba,pt %xcc, rtrap
188 clr %l6
189
190 .globl do_fpother_check_fitos
191 .align 32
192do_fpother_check_fitos:
David S. Miller56fb4df2006-02-26 23:24:22 -0800193 TRAP_LOAD_THREAD_REG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194 sethi %hi(fp_other_bounce - 4), %g7
195 or %g7, %lo(fp_other_bounce - 4), %g7
196
197 /* NOTE: Need to preserve %g7 until we fully commit
198 * to the fitos fixup.
199 */
200 stx %fsr, [%g6 + TI_XFSR]
201 rdpr %tstate, %g3
202 andcc %g3, TSTATE_PRIV, %g0
203 bne,pn %xcc, do_fptrap_after_fsr
204 nop
205 ldx [%g6 + TI_XFSR], %g3
206 srlx %g3, 14, %g1
207 and %g1, 7, %g1
208 cmp %g1, 2 ! Unfinished FP-OP
209 bne,pn %xcc, do_fptrap_after_fsr
210 sethi %hi(1 << 23), %g1 ! Inexact
211 andcc %g3, %g1, %g0
212 bne,pn %xcc, do_fptrap_after_fsr
213 rdpr %tpc, %g1
214 lduwa [%g1] ASI_AIUP, %g3 ! This cannot ever fail
215#define FITOS_MASK 0xc1f83fe0
216#define FITOS_COMPARE 0x81a01880
217 sethi %hi(FITOS_MASK), %g1
218 or %g1, %lo(FITOS_MASK), %g1
219 and %g3, %g1, %g1
220 sethi %hi(FITOS_COMPARE), %g2
221 or %g2, %lo(FITOS_COMPARE), %g2
222 cmp %g1, %g2
223 bne,pn %xcc, do_fptrap_after_fsr
224 nop
225 std %f62, [%g6 + TI_FPREGS + (62 * 4)]
226 sethi %hi(fitos_table_1), %g1
227 and %g3, 0x1f, %g2
228 or %g1, %lo(fitos_table_1), %g1
229 sllx %g2, 2, %g2
230 jmpl %g1 + %g2, %g0
231 ba,pt %xcc, fitos_emul_continue
232
233fitos_table_1:
234 fitod %f0, %f62
235 fitod %f1, %f62
236 fitod %f2, %f62
237 fitod %f3, %f62
238 fitod %f4, %f62
239 fitod %f5, %f62
240 fitod %f6, %f62
241 fitod %f7, %f62
242 fitod %f8, %f62
243 fitod %f9, %f62
244 fitod %f10, %f62
245 fitod %f11, %f62
246 fitod %f12, %f62
247 fitod %f13, %f62
248 fitod %f14, %f62
249 fitod %f15, %f62
250 fitod %f16, %f62
251 fitod %f17, %f62
252 fitod %f18, %f62
253 fitod %f19, %f62
254 fitod %f20, %f62
255 fitod %f21, %f62
256 fitod %f22, %f62
257 fitod %f23, %f62
258 fitod %f24, %f62
259 fitod %f25, %f62
260 fitod %f26, %f62
261 fitod %f27, %f62
262 fitod %f28, %f62
263 fitod %f29, %f62
264 fitod %f30, %f62
265 fitod %f31, %f62
266
267fitos_emul_continue:
268 sethi %hi(fitos_table_2), %g1
269 srl %g3, 25, %g2
270 or %g1, %lo(fitos_table_2), %g1
271 and %g2, 0x1f, %g2
272 sllx %g2, 2, %g2
273 jmpl %g1 + %g2, %g0
274 ba,pt %xcc, fitos_emul_fini
275
276fitos_table_2:
277 fdtos %f62, %f0
278 fdtos %f62, %f1
279 fdtos %f62, %f2
280 fdtos %f62, %f3
281 fdtos %f62, %f4
282 fdtos %f62, %f5
283 fdtos %f62, %f6
284 fdtos %f62, %f7
285 fdtos %f62, %f8
286 fdtos %f62, %f9
287 fdtos %f62, %f10
288 fdtos %f62, %f11
289 fdtos %f62, %f12
290 fdtos %f62, %f13
291 fdtos %f62, %f14
292 fdtos %f62, %f15
293 fdtos %f62, %f16
294 fdtos %f62, %f17
295 fdtos %f62, %f18
296 fdtos %f62, %f19
297 fdtos %f62, %f20
298 fdtos %f62, %f21
299 fdtos %f62, %f22
300 fdtos %f62, %f23
301 fdtos %f62, %f24
302 fdtos %f62, %f25
303 fdtos %f62, %f26
304 fdtos %f62, %f27
305 fdtos %f62, %f28
306 fdtos %f62, %f29
307 fdtos %f62, %f30
308 fdtos %f62, %f31
309
310fitos_emul_fini:
311 ldd [%g6 + TI_FPREGS + (62 * 4)], %f62
312 done
313
314 .globl do_fptrap
315 .align 32
316do_fptrap:
317 stx %fsr, [%g6 + TI_XFSR]
318do_fptrap_after_fsr:
319 ldub [%g6 + TI_FPSAVED], %g3
320 rd %fprs, %g1
321 or %g3, %g1, %g3
322 stb %g3, [%g6 + TI_FPSAVED]
323 rd %gsr, %g3
324 stx %g3, [%g6 + TI_GSR]
325 mov SECONDARY_CONTEXT, %g3
326 ldxa [%g3] ASI_DMMU, %g5
David S. Miller0835ae02005-10-04 15:23:20 -0700327 sethi %hi(sparc64_kern_sec_context), %g2
328 ldx [%g2 + %lo(sparc64_kern_sec_context)], %g2
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329 stxa %g2, [%g3] ASI_DMMU
330 membar #Sync
331 add %g6, TI_FPREGS, %g2
332 andcc %g1, FPRS_DL, %g0
333 be,pn %icc, 4f
334 mov 0x40, %g3
335 stda %f0, [%g2] ASI_BLK_S
336 stda %f16, [%g2 + %g3] ASI_BLK_S
337 andcc %g1, FPRS_DU, %g0
338 be,pn %icc, 5f
3394: add %g2, 128, %g2
340 stda %f32, [%g2] ASI_BLK_S
341 stda %f48, [%g2 + %g3] ASI_BLK_S
3425: mov SECONDARY_CONTEXT, %g1
343 membar #Sync
344 stxa %g5, [%g1] ASI_DMMU
345 membar #Sync
346 ba,pt %xcc, etrap
347 wr %g0, 0, %fprs
348
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349 /* The registers for cross calls will be:
350 *
351 * DATA 0: [low 32-bits] Address of function to call, jmp to this
352 * [high 32-bits] MMU Context Argument 0, place in %g5
David S. Miller80dc0d62005-09-26 00:32:17 -0700353 * DATA 1: Address Argument 1, place in %g1
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354 * DATA 2: Address Argument 2, place in %g7
355 *
356 * With this method we can do most of the cross-call tlb/cache
357 * flushing very quickly.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358 */
359 .text
360 .align 32
361 .globl do_ivec
362do_ivec:
363 mov 0x40, %g3
364 ldxa [%g3 + %g0] ASI_INTR_R, %g3
365 sethi %hi(KERNBASE), %g4
366 cmp %g3, %g4
367 bgeu,pn %xcc, do_ivec_xcall
368 srlx %g3, 32, %g5
369 stxa %g0, [%g0] ASI_INTR_RECEIVE
370 membar #Sync
371
372 sethi %hi(ivector_table), %g2
373 sllx %g3, 5, %g3
374 or %g2, %lo(ivector_table), %g2
375 add %g2, %g3, %g3
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376 ldub [%g3 + 0x04], %g4 /* pil */
David S. Miller088dd1f2005-07-04 13:24:38 -0700377 mov 1, %g2
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378 sllx %g2, %g4, %g2
379 sllx %g4, 2, %g4
David S. Miller088dd1f2005-07-04 13:24:38 -0700380
David S. Miller56fb4df2006-02-26 23:24:22 -0800381 TRAP_LOAD_IRQ_WORK
382
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383 lduw [%g6 + %g4], %g5 /* g5 = irq_work(cpu, pil) */
384 stw %g5, [%g3 + 0x00] /* bucket->irq_chain = g5 */
385 stw %g3, [%g6 + %g4] /* irq_work(cpu, pil) = bucket */
386 wr %g2, 0x0, %set_softint
387 retry
388do_ivec_xcall:
389 mov 0x50, %g1
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390 ldxa [%g1 + %g0] ASI_INTR_R, %g1
391 srl %g3, 0, %g3
David S. Miller088dd1f2005-07-04 13:24:38 -0700392
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393 mov 0x60, %g7
394 ldxa [%g7 + %g0] ASI_INTR_R, %g7
395 stxa %g0, [%g0] ASI_INTR_RECEIVE
396 membar #Sync
397 ba,pt %xcc, 1f
398 nop
399
400 .align 32
4011: jmpl %g3, %g0
402 nop
403
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404 .globl getcc, setcc
405getcc:
406 ldx [%o0 + PT_V9_TSTATE], %o1
407 srlx %o1, 32, %o1
408 and %o1, 0xf, %o1
409 retl
410 stx %o1, [%o0 + PT_V9_G1]
411setcc:
412 ldx [%o0 + PT_V9_TSTATE], %o1
413 ldx [%o0 + PT_V9_G1], %o2
414 or %g0, %ulo(TSTATE_ICC), %o3
415 sllx %o3, 32, %o3
416 andn %o1, %o3, %o1
417 sllx %o2, 32, %o2
418 and %o2, %o3, %o2
419 or %o1, %o2, %o1
420 retl
421 stx %o1, [%o0 + PT_V9_TSTATE]
422
David S. Miller56fb4df2006-02-26 23:24:22 -0800423 .globl utrap_trap
424utrap_trap: /* %g3=handler,%g4=level */
425 TRAP_LOAD_THREAD_REG
426 ldx [%g6 + TI_UTRAPS], %g1
427 brnz,pt %g1, invoke_utrap
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428 nop
David S. Miller56fb4df2006-02-26 23:24:22 -0800429
430 ba,pt %xcc, etrap
431 rd %pc, %g7
432 mov %l4, %o1
433 call bad_trap
434 add %sp, PTREGS_OFF, %o0
435 ba,pt %xcc, rtrap
436 clr %l6
437
438invoke_utrap:
439 sllx %g3, 3, %g3
440 ldx [%g1 + %g3], %g1
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441 save %sp, -128, %sp
442 rdpr %tstate, %l6
443 rdpr %cwp, %l7
444 andn %l6, TSTATE_CWP, %l6
445 wrpr %l6, %l7, %tstate
446 rdpr %tpc, %l6
447 rdpr %tnpc, %l7
448 wrpr %g1, 0, %tnpc
449 done
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450
David S. Miller6c52a962005-08-29 12:45:11 -0700451 /* We need to carefully read the error status, ACK
452 * the errors, prevent recursive traps, and pass the
453 * information on to C code for logging.
454 *
455 * We pass the AFAR in as-is, and we encode the status
456 * information as described in asm-sparc64/sfafsr.h
457 */
458 .globl __spitfire_access_error
459__spitfire_access_error:
460 /* Disable ESTATE error reporting so that we do not
461 * take recursive traps and RED state the processor.
462 */
463 stxa %g0, [%g0] ASI_ESTATE_ERROR_EN
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464 membar #Sync
David S. Miller6c52a962005-08-29 12:45:11 -0700465
466 mov UDBE_UE, %g1
467 ldxa [%g0] ASI_AFSR, %g4 ! Get AFSR
468
469 /* __spitfire_cee_trap branches here with AFSR in %g4 and
470 * UDBE_CE in %g1. It only clears ESTATE_ERR_CE in the
471 * ESTATE Error Enable register.
472 */
473__spitfire_cee_trap_continue:
474 ldxa [%g0] ASI_AFAR, %g5 ! Get AFAR
475
David S. Millerbde4e4e2005-08-29 12:44:57 -0700476 rdpr %tt, %g3
David S. Miller6c52a962005-08-29 12:45:11 -0700477 and %g3, 0x1ff, %g3 ! Paranoia
478 sllx %g3, SFSTAT_TRAP_TYPE_SHIFT, %g3
479 or %g4, %g3, %g4
480 rdpr %tl, %g3
481 cmp %g3, 1
482 mov 1, %g3
483 bleu %xcc, 1f
484 sllx %g3, SFSTAT_TL_GT_ONE_SHIFT, %g3
485
486 or %g4, %g3, %g4
487
488 /* Read in the UDB error register state, clearing the
489 * sticky error bits as-needed. We only clear them if
490 * the UE bit is set. Likewise, __spitfire_cee_trap
491 * below will only do so if the CE bit is set.
492 *
493 * NOTE: UltraSparc-I/II have high and low UDB error
494 * registers, corresponding to the two UDB units
495 * present on those chips. UltraSparc-IIi only
496 * has a single UDB, called "SDB" in the manual.
497 * For IIi the upper UDB register always reads
498 * as zero so for our purposes things will just
499 * work with the checks below.
500 */
5011: ldxa [%g0] ASI_UDBH_ERROR_R, %g3
502 and %g3, 0x3ff, %g7 ! Paranoia
503 sllx %g7, SFSTAT_UDBH_SHIFT, %g7
504 or %g4, %g7, %g4
505 andcc %g3, %g1, %g3 ! UDBE_UE or UDBE_CE
506 be,pn %xcc, 1f
David S. Millerbde4e4e2005-08-29 12:44:57 -0700507 nop
David S. Miller6c52a962005-08-29 12:45:11 -0700508 stxa %g3, [%g0] ASI_UDB_ERROR_W
509 membar #Sync
510
5111: mov 0x18, %g3
512 ldxa [%g3] ASI_UDBL_ERROR_R, %g3
513 and %g3, 0x3ff, %g7 ! Paranoia
514 sllx %g7, SFSTAT_UDBL_SHIFT, %g7
515 or %g4, %g7, %g4
516 andcc %g3, %g1, %g3 ! UDBE_UE or UDBE_CE
517 be,pn %xcc, 1f
518 nop
519 mov 0x18, %g7
520 stxa %g3, [%g7] ASI_UDB_ERROR_W
521 membar #Sync
522
5231: /* Ok, now that we've latched the error state,
524 * clear the sticky bits in the AFSR.
525 */
526 stxa %g4, [%g0] ASI_AFSR
527 membar #Sync
528
529 rdpr %tl, %g2
530 cmp %g2, 1
531 rdpr %pil, %g2
532 bleu,pt %xcc, 1f
533 wrpr %g0, 15, %pil
534
David S. Millerbde4e4e2005-08-29 12:44:57 -0700535 ba,pt %xcc, etraptl1
David S. Miller6c52a962005-08-29 12:45:11 -0700536 rd %pc, %g7
David S. Millerbde4e4e2005-08-29 12:44:57 -0700537
David S. Miller6c52a962005-08-29 12:45:11 -0700538 ba,pt %xcc, 2f
539 nop
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540
David S. Miller6c52a962005-08-29 12:45:11 -07005411: ba,pt %xcc, etrap_irq
542 rd %pc, %g7
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543
David S. Miller6c52a962005-08-29 12:45:11 -07005442: mov %l4, %o1
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545 mov %l5, %o2
David S. Miller6c52a962005-08-29 12:45:11 -0700546 call spitfire_access_error
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547 add %sp, PTREGS_OFF, %o0
548 ba,pt %xcc, rtrap
549 clr %l6
550
551 /* This is the trap handler entry point for ECC correctable
552 * errors. They are corrected, but we listen for the trap
553 * so that the event can be logged.
554 *
555 * Disrupting errors are either:
556 * 1) single-bit ECC errors during UDB reads to system
557 * memory
558 * 2) data parity errors during write-back events
559 *
560 * As far as I can make out from the manual, the CEE trap
561 * is only for correctable errors during memory read
562 * accesses by the front-end of the processor.
563 *
564 * The code below is only for trap level 1 CEE events,
565 * as it is the only situation where we can safely record
566 * and log. For trap level >1 we just clear the CE bit
567 * in the AFSR and return.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568 *
David S. Miller6c52a962005-08-29 12:45:11 -0700569 * This is just like __spiftire_access_error above, but it
570 * specifically handles correctable errors. If an
571 * uncorrectable error is indicated in the AFSR we
572 * will branch directly above to __spitfire_access_error
573 * to handle it instead. Uncorrectable therefore takes
574 * priority over correctable, and the error logging
575 * C code will notice this case by inspecting the
576 * trap type.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577 */
David S. Miller6c52a962005-08-29 12:45:11 -0700578 .globl __spitfire_cee_trap
579__spitfire_cee_trap:
580 ldxa [%g0] ASI_AFSR, %g4 ! Get AFSR
581 mov 1, %g3
582 sllx %g3, SFAFSR_UE_SHIFT, %g3
583 andcc %g4, %g3, %g0 ! Check for UE
584 bne,pn %xcc, __spitfire_access_error
585 nop
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586
David S. Miller6c52a962005-08-29 12:45:11 -0700587 /* Ok, in this case we only have a correctable error.
588 * Indicate we only wish to capture that state in register
589 * %g1, and we only disable CE error reporting unlike UE
590 * handling which disables all errors.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700591 */
David S. Miller6c52a962005-08-29 12:45:11 -0700592 ldxa [%g0] ASI_ESTATE_ERROR_EN, %g3
593 andn %g3, ESTATE_ERR_CE, %g3
594 stxa %g3, [%g0] ASI_ESTATE_ERROR_EN
595 membar #Sync
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596
David S. Miller6c52a962005-08-29 12:45:11 -0700597 /* Preserve AFSR in %g4, indicate UDB state to capture in %g1 */
598 ba,pt %xcc, __spitfire_cee_trap_continue
599 mov UDBE_CE, %g1
600
601 .globl __spitfire_data_access_exception
602 .globl __spitfire_data_access_exception_tl1
603__spitfire_data_access_exception_tl1:
604 rdpr %pstate, %g4
605 wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
606 mov TLB_SFSR, %g3
607 mov DMMU_SFAR, %g5
608 ldxa [%g3] ASI_DMMU, %g4 ! Get SFSR
609 ldxa [%g5] ASI_DMMU, %g5 ! Get SFAR
610 stxa %g0, [%g3] ASI_DMMU ! Clear SFSR.FaultValid bit
611 membar #Sync
612 rdpr %tt, %g3
613 cmp %g3, 0x80 ! first win spill/fill trap
614 blu,pn %xcc, 1f
615 cmp %g3, 0xff ! last win spill/fill trap
616 bgu,pn %xcc, 1f
Linus Torvalds1da177e2005-04-16 15:20:36 -0700617 nop
David S. Miller6c52a962005-08-29 12:45:11 -0700618 ba,pt %xcc, winfix_dax
619 rdpr %tpc, %g3
6201: sethi %hi(109f), %g7
621 ba,pt %xcc, etraptl1
622109: or %g7, %lo(109b), %g7
623 mov %l4, %o1
624 mov %l5, %o2
625 call spitfire_data_access_exception_tl1
626 add %sp, PTREGS_OFF, %o0
627 ba,pt %xcc, rtrap
628 clr %l6
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629
David S. Miller6c52a962005-08-29 12:45:11 -0700630__spitfire_data_access_exception:
631 rdpr %pstate, %g4
632 wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
633 mov TLB_SFSR, %g3
634 mov DMMU_SFAR, %g5
635 ldxa [%g3] ASI_DMMU, %g4 ! Get SFSR
636 ldxa [%g5] ASI_DMMU, %g5 ! Get SFAR
637 stxa %g0, [%g3] ASI_DMMU ! Clear SFSR.FaultValid bit
638 membar #Sync
639 sethi %hi(109f), %g7
640 ba,pt %xcc, etrap
641109: or %g7, %lo(109b), %g7
642 mov %l4, %o1
643 mov %l5, %o2
644 call spitfire_data_access_exception
645 add %sp, PTREGS_OFF, %o0
646 ba,pt %xcc, rtrap
647 clr %l6
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648
David S. Miller6c52a962005-08-29 12:45:11 -0700649 .globl __spitfire_insn_access_exception
650 .globl __spitfire_insn_access_exception_tl1
651__spitfire_insn_access_exception_tl1:
652 rdpr %pstate, %g4
653 wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
654 mov TLB_SFSR, %g3
655 ldxa [%g3] ASI_IMMU, %g4 ! Get SFSR
656 rdpr %tpc, %g5 ! IMMU has no SFAR, use TPC
657 stxa %g0, [%g3] ASI_IMMU ! Clear FaultValid bit
658 membar #Sync
659 sethi %hi(109f), %g7
660 ba,pt %xcc, etraptl1
661109: or %g7, %lo(109b), %g7
662 mov %l4, %o1
663 mov %l5, %o2
664 call spitfire_insn_access_exception_tl1
665 add %sp, PTREGS_OFF, %o0
666 ba,pt %xcc, rtrap
667 clr %l6
Linus Torvalds1da177e2005-04-16 15:20:36 -0700668
David S. Miller6c52a962005-08-29 12:45:11 -0700669__spitfire_insn_access_exception:
670 rdpr %pstate, %g4
671 wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
672 mov TLB_SFSR, %g3
673 ldxa [%g3] ASI_IMMU, %g4 ! Get SFSR
674 rdpr %tpc, %g5 ! IMMU has no SFAR, use TPC
675 stxa %g0, [%g3] ASI_IMMU ! Clear FaultValid bit
676 membar #Sync
677 sethi %hi(109f), %g7
678 ba,pt %xcc, etrap
679109: or %g7, %lo(109b), %g7
680 mov %l4, %o1
681 mov %l5, %o2
682 call spitfire_insn_access_exception
683 add %sp, PTREGS_OFF, %o0
684 ba,pt %xcc, rtrap
685 clr %l6
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686
Linus Torvalds1da177e2005-04-16 15:20:36 -0700687 /* These get patched into the trap table at boot time
688 * once we know we have a cheetah processor.
689 */
690 .globl cheetah_fecc_trap_vector, cheetah_fecc_trap_vector_tl1
691cheetah_fecc_trap_vector:
692 membar #Sync
693 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
694 andn %g1, DCU_DC | DCU_IC, %g1
695 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
696 membar #Sync
697 sethi %hi(cheetah_fast_ecc), %g2
698 jmpl %g2 + %lo(cheetah_fast_ecc), %g0
699 mov 0, %g1
700cheetah_fecc_trap_vector_tl1:
701 membar #Sync
702 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
703 andn %g1, DCU_DC | DCU_IC, %g1
704 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
705 membar #Sync
706 sethi %hi(cheetah_fast_ecc), %g2
707 jmpl %g2 + %lo(cheetah_fast_ecc), %g0
708 mov 1, %g1
709 .globl cheetah_cee_trap_vector, cheetah_cee_trap_vector_tl1
710cheetah_cee_trap_vector:
711 membar #Sync
712 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
713 andn %g1, DCU_IC, %g1
714 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
715 membar #Sync
716 sethi %hi(cheetah_cee), %g2
717 jmpl %g2 + %lo(cheetah_cee), %g0
718 mov 0, %g1
719cheetah_cee_trap_vector_tl1:
720 membar #Sync
721 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
722 andn %g1, DCU_IC, %g1
723 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
724 membar #Sync
725 sethi %hi(cheetah_cee), %g2
726 jmpl %g2 + %lo(cheetah_cee), %g0
727 mov 1, %g1
728 .globl cheetah_deferred_trap_vector, cheetah_deferred_trap_vector_tl1
729cheetah_deferred_trap_vector:
730 membar #Sync
731 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1;
732 andn %g1, DCU_DC | DCU_IC, %g1;
733 stxa %g1, [%g0] ASI_DCU_CONTROL_REG;
734 membar #Sync;
735 sethi %hi(cheetah_deferred_trap), %g2
736 jmpl %g2 + %lo(cheetah_deferred_trap), %g0
737 mov 0, %g1
738cheetah_deferred_trap_vector_tl1:
739 membar #Sync;
740 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1;
741 andn %g1, DCU_DC | DCU_IC, %g1;
742 stxa %g1, [%g0] ASI_DCU_CONTROL_REG;
743 membar #Sync;
744 sethi %hi(cheetah_deferred_trap), %g2
745 jmpl %g2 + %lo(cheetah_deferred_trap), %g0
746 mov 1, %g1
747
748 /* Cheetah+ specific traps. These are for the new I/D cache parity
749 * error traps. The first argument to cheetah_plus_parity_handler
750 * is encoded as follows:
751 *
752 * Bit0: 0=dcache,1=icache
753 * Bit1: 0=recoverable,1=unrecoverable
754 */
755 .globl cheetah_plus_dcpe_trap_vector, cheetah_plus_dcpe_trap_vector_tl1
756cheetah_plus_dcpe_trap_vector:
757 membar #Sync
758 sethi %hi(do_cheetah_plus_data_parity), %g7
759 jmpl %g7 + %lo(do_cheetah_plus_data_parity), %g0
760 nop
761 nop
762 nop
763 nop
764 nop
765
766do_cheetah_plus_data_parity:
David S. Miller80dc0d62005-09-26 00:32:17 -0700767 rdpr %pil, %g2
768 wrpr %g0, 15, %pil
769 ba,pt %xcc, etrap_irq
Linus Torvalds1da177e2005-04-16 15:20:36 -0700770 rd %pc, %g7
771 mov 0x0, %o0
772 call cheetah_plus_parity_error
773 add %sp, PTREGS_OFF, %o1
David S. Miller80dc0d62005-09-26 00:32:17 -0700774 ba,a,pt %xcc, rtrap_irq
Linus Torvalds1da177e2005-04-16 15:20:36 -0700775
776cheetah_plus_dcpe_trap_vector_tl1:
777 membar #Sync
778 wrpr PSTATE_IG | PSTATE_PEF | PSTATE_PRIV, %pstate
779 sethi %hi(do_dcpe_tl1), %g3
780 jmpl %g3 + %lo(do_dcpe_tl1), %g0
781 nop
782 nop
783 nop
784 nop
785
786 .globl cheetah_plus_icpe_trap_vector, cheetah_plus_icpe_trap_vector_tl1
787cheetah_plus_icpe_trap_vector:
788 membar #Sync
789 sethi %hi(do_cheetah_plus_insn_parity), %g7
790 jmpl %g7 + %lo(do_cheetah_plus_insn_parity), %g0
791 nop
792 nop
793 nop
794 nop
795 nop
796
797do_cheetah_plus_insn_parity:
David S. Miller80dc0d62005-09-26 00:32:17 -0700798 rdpr %pil, %g2
799 wrpr %g0, 15, %pil
800 ba,pt %xcc, etrap_irq
Linus Torvalds1da177e2005-04-16 15:20:36 -0700801 rd %pc, %g7
802 mov 0x1, %o0
803 call cheetah_plus_parity_error
804 add %sp, PTREGS_OFF, %o1
David S. Miller80dc0d62005-09-26 00:32:17 -0700805 ba,a,pt %xcc, rtrap_irq
Linus Torvalds1da177e2005-04-16 15:20:36 -0700806
807cheetah_plus_icpe_trap_vector_tl1:
808 membar #Sync
809 wrpr PSTATE_IG | PSTATE_PEF | PSTATE_PRIV, %pstate
810 sethi %hi(do_icpe_tl1), %g3
811 jmpl %g3 + %lo(do_icpe_tl1), %g0
812 nop
813 nop
814 nop
815 nop
816
817 /* If we take one of these traps when tl >= 1, then we
818 * jump to interrupt globals. If some trap level above us
819 * was also using interrupt globals, we cannot recover.
820 * We may use all interrupt global registers except %g6.
821 */
822 .globl do_dcpe_tl1, do_icpe_tl1
823do_dcpe_tl1:
824 rdpr %tl, %g1 ! Save original trap level
825 mov 1, %g2 ! Setup TSTATE checking loop
826 sethi %hi(TSTATE_IG), %g3 ! TSTATE mask bit
8271: wrpr %g2, %tl ! Set trap level to check
828 rdpr %tstate, %g4 ! Read TSTATE for this level
829 andcc %g4, %g3, %g0 ! Interrupt globals in use?
830 bne,a,pn %xcc, do_dcpe_tl1_fatal ! Yep, irrecoverable
831 wrpr %g1, %tl ! Restore original trap level
832 add %g2, 1, %g2 ! Next trap level
833 cmp %g2, %g1 ! Hit them all yet?
834 ble,pt %icc, 1b ! Not yet
835 nop
836 wrpr %g1, %tl ! Restore original trap level
837do_dcpe_tl1_nonfatal: /* Ok we may use interrupt globals safely. */
David S. Miller80dc0d62005-09-26 00:32:17 -0700838 sethi %hi(dcache_parity_tl1_occurred), %g2
839 lduw [%g2 + %lo(dcache_parity_tl1_occurred)], %g1
840 add %g1, 1, %g1
841 stw %g1, [%g2 + %lo(dcache_parity_tl1_occurred)]
Linus Torvalds1da177e2005-04-16 15:20:36 -0700842 /* Reset D-cache parity */
843 sethi %hi(1 << 16), %g1 ! D-cache size
844 mov (1 << 5), %g2 ! D-cache line size
845 sub %g1, %g2, %g1 ! Move down 1 cacheline
8461: srl %g1, 14, %g3 ! Compute UTAG
847 membar #Sync
848 stxa %g3, [%g1] ASI_DCACHE_UTAG
849 membar #Sync
850 sub %g2, 8, %g3 ! 64-bit data word within line
8512: membar #Sync
852 stxa %g0, [%g1 + %g3] ASI_DCACHE_DATA
853 membar #Sync
854 subcc %g3, 8, %g3 ! Next 64-bit data word
855 bge,pt %icc, 2b
856 nop
857 subcc %g1, %g2, %g1 ! Next cacheline
858 bge,pt %icc, 1b
859 nop
860 ba,pt %xcc, dcpe_icpe_tl1_common
861 nop
862
863do_dcpe_tl1_fatal:
864 sethi %hi(1f), %g7
865 ba,pt %xcc, etraptl1
8661: or %g7, %lo(1b), %g7
867 mov 0x2, %o0
868 call cheetah_plus_parity_error
869 add %sp, PTREGS_OFF, %o1
870 ba,pt %xcc, rtrap
871 clr %l6
872
873do_icpe_tl1:
874 rdpr %tl, %g1 ! Save original trap level
875 mov 1, %g2 ! Setup TSTATE checking loop
876 sethi %hi(TSTATE_IG), %g3 ! TSTATE mask bit
8771: wrpr %g2, %tl ! Set trap level to check
878 rdpr %tstate, %g4 ! Read TSTATE for this level
879 andcc %g4, %g3, %g0 ! Interrupt globals in use?
880 bne,a,pn %xcc, do_icpe_tl1_fatal ! Yep, irrecoverable
881 wrpr %g1, %tl ! Restore original trap level
882 add %g2, 1, %g2 ! Next trap level
883 cmp %g2, %g1 ! Hit them all yet?
884 ble,pt %icc, 1b ! Not yet
885 nop
886 wrpr %g1, %tl ! Restore original trap level
887do_icpe_tl1_nonfatal: /* Ok we may use interrupt globals safely. */
David S. Miller80dc0d62005-09-26 00:32:17 -0700888 sethi %hi(icache_parity_tl1_occurred), %g2
889 lduw [%g2 + %lo(icache_parity_tl1_occurred)], %g1
890 add %g1, 1, %g1
891 stw %g1, [%g2 + %lo(icache_parity_tl1_occurred)]
Linus Torvalds1da177e2005-04-16 15:20:36 -0700892 /* Flush I-cache */
893 sethi %hi(1 << 15), %g1 ! I-cache size
894 mov (1 << 5), %g2 ! I-cache line size
895 sub %g1, %g2, %g1
8961: or %g1, (2 << 3), %g3
897 stxa %g0, [%g3] ASI_IC_TAG
898 membar #Sync
899 subcc %g1, %g2, %g1
900 bge,pt %icc, 1b
901 nop
902 ba,pt %xcc, dcpe_icpe_tl1_common
903 nop
904
905do_icpe_tl1_fatal:
906 sethi %hi(1f), %g7
907 ba,pt %xcc, etraptl1
9081: or %g7, %lo(1b), %g7
909 mov 0x3, %o0
910 call cheetah_plus_parity_error
911 add %sp, PTREGS_OFF, %o1
912 ba,pt %xcc, rtrap
913 clr %l6
914
915dcpe_icpe_tl1_common:
916 /* Flush D-cache, re-enable D/I caches in DCU and finally
917 * retry the trapping instruction.
918 */
919 sethi %hi(1 << 16), %g1 ! D-cache size
920 mov (1 << 5), %g2 ! D-cache line size
921 sub %g1, %g2, %g1
9221: stxa %g0, [%g1] ASI_DCACHE_TAG
923 membar #Sync
924 subcc %g1, %g2, %g1
925 bge,pt %icc, 1b
926 nop
927 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
928 or %g1, (DCU_DC | DCU_IC), %g1
929 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
930 membar #Sync
931 retry
932
David S. Miller3c2cafa2005-08-30 15:11:52 -0700933 /* Capture I/D/E-cache state into per-cpu error scoreboard.
934 *
935 * %g1: (TL>=0) ? 1 : 0
936 * %g2: scratch
937 * %g3: scratch
938 * %g4: AFSR
939 * %g5: AFAR
David S. Miller56fb4df2006-02-26 23:24:22 -0800940 * %g6: unused, will have current thread ptr after etrap
David S. Miller3c2cafa2005-08-30 15:11:52 -0700941 * %g7: scratch
942 */
943__cheetah_log_error:
944 /* Put "TL1" software bit into AFSR. */
945 and %g1, 0x1, %g1
946 sllx %g1, 63, %g2
947 or %g4, %g2, %g4
948
949 /* Get log entry pointer for this cpu at this trap level. */
950 BRANCH_IF_JALAPENO(g2,g3,50f)
951 ldxa [%g0] ASI_SAFARI_CONFIG, %g2
952 srlx %g2, 17, %g2
953 ba,pt %xcc, 60f
954 and %g2, 0x3ff, %g2
955
95650: ldxa [%g0] ASI_JBUS_CONFIG, %g2
957 srlx %g2, 17, %g2
958 and %g2, 0x1f, %g2
959
96060: sllx %g2, 9, %g2
961 sethi %hi(cheetah_error_log), %g3
962 ldx [%g3 + %lo(cheetah_error_log)], %g3
963 brz,pn %g3, 80f
964 nop
965
966 add %g3, %g2, %g3
967 sllx %g1, 8, %g1
968 add %g3, %g1, %g1
969
970 /* %g1 holds pointer to the top of the logging scoreboard */
971 ldx [%g1 + 0x0], %g7
972 cmp %g7, -1
973 bne,pn %xcc, 80f
974 nop
975
976 stx %g4, [%g1 + 0x0]
977 stx %g5, [%g1 + 0x8]
978 add %g1, 0x10, %g1
979
980 /* %g1 now points to D-cache logging area */
981 set 0x3ff8, %g2 /* DC_addr mask */
982 and %g5, %g2, %g2 /* DC_addr bits of AFAR */
983 srlx %g5, 12, %g3
984 or %g3, 1, %g3 /* PHYS tag + valid */
985
98610: ldxa [%g2] ASI_DCACHE_TAG, %g7
987 cmp %g3, %g7 /* TAG match? */
988 bne,pt %xcc, 13f
989 nop
990
991 /* Yep, what we want, capture state. */
992 stx %g2, [%g1 + 0x20]
993 stx %g7, [%g1 + 0x28]
994
995 /* A membar Sync is required before and after utag access. */
996 membar #Sync
997 ldxa [%g2] ASI_DCACHE_UTAG, %g7
998 membar #Sync
999 stx %g7, [%g1 + 0x30]
1000 ldxa [%g2] ASI_DCACHE_SNOOP_TAG, %g7
1001 stx %g7, [%g1 + 0x38]
1002 clr %g3
1003
100412: ldxa [%g2 + %g3] ASI_DCACHE_DATA, %g7
1005 stx %g7, [%g1]
1006 add %g3, (1 << 5), %g3
1007 cmp %g3, (4 << 5)
1008 bl,pt %xcc, 12b
1009 add %g1, 0x8, %g1
1010
1011 ba,pt %xcc, 20f
1012 add %g1, 0x20, %g1
1013
101413: sethi %hi(1 << 14), %g7
1015 add %g2, %g7, %g2
1016 srlx %g2, 14, %g7
1017 cmp %g7, 4
1018 bl,pt %xcc, 10b
1019 nop
1020
1021 add %g1, 0x40, %g1
1022
1023 /* %g1 now points to I-cache logging area */
102420: set 0x1fe0, %g2 /* IC_addr mask */
1025 and %g5, %g2, %g2 /* IC_addr bits of AFAR */
1026 sllx %g2, 1, %g2 /* IC_addr[13:6]==VA[12:5] */
1027 srlx %g5, (13 - 8), %g3 /* Make PTAG */
1028 andn %g3, 0xff, %g3 /* Mask off undefined bits */
1029
103021: ldxa [%g2] ASI_IC_TAG, %g7
1031 andn %g7, 0xff, %g7
1032 cmp %g3, %g7
1033 bne,pt %xcc, 23f
1034 nop
1035
1036 /* Yep, what we want, capture state. */
1037 stx %g2, [%g1 + 0x40]
1038 stx %g7, [%g1 + 0x48]
1039 add %g2, (1 << 3), %g2
1040 ldxa [%g2] ASI_IC_TAG, %g7
1041 add %g2, (1 << 3), %g2
1042 stx %g7, [%g1 + 0x50]
1043 ldxa [%g2] ASI_IC_TAG, %g7
1044 add %g2, (1 << 3), %g2
1045 stx %g7, [%g1 + 0x60]
1046 ldxa [%g2] ASI_IC_TAG, %g7
1047 stx %g7, [%g1 + 0x68]
1048 sub %g2, (3 << 3), %g2
1049 ldxa [%g2] ASI_IC_STAG, %g7
1050 stx %g7, [%g1 + 0x58]
1051 clr %g3
1052 srlx %g2, 2, %g2
1053
105422: ldxa [%g2 + %g3] ASI_IC_INSTR, %g7
1055 stx %g7, [%g1]
1056 add %g3, (1 << 3), %g3
1057 cmp %g3, (8 << 3)
1058 bl,pt %xcc, 22b
1059 add %g1, 0x8, %g1
1060
1061 ba,pt %xcc, 30f
1062 add %g1, 0x30, %g1
1063
106423: sethi %hi(1 << 14), %g7
1065 add %g2, %g7, %g2
1066 srlx %g2, 14, %g7
1067 cmp %g7, 4
1068 bl,pt %xcc, 21b
1069 nop
1070
1071 add %g1, 0x70, %g1
1072
1073 /* %g1 now points to E-cache logging area */
107430: andn %g5, (32 - 1), %g2
1075 stx %g2, [%g1 + 0x20]
1076 ldxa [%g2] ASI_EC_TAG_DATA, %g7
1077 stx %g7, [%g1 + 0x28]
1078 ldxa [%g2] ASI_EC_R, %g0
1079 clr %g3
1080
108131: ldxa [%g3] ASI_EC_DATA, %g7
1082 stx %g7, [%g1 + %g3]
1083 add %g3, 0x8, %g3
1084 cmp %g3, 0x20
1085
1086 bl,pt %xcc, 31b
1087 nop
108880:
1089 rdpr %tt, %g2
1090 cmp %g2, 0x70
1091 be c_fast_ecc
1092 cmp %g2, 0x63
1093 be c_cee
1094 nop
1095 ba,pt %xcc, c_deferred
1096
Linus Torvalds1da177e2005-04-16 15:20:36 -07001097 /* Cheetah FECC trap handling, we get here from tl{0,1}_fecc
1098 * in the trap table. That code has done a memory barrier
1099 * and has disabled both the I-cache and D-cache in the DCU
1100 * control register. The I-cache is disabled so that we may
1101 * capture the corrupted cache line, and the D-cache is disabled
1102 * because corrupt data may have been placed there and we don't
1103 * want to reference it.
1104 *
1105 * %g1 is one if this trap occurred at %tl >= 1.
1106 *
1107 * Next, we turn off error reporting so that we don't recurse.
1108 */
1109 .globl cheetah_fast_ecc
1110cheetah_fast_ecc:
1111 ldxa [%g0] ASI_ESTATE_ERROR_EN, %g2
1112 andn %g2, ESTATE_ERROR_NCEEN | ESTATE_ERROR_CEEN, %g2
1113 stxa %g2, [%g0] ASI_ESTATE_ERROR_EN
1114 membar #Sync
1115
1116 /* Fetch and clear AFSR/AFAR */
1117 ldxa [%g0] ASI_AFSR, %g4
1118 ldxa [%g0] ASI_AFAR, %g5
1119 stxa %g4, [%g0] ASI_AFSR
1120 membar #Sync
1121
David S. Miller3c2cafa2005-08-30 15:11:52 -07001122 ba,pt %xcc, __cheetah_log_error
1123 nop
Linus Torvalds1da177e2005-04-16 15:20:36 -07001124
David S. Miller3c2cafa2005-08-30 15:11:52 -07001125c_fast_ecc:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001126 rdpr %pil, %g2
1127 wrpr %g0, 15, %pil
1128 ba,pt %xcc, etrap_irq
1129 rd %pc, %g7
1130 mov %l4, %o1
1131 mov %l5, %o2
1132 call cheetah_fecc_handler
1133 add %sp, PTREGS_OFF, %o0
1134 ba,a,pt %xcc, rtrap_irq
1135
1136 /* Our caller has disabled I-cache and performed membar Sync. */
1137 .globl cheetah_cee
1138cheetah_cee:
1139 ldxa [%g0] ASI_ESTATE_ERROR_EN, %g2
1140 andn %g2, ESTATE_ERROR_CEEN, %g2
1141 stxa %g2, [%g0] ASI_ESTATE_ERROR_EN
1142 membar #Sync
1143
1144 /* Fetch and clear AFSR/AFAR */
1145 ldxa [%g0] ASI_AFSR, %g4
1146 ldxa [%g0] ASI_AFAR, %g5
1147 stxa %g4, [%g0] ASI_AFSR
1148 membar #Sync
1149
David S. Miller3c2cafa2005-08-30 15:11:52 -07001150 ba,pt %xcc, __cheetah_log_error
1151 nop
Linus Torvalds1da177e2005-04-16 15:20:36 -07001152
David S. Miller3c2cafa2005-08-30 15:11:52 -07001153c_cee:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001154 rdpr %pil, %g2
1155 wrpr %g0, 15, %pil
1156 ba,pt %xcc, etrap_irq
1157 rd %pc, %g7
1158 mov %l4, %o1
1159 mov %l5, %o2
1160 call cheetah_cee_handler
1161 add %sp, PTREGS_OFF, %o0
1162 ba,a,pt %xcc, rtrap_irq
1163
1164 /* Our caller has disabled I-cache+D-cache and performed membar Sync. */
1165 .globl cheetah_deferred_trap
1166cheetah_deferred_trap:
1167 ldxa [%g0] ASI_ESTATE_ERROR_EN, %g2
1168 andn %g2, ESTATE_ERROR_NCEEN | ESTATE_ERROR_CEEN, %g2
1169 stxa %g2, [%g0] ASI_ESTATE_ERROR_EN
1170 membar #Sync
1171
1172 /* Fetch and clear AFSR/AFAR */
1173 ldxa [%g0] ASI_AFSR, %g4
1174 ldxa [%g0] ASI_AFAR, %g5
1175 stxa %g4, [%g0] ASI_AFSR
1176 membar #Sync
1177
David S. Miller3c2cafa2005-08-30 15:11:52 -07001178 ba,pt %xcc, __cheetah_log_error
1179 nop
Linus Torvalds1da177e2005-04-16 15:20:36 -07001180
David S. Miller3c2cafa2005-08-30 15:11:52 -07001181c_deferred:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001182 rdpr %pil, %g2
1183 wrpr %g0, 15, %pil
1184 ba,pt %xcc, etrap_irq
1185 rd %pc, %g7
1186 mov %l4, %o1
1187 mov %l5, %o2
1188 call cheetah_deferred_handler
1189 add %sp, PTREGS_OFF, %o0
1190 ba,a,pt %xcc, rtrap_irq
1191
1192 .globl __do_privact
1193__do_privact:
1194 mov TLB_SFSR, %g3
1195 stxa %g0, [%g3] ASI_DMMU ! Clear FaultValid bit
1196 membar #Sync
1197 sethi %hi(109f), %g7
1198 ba,pt %xcc, etrap
1199109: or %g7, %lo(109b), %g7
1200 call do_privact
1201 add %sp, PTREGS_OFF, %o0
1202 ba,pt %xcc, rtrap
1203 clr %l6
1204
1205 .globl do_mna
1206do_mna:
1207 rdpr %tl, %g3
1208 cmp %g3, 1
1209
1210 /* Setup %g4/%g5 now as they are used in the
1211 * winfixup code.
1212 */
1213 mov TLB_SFSR, %g3
1214 mov DMMU_SFAR, %g4
1215 ldxa [%g4] ASI_DMMU, %g4
1216 ldxa [%g3] ASI_DMMU, %g5
1217 stxa %g0, [%g3] ASI_DMMU ! Clear FaultValid bit
1218 membar #Sync
1219 bgu,pn %icc, winfix_mna
1220 rdpr %tpc, %g3
1221
12221: sethi %hi(109f), %g7
1223 ba,pt %xcc, etrap
1224109: or %g7, %lo(109b), %g7
1225 mov %l4, %o1
1226 mov %l5, %o2
1227 call mem_address_unaligned
1228 add %sp, PTREGS_OFF, %o0
1229 ba,pt %xcc, rtrap
1230 clr %l6
1231
1232 .globl do_lddfmna
1233do_lddfmna:
1234 sethi %hi(109f), %g7
1235 mov TLB_SFSR, %g4
1236 ldxa [%g4] ASI_DMMU, %g5
1237 stxa %g0, [%g4] ASI_DMMU ! Clear FaultValid bit
1238 membar #Sync
1239 mov DMMU_SFAR, %g4
1240 ldxa [%g4] ASI_DMMU, %g4
1241 ba,pt %xcc, etrap
1242109: or %g7, %lo(109b), %g7
1243 mov %l4, %o1
1244 mov %l5, %o2
1245 call handle_lddfmna
1246 add %sp, PTREGS_OFF, %o0
1247 ba,pt %xcc, rtrap
1248 clr %l6
1249
1250 .globl do_stdfmna
1251do_stdfmna:
1252 sethi %hi(109f), %g7
1253 mov TLB_SFSR, %g4
1254 ldxa [%g4] ASI_DMMU, %g5
1255 stxa %g0, [%g4] ASI_DMMU ! Clear FaultValid bit
1256 membar #Sync
1257 mov DMMU_SFAR, %g4
1258 ldxa [%g4] ASI_DMMU, %g4
1259 ba,pt %xcc, etrap
1260109: or %g7, %lo(109b), %g7
1261 mov %l4, %o1
1262 mov %l5, %o2
1263 call handle_stdfmna
1264 add %sp, PTREGS_OFF, %o0
1265 ba,pt %xcc, rtrap
1266 clr %l6
1267
1268 .globl breakpoint_trap
1269breakpoint_trap:
1270 call sparc_breakpoint
1271 add %sp, PTREGS_OFF, %o0
1272 ba,pt %xcc, rtrap
1273 nop
1274
1275#if defined(CONFIG_SUNOS_EMUL) || defined(CONFIG_SOLARIS_EMUL) || \
1276 defined(CONFIG_SOLARIS_EMUL_MODULE)
1277 /* SunOS uses syscall zero as the 'indirect syscall' it looks
1278 * like indir_syscall(scall_num, arg0, arg1, arg2...); etc.
1279 * This is complete brain damage.
1280 */
1281 .globl sunos_indir
1282sunos_indir:
1283 srl %o0, 0, %o0
1284 mov %o7, %l4
1285 cmp %o0, NR_SYSCALLS
1286 blu,a,pt %icc, 1f
1287 sll %o0, 0x2, %o0
1288 sethi %hi(sunos_nosys), %l6
1289 b,pt %xcc, 2f
1290 or %l6, %lo(sunos_nosys), %l6
12911: sethi %hi(sunos_sys_table), %l7
1292 or %l7, %lo(sunos_sys_table), %l7
1293 lduw [%l7 + %o0], %l6
12942: mov %o1, %o0
1295 mov %o2, %o1
1296 mov %o3, %o2
1297 mov %o4, %o3
1298 mov %o5, %o4
1299 call %l6
1300 mov %l4, %o7
1301
1302 .globl sunos_getpid
1303sunos_getpid:
1304 call sys_getppid
1305 nop
1306 call sys_getpid
1307 stx %o0, [%sp + PTREGS_OFF + PT_V9_I1]
1308 b,pt %xcc, ret_sys_call
1309 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
1310
1311 /* SunOS getuid() returns uid in %o0 and euid in %o1 */
1312 .globl sunos_getuid
1313sunos_getuid:
1314 call sys32_geteuid16
1315 nop
1316 call sys32_getuid16
1317 stx %o0, [%sp + PTREGS_OFF + PT_V9_I1]
1318 b,pt %xcc, ret_sys_call
1319 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
1320
1321 /* SunOS getgid() returns gid in %o0 and egid in %o1 */
1322 .globl sunos_getgid
1323sunos_getgid:
1324 call sys32_getegid16
1325 nop
1326 call sys32_getgid16
1327 stx %o0, [%sp + PTREGS_OFF + PT_V9_I1]
1328 b,pt %xcc, ret_sys_call
1329 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
1330#endif
1331
1332 /* SunOS's execv() call only specifies the argv argument, the
1333 * environment settings are the same as the calling processes.
1334 */
1335 .globl sunos_execv
1336sys_execve:
1337 sethi %hi(sparc_execve), %g1
1338 ba,pt %xcc, execve_merge
1339 or %g1, %lo(sparc_execve), %g1
1340#ifdef CONFIG_COMPAT
1341 .globl sys_execve
1342sunos_execv:
1343 stx %g0, [%sp + PTREGS_OFF + PT_V9_I2]
1344 .globl sys32_execve
1345sys32_execve:
1346 sethi %hi(sparc32_execve), %g1
1347 or %g1, %lo(sparc32_execve), %g1
1348#endif
1349execve_merge:
1350 flushw
1351 jmpl %g1, %g0
1352 add %sp, PTREGS_OFF, %o0
1353
1354 .globl sys_pipe, sys_sigpause, sys_nis_syscall
Linus Torvalds1da177e2005-04-16 15:20:36 -07001355 .globl sys_rt_sigreturn
1356 .globl sys_ptrace
1357 .globl sys_sigaltstack
1358 .align 32
1359sys_pipe: ba,pt %xcc, sparc_pipe
1360 add %sp, PTREGS_OFF, %o0
1361sys_nis_syscall:ba,pt %xcc, c_sys_nis_syscall
1362 add %sp, PTREGS_OFF, %o0
1363sys_memory_ordering:
1364 ba,pt %xcc, sparc_memory_ordering
1365 add %sp, PTREGS_OFF, %o1
1366sys_sigaltstack:ba,pt %xcc, do_sigaltstack
1367 add %i6, STACK_BIAS, %o2
1368#ifdef CONFIG_COMPAT
1369 .globl sys32_sigstack
1370sys32_sigstack: ba,pt %xcc, do_sys32_sigstack
1371 mov %i6, %o2
1372 .globl sys32_sigaltstack
1373sys32_sigaltstack:
1374 ba,pt %xcc, do_sys32_sigaltstack
1375 mov %i6, %o2
1376#endif
1377 .align 32
Linus Torvalds1da177e2005-04-16 15:20:36 -07001378#ifdef CONFIG_COMPAT
1379 .globl sys32_sigreturn
1380sys32_sigreturn:
1381 add %sp, PTREGS_OFF, %o0
1382 call do_sigreturn32
1383 add %o7, 1f-.-4, %o7
1384 nop
1385#endif
1386sys_rt_sigreturn:
1387 add %sp, PTREGS_OFF, %o0
1388 call do_rt_sigreturn
1389 add %o7, 1f-.-4, %o7
1390 nop
1391#ifdef CONFIG_COMPAT
1392 .globl sys32_rt_sigreturn
1393sys32_rt_sigreturn:
1394 add %sp, PTREGS_OFF, %o0
1395 call do_rt_sigreturn32
1396 add %o7, 1f-.-4, %o7
1397 nop
1398#endif
1399sys_ptrace: add %sp, PTREGS_OFF, %o0
1400 call do_ptrace
1401 add %o7, 1f-.-4, %o7
1402 nop
1403 .align 32
14041: ldx [%curptr + TI_FLAGS], %l5
David S. Millerf7ceba32005-07-10 19:29:45 -07001405 andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
Linus Torvalds1da177e2005-04-16 15:20:36 -07001406 be,pt %icc, rtrap
1407 clr %l6
David S. Miller8d8a6472005-07-10 16:55:48 -07001408 add %sp, PTREGS_OFF, %o0
Linus Torvalds1da177e2005-04-16 15:20:36 -07001409 call syscall_trace
David S. Miller8d8a6472005-07-10 16:55:48 -07001410 mov 1, %o1
Linus Torvalds1da177e2005-04-16 15:20:36 -07001411
1412 ba,pt %xcc, rtrap
1413 clr %l6
1414
1415 /* This is how fork() was meant to be done, 8 instruction entry.
1416 *
1417 * I questioned the following code briefly, let me clear things
1418 * up so you must not reason on it like I did.
1419 *
1420 * Know the fork_kpsr etc. we use in the sparc32 port? We don't
1421 * need it here because the only piece of window state we copy to
1422 * the child is the CWP register. Even if the parent sleeps,
1423 * we are safe because we stuck it into pt_regs of the parent
1424 * so it will not change.
1425 *
1426 * XXX This raises the question, whether we can do the same on
1427 * XXX sparc32 to get rid of fork_kpsr _and_ fork_kwim. The
1428 * XXX answer is yes. We stick fork_kpsr in UREG_G0 and
1429 * XXX fork_kwim in UREG_G1 (global registers are considered
1430 * XXX volatile across a system call in the sparc ABI I think
1431 * XXX if it isn't we can use regs->y instead, anyone who depends
1432 * XXX upon the Y register being preserved across a fork deserves
1433 * XXX to lose).
1434 *
1435 * In fact we should take advantage of that fact for other things
1436 * during system calls...
1437 */
1438 .globl sys_fork, sys_vfork, sys_clone, sparc_exit
1439 .globl ret_from_syscall
1440 .align 32
1441sys_vfork: /* Under Linux, vfork and fork are just special cases of clone. */
1442 sethi %hi(0x4000 | 0x0100 | SIGCHLD), %o0
1443 or %o0, %lo(0x4000 | 0x0100 | SIGCHLD), %o0
1444 ba,pt %xcc, sys_clone
1445sys_fork: clr %o1
1446 mov SIGCHLD, %o0
1447sys_clone: flushw
1448 movrz %o1, %fp, %o1
1449 mov 0, %o3
1450 ba,pt %xcc, sparc_do_fork
1451 add %sp, PTREGS_OFF, %o2
1452ret_from_syscall:
David S. Millerdb7d9a42005-07-24 19:36:26 -07001453 /* Clear current_thread_info()->new_child, and
1454 * check performance counter stuff too.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001455 */
David S. Millerdb7d9a42005-07-24 19:36:26 -07001456 stb %g0, [%g6 + TI_NEW_CHILD]
1457 ldx [%g6 + TI_FLAGS], %l0
Linus Torvalds1da177e2005-04-16 15:20:36 -07001458 call schedule_tail
1459 mov %g7, %o0
1460 andcc %l0, _TIF_PERFCTR, %g0
1461 be,pt %icc, 1f
1462 nop
1463 ldx [%g6 + TI_PCR], %o7
1464 wr %g0, %o7, %pcr
1465
1466 /* Blackbird errata workaround. See commentary in
1467 * smp.c:smp_percpu_timer_interrupt() for more
1468 * information.
1469 */
1470 ba,pt %xcc, 99f
1471 nop
1472 .align 64
147399: wr %g0, %g0, %pic
1474 rd %pic, %g0
1475
14761: b,pt %xcc, ret_sys_call
1477 ldx [%sp + PTREGS_OFF + PT_V9_I0], %o0
1478sparc_exit: wrpr %g0, (PSTATE_RMO | PSTATE_PEF | PSTATE_PRIV), %pstate
1479 rdpr %otherwin, %g1
1480 rdpr %cansave, %g3
1481 add %g3, %g1, %g3
1482 wrpr %g3, 0x0, %cansave
1483 wrpr %g0, 0x0, %otherwin
1484 wrpr %g0, (PSTATE_RMO | PSTATE_PEF | PSTATE_PRIV | PSTATE_IE), %pstate
1485 ba,pt %xcc, sys_exit
1486 stb %g0, [%g6 + TI_WSAVED]
1487
1488linux_sparc_ni_syscall:
1489 sethi %hi(sys_ni_syscall), %l7
1490 b,pt %xcc, 4f
1491 or %l7, %lo(sys_ni_syscall), %l7
1492
1493linux_syscall_trace32:
David S. Miller8d8a6472005-07-10 16:55:48 -07001494 add %sp, PTREGS_OFF, %o0
Linus Torvalds1da177e2005-04-16 15:20:36 -07001495 call syscall_trace
David S. Miller8d8a6472005-07-10 16:55:48 -07001496 clr %o1
Linus Torvalds1da177e2005-04-16 15:20:36 -07001497 srl %i0, 0, %o0
David S. Miller8d8a6472005-07-10 16:55:48 -07001498 srl %i4, 0, %o4
Linus Torvalds1da177e2005-04-16 15:20:36 -07001499 srl %i1, 0, %o1
1500 srl %i2, 0, %o2
1501 b,pt %xcc, 2f
1502 srl %i3, 0, %o3
1503
1504linux_syscall_trace:
David S. Miller8d8a6472005-07-10 16:55:48 -07001505 add %sp, PTREGS_OFF, %o0
Linus Torvalds1da177e2005-04-16 15:20:36 -07001506 call syscall_trace
David S. Miller8d8a6472005-07-10 16:55:48 -07001507 clr %o1
Linus Torvalds1da177e2005-04-16 15:20:36 -07001508 mov %i0, %o0
1509 mov %i1, %o1
1510 mov %i2, %o2
1511 mov %i3, %o3
1512 b,pt %xcc, 2f
1513 mov %i4, %o4
1514
1515
1516 /* Linux 32-bit and SunOS system calls enter here... */
1517 .align 32
1518 .globl linux_sparc_syscall32
1519linux_sparc_syscall32:
1520 /* Direct access to user regs, much faster. */
1521 cmp %g1, NR_SYSCALLS ! IEU1 Group
1522 bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI
1523 srl %i0, 0, %o0 ! IEU0
1524 sll %g1, 2, %l4 ! IEU0 Group
Linus Torvalds1da177e2005-04-16 15:20:36 -07001525 srl %i4, 0, %o4 ! IEU1
1526 lduw [%l7 + %l4], %l7 ! Load
1527 srl %i1, 0, %o1 ! IEU0 Group
1528 ldx [%curptr + TI_FLAGS], %l0 ! Load
1529
1530 srl %i5, 0, %o5 ! IEU1
1531 srl %i2, 0, %o2 ! IEU0 Group
David S. Millerf7ceba32005-07-10 19:29:45 -07001532 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
Linus Torvalds1da177e2005-04-16 15:20:36 -07001533 bne,pn %icc, linux_syscall_trace32 ! CTI
1534 mov %i0, %l5 ! IEU1
1535 call %l7 ! CTI Group brk forced
1536 srl %i3, 0, %o3 ! IEU0
1537 ba,a,pt %xcc, 3f
1538
1539 /* Linux native and SunOS system calls enter here... */
1540 .align 32
1541 .globl linux_sparc_syscall, ret_sys_call
1542linux_sparc_syscall:
1543 /* Direct access to user regs, much faster. */
1544 cmp %g1, NR_SYSCALLS ! IEU1 Group
1545 bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI
1546 mov %i0, %o0 ! IEU0
1547 sll %g1, 2, %l4 ! IEU0 Group
Linus Torvalds1da177e2005-04-16 15:20:36 -07001548 mov %i1, %o1 ! IEU1
1549 lduw [%l7 + %l4], %l7 ! Load
15504: mov %i2, %o2 ! IEU0 Group
1551 ldx [%curptr + TI_FLAGS], %l0 ! Load
1552
1553 mov %i3, %o3 ! IEU1
1554 mov %i4, %o4 ! IEU0 Group
David S. Millerf7ceba32005-07-10 19:29:45 -07001555 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
Linus Torvalds1da177e2005-04-16 15:20:36 -07001556 bne,pn %icc, linux_syscall_trace ! CTI Group
1557 mov %i0, %l5 ! IEU0
15582: call %l7 ! CTI Group brk forced
1559 mov %i5, %o5 ! IEU0
1560 nop
1561
15623: stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
1563ret_sys_call:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001564 ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %g3
1565 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
1566 sra %o0, 0, %o0
1567 mov %ulo(TSTATE_XCARRY | TSTATE_ICARRY), %g2
1568 sllx %g2, 32, %g2
1569
1570 /* Check if force_successful_syscall_return()
1571 * was invoked.
1572 */
Richard Mortimer695ca072006-01-09 14:35:50 -08001573 ldub [%curptr + TI_SYS_NOERROR], %l2
1574 brnz,a,pn %l2, 80f
David S. Millerdb7d9a42005-07-24 19:36:26 -07001575 stb %g0, [%curptr + TI_SYS_NOERROR]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001576
Linus Torvalds1da177e2005-04-16 15:20:36 -07001577 cmp %o0, -ERESTART_RESTARTBLOCK
1578 bgeu,pn %xcc, 1f
David S. Millerf7ceba32005-07-10 19:29:45 -07001579 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %l6
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158080:
1581 /* System call success, clear Carry condition code. */
1582 andn %g3, %g2, %g3
1583 stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE]
1584 bne,pn %icc, linux_syscall_trace2
1585 add %l1, 0x4, %l2 ! npc = npc+4
1586 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
1587 ba,pt %xcc, rtrap_clr_l6
1588 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
1589
15901:
1591 /* System call failure, set Carry condition code.
1592 * Also, get abs(errno) to return to the process.
1593 */
David S. Millerf7ceba32005-07-10 19:29:45 -07001594 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %l6
Linus Torvalds1da177e2005-04-16 15:20:36 -07001595 sub %g0, %o0, %o0
1596 or %g3, %g2, %g3
1597 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
1598 mov 1, %l6
1599 stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE]
1600 bne,pn %icc, linux_syscall_trace2
1601 add %l1, 0x4, %l2 ! npc = npc+4
1602 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
1603
1604 b,pt %xcc, rtrap
1605 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
1606linux_syscall_trace2:
David S. Miller8d8a6472005-07-10 16:55:48 -07001607 add %sp, PTREGS_OFF, %o0
Linus Torvalds1da177e2005-04-16 15:20:36 -07001608 call syscall_trace
David S. Miller8d8a6472005-07-10 16:55:48 -07001609 mov 1, %o1
Linus Torvalds1da177e2005-04-16 15:20:36 -07001610 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
1611 ba,pt %xcc, rtrap
1612 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
1613
1614 .align 32
1615 .globl __flushw_user
1616__flushw_user:
1617 rdpr %otherwin, %g1
1618 brz,pn %g1, 2f
1619 clr %g2
16201: save %sp, -128, %sp
1621 rdpr %otherwin, %g1
1622 brnz,pt %g1, 1b
1623 add %g2, 1, %g2
16241: sub %g2, 1, %g2
1625 brnz,pt %g2, 1b
1626 restore %g0, %g0, %g0
16272: retl
1628 nop
David S. Miller56fb4df2006-02-26 23:24:22 -08001629
1630 /* Read cpu ID from hardware, return in %g6.
1631 * (callers_pc - 4) is in %g1. Patched at boot time.
1632 *
1633 * Default is spitfire implementation.
1634 *
1635 * The instruction sequence needs to be 5 instructions
1636 * in order to fit the longest implementation, which is
1637 * currently starfire.
1638 */
1639 .align 32
1640 .globl __get_cpu_id
1641__get_cpu_id:
1642 ldxa [%g0] ASI_UPA_CONFIG, %g6
1643 srlx %g6, 17, %g6
1644 jmpl %g1 + 0x4, %g0
1645 and %g6, 0x1f, %g6
1646 nop
1647
1648__get_cpu_id_cheetah_safari:
1649 ldxa [%g0] ASI_SAFARI_CONFIG, %g6
1650 srlx %g6, 17, %g6
1651 jmpl %g1 + 0x4, %g0
1652 and %g6, 0x3ff, %g6
1653 nop
1654
1655__get_cpu_id_cheetah_jbus:
1656 ldxa [%g0] ASI_JBUS_CONFIG, %g6
1657 srlx %g6, 17, %g6
1658 jmpl %g1 + 0x4, %g0
1659 and %g6, 0x1f, %g6
1660 nop
1661
1662__get_cpu_id_starfire:
1663 sethi %hi(0x1fff40000d0 >> 9), %g6
1664 sllx %g6, 9, %g6
1665 or %g6, 0xd0, %g6
1666 jmpl %g1 + 0x4, %g0
1667 lduwa [%g6] ASI_PHYS_BYPASS_EC_E, %g6
1668
1669 .globl per_cpu_patch
1670per_cpu_patch:
1671 sethi %hi(this_is_starfire), %o0
1672 lduw [%o0 + %lo(this_is_starfire)], %o1
1673 sethi %hi(__get_cpu_id_starfire), %o0
1674 brnz,pn %o1, 10f
1675 or %o0, %lo(__get_cpu_id_starfire), %o0
1676 sethi %hi(tlb_type), %o0
1677 lduw [%o0 + %lo(tlb_type)], %o1
1678 brz,pt %o1, 11f
1679 nop
1680 rdpr %ver, %o0
1681 srlx %o0, 32, %o0
1682 sethi %hi(0x003e0016), %o1
1683 or %o1, %lo(0x003e0016), %o1
1684 cmp %o0, %o1
1685 sethi %hi(__get_cpu_id_cheetah_jbus), %o0
1686 be,pn %icc, 10f
1687 or %o0, %lo(__get_cpu_id_cheetah_jbus), %o0
1688 sethi %hi(__get_cpu_id_cheetah_safari), %o0
1689 or %o0, %lo(__get_cpu_id_cheetah_safari), %o0
169010:
1691 sethi %hi(__get_cpu_id), %o1
1692 or %o1, %lo(__get_cpu_id), %o1
1693 lduw [%o0 + 0x00], %o2
1694 stw %o2, [%o1 + 0x00]
1695 flush %o1 + 0x00
1696 lduw [%o0 + 0x04], %o2
1697 stw %o2, [%o1 + 0x04]
1698 flush %o1 + 0x04
1699 lduw [%o0 + 0x08], %o2
1700 stw %o2, [%o1 + 0x08]
1701 flush %o1 + 0x08
1702 lduw [%o0 + 0x0c], %o2
1703 stw %o2, [%o1 + 0x0c]
1704 flush %o1 + 0x0c
1705 lduw [%o0 + 0x10], %o2
1706 stw %o2, [%o1 + 0x10]
1707 flush %o1 + 0x10
170811:
1709 retl
1710 nop