blob: 49eca4b1cf25d41c44a7f165dc97b50e2974136f [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
Linus Torvalds1da177e2005-04-16 15:20:36 -070010#include <linux/errno.h>
11
12#include <asm/head.h>
13#include <asm/asi.h>
14#include <asm/smp.h>
15#include <asm/ptrace.h>
16#include <asm/page.h>
17#include <asm/signal.h>
18#include <asm/pgtable.h>
19#include <asm/processor.h>
20#include <asm/visasm.h>
21#include <asm/estate.h>
22#include <asm/auxio.h>
David S. Miller6c52a962005-08-29 12:45:11 -070023#include <asm/sfafsr.h>
David S. Millerfd0504c32006-06-20 01:20:00 -070024#include <asm/pil.h>
David S. Miller59359ff2006-11-05 16:51:03 -080025#include <asm/unistd.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#define curptr g6
28
Linus Torvalds1da177e2005-04-16 15:20:36 -070029 .text
30 .align 32
31
Linus Torvalds1da177e2005-04-16 15:20:36 -070032 /* This is trivial with the new code... */
33 .globl do_fpdis
34do_fpdis:
David S. Millerba6399332005-10-07 13:30:49 -070035 sethi %hi(TSTATE_PEF), %g4
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 rdpr %tstate, %g5
37 andcc %g5, %g4, %g0
38 be,pt %xcc, 1f
39 nop
40 rd %fprs, %g5
41 andcc %g5, FPRS_FEF, %g0
42 be,pt %xcc, 1f
43 nop
44
45 /* Legal state when DCR_IFPOE is set in Cheetah %dcr. */
46 sethi %hi(109f), %g7
47 ba,pt %xcc, etrap
48109: or %g7, %lo(109b), %g7
49 add %g0, %g0, %g0
50 ba,a,pt %xcc, rtrap_clr_l6
51
David S. Millerffe483d2006-02-02 21:55:10 -0800521: TRAP_LOAD_THREAD_REG(%g6, %g1)
David S. Miller56fb4df2006-02-26 23:24:22 -080053 ldub [%g6 + TI_FPSAVED], %g5
David S. Millerba6399332005-10-07 13:30:49 -070054 wr %g0, FPRS_FEF, %fprs
55 andcc %g5, FPRS_FEF, %g0
56 be,a,pt %icc, 1f
57 clr %g7
58 ldx [%g6 + TI_GSR], %g7
591: andcc %g5, FPRS_DL, %g0
60 bne,pn %icc, 2f
61 fzero %f0
62 andcc %g5, FPRS_DU, %g0
63 bne,pn %icc, 1f
64 fzero %f2
Linus Torvalds1da177e2005-04-16 15:20:36 -070065 faddd %f0, %f2, %f4
66 fmuld %f0, %f2, %f6
67 faddd %f0, %f2, %f8
68 fmuld %f0, %f2, %f10
69 faddd %f0, %f2, %f12
70 fmuld %f0, %f2, %f14
71 faddd %f0, %f2, %f16
72 fmuld %f0, %f2, %f18
73 faddd %f0, %f2, %f20
74 fmuld %f0, %f2, %f22
75 faddd %f0, %f2, %f24
76 fmuld %f0, %f2, %f26
77 faddd %f0, %f2, %f28
78 fmuld %f0, %f2, %f30
79 faddd %f0, %f2, %f32
80 fmuld %f0, %f2, %f34
81 faddd %f0, %f2, %f36
82 fmuld %f0, %f2, %f38
83 faddd %f0, %f2, %f40
84 fmuld %f0, %f2, %f42
85 faddd %f0, %f2, %f44
86 fmuld %f0, %f2, %f46
87 faddd %f0, %f2, %f48
88 fmuld %f0, %f2, %f50
89 faddd %f0, %f2, %f52
90 fmuld %f0, %f2, %f54
91 faddd %f0, %f2, %f56
92 fmuld %f0, %f2, %f58
93 b,pt %xcc, fpdis_exit2
94 faddd %f0, %f2, %f60
951: mov SECONDARY_CONTEXT, %g3
96 add %g6, TI_FPREGS + 0x80, %g1
97 faddd %f0, %f2, %f4
98 fmuld %f0, %f2, %f6
David S. Miller8b11bd12006-02-07 22:13:05 -080099
100661: ldxa [%g3] ASI_DMMU, %g5
101 .section .sun4v_1insn_patch, "ax"
102 .word 661b
103 ldxa [%g3] ASI_MMU, %g5
104 .previous
105
David S. Miller0835ae02005-10-04 15:23:20 -0700106 sethi %hi(sparc64_kern_sec_context), %g2
107 ldx [%g2 + %lo(sparc64_kern_sec_context)], %g2
David S. Miller8b11bd12006-02-07 22:13:05 -0800108
109661: stxa %g2, [%g3] ASI_DMMU
110 .section .sun4v_1insn_patch, "ax"
111 .word 661b
112 stxa %g2, [%g3] ASI_MMU
113 .previous
114
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 membar #Sync
116 add %g6, TI_FPREGS + 0xc0, %g2
117 faddd %f0, %f2, %f8
118 fmuld %f0, %f2, %f10
David S. Millerba6399332005-10-07 13:30:49 -0700119 membar #Sync
120 ldda [%g1] ASI_BLK_S, %f32
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121 ldda [%g2] ASI_BLK_S, %f48
David S. Millerba6399332005-10-07 13:30:49 -0700122 membar #Sync
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 faddd %f0, %f2, %f12
124 fmuld %f0, %f2, %f14
125 faddd %f0, %f2, %f16
126 fmuld %f0, %f2, %f18
127 faddd %f0, %f2, %f20
128 fmuld %f0, %f2, %f22
129 faddd %f0, %f2, %f24
130 fmuld %f0, %f2, %f26
131 faddd %f0, %f2, %f28
132 fmuld %f0, %f2, %f30
133 b,pt %xcc, fpdis_exit
David S. Millerb445e262005-06-27 15:42:04 -0700134 nop
Linus Torvalds1da177e2005-04-16 15:20:36 -07001352: andcc %g5, FPRS_DU, %g0
136 bne,pt %icc, 3f
137 fzero %f32
138 mov SECONDARY_CONTEXT, %g3
139 fzero %f34
David S. Miller8b11bd12006-02-07 22:13:05 -0800140
141661: ldxa [%g3] ASI_DMMU, %g5
142 .section .sun4v_1insn_patch, "ax"
143 .word 661b
144 ldxa [%g3] ASI_MMU, %g5
145 .previous
146
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147 add %g6, TI_FPREGS, %g1
David S. Miller0835ae02005-10-04 15:23:20 -0700148 sethi %hi(sparc64_kern_sec_context), %g2
149 ldx [%g2 + %lo(sparc64_kern_sec_context)], %g2
David S. Miller8b11bd12006-02-07 22:13:05 -0800150
151661: stxa %g2, [%g3] ASI_DMMU
152 .section .sun4v_1insn_patch, "ax"
153 .word 661b
154 stxa %g2, [%g3] ASI_MMU
155 .previous
156
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157 membar #Sync
158 add %g6, TI_FPREGS + 0x40, %g2
159 faddd %f32, %f34, %f36
160 fmuld %f32, %f34, %f38
David S. Millerba6399332005-10-07 13:30:49 -0700161 membar #Sync
162 ldda [%g1] ASI_BLK_S, %f0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163 ldda [%g2] ASI_BLK_S, %f16
David S. Millerba6399332005-10-07 13:30:49 -0700164 membar #Sync
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165 faddd %f32, %f34, %f40
166 fmuld %f32, %f34, %f42
167 faddd %f32, %f34, %f44
168 fmuld %f32, %f34, %f46
169 faddd %f32, %f34, %f48
170 fmuld %f32, %f34, %f50
171 faddd %f32, %f34, %f52
172 fmuld %f32, %f34, %f54
173 faddd %f32, %f34, %f56
174 fmuld %f32, %f34, %f58
175 faddd %f32, %f34, %f60
176 fmuld %f32, %f34, %f62
177 ba,pt %xcc, fpdis_exit
David S. Millerb445e262005-06-27 15:42:04 -0700178 nop
Linus Torvalds1da177e2005-04-16 15:20:36 -07001793: mov SECONDARY_CONTEXT, %g3
180 add %g6, TI_FPREGS, %g1
David S. Miller8b11bd12006-02-07 22:13:05 -0800181
182661: ldxa [%g3] ASI_DMMU, %g5
183 .section .sun4v_1insn_patch, "ax"
184 .word 661b
185 ldxa [%g3] ASI_MMU, %g5
186 .previous
187
David S. Miller0835ae02005-10-04 15:23:20 -0700188 sethi %hi(sparc64_kern_sec_context), %g2
189 ldx [%g2 + %lo(sparc64_kern_sec_context)], %g2
David S. Miller8b11bd12006-02-07 22:13:05 -0800190
191661: stxa %g2, [%g3] ASI_DMMU
192 .section .sun4v_1insn_patch, "ax"
193 .word 661b
194 stxa %g2, [%g3] ASI_MMU
195 .previous
196
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 membar #Sync
198 mov 0x40, %g2
David S. Millerba6399332005-10-07 13:30:49 -0700199 membar #Sync
200 ldda [%g1] ASI_BLK_S, %f0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201 ldda [%g1 + %g2] ASI_BLK_S, %f16
202 add %g1, 0x80, %g1
203 ldda [%g1] ASI_BLK_S, %f32
204 ldda [%g1 + %g2] ASI_BLK_S, %f48
205 membar #Sync
206fpdis_exit:
David S. Miller8b11bd12006-02-07 22:13:05 -0800207
208661: stxa %g5, [%g3] ASI_DMMU
209 .section .sun4v_1insn_patch, "ax"
210 .word 661b
211 stxa %g5, [%g3] ASI_MMU
212 .previous
213
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 membar #Sync
215fpdis_exit2:
216 wr %g7, 0, %gsr
217 ldx [%g6 + TI_XFSR], %fsr
218 rdpr %tstate, %g3
219 or %g3, %g4, %g3 ! anal...
220 wrpr %g3, %tstate
221 wr %g0, FPRS_FEF, %fprs ! clean DU/DL bits
222 retry
223
224 .align 32
225fp_other_bounce:
226 call do_fpother
227 add %sp, PTREGS_OFF, %o0
228 ba,pt %xcc, rtrap
229 clr %l6
230
231 .globl do_fpother_check_fitos
232 .align 32
233do_fpother_check_fitos:
David S. Millerffe483d2006-02-02 21:55:10 -0800234 TRAP_LOAD_THREAD_REG(%g6, %g1)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235 sethi %hi(fp_other_bounce - 4), %g7
236 or %g7, %lo(fp_other_bounce - 4), %g7
237
238 /* NOTE: Need to preserve %g7 until we fully commit
239 * to the fitos fixup.
240 */
241 stx %fsr, [%g6 + TI_XFSR]
242 rdpr %tstate, %g3
243 andcc %g3, TSTATE_PRIV, %g0
244 bne,pn %xcc, do_fptrap_after_fsr
245 nop
246 ldx [%g6 + TI_XFSR], %g3
247 srlx %g3, 14, %g1
248 and %g1, 7, %g1
249 cmp %g1, 2 ! Unfinished FP-OP
250 bne,pn %xcc, do_fptrap_after_fsr
251 sethi %hi(1 << 23), %g1 ! Inexact
252 andcc %g3, %g1, %g0
253 bne,pn %xcc, do_fptrap_after_fsr
254 rdpr %tpc, %g1
255 lduwa [%g1] ASI_AIUP, %g3 ! This cannot ever fail
256#define FITOS_MASK 0xc1f83fe0
257#define FITOS_COMPARE 0x81a01880
258 sethi %hi(FITOS_MASK), %g1
259 or %g1, %lo(FITOS_MASK), %g1
260 and %g3, %g1, %g1
261 sethi %hi(FITOS_COMPARE), %g2
262 or %g2, %lo(FITOS_COMPARE), %g2
263 cmp %g1, %g2
264 bne,pn %xcc, do_fptrap_after_fsr
265 nop
266 std %f62, [%g6 + TI_FPREGS + (62 * 4)]
267 sethi %hi(fitos_table_1), %g1
268 and %g3, 0x1f, %g2
269 or %g1, %lo(fitos_table_1), %g1
270 sllx %g2, 2, %g2
271 jmpl %g1 + %g2, %g0
272 ba,pt %xcc, fitos_emul_continue
273
274fitos_table_1:
275 fitod %f0, %f62
276 fitod %f1, %f62
277 fitod %f2, %f62
278 fitod %f3, %f62
279 fitod %f4, %f62
280 fitod %f5, %f62
281 fitod %f6, %f62
282 fitod %f7, %f62
283 fitod %f8, %f62
284 fitod %f9, %f62
285 fitod %f10, %f62
286 fitod %f11, %f62
287 fitod %f12, %f62
288 fitod %f13, %f62
289 fitod %f14, %f62
290 fitod %f15, %f62
291 fitod %f16, %f62
292 fitod %f17, %f62
293 fitod %f18, %f62
294 fitod %f19, %f62
295 fitod %f20, %f62
296 fitod %f21, %f62
297 fitod %f22, %f62
298 fitod %f23, %f62
299 fitod %f24, %f62
300 fitod %f25, %f62
301 fitod %f26, %f62
302 fitod %f27, %f62
303 fitod %f28, %f62
304 fitod %f29, %f62
305 fitod %f30, %f62
306 fitod %f31, %f62
307
308fitos_emul_continue:
309 sethi %hi(fitos_table_2), %g1
310 srl %g3, 25, %g2
311 or %g1, %lo(fitos_table_2), %g1
312 and %g2, 0x1f, %g2
313 sllx %g2, 2, %g2
314 jmpl %g1 + %g2, %g0
315 ba,pt %xcc, fitos_emul_fini
316
317fitos_table_2:
318 fdtos %f62, %f0
319 fdtos %f62, %f1
320 fdtos %f62, %f2
321 fdtos %f62, %f3
322 fdtos %f62, %f4
323 fdtos %f62, %f5
324 fdtos %f62, %f6
325 fdtos %f62, %f7
326 fdtos %f62, %f8
327 fdtos %f62, %f9
328 fdtos %f62, %f10
329 fdtos %f62, %f11
330 fdtos %f62, %f12
331 fdtos %f62, %f13
332 fdtos %f62, %f14
333 fdtos %f62, %f15
334 fdtos %f62, %f16
335 fdtos %f62, %f17
336 fdtos %f62, %f18
337 fdtos %f62, %f19
338 fdtos %f62, %f20
339 fdtos %f62, %f21
340 fdtos %f62, %f22
341 fdtos %f62, %f23
342 fdtos %f62, %f24
343 fdtos %f62, %f25
344 fdtos %f62, %f26
345 fdtos %f62, %f27
346 fdtos %f62, %f28
347 fdtos %f62, %f29
348 fdtos %f62, %f30
349 fdtos %f62, %f31
350
351fitos_emul_fini:
352 ldd [%g6 + TI_FPREGS + (62 * 4)], %f62
353 done
354
355 .globl do_fptrap
356 .align 32
357do_fptrap:
David S. Miller8e425502006-02-16 02:18:49 -0800358 TRAP_LOAD_THREAD_REG(%g6, %g1)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359 stx %fsr, [%g6 + TI_XFSR]
360do_fptrap_after_fsr:
361 ldub [%g6 + TI_FPSAVED], %g3
362 rd %fprs, %g1
363 or %g3, %g1, %g3
364 stb %g3, [%g6 + TI_FPSAVED]
365 rd %gsr, %g3
366 stx %g3, [%g6 + TI_GSR]
367 mov SECONDARY_CONTEXT, %g3
David S. Miller8b11bd12006-02-07 22:13:05 -0800368
369661: ldxa [%g3] ASI_DMMU, %g5
370 .section .sun4v_1insn_patch, "ax"
371 .word 661b
372 ldxa [%g3] ASI_MMU, %g5
373 .previous
374
David S. Miller0835ae02005-10-04 15:23:20 -0700375 sethi %hi(sparc64_kern_sec_context), %g2
376 ldx [%g2 + %lo(sparc64_kern_sec_context)], %g2
David S. Miller8b11bd12006-02-07 22:13:05 -0800377
378661: stxa %g2, [%g3] ASI_DMMU
379 .section .sun4v_1insn_patch, "ax"
380 .word 661b
381 stxa %g2, [%g3] ASI_MMU
382 .previous
383
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384 membar #Sync
385 add %g6, TI_FPREGS, %g2
386 andcc %g1, FPRS_DL, %g0
387 be,pn %icc, 4f
388 mov 0x40, %g3
389 stda %f0, [%g2] ASI_BLK_S
390 stda %f16, [%g2 + %g3] ASI_BLK_S
391 andcc %g1, FPRS_DU, %g0
392 be,pn %icc, 5f
3934: add %g2, 128, %g2
394 stda %f32, [%g2] ASI_BLK_S
395 stda %f48, [%g2 + %g3] ASI_BLK_S
3965: mov SECONDARY_CONTEXT, %g1
397 membar #Sync
David S. Miller8b11bd12006-02-07 22:13:05 -0800398
399661: stxa %g5, [%g1] ASI_DMMU
400 .section .sun4v_1insn_patch, "ax"
401 .word 661b
402 stxa %g5, [%g1] ASI_MMU
403 .previous
404
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405 membar #Sync
406 ba,pt %xcc, etrap
407 wr %g0, 0, %fprs
408
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409 /* The registers for cross calls will be:
410 *
411 * DATA 0: [low 32-bits] Address of function to call, jmp to this
412 * [high 32-bits] MMU Context Argument 0, place in %g5
David S. Miller80dc0d62005-09-26 00:32:17 -0700413 * DATA 1: Address Argument 1, place in %g1
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414 * DATA 2: Address Argument 2, place in %g7
415 *
416 * With this method we can do most of the cross-call tlb/cache
417 * flushing very quickly.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418 */
419 .text
420 .align 32
421 .globl do_ivec
422do_ivec:
423 mov 0x40, %g3
424 ldxa [%g3 + %g0] ASI_INTR_R, %g3
425 sethi %hi(KERNBASE), %g4
426 cmp %g3, %g4
427 bgeu,pn %xcc, do_ivec_xcall
428 srlx %g3, 32, %g5
429 stxa %g0, [%g0] ASI_INTR_RECEIVE
430 membar #Sync
431
David S. Millereb2d8d62007-10-13 21:42:46 -0700432 sethi %hi(ivector_table_pa), %g2
433 ldx [%g2 + %lo(ivector_table_pa)], %g2
David S. Millera650d382007-10-12 02:59:40 -0700434 sllx %g3, 4, %g3
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435 add %g2, %g3, %g3
David S. Miller088dd1f2005-07-04 13:24:38 -0700436
David S. Millereb2d8d62007-10-13 21:42:46 -0700437 TRAP_LOAD_IRQ_WORK_PA(%g6, %g1)
David S. Miller56fb4df2006-02-26 23:24:22 -0800438
David S. Millereb2d8d62007-10-13 21:42:46 -0700439 ldx [%g6], %g5
440 stxa %g5, [%g3] ASI_PHYS_USE_EC
441 stx %g3, [%g6]
David S. Millerfd0504c32006-06-20 01:20:00 -0700442 wr %g0, 1 << PIL_DEVICE_IRQ, %set_softint
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443 retry
444do_ivec_xcall:
445 mov 0x50, %g1
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446 ldxa [%g1 + %g0] ASI_INTR_R, %g1
447 srl %g3, 0, %g3
David S. Miller088dd1f2005-07-04 13:24:38 -0700448
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449 mov 0x60, %g7
450 ldxa [%g7 + %g0] ASI_INTR_R, %g7
451 stxa %g0, [%g0] ASI_INTR_RECEIVE
452 membar #Sync
453 ba,pt %xcc, 1f
454 nop
455
456 .align 32
4571: jmpl %g3, %g0
458 nop
459
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460 .globl getcc, setcc
461getcc:
462 ldx [%o0 + PT_V9_TSTATE], %o1
463 srlx %o1, 32, %o1
464 and %o1, 0xf, %o1
465 retl
466 stx %o1, [%o0 + PT_V9_G1]
467setcc:
468 ldx [%o0 + PT_V9_TSTATE], %o1
469 ldx [%o0 + PT_V9_G1], %o2
470 or %g0, %ulo(TSTATE_ICC), %o3
471 sllx %o3, 32, %o3
472 andn %o1, %o3, %o1
473 sllx %o2, 32, %o2
474 and %o2, %o3, %o2
475 or %o1, %o2, %o1
476 retl
477 stx %o1, [%o0 + PT_V9_TSTATE]
478
David S. Miller56fb4df2006-02-26 23:24:22 -0800479 .globl utrap_trap
480utrap_trap: /* %g3=handler,%g4=level */
David S. Millerffe483d2006-02-02 21:55:10 -0800481 TRAP_LOAD_THREAD_REG(%g6, %g1)
David S. Miller56fb4df2006-02-26 23:24:22 -0800482 ldx [%g6 + TI_UTRAPS], %g1
483 brnz,pt %g1, invoke_utrap
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484 nop
David S. Miller56fb4df2006-02-26 23:24:22 -0800485
486 ba,pt %xcc, etrap
487 rd %pc, %g7
488 mov %l4, %o1
489 call bad_trap
490 add %sp, PTREGS_OFF, %o0
491 ba,pt %xcc, rtrap
492 clr %l6
493
494invoke_utrap:
495 sllx %g3, 3, %g3
496 ldx [%g1 + %g3], %g1
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497 save %sp, -128, %sp
498 rdpr %tstate, %l6
499 rdpr %cwp, %l7
500 andn %l6, TSTATE_CWP, %l6
501 wrpr %l6, %l7, %tstate
502 rdpr %tpc, %l6
503 rdpr %tnpc, %l7
504 wrpr %g1, 0, %tnpc
505 done
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506
David S. Miller6c52a962005-08-29 12:45:11 -0700507 /* We need to carefully read the error status, ACK
508 * the errors, prevent recursive traps, and pass the
509 * information on to C code for logging.
510 *
511 * We pass the AFAR in as-is, and we encode the status
512 * information as described in asm-sparc64/sfafsr.h
513 */
514 .globl __spitfire_access_error
515__spitfire_access_error:
516 /* Disable ESTATE error reporting so that we do not
517 * take recursive traps and RED state the processor.
518 */
519 stxa %g0, [%g0] ASI_ESTATE_ERROR_EN
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520 membar #Sync
David S. Miller6c52a962005-08-29 12:45:11 -0700521
522 mov UDBE_UE, %g1
523 ldxa [%g0] ASI_AFSR, %g4 ! Get AFSR
524
525 /* __spitfire_cee_trap branches here with AFSR in %g4 and
526 * UDBE_CE in %g1. It only clears ESTATE_ERR_CE in the
527 * ESTATE Error Enable register.
528 */
529__spitfire_cee_trap_continue:
530 ldxa [%g0] ASI_AFAR, %g5 ! Get AFAR
531
David S. Millerbde4e4e2005-08-29 12:44:57 -0700532 rdpr %tt, %g3
David S. Miller6c52a962005-08-29 12:45:11 -0700533 and %g3, 0x1ff, %g3 ! Paranoia
534 sllx %g3, SFSTAT_TRAP_TYPE_SHIFT, %g3
535 or %g4, %g3, %g4
536 rdpr %tl, %g3
537 cmp %g3, 1
538 mov 1, %g3
539 bleu %xcc, 1f
540 sllx %g3, SFSTAT_TL_GT_ONE_SHIFT, %g3
541
542 or %g4, %g3, %g4
543
544 /* Read in the UDB error register state, clearing the
545 * sticky error bits as-needed. We only clear them if
546 * the UE bit is set. Likewise, __spitfire_cee_trap
547 * below will only do so if the CE bit is set.
548 *
549 * NOTE: UltraSparc-I/II have high and low UDB error
550 * registers, corresponding to the two UDB units
551 * present on those chips. UltraSparc-IIi only
552 * has a single UDB, called "SDB" in the manual.
553 * For IIi the upper UDB register always reads
554 * as zero so for our purposes things will just
555 * work with the checks below.
556 */
5571: ldxa [%g0] ASI_UDBH_ERROR_R, %g3
558 and %g3, 0x3ff, %g7 ! Paranoia
559 sllx %g7, SFSTAT_UDBH_SHIFT, %g7
560 or %g4, %g7, %g4
561 andcc %g3, %g1, %g3 ! UDBE_UE or UDBE_CE
562 be,pn %xcc, 1f
David S. Millerbde4e4e2005-08-29 12:44:57 -0700563 nop
David S. Miller6c52a962005-08-29 12:45:11 -0700564 stxa %g3, [%g0] ASI_UDB_ERROR_W
565 membar #Sync
566
5671: mov 0x18, %g3
568 ldxa [%g3] ASI_UDBL_ERROR_R, %g3
569 and %g3, 0x3ff, %g7 ! Paranoia
570 sllx %g7, SFSTAT_UDBL_SHIFT, %g7
571 or %g4, %g7, %g4
572 andcc %g3, %g1, %g3 ! UDBE_UE or UDBE_CE
573 be,pn %xcc, 1f
574 nop
575 mov 0x18, %g7
576 stxa %g3, [%g7] ASI_UDB_ERROR_W
577 membar #Sync
578
5791: /* Ok, now that we've latched the error state,
580 * clear the sticky bits in the AFSR.
581 */
582 stxa %g4, [%g0] ASI_AFSR
583 membar #Sync
584
585 rdpr %tl, %g2
586 cmp %g2, 1
587 rdpr %pil, %g2
588 bleu,pt %xcc, 1f
589 wrpr %g0, 15, %pil
590
David S. Millerbde4e4e2005-08-29 12:44:57 -0700591 ba,pt %xcc, etraptl1
David S. Miller6c52a962005-08-29 12:45:11 -0700592 rd %pc, %g7
David S. Millerbde4e4e2005-08-29 12:44:57 -0700593
David S. Miller6c52a962005-08-29 12:45:11 -0700594 ba,pt %xcc, 2f
595 nop
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596
David S. Miller6c52a962005-08-29 12:45:11 -07005971: ba,pt %xcc, etrap_irq
598 rd %pc, %g7
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599
David S. Miller10e26722006-11-16 13:38:57 -08006002:
601#ifdef CONFIG_TRACE_IRQFLAGS
602 call trace_hardirqs_off
603 nop
604#endif
605 mov %l4, %o1
Linus Torvalds1da177e2005-04-16 15:20:36 -0700606 mov %l5, %o2
David S. Miller6c52a962005-08-29 12:45:11 -0700607 call spitfire_access_error
Linus Torvalds1da177e2005-04-16 15:20:36 -0700608 add %sp, PTREGS_OFF, %o0
609 ba,pt %xcc, rtrap
610 clr %l6
611
612 /* This is the trap handler entry point for ECC correctable
613 * errors. They are corrected, but we listen for the trap
614 * so that the event can be logged.
615 *
616 * Disrupting errors are either:
617 * 1) single-bit ECC errors during UDB reads to system
618 * memory
619 * 2) data parity errors during write-back events
620 *
621 * As far as I can make out from the manual, the CEE trap
622 * is only for correctable errors during memory read
623 * accesses by the front-end of the processor.
624 *
625 * The code below is only for trap level 1 CEE events,
626 * as it is the only situation where we can safely record
627 * and log. For trap level >1 we just clear the CE bit
628 * in the AFSR and return.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629 *
David S. Miller6c52a962005-08-29 12:45:11 -0700630 * This is just like __spiftire_access_error above, but it
631 * specifically handles correctable errors. If an
632 * uncorrectable error is indicated in the AFSR we
633 * will branch directly above to __spitfire_access_error
634 * to handle it instead. Uncorrectable therefore takes
635 * priority over correctable, and the error logging
636 * C code will notice this case by inspecting the
637 * trap type.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638 */
David S. Miller6c52a962005-08-29 12:45:11 -0700639 .globl __spitfire_cee_trap
640__spitfire_cee_trap:
641 ldxa [%g0] ASI_AFSR, %g4 ! Get AFSR
642 mov 1, %g3
643 sllx %g3, SFAFSR_UE_SHIFT, %g3
644 andcc %g4, %g3, %g0 ! Check for UE
645 bne,pn %xcc, __spitfire_access_error
646 nop
Linus Torvalds1da177e2005-04-16 15:20:36 -0700647
David S. Miller6c52a962005-08-29 12:45:11 -0700648 /* Ok, in this case we only have a correctable error.
649 * Indicate we only wish to capture that state in register
650 * %g1, and we only disable CE error reporting unlike UE
651 * handling which disables all errors.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652 */
David S. Miller6c52a962005-08-29 12:45:11 -0700653 ldxa [%g0] ASI_ESTATE_ERROR_EN, %g3
654 andn %g3, ESTATE_ERR_CE, %g3
655 stxa %g3, [%g0] ASI_ESTATE_ERROR_EN
656 membar #Sync
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657
David S. Miller6c52a962005-08-29 12:45:11 -0700658 /* Preserve AFSR in %g4, indicate UDB state to capture in %g1 */
659 ba,pt %xcc, __spitfire_cee_trap_continue
660 mov UDBE_CE, %g1
661
662 .globl __spitfire_data_access_exception
663 .globl __spitfire_data_access_exception_tl1
664__spitfire_data_access_exception_tl1:
665 rdpr %pstate, %g4
666 wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
667 mov TLB_SFSR, %g3
668 mov DMMU_SFAR, %g5
669 ldxa [%g3] ASI_DMMU, %g4 ! Get SFSR
670 ldxa [%g5] ASI_DMMU, %g5 ! Get SFAR
671 stxa %g0, [%g3] ASI_DMMU ! Clear SFSR.FaultValid bit
672 membar #Sync
673 rdpr %tt, %g3
674 cmp %g3, 0x80 ! first win spill/fill trap
675 blu,pn %xcc, 1f
676 cmp %g3, 0xff ! last win spill/fill trap
677 bgu,pn %xcc, 1f
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678 nop
David S. Miller6c52a962005-08-29 12:45:11 -0700679 ba,pt %xcc, winfix_dax
680 rdpr %tpc, %g3
6811: sethi %hi(109f), %g7
682 ba,pt %xcc, etraptl1
683109: or %g7, %lo(109b), %g7
684 mov %l4, %o1
685 mov %l5, %o2
686 call spitfire_data_access_exception_tl1
687 add %sp, PTREGS_OFF, %o0
688 ba,pt %xcc, rtrap
689 clr %l6
Linus Torvalds1da177e2005-04-16 15:20:36 -0700690
David S. Miller6c52a962005-08-29 12:45:11 -0700691__spitfire_data_access_exception:
692 rdpr %pstate, %g4
693 wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
694 mov TLB_SFSR, %g3
695 mov DMMU_SFAR, %g5
696 ldxa [%g3] ASI_DMMU, %g4 ! Get SFSR
697 ldxa [%g5] ASI_DMMU, %g5 ! Get SFAR
698 stxa %g0, [%g3] ASI_DMMU ! Clear SFSR.FaultValid bit
699 membar #Sync
700 sethi %hi(109f), %g7
701 ba,pt %xcc, etrap
702109: or %g7, %lo(109b), %g7
703 mov %l4, %o1
704 mov %l5, %o2
705 call spitfire_data_access_exception
706 add %sp, PTREGS_OFF, %o0
707 ba,pt %xcc, rtrap
708 clr %l6
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709
David S. Miller6c52a962005-08-29 12:45:11 -0700710 .globl __spitfire_insn_access_exception
711 .globl __spitfire_insn_access_exception_tl1
712__spitfire_insn_access_exception_tl1:
713 rdpr %pstate, %g4
714 wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
715 mov TLB_SFSR, %g3
716 ldxa [%g3] ASI_IMMU, %g4 ! Get SFSR
717 rdpr %tpc, %g5 ! IMMU has no SFAR, use TPC
718 stxa %g0, [%g3] ASI_IMMU ! Clear FaultValid bit
719 membar #Sync
720 sethi %hi(109f), %g7
721 ba,pt %xcc, etraptl1
722109: or %g7, %lo(109b), %g7
723 mov %l4, %o1
724 mov %l5, %o2
725 call spitfire_insn_access_exception_tl1
726 add %sp, PTREGS_OFF, %o0
727 ba,pt %xcc, rtrap
728 clr %l6
Linus Torvalds1da177e2005-04-16 15:20:36 -0700729
David S. Miller6c52a962005-08-29 12:45:11 -0700730__spitfire_insn_access_exception:
731 rdpr %pstate, %g4
732 wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
733 mov TLB_SFSR, %g3
734 ldxa [%g3] ASI_IMMU, %g4 ! Get SFSR
735 rdpr %tpc, %g5 ! IMMU has no SFAR, use TPC
736 stxa %g0, [%g3] ASI_IMMU ! Clear FaultValid bit
737 membar #Sync
738 sethi %hi(109f), %g7
739 ba,pt %xcc, etrap
740109: or %g7, %lo(109b), %g7
741 mov %l4, %o1
742 mov %l5, %o2
743 call spitfire_insn_access_exception
744 add %sp, PTREGS_OFF, %o0
745 ba,pt %xcc, rtrap
746 clr %l6
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747
Linus Torvalds1da177e2005-04-16 15:20:36 -0700748 /* These get patched into the trap table at boot time
749 * once we know we have a cheetah processor.
750 */
751 .globl cheetah_fecc_trap_vector, cheetah_fecc_trap_vector_tl1
752cheetah_fecc_trap_vector:
753 membar #Sync
754 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
755 andn %g1, DCU_DC | DCU_IC, %g1
756 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
757 membar #Sync
758 sethi %hi(cheetah_fast_ecc), %g2
759 jmpl %g2 + %lo(cheetah_fast_ecc), %g0
760 mov 0, %g1
761cheetah_fecc_trap_vector_tl1:
762 membar #Sync
763 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
764 andn %g1, DCU_DC | DCU_IC, %g1
765 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
766 membar #Sync
767 sethi %hi(cheetah_fast_ecc), %g2
768 jmpl %g2 + %lo(cheetah_fast_ecc), %g0
769 mov 1, %g1
770 .globl cheetah_cee_trap_vector, cheetah_cee_trap_vector_tl1
771cheetah_cee_trap_vector:
772 membar #Sync
773 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
774 andn %g1, DCU_IC, %g1
775 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
776 membar #Sync
777 sethi %hi(cheetah_cee), %g2
778 jmpl %g2 + %lo(cheetah_cee), %g0
779 mov 0, %g1
780cheetah_cee_trap_vector_tl1:
781 membar #Sync
782 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
783 andn %g1, DCU_IC, %g1
784 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
785 membar #Sync
786 sethi %hi(cheetah_cee), %g2
787 jmpl %g2 + %lo(cheetah_cee), %g0
788 mov 1, %g1
789 .globl cheetah_deferred_trap_vector, cheetah_deferred_trap_vector_tl1
790cheetah_deferred_trap_vector:
791 membar #Sync
792 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1;
793 andn %g1, DCU_DC | DCU_IC, %g1;
794 stxa %g1, [%g0] ASI_DCU_CONTROL_REG;
795 membar #Sync;
796 sethi %hi(cheetah_deferred_trap), %g2
797 jmpl %g2 + %lo(cheetah_deferred_trap), %g0
798 mov 0, %g1
799cheetah_deferred_trap_vector_tl1:
800 membar #Sync;
801 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1;
802 andn %g1, DCU_DC | DCU_IC, %g1;
803 stxa %g1, [%g0] ASI_DCU_CONTROL_REG;
804 membar #Sync;
805 sethi %hi(cheetah_deferred_trap), %g2
806 jmpl %g2 + %lo(cheetah_deferred_trap), %g0
807 mov 1, %g1
808
809 /* Cheetah+ specific traps. These are for the new I/D cache parity
810 * error traps. The first argument to cheetah_plus_parity_handler
811 * is encoded as follows:
812 *
813 * Bit0: 0=dcache,1=icache
814 * Bit1: 0=recoverable,1=unrecoverable
815 */
816 .globl cheetah_plus_dcpe_trap_vector, cheetah_plus_dcpe_trap_vector_tl1
817cheetah_plus_dcpe_trap_vector:
818 membar #Sync
819 sethi %hi(do_cheetah_plus_data_parity), %g7
820 jmpl %g7 + %lo(do_cheetah_plus_data_parity), %g0
821 nop
822 nop
823 nop
824 nop
825 nop
826
827do_cheetah_plus_data_parity:
David S. Miller80dc0d62005-09-26 00:32:17 -0700828 rdpr %pil, %g2
829 wrpr %g0, 15, %pil
830 ba,pt %xcc, etrap_irq
Linus Torvalds1da177e2005-04-16 15:20:36 -0700831 rd %pc, %g7
David S. Miller10e26722006-11-16 13:38:57 -0800832#ifdef CONFIG_TRACE_IRQFLAGS
833 call trace_hardirqs_off
834 nop
835#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700836 mov 0x0, %o0
837 call cheetah_plus_parity_error
838 add %sp, PTREGS_OFF, %o1
David S. Miller80dc0d62005-09-26 00:32:17 -0700839 ba,a,pt %xcc, rtrap_irq
Linus Torvalds1da177e2005-04-16 15:20:36 -0700840
841cheetah_plus_dcpe_trap_vector_tl1:
842 membar #Sync
843 wrpr PSTATE_IG | PSTATE_PEF | PSTATE_PRIV, %pstate
844 sethi %hi(do_dcpe_tl1), %g3
845 jmpl %g3 + %lo(do_dcpe_tl1), %g0
846 nop
847 nop
848 nop
849 nop
850
851 .globl cheetah_plus_icpe_trap_vector, cheetah_plus_icpe_trap_vector_tl1
852cheetah_plus_icpe_trap_vector:
853 membar #Sync
854 sethi %hi(do_cheetah_plus_insn_parity), %g7
855 jmpl %g7 + %lo(do_cheetah_plus_insn_parity), %g0
856 nop
857 nop
858 nop
859 nop
860 nop
861
862do_cheetah_plus_insn_parity:
David S. Miller80dc0d62005-09-26 00:32:17 -0700863 rdpr %pil, %g2
864 wrpr %g0, 15, %pil
865 ba,pt %xcc, etrap_irq
Linus Torvalds1da177e2005-04-16 15:20:36 -0700866 rd %pc, %g7
David S. Miller10e26722006-11-16 13:38:57 -0800867#ifdef CONFIG_TRACE_IRQFLAGS
868 call trace_hardirqs_off
869 nop
870#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700871 mov 0x1, %o0
872 call cheetah_plus_parity_error
873 add %sp, PTREGS_OFF, %o1
David S. Miller80dc0d62005-09-26 00:32:17 -0700874 ba,a,pt %xcc, rtrap_irq
Linus Torvalds1da177e2005-04-16 15:20:36 -0700875
876cheetah_plus_icpe_trap_vector_tl1:
877 membar #Sync
878 wrpr PSTATE_IG | PSTATE_PEF | PSTATE_PRIV, %pstate
879 sethi %hi(do_icpe_tl1), %g3
880 jmpl %g3 + %lo(do_icpe_tl1), %g0
881 nop
882 nop
883 nop
884 nop
885
886 /* If we take one of these traps when tl >= 1, then we
887 * jump to interrupt globals. If some trap level above us
888 * was also using interrupt globals, we cannot recover.
889 * We may use all interrupt global registers except %g6.
890 */
891 .globl do_dcpe_tl1, do_icpe_tl1
892do_dcpe_tl1:
893 rdpr %tl, %g1 ! Save original trap level
894 mov 1, %g2 ! Setup TSTATE checking loop
895 sethi %hi(TSTATE_IG), %g3 ! TSTATE mask bit
8961: wrpr %g2, %tl ! Set trap level to check
897 rdpr %tstate, %g4 ! Read TSTATE for this level
898 andcc %g4, %g3, %g0 ! Interrupt globals in use?
899 bne,a,pn %xcc, do_dcpe_tl1_fatal ! Yep, irrecoverable
900 wrpr %g1, %tl ! Restore original trap level
901 add %g2, 1, %g2 ! Next trap level
902 cmp %g2, %g1 ! Hit them all yet?
903 ble,pt %icc, 1b ! Not yet
904 nop
905 wrpr %g1, %tl ! Restore original trap level
906do_dcpe_tl1_nonfatal: /* Ok we may use interrupt globals safely. */
David S. Miller80dc0d62005-09-26 00:32:17 -0700907 sethi %hi(dcache_parity_tl1_occurred), %g2
908 lduw [%g2 + %lo(dcache_parity_tl1_occurred)], %g1
909 add %g1, 1, %g1
910 stw %g1, [%g2 + %lo(dcache_parity_tl1_occurred)]
Linus Torvalds1da177e2005-04-16 15:20:36 -0700911 /* Reset D-cache parity */
912 sethi %hi(1 << 16), %g1 ! D-cache size
913 mov (1 << 5), %g2 ! D-cache line size
914 sub %g1, %g2, %g1 ! Move down 1 cacheline
9151: srl %g1, 14, %g3 ! Compute UTAG
916 membar #Sync
917 stxa %g3, [%g1] ASI_DCACHE_UTAG
918 membar #Sync
919 sub %g2, 8, %g3 ! 64-bit data word within line
9202: membar #Sync
921 stxa %g0, [%g1 + %g3] ASI_DCACHE_DATA
922 membar #Sync
923 subcc %g3, 8, %g3 ! Next 64-bit data word
924 bge,pt %icc, 2b
925 nop
926 subcc %g1, %g2, %g1 ! Next cacheline
927 bge,pt %icc, 1b
928 nop
929 ba,pt %xcc, dcpe_icpe_tl1_common
930 nop
931
932do_dcpe_tl1_fatal:
933 sethi %hi(1f), %g7
934 ba,pt %xcc, etraptl1
9351: or %g7, %lo(1b), %g7
936 mov 0x2, %o0
937 call cheetah_plus_parity_error
938 add %sp, PTREGS_OFF, %o1
939 ba,pt %xcc, rtrap
940 clr %l6
941
942do_icpe_tl1:
943 rdpr %tl, %g1 ! Save original trap level
944 mov 1, %g2 ! Setup TSTATE checking loop
945 sethi %hi(TSTATE_IG), %g3 ! TSTATE mask bit
9461: wrpr %g2, %tl ! Set trap level to check
947 rdpr %tstate, %g4 ! Read TSTATE for this level
948 andcc %g4, %g3, %g0 ! Interrupt globals in use?
949 bne,a,pn %xcc, do_icpe_tl1_fatal ! Yep, irrecoverable
950 wrpr %g1, %tl ! Restore original trap level
951 add %g2, 1, %g2 ! Next trap level
952 cmp %g2, %g1 ! Hit them all yet?
953 ble,pt %icc, 1b ! Not yet
954 nop
955 wrpr %g1, %tl ! Restore original trap level
956do_icpe_tl1_nonfatal: /* Ok we may use interrupt globals safely. */
David S. Miller80dc0d62005-09-26 00:32:17 -0700957 sethi %hi(icache_parity_tl1_occurred), %g2
958 lduw [%g2 + %lo(icache_parity_tl1_occurred)], %g1
959 add %g1, 1, %g1
960 stw %g1, [%g2 + %lo(icache_parity_tl1_occurred)]
Linus Torvalds1da177e2005-04-16 15:20:36 -0700961 /* Flush I-cache */
962 sethi %hi(1 << 15), %g1 ! I-cache size
963 mov (1 << 5), %g2 ! I-cache line size
964 sub %g1, %g2, %g1
9651: or %g1, (2 << 3), %g3
966 stxa %g0, [%g3] ASI_IC_TAG
967 membar #Sync
968 subcc %g1, %g2, %g1
969 bge,pt %icc, 1b
970 nop
971 ba,pt %xcc, dcpe_icpe_tl1_common
972 nop
973
974do_icpe_tl1_fatal:
975 sethi %hi(1f), %g7
976 ba,pt %xcc, etraptl1
9771: or %g7, %lo(1b), %g7
978 mov 0x3, %o0
979 call cheetah_plus_parity_error
980 add %sp, PTREGS_OFF, %o1
981 ba,pt %xcc, rtrap
982 clr %l6
983
984dcpe_icpe_tl1_common:
985 /* Flush D-cache, re-enable D/I caches in DCU and finally
986 * retry the trapping instruction.
987 */
988 sethi %hi(1 << 16), %g1 ! D-cache size
989 mov (1 << 5), %g2 ! D-cache line size
990 sub %g1, %g2, %g1
9911: stxa %g0, [%g1] ASI_DCACHE_TAG
992 membar #Sync
993 subcc %g1, %g2, %g1
994 bge,pt %icc, 1b
995 nop
996 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
997 or %g1, (DCU_DC | DCU_IC), %g1
998 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
999 membar #Sync
1000 retry
1001
David S. Miller3c2cafa2005-08-30 15:11:52 -07001002 /* Capture I/D/E-cache state into per-cpu error scoreboard.
1003 *
1004 * %g1: (TL>=0) ? 1 : 0
1005 * %g2: scratch
1006 * %g3: scratch
1007 * %g4: AFSR
1008 * %g5: AFAR
David S. Miller56fb4df2006-02-26 23:24:22 -08001009 * %g6: unused, will have current thread ptr after etrap
David S. Miller3c2cafa2005-08-30 15:11:52 -07001010 * %g7: scratch
1011 */
1012__cheetah_log_error:
1013 /* Put "TL1" software bit into AFSR. */
1014 and %g1, 0x1, %g1
1015 sllx %g1, 63, %g2
1016 or %g4, %g2, %g4
1017
1018 /* Get log entry pointer for this cpu at this trap level. */
1019 BRANCH_IF_JALAPENO(g2,g3,50f)
1020 ldxa [%g0] ASI_SAFARI_CONFIG, %g2
1021 srlx %g2, 17, %g2
1022 ba,pt %xcc, 60f
1023 and %g2, 0x3ff, %g2
1024
102550: ldxa [%g0] ASI_JBUS_CONFIG, %g2
1026 srlx %g2, 17, %g2
1027 and %g2, 0x1f, %g2
1028
102960: sllx %g2, 9, %g2
1030 sethi %hi(cheetah_error_log), %g3
1031 ldx [%g3 + %lo(cheetah_error_log)], %g3
1032 brz,pn %g3, 80f
1033 nop
1034
1035 add %g3, %g2, %g3
1036 sllx %g1, 8, %g1
1037 add %g3, %g1, %g1
1038
1039 /* %g1 holds pointer to the top of the logging scoreboard */
1040 ldx [%g1 + 0x0], %g7
1041 cmp %g7, -1
1042 bne,pn %xcc, 80f
1043 nop
1044
1045 stx %g4, [%g1 + 0x0]
1046 stx %g5, [%g1 + 0x8]
1047 add %g1, 0x10, %g1
1048
1049 /* %g1 now points to D-cache logging area */
1050 set 0x3ff8, %g2 /* DC_addr mask */
1051 and %g5, %g2, %g2 /* DC_addr bits of AFAR */
1052 srlx %g5, 12, %g3
1053 or %g3, 1, %g3 /* PHYS tag + valid */
1054
105510: ldxa [%g2] ASI_DCACHE_TAG, %g7
1056 cmp %g3, %g7 /* TAG match? */
1057 bne,pt %xcc, 13f
1058 nop
1059
1060 /* Yep, what we want, capture state. */
1061 stx %g2, [%g1 + 0x20]
1062 stx %g7, [%g1 + 0x28]
1063
1064 /* A membar Sync is required before and after utag access. */
1065 membar #Sync
1066 ldxa [%g2] ASI_DCACHE_UTAG, %g7
1067 membar #Sync
1068 stx %g7, [%g1 + 0x30]
1069 ldxa [%g2] ASI_DCACHE_SNOOP_TAG, %g7
1070 stx %g7, [%g1 + 0x38]
1071 clr %g3
1072
107312: ldxa [%g2 + %g3] ASI_DCACHE_DATA, %g7
1074 stx %g7, [%g1]
1075 add %g3, (1 << 5), %g3
1076 cmp %g3, (4 << 5)
1077 bl,pt %xcc, 12b
1078 add %g1, 0x8, %g1
1079
1080 ba,pt %xcc, 20f
1081 add %g1, 0x20, %g1
1082
108313: sethi %hi(1 << 14), %g7
1084 add %g2, %g7, %g2
1085 srlx %g2, 14, %g7
1086 cmp %g7, 4
1087 bl,pt %xcc, 10b
1088 nop
1089
1090 add %g1, 0x40, %g1
1091
1092 /* %g1 now points to I-cache logging area */
109320: set 0x1fe0, %g2 /* IC_addr mask */
1094 and %g5, %g2, %g2 /* IC_addr bits of AFAR */
1095 sllx %g2, 1, %g2 /* IC_addr[13:6]==VA[12:5] */
1096 srlx %g5, (13 - 8), %g3 /* Make PTAG */
1097 andn %g3, 0xff, %g3 /* Mask off undefined bits */
1098
109921: ldxa [%g2] ASI_IC_TAG, %g7
1100 andn %g7, 0xff, %g7
1101 cmp %g3, %g7
1102 bne,pt %xcc, 23f
1103 nop
1104
1105 /* Yep, what we want, capture state. */
1106 stx %g2, [%g1 + 0x40]
1107 stx %g7, [%g1 + 0x48]
1108 add %g2, (1 << 3), %g2
1109 ldxa [%g2] ASI_IC_TAG, %g7
1110 add %g2, (1 << 3), %g2
1111 stx %g7, [%g1 + 0x50]
1112 ldxa [%g2] ASI_IC_TAG, %g7
1113 add %g2, (1 << 3), %g2
1114 stx %g7, [%g1 + 0x60]
1115 ldxa [%g2] ASI_IC_TAG, %g7
1116 stx %g7, [%g1 + 0x68]
1117 sub %g2, (3 << 3), %g2
1118 ldxa [%g2] ASI_IC_STAG, %g7
1119 stx %g7, [%g1 + 0x58]
1120 clr %g3
1121 srlx %g2, 2, %g2
1122
112322: ldxa [%g2 + %g3] ASI_IC_INSTR, %g7
1124 stx %g7, [%g1]
1125 add %g3, (1 << 3), %g3
1126 cmp %g3, (8 << 3)
1127 bl,pt %xcc, 22b
1128 add %g1, 0x8, %g1
1129
1130 ba,pt %xcc, 30f
1131 add %g1, 0x30, %g1
1132
113323: sethi %hi(1 << 14), %g7
1134 add %g2, %g7, %g2
1135 srlx %g2, 14, %g7
1136 cmp %g7, 4
1137 bl,pt %xcc, 21b
1138 nop
1139
1140 add %g1, 0x70, %g1
1141
1142 /* %g1 now points to E-cache logging area */
114330: andn %g5, (32 - 1), %g2
1144 stx %g2, [%g1 + 0x20]
1145 ldxa [%g2] ASI_EC_TAG_DATA, %g7
1146 stx %g7, [%g1 + 0x28]
1147 ldxa [%g2] ASI_EC_R, %g0
1148 clr %g3
1149
115031: ldxa [%g3] ASI_EC_DATA, %g7
1151 stx %g7, [%g1 + %g3]
1152 add %g3, 0x8, %g3
1153 cmp %g3, 0x20
1154
1155 bl,pt %xcc, 31b
1156 nop
115780:
1158 rdpr %tt, %g2
1159 cmp %g2, 0x70
1160 be c_fast_ecc
1161 cmp %g2, 0x63
1162 be c_cee
1163 nop
1164 ba,pt %xcc, c_deferred
1165
Linus Torvalds1da177e2005-04-16 15:20:36 -07001166 /* Cheetah FECC trap handling, we get here from tl{0,1}_fecc
1167 * in the trap table. That code has done a memory barrier
1168 * and has disabled both the I-cache and D-cache in the DCU
1169 * control register. The I-cache is disabled so that we may
1170 * capture the corrupted cache line, and the D-cache is disabled
1171 * because corrupt data may have been placed there and we don't
1172 * want to reference it.
1173 *
1174 * %g1 is one if this trap occurred at %tl >= 1.
1175 *
1176 * Next, we turn off error reporting so that we don't recurse.
1177 */
1178 .globl cheetah_fast_ecc
1179cheetah_fast_ecc:
1180 ldxa [%g0] ASI_ESTATE_ERROR_EN, %g2
1181 andn %g2, ESTATE_ERROR_NCEEN | ESTATE_ERROR_CEEN, %g2
1182 stxa %g2, [%g0] ASI_ESTATE_ERROR_EN
1183 membar #Sync
1184
1185 /* Fetch and clear AFSR/AFAR */
1186 ldxa [%g0] ASI_AFSR, %g4
1187 ldxa [%g0] ASI_AFAR, %g5
1188 stxa %g4, [%g0] ASI_AFSR
1189 membar #Sync
1190
David S. Miller3c2cafa2005-08-30 15:11:52 -07001191 ba,pt %xcc, __cheetah_log_error
1192 nop
Linus Torvalds1da177e2005-04-16 15:20:36 -07001193
David S. Miller3c2cafa2005-08-30 15:11:52 -07001194c_fast_ecc:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001195 rdpr %pil, %g2
1196 wrpr %g0, 15, %pil
1197 ba,pt %xcc, etrap_irq
1198 rd %pc, %g7
David S. Miller10e26722006-11-16 13:38:57 -08001199#ifdef CONFIG_TRACE_IRQFLAGS
1200 call trace_hardirqs_off
1201 nop
1202#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001203 mov %l4, %o1
1204 mov %l5, %o2
1205 call cheetah_fecc_handler
1206 add %sp, PTREGS_OFF, %o0
1207 ba,a,pt %xcc, rtrap_irq
1208
1209 /* Our caller has disabled I-cache and performed membar Sync. */
1210 .globl cheetah_cee
1211cheetah_cee:
1212 ldxa [%g0] ASI_ESTATE_ERROR_EN, %g2
1213 andn %g2, ESTATE_ERROR_CEEN, %g2
1214 stxa %g2, [%g0] ASI_ESTATE_ERROR_EN
1215 membar #Sync
1216
1217 /* Fetch and clear AFSR/AFAR */
1218 ldxa [%g0] ASI_AFSR, %g4
1219 ldxa [%g0] ASI_AFAR, %g5
1220 stxa %g4, [%g0] ASI_AFSR
1221 membar #Sync
1222
David S. Miller3c2cafa2005-08-30 15:11:52 -07001223 ba,pt %xcc, __cheetah_log_error
1224 nop
Linus Torvalds1da177e2005-04-16 15:20:36 -07001225
David S. Miller3c2cafa2005-08-30 15:11:52 -07001226c_cee:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001227 rdpr %pil, %g2
1228 wrpr %g0, 15, %pil
1229 ba,pt %xcc, etrap_irq
1230 rd %pc, %g7
David S. Miller10e26722006-11-16 13:38:57 -08001231#ifdef CONFIG_TRACE_IRQFLAGS
1232 call trace_hardirqs_off
1233 nop
1234#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001235 mov %l4, %o1
1236 mov %l5, %o2
1237 call cheetah_cee_handler
1238 add %sp, PTREGS_OFF, %o0
1239 ba,a,pt %xcc, rtrap_irq
1240
1241 /* Our caller has disabled I-cache+D-cache and performed membar Sync. */
1242 .globl cheetah_deferred_trap
1243cheetah_deferred_trap:
1244 ldxa [%g0] ASI_ESTATE_ERROR_EN, %g2
1245 andn %g2, ESTATE_ERROR_NCEEN | ESTATE_ERROR_CEEN, %g2
1246 stxa %g2, [%g0] ASI_ESTATE_ERROR_EN
1247 membar #Sync
1248
1249 /* Fetch and clear AFSR/AFAR */
1250 ldxa [%g0] ASI_AFSR, %g4
1251 ldxa [%g0] ASI_AFAR, %g5
1252 stxa %g4, [%g0] ASI_AFSR
1253 membar #Sync
1254
David S. Miller3c2cafa2005-08-30 15:11:52 -07001255 ba,pt %xcc, __cheetah_log_error
1256 nop
Linus Torvalds1da177e2005-04-16 15:20:36 -07001257
David S. Miller3c2cafa2005-08-30 15:11:52 -07001258c_deferred:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001259 rdpr %pil, %g2
1260 wrpr %g0, 15, %pil
1261 ba,pt %xcc, etrap_irq
1262 rd %pc, %g7
David S. Miller10e26722006-11-16 13:38:57 -08001263#ifdef CONFIG_TRACE_IRQFLAGS
1264 call trace_hardirqs_off
1265 nop
1266#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001267 mov %l4, %o1
1268 mov %l5, %o2
1269 call cheetah_deferred_handler
1270 add %sp, PTREGS_OFF, %o0
1271 ba,a,pt %xcc, rtrap_irq
1272
1273 .globl __do_privact
1274__do_privact:
1275 mov TLB_SFSR, %g3
1276 stxa %g0, [%g3] ASI_DMMU ! Clear FaultValid bit
1277 membar #Sync
1278 sethi %hi(109f), %g7
1279 ba,pt %xcc, etrap
1280109: or %g7, %lo(109b), %g7
1281 call do_privact
1282 add %sp, PTREGS_OFF, %o0
1283 ba,pt %xcc, rtrap
1284 clr %l6
1285
1286 .globl do_mna
1287do_mna:
1288 rdpr %tl, %g3
1289 cmp %g3, 1
1290
1291 /* Setup %g4/%g5 now as they are used in the
1292 * winfixup code.
1293 */
1294 mov TLB_SFSR, %g3
1295 mov DMMU_SFAR, %g4
1296 ldxa [%g4] ASI_DMMU, %g4
1297 ldxa [%g3] ASI_DMMU, %g5
1298 stxa %g0, [%g3] ASI_DMMU ! Clear FaultValid bit
1299 membar #Sync
1300 bgu,pn %icc, winfix_mna
1301 rdpr %tpc, %g3
1302
13031: sethi %hi(109f), %g7
1304 ba,pt %xcc, etrap
1305109: or %g7, %lo(109b), %g7
1306 mov %l4, %o1
1307 mov %l5, %o2
1308 call mem_address_unaligned
1309 add %sp, PTREGS_OFF, %o0
1310 ba,pt %xcc, rtrap
1311 clr %l6
1312
1313 .globl do_lddfmna
1314do_lddfmna:
1315 sethi %hi(109f), %g7
1316 mov TLB_SFSR, %g4
1317 ldxa [%g4] ASI_DMMU, %g5
1318 stxa %g0, [%g4] ASI_DMMU ! Clear FaultValid bit
1319 membar #Sync
1320 mov DMMU_SFAR, %g4
1321 ldxa [%g4] ASI_DMMU, %g4
1322 ba,pt %xcc, etrap
1323109: or %g7, %lo(109b), %g7
1324 mov %l4, %o1
1325 mov %l5, %o2
1326 call handle_lddfmna
1327 add %sp, PTREGS_OFF, %o0
1328 ba,pt %xcc, rtrap
1329 clr %l6
1330
1331 .globl do_stdfmna
1332do_stdfmna:
1333 sethi %hi(109f), %g7
1334 mov TLB_SFSR, %g4
1335 ldxa [%g4] ASI_DMMU, %g5
1336 stxa %g0, [%g4] ASI_DMMU ! Clear FaultValid bit
1337 membar #Sync
1338 mov DMMU_SFAR, %g4
1339 ldxa [%g4] ASI_DMMU, %g4
1340 ba,pt %xcc, etrap
1341109: or %g7, %lo(109b), %g7
1342 mov %l4, %o1
1343 mov %l5, %o2
1344 call handle_stdfmna
1345 add %sp, PTREGS_OFF, %o0
1346 ba,pt %xcc, rtrap
1347 clr %l6
1348
1349 .globl breakpoint_trap
1350breakpoint_trap:
1351 call sparc_breakpoint
1352 add %sp, PTREGS_OFF, %o0
1353 ba,pt %xcc, rtrap
1354 nop
1355
1356#if defined(CONFIG_SUNOS_EMUL) || defined(CONFIG_SOLARIS_EMUL) || \
1357 defined(CONFIG_SOLARIS_EMUL_MODULE)
1358 /* SunOS uses syscall zero as the 'indirect syscall' it looks
1359 * like indir_syscall(scall_num, arg0, arg1, arg2...); etc.
1360 * This is complete brain damage.
1361 */
1362 .globl sunos_indir
1363sunos_indir:
1364 srl %o0, 0, %o0
1365 mov %o7, %l4
1366 cmp %o0, NR_SYSCALLS
1367 blu,a,pt %icc, 1f
1368 sll %o0, 0x2, %o0
1369 sethi %hi(sunos_nosys), %l6
1370 b,pt %xcc, 2f
1371 or %l6, %lo(sunos_nosys), %l6
13721: sethi %hi(sunos_sys_table), %l7
1373 or %l7, %lo(sunos_sys_table), %l7
1374 lduw [%l7 + %o0], %l6
13752: mov %o1, %o0
1376 mov %o2, %o1
1377 mov %o3, %o2
1378 mov %o4, %o3
1379 mov %o5, %o4
1380 call %l6
1381 mov %l4, %o7
1382
1383 .globl sunos_getpid
1384sunos_getpid:
1385 call sys_getppid
1386 nop
1387 call sys_getpid
1388 stx %o0, [%sp + PTREGS_OFF + PT_V9_I1]
1389 b,pt %xcc, ret_sys_call
1390 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
1391
1392 /* SunOS getuid() returns uid in %o0 and euid in %o1 */
1393 .globl sunos_getuid
1394sunos_getuid:
1395 call sys32_geteuid16
1396 nop
1397 call sys32_getuid16
1398 stx %o0, [%sp + PTREGS_OFF + PT_V9_I1]
1399 b,pt %xcc, ret_sys_call
1400 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
1401
1402 /* SunOS getgid() returns gid in %o0 and egid in %o1 */
1403 .globl sunos_getgid
1404sunos_getgid:
1405 call sys32_getegid16
1406 nop
1407 call sys32_getgid16
1408 stx %o0, [%sp + PTREGS_OFF + PT_V9_I1]
1409 b,pt %xcc, ret_sys_call
1410 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
1411#endif
1412
1413 /* SunOS's execv() call only specifies the argv argument, the
1414 * environment settings are the same as the calling processes.
1415 */
1416 .globl sunos_execv
1417sys_execve:
1418 sethi %hi(sparc_execve), %g1
1419 ba,pt %xcc, execve_merge
1420 or %g1, %lo(sparc_execve), %g1
1421#ifdef CONFIG_COMPAT
1422 .globl sys_execve
1423sunos_execv:
1424 stx %g0, [%sp + PTREGS_OFF + PT_V9_I2]
1425 .globl sys32_execve
1426sys32_execve:
1427 sethi %hi(sparc32_execve), %g1
1428 or %g1, %lo(sparc32_execve), %g1
1429#endif
1430execve_merge:
1431 flushw
1432 jmpl %g1, %g0
1433 add %sp, PTREGS_OFF, %o0
1434
1435 .globl sys_pipe, sys_sigpause, sys_nis_syscall
Linus Torvalds1da177e2005-04-16 15:20:36 -07001436 .globl sys_rt_sigreturn
1437 .globl sys_ptrace
1438 .globl sys_sigaltstack
1439 .align 32
1440sys_pipe: ba,pt %xcc, sparc_pipe
1441 add %sp, PTREGS_OFF, %o0
1442sys_nis_syscall:ba,pt %xcc, c_sys_nis_syscall
1443 add %sp, PTREGS_OFF, %o0
1444sys_memory_ordering:
1445 ba,pt %xcc, sparc_memory_ordering
1446 add %sp, PTREGS_OFF, %o1
1447sys_sigaltstack:ba,pt %xcc, do_sigaltstack
1448 add %i6, STACK_BIAS, %o2
1449#ifdef CONFIG_COMPAT
1450 .globl sys32_sigstack
1451sys32_sigstack: ba,pt %xcc, do_sys32_sigstack
1452 mov %i6, %o2
1453 .globl sys32_sigaltstack
1454sys32_sigaltstack:
1455 ba,pt %xcc, do_sys32_sigaltstack
1456 mov %i6, %o2
1457#endif
1458 .align 32
Linus Torvalds1da177e2005-04-16 15:20:36 -07001459#ifdef CONFIG_COMPAT
1460 .globl sys32_sigreturn
1461sys32_sigreturn:
1462 add %sp, PTREGS_OFF, %o0
1463 call do_sigreturn32
1464 add %o7, 1f-.-4, %o7
1465 nop
1466#endif
1467sys_rt_sigreturn:
1468 add %sp, PTREGS_OFF, %o0
1469 call do_rt_sigreturn
1470 add %o7, 1f-.-4, %o7
1471 nop
1472#ifdef CONFIG_COMPAT
1473 .globl sys32_rt_sigreturn
1474sys32_rt_sigreturn:
1475 add %sp, PTREGS_OFF, %o0
1476 call do_rt_sigreturn32
1477 add %o7, 1f-.-4, %o7
1478 nop
1479#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001480 .align 32
14811: ldx [%curptr + TI_FLAGS], %l5
David S. Millerf7ceba32005-07-10 19:29:45 -07001482 andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
Linus Torvalds1da177e2005-04-16 15:20:36 -07001483 be,pt %icc, rtrap
1484 clr %l6
David S. Miller8d8a6472005-07-10 16:55:48 -07001485 add %sp, PTREGS_OFF, %o0
Linus Torvalds1da177e2005-04-16 15:20:36 -07001486 call syscall_trace
David S. Miller8d8a6472005-07-10 16:55:48 -07001487 mov 1, %o1
Linus Torvalds1da177e2005-04-16 15:20:36 -07001488
1489 ba,pt %xcc, rtrap
1490 clr %l6
1491
1492 /* This is how fork() was meant to be done, 8 instruction entry.
1493 *
1494 * I questioned the following code briefly, let me clear things
1495 * up so you must not reason on it like I did.
1496 *
1497 * Know the fork_kpsr etc. we use in the sparc32 port? We don't
1498 * need it here because the only piece of window state we copy to
1499 * the child is the CWP register. Even if the parent sleeps,
1500 * we are safe because we stuck it into pt_regs of the parent
1501 * so it will not change.
1502 *
1503 * XXX This raises the question, whether we can do the same on
1504 * XXX sparc32 to get rid of fork_kpsr _and_ fork_kwim. The
1505 * XXX answer is yes. We stick fork_kpsr in UREG_G0 and
1506 * XXX fork_kwim in UREG_G1 (global registers are considered
1507 * XXX volatile across a system call in the sparc ABI I think
1508 * XXX if it isn't we can use regs->y instead, anyone who depends
1509 * XXX upon the Y register being preserved across a fork deserves
1510 * XXX to lose).
1511 *
1512 * In fact we should take advantage of that fact for other things
1513 * during system calls...
1514 */
1515 .globl sys_fork, sys_vfork, sys_clone, sparc_exit
1516 .globl ret_from_syscall
1517 .align 32
1518sys_vfork: /* Under Linux, vfork and fork are just special cases of clone. */
1519 sethi %hi(0x4000 | 0x0100 | SIGCHLD), %o0
1520 or %o0, %lo(0x4000 | 0x0100 | SIGCHLD), %o0
1521 ba,pt %xcc, sys_clone
1522sys_fork: clr %o1
1523 mov SIGCHLD, %o0
1524sys_clone: flushw
1525 movrz %o1, %fp, %o1
1526 mov 0, %o3
1527 ba,pt %xcc, sparc_do_fork
1528 add %sp, PTREGS_OFF, %o2
1529ret_from_syscall:
David S. Millerdb7d9a42005-07-24 19:36:26 -07001530 /* Clear current_thread_info()->new_child, and
1531 * check performance counter stuff too.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001532 */
David S. Millerdb7d9a42005-07-24 19:36:26 -07001533 stb %g0, [%g6 + TI_NEW_CHILD]
1534 ldx [%g6 + TI_FLAGS], %l0
Linus Torvalds1da177e2005-04-16 15:20:36 -07001535 call schedule_tail
1536 mov %g7, %o0
1537 andcc %l0, _TIF_PERFCTR, %g0
1538 be,pt %icc, 1f
1539 nop
1540 ldx [%g6 + TI_PCR], %o7
1541 wr %g0, %o7, %pcr
1542
1543 /* Blackbird errata workaround. See commentary in
1544 * smp.c:smp_percpu_timer_interrupt() for more
1545 * information.
1546 */
1547 ba,pt %xcc, 99f
1548 nop
1549 .align 64
155099: wr %g0, %g0, %pic
1551 rd %pic, %g0
1552
15531: b,pt %xcc, ret_sys_call
1554 ldx [%sp + PTREGS_OFF + PT_V9_I0], %o0
David S. Miller764afe22006-01-31 18:34:06 -08001555sparc_exit: rdpr %pstate, %g2
1556 wrpr %g2, PSTATE_IE, %pstate
Linus Torvalds1da177e2005-04-16 15:20:36 -07001557 rdpr %otherwin, %g1
1558 rdpr %cansave, %g3
1559 add %g3, %g1, %g3
1560 wrpr %g3, 0x0, %cansave
1561 wrpr %g0, 0x0, %otherwin
David S. Miller764afe22006-01-31 18:34:06 -08001562 wrpr %g2, 0x0, %pstate
Linus Torvalds1da177e2005-04-16 15:20:36 -07001563 ba,pt %xcc, sys_exit
1564 stb %g0, [%g6 + TI_WSAVED]
1565
1566linux_sparc_ni_syscall:
1567 sethi %hi(sys_ni_syscall), %l7
1568 b,pt %xcc, 4f
1569 or %l7, %lo(sys_ni_syscall), %l7
1570
1571linux_syscall_trace32:
David S. Miller8d8a6472005-07-10 16:55:48 -07001572 add %sp, PTREGS_OFF, %o0
Linus Torvalds1da177e2005-04-16 15:20:36 -07001573 call syscall_trace
David S. Miller8d8a6472005-07-10 16:55:48 -07001574 clr %o1
Linus Torvalds1da177e2005-04-16 15:20:36 -07001575 srl %i0, 0, %o0
David S. Miller8d8a6472005-07-10 16:55:48 -07001576 srl %i4, 0, %o4
Linus Torvalds1da177e2005-04-16 15:20:36 -07001577 srl %i1, 0, %o1
1578 srl %i2, 0, %o2
1579 b,pt %xcc, 2f
1580 srl %i3, 0, %o3
1581
1582linux_syscall_trace:
David S. Miller8d8a6472005-07-10 16:55:48 -07001583 add %sp, PTREGS_OFF, %o0
Linus Torvalds1da177e2005-04-16 15:20:36 -07001584 call syscall_trace
David S. Miller8d8a6472005-07-10 16:55:48 -07001585 clr %o1
Linus Torvalds1da177e2005-04-16 15:20:36 -07001586 mov %i0, %o0
1587 mov %i1, %o1
1588 mov %i2, %o2
1589 mov %i3, %o3
1590 b,pt %xcc, 2f
1591 mov %i4, %o4
1592
1593
1594 /* Linux 32-bit and SunOS system calls enter here... */
1595 .align 32
1596 .globl linux_sparc_syscall32
1597linux_sparc_syscall32:
1598 /* Direct access to user regs, much faster. */
1599 cmp %g1, NR_SYSCALLS ! IEU1 Group
1600 bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI
1601 srl %i0, 0, %o0 ! IEU0
1602 sll %g1, 2, %l4 ! IEU0 Group
Linus Torvalds1da177e2005-04-16 15:20:36 -07001603 srl %i4, 0, %o4 ! IEU1
1604 lduw [%l7 + %l4], %l7 ! Load
1605 srl %i1, 0, %o1 ! IEU0 Group
1606 ldx [%curptr + TI_FLAGS], %l0 ! Load
1607
1608 srl %i5, 0, %o5 ! IEU1
1609 srl %i2, 0, %o2 ! IEU0 Group
David S. Millerf7ceba32005-07-10 19:29:45 -07001610 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
Linus Torvalds1da177e2005-04-16 15:20:36 -07001611 bne,pn %icc, linux_syscall_trace32 ! CTI
1612 mov %i0, %l5 ! IEU1
1613 call %l7 ! CTI Group brk forced
1614 srl %i3, 0, %o3 ! IEU0
1615 ba,a,pt %xcc, 3f
1616
1617 /* Linux native and SunOS system calls enter here... */
1618 .align 32
1619 .globl linux_sparc_syscall, ret_sys_call
1620linux_sparc_syscall:
1621 /* Direct access to user regs, much faster. */
1622 cmp %g1, NR_SYSCALLS ! IEU1 Group
1623 bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI
1624 mov %i0, %o0 ! IEU0
1625 sll %g1, 2, %l4 ! IEU0 Group
Linus Torvalds1da177e2005-04-16 15:20:36 -07001626 mov %i1, %o1 ! IEU1
1627 lduw [%l7 + %l4], %l7 ! Load
16284: mov %i2, %o2 ! IEU0 Group
1629 ldx [%curptr + TI_FLAGS], %l0 ! Load
1630
1631 mov %i3, %o3 ! IEU1
1632 mov %i4, %o4 ! IEU0 Group
David S. Millerf7ceba32005-07-10 19:29:45 -07001633 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
Linus Torvalds1da177e2005-04-16 15:20:36 -07001634 bne,pn %icc, linux_syscall_trace ! CTI Group
1635 mov %i0, %l5 ! IEU0
16362: call %l7 ! CTI Group brk forced
1637 mov %i5, %o5 ! IEU0
1638 nop
1639
16403: stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
1641ret_sys_call:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001642 ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %g3
1643 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
1644 sra %o0, 0, %o0
1645 mov %ulo(TSTATE_XCARRY | TSTATE_ICARRY), %g2
1646 sllx %g2, 32, %g2
1647
1648 /* Check if force_successful_syscall_return()
1649 * was invoked.
1650 */
Richard Mortimer695ca072006-01-09 14:35:50 -08001651 ldub [%curptr + TI_SYS_NOERROR], %l2
1652 brnz,a,pn %l2, 80f
David S. Millerdb7d9a42005-07-24 19:36:26 -07001653 stb %g0, [%curptr + TI_SYS_NOERROR]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001654
Linus Torvalds1da177e2005-04-16 15:20:36 -07001655 cmp %o0, -ERESTART_RESTARTBLOCK
1656 bgeu,pn %xcc, 1f
David S. Millerf7ceba32005-07-10 19:29:45 -07001657 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %l6
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165880:
1659 /* System call success, clear Carry condition code. */
1660 andn %g3, %g2, %g3
1661 stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE]
1662 bne,pn %icc, linux_syscall_trace2
1663 add %l1, 0x4, %l2 ! npc = npc+4
1664 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
1665 ba,pt %xcc, rtrap_clr_l6
1666 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
1667
16681:
1669 /* System call failure, set Carry condition code.
1670 * Also, get abs(errno) to return to the process.
1671 */
David S. Millerf7ceba32005-07-10 19:29:45 -07001672 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %l6
Linus Torvalds1da177e2005-04-16 15:20:36 -07001673 sub %g0, %o0, %o0
1674 or %g3, %g2, %g3
1675 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
1676 mov 1, %l6
1677 stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE]
1678 bne,pn %icc, linux_syscall_trace2
1679 add %l1, 0x4, %l2 ! npc = npc+4
1680 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
1681
1682 b,pt %xcc, rtrap
1683 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
1684linux_syscall_trace2:
David S. Miller8d8a6472005-07-10 16:55:48 -07001685 add %sp, PTREGS_OFF, %o0
Linus Torvalds1da177e2005-04-16 15:20:36 -07001686 call syscall_trace
David S. Miller8d8a6472005-07-10 16:55:48 -07001687 mov 1, %o1
Linus Torvalds1da177e2005-04-16 15:20:36 -07001688 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
1689 ba,pt %xcc, rtrap
1690 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
1691
1692 .align 32
1693 .globl __flushw_user
1694__flushw_user:
1695 rdpr %otherwin, %g1
1696 brz,pn %g1, 2f
1697 clr %g2
16981: save %sp, -128, %sp
1699 rdpr %otherwin, %g1
1700 brnz,pt %g1, 1b
1701 add %g2, 1, %g2
17021: sub %g2, 1, %g2
1703 brnz,pt %g2, 1b
1704 restore %g0, %g0, %g0
17052: retl
1706 nop
David S. Miller56fb4df2006-02-26 23:24:22 -08001707
David S. Miller85a79352008-03-24 20:06:24 -07001708 /* Flush %fp and %i7 to the stack for all register
1709 * windows active inside of the cpu. This allows
1710 * show_stack_trace() to avoid using an expensive
1711 * 'flushw'.
1712 */
1713 .globl stack_trace_flush
1714 .type stack_trace_flush,#function
1715stack_trace_flush:
1716 rdpr %pstate, %o0
1717 wrpr %o0, PSTATE_IE, %pstate
1718
1719 rdpr %cwp, %g1
1720 rdpr %canrestore, %g2
1721 sub %g1, 1, %g3
1722
17231: brz,pn %g2, 2f
1724 sub %g2, 1, %g2
1725 wrpr %g3, %cwp
1726 stx %fp, [%sp + STACK_BIAS + RW_V9_I6]
1727 stx %i7, [%sp + STACK_BIAS + RW_V9_I7]
1728 ba,pt %xcc, 1b
1729 sub %g3, 1, %g3
1730
17312: wrpr %g1, %cwp
1732 wrpr %o0, %pstate
1733
1734 retl
1735 nop
1736 .size stack_trace_flush,.-stack_trace_flush
1737
David S. Miller92704a12006-02-26 23:27:19 -08001738#ifdef CONFIG_SMP
1739 .globl hard_smp_processor_id
1740hard_smp_processor_id:
David S. Millerebd8c562006-02-17 08:38:06 -08001741#endif
1742 .globl real_hard_smp_processor_id
1743real_hard_smp_processor_id:
David S. Miller92704a12006-02-26 23:27:19 -08001744 __GET_CPUID(%o0)
David S. Miller56fb4df2006-02-26 23:24:22 -08001745 retl
1746 nop
David S. Miller85dfa192006-02-13 00:02:16 -08001747
1748 /* %o0: devhandle
1749 * %o1: devino
1750 *
1751 * returns %o0: sysino
1752 */
David S. Miller6c0f402f2006-02-13 00:23:32 -08001753 .globl sun4v_devino_to_sysino
David S. Miller7db35f32007-05-29 02:22:14 -07001754 .type sun4v_devino_to_sysino,#function
David S. Miller85dfa192006-02-13 00:02:16 -08001755sun4v_devino_to_sysino:
1756 mov HV_FAST_INTR_DEVINO2SYSINO, %o5
1757 ta HV_FAST_TRAP
1758 retl
1759 mov %o1, %o0
David S. Miller7db35f32007-05-29 02:22:14 -07001760 .size sun4v_devino_to_sysino, .-sun4v_devino_to_sysino
David S. Miller6c0f402f2006-02-13 00:23:32 -08001761
1762 /* %o0: sysino
1763 *
1764 * returns %o0: intr_enabled (HV_INTR_{DISABLED,ENABLED})
1765 */
1766 .globl sun4v_intr_getenabled
David S. Miller7db35f32007-05-29 02:22:14 -07001767 .type sun4v_intr_getenabled,#function
David S. Miller6c0f402f2006-02-13 00:23:32 -08001768sun4v_intr_getenabled:
1769 mov HV_FAST_INTR_GETENABLED, %o5
1770 ta HV_FAST_TRAP
1771 retl
1772 mov %o1, %o0
David S. Miller7db35f32007-05-29 02:22:14 -07001773 .size sun4v_intr_getenabled, .-sun4v_intr_getenabled
David S. Miller6c0f402f2006-02-13 00:23:32 -08001774
1775 /* %o0: sysino
1776 * %o1: intr_enabled (HV_INTR_{DISABLED,ENABLED})
1777 */
1778 .globl sun4v_intr_setenabled
David S. Miller7db35f32007-05-29 02:22:14 -07001779 .type sun4v_intr_setenabled,#function
David S. Miller6c0f402f2006-02-13 00:23:32 -08001780sun4v_intr_setenabled:
1781 mov HV_FAST_INTR_SETENABLED, %o5
1782 ta HV_FAST_TRAP
1783 retl
1784 nop
David S. Miller7db35f32007-05-29 02:22:14 -07001785 .size sun4v_intr_setenabled, .-sun4v_intr_setenabled
David S. Miller6c0f402f2006-02-13 00:23:32 -08001786
1787 /* %o0: sysino
1788 *
1789 * returns %o0: intr_state (HV_INTR_STATE_*)
1790 */
1791 .globl sun4v_intr_getstate
David S. Miller7db35f32007-05-29 02:22:14 -07001792 .type sun4v_intr_getstate,#function
David S. Miller6c0f402f2006-02-13 00:23:32 -08001793sun4v_intr_getstate:
1794 mov HV_FAST_INTR_GETSTATE, %o5
1795 ta HV_FAST_TRAP
1796 retl
1797 mov %o1, %o0
David S. Miller7db35f32007-05-29 02:22:14 -07001798 .size sun4v_intr_getstate, .-sun4v_intr_getstate
David S. Miller6c0f402f2006-02-13 00:23:32 -08001799
1800 /* %o0: sysino
1801 * %o1: intr_state (HV_INTR_STATE_*)
1802 */
1803 .globl sun4v_intr_setstate
David S. Miller7db35f32007-05-29 02:22:14 -07001804 .type sun4v_intr_setstate,#function
David S. Miller6c0f402f2006-02-13 00:23:32 -08001805sun4v_intr_setstate:
1806 mov HV_FAST_INTR_SETSTATE, %o5
1807 ta HV_FAST_TRAP
1808 retl
1809 nop
David S. Miller7db35f32007-05-29 02:22:14 -07001810 .size sun4v_intr_setstate, .-sun4v_intr_setstate
David S. Miller6c0f402f2006-02-13 00:23:32 -08001811
1812 /* %o0: sysino
1813 *
1814 * returns %o0: cpuid
1815 */
1816 .globl sun4v_intr_gettarget
David S. Miller7db35f32007-05-29 02:22:14 -07001817 .type sun4v_intr_gettarget,#function
David S. Miller6c0f402f2006-02-13 00:23:32 -08001818sun4v_intr_gettarget:
1819 mov HV_FAST_INTR_GETTARGET, %o5
1820 ta HV_FAST_TRAP
1821 retl
1822 mov %o1, %o0
David S. Miller7db35f32007-05-29 02:22:14 -07001823 .size sun4v_intr_gettarget, .-sun4v_intr_gettarget
David S. Miller6c0f402f2006-02-13 00:23:32 -08001824
1825 /* %o0: sysino
1826 * %o1: cpuid
1827 */
1828 .globl sun4v_intr_settarget
David S. Miller7db35f32007-05-29 02:22:14 -07001829 .type sun4v_intr_settarget,#function
David S. Miller6c0f402f2006-02-13 00:23:32 -08001830sun4v_intr_settarget:
1831 mov HV_FAST_INTR_SETTARGET, %o5
1832 ta HV_FAST_TRAP
1833 retl
1834 nop
David S. Miller7db35f32007-05-29 02:22:14 -07001835 .size sun4v_intr_settarget, .-sun4v_intr_settarget
1836
1837 /* %o0: cpuid
1838 * %o1: pc
1839 * %o2: rtba
1840 * %o3: arg0
1841 *
1842 * returns %o0: status
1843 */
1844 .globl sun4v_cpu_start
1845 .type sun4v_cpu_start,#function
1846sun4v_cpu_start:
1847 mov HV_FAST_CPU_START, %o5
1848 ta HV_FAST_TRAP
1849 retl
1850 nop
1851 .size sun4v_cpu_start, .-sun4v_cpu_start
1852
1853 /* %o0: cpuid
1854 *
1855 * returns %o0: status
1856 */
1857 .globl sun4v_cpu_stop
1858 .type sun4v_cpu_stop,#function
1859sun4v_cpu_stop:
1860 mov HV_FAST_CPU_STOP, %o5
1861 ta HV_FAST_TRAP
1862 retl
1863 nop
1864 .size sun4v_cpu_stop, .-sun4v_cpu_stop
1865
1866 /* returns %o0: status */
1867 .globl sun4v_cpu_yield
1868 .type sun4v_cpu_yield, #function
1869sun4v_cpu_yield:
1870 mov HV_FAST_CPU_YIELD, %o5
1871 ta HV_FAST_TRAP
1872 retl
1873 nop
1874 .size sun4v_cpu_yield, .-sun4v_cpu_yield
David S. Miller6c0f402f2006-02-13 00:23:32 -08001875
David S. Miller94f87622006-02-16 14:26:53 -08001876 /* %o0: type
1877 * %o1: queue paddr
1878 * %o2: num queue entries
1879 *
1880 * returns %o0: status
1881 */
1882 .globl sun4v_cpu_qconf
David S. Miller7db35f32007-05-29 02:22:14 -07001883 .type sun4v_cpu_qconf,#function
David S. Miller94f87622006-02-16 14:26:53 -08001884sun4v_cpu_qconf:
1885 mov HV_FAST_CPU_QCONF, %o5
1886 ta HV_FAST_TRAP
1887 retl
1888 nop
David S. Miller7db35f32007-05-29 02:22:14 -07001889 .size sun4v_cpu_qconf, .-sun4v_cpu_qconf
David S. Millerb830ab62006-02-28 15:10:26 -08001890
1891 /* %o0: num cpus in cpu list
1892 * %o1: cpu list paddr
1893 * %o2: mondo block paddr
1894 *
1895 * returns %o0: status
1896 */
1897 .globl sun4v_cpu_mondo_send
David S. Miller7db35f32007-05-29 02:22:14 -07001898 .type sun4v_cpu_mondo_send,#function
David S. Millerb830ab62006-02-28 15:10:26 -08001899sun4v_cpu_mondo_send:
1900 mov HV_FAST_CPU_MONDO_SEND, %o5
1901 ta HV_FAST_TRAP
1902 retl
1903 nop
David S. Miller7db35f32007-05-29 02:22:14 -07001904 .size sun4v_cpu_mondo_send, .-sun4v_cpu_mondo_send
David S. Millerb830ab62006-02-28 15:10:26 -08001905
1906 /* %o0: CPU ID
1907 *
1908 * returns %o0: -status if status non-zero, else
1909 * %o0: cpu state as HV_CPU_STATE_*
1910 */
1911 .globl sun4v_cpu_state
David S. Miller7db35f32007-05-29 02:22:14 -07001912 .type sun4v_cpu_state,#function
David S. Millerb830ab62006-02-28 15:10:26 -08001913sun4v_cpu_state:
1914 mov HV_FAST_CPU_STATE, %o5
1915 ta HV_FAST_TRAP
1916 brnz,pn %o0, 1f
1917 sub %g0, %o0, %o0
1918 mov %o1, %o0
19191: retl
1920 nop
David S. Miller7db35f32007-05-29 02:22:14 -07001921 .size sun4v_cpu_state, .-sun4v_cpu_state
1922
1923 /* %o0: virtual address
1924 * %o1: must be zero
1925 * %o2: TTE
1926 * %o3: HV_MMU_* flags
1927 *
1928 * returns %o0: status
1929 */
1930 .globl sun4v_mmu_map_perm_addr
1931 .type sun4v_mmu_map_perm_addr,#function
1932sun4v_mmu_map_perm_addr:
1933 mov HV_FAST_MMU_MAP_PERM_ADDR, %o5
1934 ta HV_FAST_TRAP
1935 retl
1936 nop
1937 .size sun4v_mmu_map_perm_addr, .-sun4v_mmu_map_perm_addr
1938
1939 /* %o0: number of TSB descriptions
1940 * %o1: TSB descriptions real address
1941 *
1942 * returns %o0: status
1943 */
1944 .globl sun4v_mmu_tsb_ctx0
1945 .type sun4v_mmu_tsb_ctx0,#function
1946sun4v_mmu_tsb_ctx0:
1947 mov HV_FAST_MMU_TSB_CTX0, %o5
1948 ta HV_FAST_TRAP
1949 retl
1950 nop
1951 .size sun4v_mmu_tsb_ctx0, .-sun4v_mmu_tsb_ctx0
David S. Millerc7754d42007-05-15 17:03:54 -07001952
1953 /* %o0: API group number
1954 * %o1: pointer to unsigned long major number storage
1955 * %o2: pointer to unsigned long minor number storage
1956 *
1957 * returns %o0: status
1958 */
1959 .globl sun4v_get_version
David S. Miller7db35f32007-05-29 02:22:14 -07001960 .type sun4v_get_version,#function
David S. Millerc7754d42007-05-15 17:03:54 -07001961sun4v_get_version:
1962 mov HV_CORE_GET_VER, %o5
1963 mov %o1, %o3
1964 mov %o2, %o4
1965 ta HV_CORE_TRAP
1966 stx %o1, [%o3]
1967 retl
1968 stx %o2, [%o4]
David S. Miller7db35f32007-05-29 02:22:14 -07001969 .size sun4v_get_version, .-sun4v_get_version
David S. Millerc7754d42007-05-15 17:03:54 -07001970
1971 /* %o0: API group number
1972 * %o1: desired major number
1973 * %o2: desired minor number
1974 * %o3: pointer to unsigned long actual minor number storage
1975 *
1976 * returns %o0: status
1977 */
1978 .globl sun4v_set_version
David S. Miller7db35f32007-05-29 02:22:14 -07001979 .type sun4v_set_version,#function
David S. Millerc7754d42007-05-15 17:03:54 -07001980sun4v_set_version:
1981 mov HV_CORE_SET_VER, %o5
1982 mov %o3, %o4
1983 ta HV_CORE_TRAP
1984 retl
1985 stx %o1, [%o4]
David S. Miller7db35f32007-05-29 02:22:14 -07001986 .size sun4v_set_version, .-sun4v_set_version
1987
1988 /* %o0: pointer to unsigned long time
1989 *
1990 * returns %o0: status
1991 */
1992 .globl sun4v_tod_get
1993 .type sun4v_tod_get,#function
1994sun4v_tod_get:
1995 mov %o0, %o4
1996 mov HV_FAST_TOD_GET, %o5
1997 ta HV_FAST_TRAP
1998 stx %o1, [%o4]
1999 retl
2000 nop
2001 .size sun4v_tod_get, .-sun4v_tod_get
2002
2003 /* %o0: time
2004 *
2005 * returns %o0: status
2006 */
2007 .globl sun4v_tod_set
2008 .type sun4v_tod_set,#function
2009sun4v_tod_set:
2010 mov HV_FAST_TOD_SET, %o5
2011 ta HV_FAST_TRAP
2012 retl
2013 nop
2014 .size sun4v_tod_set, .-sun4v_tod_set
David S. Millerc7754d42007-05-15 17:03:54 -07002015
2016 /* %o0: pointer to unsigned long status
2017 *
2018 * returns %o0: signed character
2019 */
2020 .globl sun4v_con_getchar
David S. Miller7db35f32007-05-29 02:22:14 -07002021 .type sun4v_con_getchar,#function
David S. Millerc7754d42007-05-15 17:03:54 -07002022sun4v_con_getchar:
2023 mov %o0, %o4
2024 mov HV_FAST_CONS_GETCHAR, %o5
2025 clr %o0
2026 clr %o1
2027 ta HV_FAST_TRAP
2028 stx %o0, [%o4]
2029 retl
2030 sra %o1, 0, %o0
David S. Miller7db35f32007-05-29 02:22:14 -07002031 .size sun4v_con_getchar, .-sun4v_con_getchar
David S. Millerc7754d42007-05-15 17:03:54 -07002032
2033 /* %o0: signed long character
2034 *
2035 * returns %o0: status
2036 */
2037 .globl sun4v_con_putchar
David S. Miller7db35f32007-05-29 02:22:14 -07002038 .type sun4v_con_putchar,#function
David S. Millerc7754d42007-05-15 17:03:54 -07002039sun4v_con_putchar:
2040 mov HV_FAST_CONS_PUTCHAR, %o5
2041 ta HV_FAST_TRAP
2042 retl
2043 sra %o0, 0, %o0
David S. Miller7db35f32007-05-29 02:22:14 -07002044 .size sun4v_con_putchar, .-sun4v_con_putchar
David S. Millerc7754d42007-05-15 17:03:54 -07002045
2046 /* %o0: buffer real address
2047 * %o1: buffer size
2048 * %o2: pointer to unsigned long bytes_read
2049 *
2050 * returns %o0: status
2051 */
2052 .globl sun4v_con_read
David S. Miller7db35f32007-05-29 02:22:14 -07002053 .type sun4v_con_read,#function
David S. Millerc7754d42007-05-15 17:03:54 -07002054sun4v_con_read:
2055 mov %o2, %o4
2056 mov HV_FAST_CONS_READ, %o5
2057 ta HV_FAST_TRAP
2058 brnz %o0, 1f
2059 cmp %o1, -1 /* break */
2060 be,a,pn %icc, 1f
2061 mov %o1, %o0
2062 cmp %o1, -2 /* hup */
2063 be,a,pn %icc, 1f
2064 mov %o1, %o0
2065 stx %o1, [%o4]
20661: retl
2067 nop
David S. Miller7db35f32007-05-29 02:22:14 -07002068 .size sun4v_con_read, .-sun4v_con_read
David S. Millerc7754d42007-05-15 17:03:54 -07002069
2070 /* %o0: buffer real address
2071 * %o1: buffer size
2072 * %o2: pointer to unsigned long bytes_written
2073 *
2074 * returns %o0: status
2075 */
2076 .globl sun4v_con_write
David S. Miller7db35f32007-05-29 02:22:14 -07002077 .type sun4v_con_write,#function
David S. Millerc7754d42007-05-15 17:03:54 -07002078sun4v_con_write:
2079 mov %o2, %o4
2080 mov HV_FAST_CONS_WRITE, %o5
2081 ta HV_FAST_TRAP
2082 stx %o1, [%o4]
2083 retl
2084 nop
David S. Miller7db35f32007-05-29 02:22:14 -07002085 .size sun4v_con_write, .-sun4v_con_write
David S. Miller22d6a1c2007-05-25 00:37:12 -07002086
2087 /* %o0: soft state
2088 * %o1: address of description string
2089 *
2090 * returns %o0: status
2091 */
2092 .globl sun4v_mach_set_soft_state
David S. Miller7db35f32007-05-29 02:22:14 -07002093 .type sun4v_mach_set_soft_state,#function
David S. Miller22d6a1c2007-05-25 00:37:12 -07002094sun4v_mach_set_soft_state:
2095 mov HV_FAST_MACH_SET_SOFT_STATE, %o5
2096 ta HV_FAST_TRAP
2097 retl
2098 nop
David S. Miller7db35f32007-05-29 02:22:14 -07002099 .size sun4v_mach_set_soft_state, .-sun4v_mach_set_soft_state
David S. Miller5cbc3072007-05-25 15:49:59 -07002100
David S. Miller7db35f32007-05-29 02:22:14 -07002101 /* %o0: exit code
2102 *
2103 * Does not return.
2104 */
2105 .globl sun4v_mach_exit
2106 .type sun4v_mach_exit,#function
2107sun4v_mach_exit:
2108 mov HV_FAST_MACH_EXIT, %o5
2109 ta HV_FAST_TRAP
2110 retl
2111 nop
2112 .size sun4v_mach_exit, .-sun4v_mach_exit
2113
2114 /* %o0: buffer real address
2115 * %o1: buffer length
2116 * %o2: pointer to unsigned long real_buf_len
2117 *
2118 * returns %o0: status
2119 */
David S. Miller5cbc3072007-05-25 15:49:59 -07002120 .globl sun4v_mach_desc
David S. Miller7db35f32007-05-29 02:22:14 -07002121 .type sun4v_mach_desc,#function
David S. Miller5cbc3072007-05-25 15:49:59 -07002122sun4v_mach_desc:
2123 mov %o2, %o4
2124 mov HV_FAST_MACH_DESC, %o5
2125 ta HV_FAST_TRAP
2126 stx %o1, [%o4]
2127 retl
2128 nop
David S. Miller7db35f32007-05-29 02:22:14 -07002129 .size sun4v_mach_desc, .-sun4v_mach_desc
2130
2131 /* %o0: new timeout in milliseconds
2132 * %o1: pointer to unsigned long orig_timeout
2133 *
2134 * returns %o0: status
2135 */
2136 .globl sun4v_mach_set_watchdog
2137 .type sun4v_mach_set_watchdog,#function
2138sun4v_mach_set_watchdog:
2139 mov %o1, %o4
2140 mov HV_FAST_MACH_SET_WATCHDOG, %o5
2141 ta HV_FAST_TRAP
2142 stx %o1, [%o4]
2143 retl
2144 nop
2145 .size sun4v_mach_set_watchdog, .-sun4v_mach_set_watchdog
2146
2147 /* No inputs and does not return. */
2148 .globl sun4v_mach_sir
2149 .type sun4v_mach_sir,#function
2150sun4v_mach_sir:
2151 mov %o1, %o4
2152 mov HV_FAST_MACH_SIR, %o5
2153 ta HV_FAST_TRAP
2154 stx %o1, [%o4]
2155 retl
2156 nop
2157 .size sun4v_mach_sir, .-sun4v_mach_sir
2158
2159 /* %o0: channel
2160 * %o1: ra
2161 * %o2: num_entries
2162 *
2163 * returns %o0: status
2164 */
2165 .globl sun4v_ldc_tx_qconf
2166 .type sun4v_ldc_tx_qconf,#function
2167sun4v_ldc_tx_qconf:
2168 mov HV_FAST_LDC_TX_QCONF, %o5
2169 ta HV_FAST_TRAP
2170 retl
2171 nop
2172 .size sun4v_ldc_tx_qconf, .-sun4v_ldc_tx_qconf
2173
2174 /* %o0: channel
2175 * %o1: pointer to unsigned long ra
2176 * %o2: pointer to unsigned long num_entries
2177 *
2178 * returns %o0: status
2179 */
2180 .globl sun4v_ldc_tx_qinfo
2181 .type sun4v_ldc_tx_qinfo,#function
2182sun4v_ldc_tx_qinfo:
2183 mov %o1, %g1
2184 mov %o2, %g2
2185 mov HV_FAST_LDC_TX_QINFO, %o5
2186 ta HV_FAST_TRAP
2187 stx %o1, [%g1]
2188 stx %o2, [%g2]
2189 retl
2190 nop
2191 .size sun4v_ldc_tx_qinfo, .-sun4v_ldc_tx_qinfo
2192
2193 /* %o0: channel
2194 * %o1: pointer to unsigned long head_off
2195 * %o2: pointer to unsigned long tail_off
2196 * %o2: pointer to unsigned long chan_state
2197 *
2198 * returns %o0: status
2199 */
2200 .globl sun4v_ldc_tx_get_state
2201 .type sun4v_ldc_tx_get_state,#function
2202sun4v_ldc_tx_get_state:
2203 mov %o1, %g1
2204 mov %o2, %g2
2205 mov %o3, %g3
2206 mov HV_FAST_LDC_TX_GET_STATE, %o5
2207 ta HV_FAST_TRAP
2208 stx %o1, [%g1]
2209 stx %o2, [%g2]
2210 stx %o3, [%g3]
2211 retl
2212 nop
2213 .size sun4v_ldc_tx_get_state, .-sun4v_ldc_tx_get_state
2214
2215 /* %o0: channel
2216 * %o1: tail_off
2217 *
2218 * returns %o0: status
2219 */
2220 .globl sun4v_ldc_tx_set_qtail
2221 .type sun4v_ldc_tx_set_qtail,#function
2222sun4v_ldc_tx_set_qtail:
2223 mov HV_FAST_LDC_TX_SET_QTAIL, %o5
2224 ta HV_FAST_TRAP
2225 retl
2226 nop
2227 .size sun4v_ldc_tx_set_qtail, .-sun4v_ldc_tx_set_qtail
2228
2229 /* %o0: channel
2230 * %o1: ra
2231 * %o2: num_entries
2232 *
2233 * returns %o0: status
2234 */
2235 .globl sun4v_ldc_rx_qconf
2236 .type sun4v_ldc_rx_qconf,#function
2237sun4v_ldc_rx_qconf:
2238 mov HV_FAST_LDC_RX_QCONF, %o5
2239 ta HV_FAST_TRAP
2240 retl
2241 nop
2242 .size sun4v_ldc_rx_qconf, .-sun4v_ldc_rx_qconf
2243
2244 /* %o0: channel
2245 * %o1: pointer to unsigned long ra
2246 * %o2: pointer to unsigned long num_entries
2247 *
2248 * returns %o0: status
2249 */
2250 .globl sun4v_ldc_rx_qinfo
2251 .type sun4v_ldc_rx_qinfo,#function
2252sun4v_ldc_rx_qinfo:
2253 mov %o1, %g1
2254 mov %o2, %g2
2255 mov HV_FAST_LDC_RX_QINFO, %o5
2256 ta HV_FAST_TRAP
2257 stx %o1, [%g1]
2258 stx %o2, [%g2]
2259 retl
2260 nop
2261 .size sun4v_ldc_rx_qinfo, .-sun4v_ldc_rx_qinfo
2262
2263 /* %o0: channel
2264 * %o1: pointer to unsigned long head_off
2265 * %o2: pointer to unsigned long tail_off
2266 * %o2: pointer to unsigned long chan_state
2267 *
2268 * returns %o0: status
2269 */
2270 .globl sun4v_ldc_rx_get_state
2271 .type sun4v_ldc_rx_get_state,#function
2272sun4v_ldc_rx_get_state:
2273 mov %o1, %g1
2274 mov %o2, %g2
2275 mov %o3, %g3
2276 mov HV_FAST_LDC_RX_GET_STATE, %o5
2277 ta HV_FAST_TRAP
2278 stx %o1, [%g1]
2279 stx %o2, [%g2]
2280 stx %o3, [%g3]
2281 retl
2282 nop
2283 .size sun4v_ldc_rx_get_state, .-sun4v_ldc_rx_get_state
2284
2285 /* %o0: channel
2286 * %o1: head_off
2287 *
2288 * returns %o0: status
2289 */
2290 .globl sun4v_ldc_rx_set_qhead
2291 .type sun4v_ldc_rx_set_qhead,#function
2292sun4v_ldc_rx_set_qhead:
2293 mov HV_FAST_LDC_RX_SET_QHEAD, %o5
2294 ta HV_FAST_TRAP
2295 retl
2296 nop
2297 .size sun4v_ldc_rx_set_qhead, .-sun4v_ldc_rx_set_qhead
2298
2299 /* %o0: channel
2300 * %o1: ra
2301 * %o2: num_entries
2302 *
2303 * returns %o0: status
2304 */
2305 .globl sun4v_ldc_set_map_table
2306 .type sun4v_ldc_set_map_table,#function
2307sun4v_ldc_set_map_table:
2308 mov HV_FAST_LDC_SET_MAP_TABLE, %o5
2309 ta HV_FAST_TRAP
2310 retl
2311 nop
2312 .size sun4v_ldc_set_map_table, .-sun4v_ldc_set_map_table
2313
2314 /* %o0: channel
2315 * %o1: pointer to unsigned long ra
2316 * %o2: pointer to unsigned long num_entries
2317 *
2318 * returns %o0: status
2319 */
2320 .globl sun4v_ldc_get_map_table
2321 .type sun4v_ldc_get_map_table,#function
2322sun4v_ldc_get_map_table:
2323 mov %o1, %g1
2324 mov %o2, %g2
2325 mov HV_FAST_LDC_GET_MAP_TABLE, %o5
2326 ta HV_FAST_TRAP
2327 stx %o1, [%g1]
2328 stx %o2, [%g2]
2329 retl
2330 nop
2331 .size sun4v_ldc_get_map_table, .-sun4v_ldc_get_map_table
2332
2333 /* %o0: channel
2334 * %o1: dir_code
2335 * %o2: tgt_raddr
2336 * %o3: lcl_raddr
2337 * %o4: len
2338 * %o5: pointer to unsigned long actual_len
2339 *
2340 * returns %o0: status
2341 */
2342 .globl sun4v_ldc_copy
2343 .type sun4v_ldc_copy,#function
2344sun4v_ldc_copy:
2345 mov %o5, %g1
2346 mov HV_FAST_LDC_COPY, %o5
2347 ta HV_FAST_TRAP
2348 stx %o1, [%g1]
2349 retl
2350 nop
2351 .size sun4v_ldc_copy, .-sun4v_ldc_copy
2352
2353 /* %o0: channel
2354 * %o1: cookie
2355 * %o2: pointer to unsigned long ra
2356 * %o3: pointer to unsigned long perm
2357 *
2358 * returns %o0: status
2359 */
2360 .globl sun4v_ldc_mapin
2361 .type sun4v_ldc_mapin,#function
2362sun4v_ldc_mapin:
2363 mov %o2, %g1
2364 mov %o3, %g2
2365 mov HV_FAST_LDC_MAPIN, %o5
2366 ta HV_FAST_TRAP
2367 stx %o1, [%g1]
2368 stx %o2, [%g2]
2369 retl
2370 nop
2371 .size sun4v_ldc_mapin, .-sun4v_ldc_mapin
2372
2373 /* %o0: ra
2374 *
2375 * returns %o0: status
2376 */
2377 .globl sun4v_ldc_unmap
2378 .type sun4v_ldc_unmap,#function
2379sun4v_ldc_unmap:
2380 mov HV_FAST_LDC_UNMAP, %o5
2381 ta HV_FAST_TRAP
2382 retl
2383 nop
2384 .size sun4v_ldc_unmap, .-sun4v_ldc_unmap
2385
David S. Millerfc395f82007-06-12 23:56:52 -07002386 /* %o0: channel
2387 * %o1: cookie
2388 * %o2: mte_cookie
David S. Miller7db35f32007-05-29 02:22:14 -07002389 *
2390 * returns %o0: status
2391 */
2392 .globl sun4v_ldc_revoke
2393 .type sun4v_ldc_revoke,#function
2394sun4v_ldc_revoke:
2395 mov HV_FAST_LDC_REVOKE, %o5
2396 ta HV_FAST_TRAP
2397 retl
2398 nop
2399 .size sun4v_ldc_revoke, .-sun4v_ldc_revoke
2400
2401 /* %o0: device handle
2402 * %o1: device INO
2403 * %o2: pointer to unsigned long cookie
2404 *
2405 * returns %o0: status
2406 */
2407 .globl sun4v_vintr_get_cookie
2408 .type sun4v_vintr_get_cookie,#function
2409sun4v_vintr_get_cookie:
2410 mov %o2, %g1
2411 mov HV_FAST_VINTR_GET_COOKIE, %o5
2412 ta HV_FAST_TRAP
2413 stx %o1, [%g1]
2414 retl
2415 nop
2416 .size sun4v_vintr_get_cookie, .-sun4v_vintr_get_cookie
2417
2418 /* %o0: device handle
2419 * %o1: device INO
2420 * %o2: cookie
2421 *
2422 * returns %o0: status
2423 */
2424 .globl sun4v_vintr_set_cookie
2425 .type sun4v_vintr_set_cookie,#function
2426sun4v_vintr_set_cookie:
2427 mov HV_FAST_VINTR_SET_COOKIE, %o5
2428 ta HV_FAST_TRAP
2429 retl
2430 nop
2431 .size sun4v_vintr_set_cookie, .-sun4v_vintr_set_cookie
2432
2433 /* %o0: device handle
2434 * %o1: device INO
2435 * %o2: pointer to unsigned long valid_state
2436 *
2437 * returns %o0: status
2438 */
2439 .globl sun4v_vintr_get_valid
2440 .type sun4v_vintr_get_valid,#function
2441sun4v_vintr_get_valid:
2442 mov %o2, %g1
2443 mov HV_FAST_VINTR_GET_VALID, %o5
2444 ta HV_FAST_TRAP
2445 stx %o1, [%g1]
2446 retl
2447 nop
2448 .size sun4v_vintr_get_valid, .-sun4v_vintr_get_valid
2449
2450 /* %o0: device handle
2451 * %o1: device INO
2452 * %o2: valid_state
2453 *
2454 * returns %o0: status
2455 */
2456 .globl sun4v_vintr_set_valid
2457 .type sun4v_vintr_set_valid,#function
2458sun4v_vintr_set_valid:
2459 mov HV_FAST_VINTR_SET_VALID, %o5
2460 ta HV_FAST_TRAP
2461 retl
2462 nop
2463 .size sun4v_vintr_set_valid, .-sun4v_vintr_set_valid
2464
2465 /* %o0: device handle
2466 * %o1: device INO
2467 * %o2: pointer to unsigned long state
2468 *
2469 * returns %o0: status
2470 */
2471 .globl sun4v_vintr_get_state
2472 .type sun4v_vintr_get_state,#function
2473sun4v_vintr_get_state:
2474 mov %o2, %g1
2475 mov HV_FAST_VINTR_GET_STATE, %o5
2476 ta HV_FAST_TRAP
2477 stx %o1, [%g1]
2478 retl
2479 nop
2480 .size sun4v_vintr_get_state, .-sun4v_vintr_get_state
2481
2482 /* %o0: device handle
2483 * %o1: device INO
2484 * %o2: state
2485 *
2486 * returns %o0: status
2487 */
2488 .globl sun4v_vintr_set_state
2489 .type sun4v_vintr_set_state,#function
2490sun4v_vintr_set_state:
2491 mov HV_FAST_VINTR_SET_STATE, %o5
2492 ta HV_FAST_TRAP
2493 retl
2494 nop
2495 .size sun4v_vintr_set_state, .-sun4v_vintr_set_state
2496
2497 /* %o0: device handle
2498 * %o1: device INO
2499 * %o2: pointer to unsigned long cpuid
2500 *
2501 * returns %o0: status
2502 */
2503 .globl sun4v_vintr_get_target
2504 .type sun4v_vintr_get_target,#function
2505sun4v_vintr_get_target:
2506 mov %o2, %g1
2507 mov HV_FAST_VINTR_GET_TARGET, %o5
2508 ta HV_FAST_TRAP
2509 stx %o1, [%g1]
2510 retl
2511 nop
2512 .size sun4v_vintr_get_target, .-sun4v_vintr_get_target
2513
2514 /* %o0: device handle
2515 * %o1: device INO
2516 * %o2: cpuid
2517 *
2518 * returns %o0: status
2519 */
2520 .globl sun4v_vintr_set_target
2521 .type sun4v_vintr_set_target,#function
2522sun4v_vintr_set_target:
2523 mov HV_FAST_VINTR_SET_TARGET, %o5
2524 ta HV_FAST_TRAP
2525 retl
2526 nop
2527 .size sun4v_vintr_set_target, .-sun4v_vintr_set_target
David S. Millerdbbe3cb2007-05-30 19:01:47 -07002528
2529 /* %o0: NCS sub-function
2530 * %o1: sub-function arg real-address
2531 * %o2: sub-function arg size
2532 *
2533 * returns %o0: status
2534 */
2535 .globl sun4v_ncs_request
2536 .type sun4v_ncs_request,#function
2537sun4v_ncs_request:
2538 mov HV_FAST_NCS_REQUEST, %o5
2539 ta HV_FAST_TRAP
2540 retl
2541 nop
2542 .size sun4v_ncs_request, .-sun4v_ncs_request
2543
David Miller48b67352007-06-03 19:07:32 -07002544 .globl sun4v_svc_send
2545 .type sun4v_svc_send,#function
2546sun4v_svc_send:
David S. Millerdbbe3cb2007-05-30 19:01:47 -07002547 save %sp, -192, %sp
2548 mov %i0, %o0
2549 mov %i1, %o1
2550 mov %i2, %o2
2551 mov HV_FAST_SVC_SEND, %o5
2552 ta HV_FAST_TRAP
2553 stx %o1, [%i3]
2554 ret
2555 restore
David Miller48b67352007-06-03 19:07:32 -07002556 .size sun4v_svc_send, .-sun4v_svc_send
David S. Millerdbbe3cb2007-05-30 19:01:47 -07002557
David Miller48b67352007-06-03 19:07:32 -07002558 .globl sun4v_svc_recv
2559 .type sun4v_svc_recv,#function
2560sun4v_svc_recv:
David S. Millerdbbe3cb2007-05-30 19:01:47 -07002561 save %sp, -192, %sp
2562 mov %i0, %o0
2563 mov %i1, %o1
2564 mov %i2, %o2
2565 mov HV_FAST_SVC_RECV, %o5
2566 ta HV_FAST_TRAP
2567 stx %o1, [%i3]
2568 ret
2569 restore
David Miller48b67352007-06-03 19:07:32 -07002570 .size sun4v_svc_recv, .-sun4v_svc_recv
David S. Millerdbbe3cb2007-05-30 19:01:47 -07002571
David Miller48b67352007-06-03 19:07:32 -07002572 .globl sun4v_svc_getstatus
2573 .type sun4v_svc_getstatus,#function
2574sun4v_svc_getstatus:
David S. Millerdbbe3cb2007-05-30 19:01:47 -07002575 mov HV_FAST_SVC_GETSTATUS, %o5
2576 mov %o1, %o4
2577 ta HV_FAST_TRAP
2578 stx %o1, [%o4]
2579 retl
2580 nop
David Miller48b67352007-06-03 19:07:32 -07002581 .size sun4v_svc_getstatus, .-sun4v_svc_getstatus
David S. Millerdbbe3cb2007-05-30 19:01:47 -07002582
David Miller48b67352007-06-03 19:07:32 -07002583 .globl sun4v_svc_setstatus
2584 .type sun4v_svc_setstatus,#function
2585sun4v_svc_setstatus:
David S. Millerdbbe3cb2007-05-30 19:01:47 -07002586 mov HV_FAST_SVC_SETSTATUS, %o5
2587 ta HV_FAST_TRAP
2588 retl
2589 nop
David Miller48b67352007-06-03 19:07:32 -07002590 .size sun4v_svc_setstatus, .-sun4v_svc_setstatus
David S. Millerdbbe3cb2007-05-30 19:01:47 -07002591
David Miller48b67352007-06-03 19:07:32 -07002592 .globl sun4v_svc_clrstatus
2593 .type sun4v_svc_clrstatus,#function
2594sun4v_svc_clrstatus:
David S. Millerdbbe3cb2007-05-30 19:01:47 -07002595 mov HV_FAST_SVC_CLRSTATUS, %o5
2596 ta HV_FAST_TRAP
2597 retl
2598 nop
David Miller48b67352007-06-03 19:07:32 -07002599 .size sun4v_svc_clrstatus, .-sun4v_svc_clrstatus
David Millerd887ab32007-06-03 23:38:09 -07002600
2601 .globl sun4v_mmustat_conf
2602 .type sun4v_mmustat_conf,#function
2603sun4v_mmustat_conf:
2604 mov %o1, %o4
2605 mov HV_FAST_MMUSTAT_CONF, %o5
2606 ta HV_FAST_TRAP
2607 stx %o1, [%o4]
2608 retl
2609 nop
2610 .size sun4v_mmustat_conf, .-sun4v_mmustat_conf
2611
2612 .globl sun4v_mmustat_info
2613 .type sun4v_mmustat_info,#function
2614sun4v_mmustat_info:
2615 mov %o0, %o4
2616 mov HV_FAST_MMUSTAT_INFO, %o5
2617 ta HV_FAST_TRAP
2618 stx %o1, [%o4]
2619 retl
2620 nop
2621 .size sun4v_mmustat_info, .-sun4v_mmustat_info
David S. Miller8f3614532007-12-13 06:13:38 -08002622
2623 .globl sun4v_mmu_demap_all
2624 .type sun4v_mmu_demap_all,#function
2625sun4v_mmu_demap_all:
2626 clr %o0
2627 clr %o1
2628 mov HV_MMU_ALL, %o2
2629 mov HV_FAST_MMU_DEMAP_ALL, %o5
2630 ta HV_FAST_TRAP
2631 retl
2632 nop
2633 .size sun4v_mmu_demap_all, .-sun4v_mmu_demap_all