Blame view
arch/mips/kernel/genex.S
11.8 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 3 4 5 6 7 8 |
/* * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * * Copyright (C) 1994 - 2000, 2001, 2003 Ralf Baechle * Copyright (C) 1999, 2000 Silicon Graphics, Inc. * Copyright (C) 2001 MIPS Technologies, Inc. |
619b6e18f [MIPS] R4000/R440... |
9 |
* Copyright (C) 2002, 2007 Maciej W. Rozycki |
1da177e4c Linux-2.6.12-rc2 |
10 |
*/ |
1da177e4c Linux-2.6.12-rc2 |
11 12 13 |
#include <linux/init.h> #include <asm/asm.h> |
41c594ab6 [MIPS] MT: Improv... |
14 |
#include <asm/asmmacro.h> |
1da177e4c Linux-2.6.12-rc2 |
15 |
#include <asm/cacheops.h> |
192ef3661 [MIPS] TRACE_IRQF... |
16 |
#include <asm/irqflags.h> |
1da177e4c Linux-2.6.12-rc2 |
17 18 19 20 21 |
#include <asm/regdef.h> #include <asm/fpregdef.h> #include <asm/mipsregs.h> #include <asm/stackframe.h> #include <asm/war.h> |
5b10496b6 [MIPS] Fast path ... |
22 |
#include <asm/page.h> |
c65a5480f [MIPS] Fix potent... |
23 |
#include <asm/thread_info.h> |
1da177e4c Linux-2.6.12-rc2 |
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
#define PANIC_PIC(msg) \ .set push; \ .set reorder; \ PTR_LA a0,8f; \ .set noat; \ PTR_LA AT, panic; \ jr AT; \ 9: b 9b; \ .set pop; \ TEXT(msg) __INIT NESTED(except_vec0_generic, 0, sp) PANIC_PIC("Exception vector 0 called") END(except_vec0_generic) NESTED(except_vec1_generic, 0, sp) PANIC_PIC("Exception vector 1 called") END(except_vec1_generic) /* * General exception vector for all other CPUs. * * Be careful when changing this, it has to be at most 128 bytes * to fit into space reserved for the exception handler. */ NESTED(except_vec3_generic, 0, sp) .set push .set noat #if R5432_CP0_INTERRUPT_WAR mfc0 k0, CP0_INDEX #endif mfc0 k1, CP0_CAUSE andi k1, k1, 0x7c |
875d43e72 [PATCH] mips: cle... |
60 |
#ifdef CONFIG_64BIT |
1da177e4c Linux-2.6.12-rc2 |
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
dsll k1, k1, 1 #endif PTR_L k0, exception_handlers(k1) jr k0 .set pop END(except_vec3_generic) /* * General exception handler for CPUs with virtual coherency exception. * * Be careful when changing this, it has to be at most 256 (as a special * exception) bytes to fit into space reserved for the exception handler. */ NESTED(except_vec3_r4000, 0, sp) .set push .set mips3 .set noat mfc0 k1, CP0_CAUSE li k0, 31<<2 andi k1, k1, 0x7c .set push .set noreorder .set nomacro beq k1, k0, handle_vced li k0, 14<<2 beq k1, k0, handle_vcei |
875d43e72 [PATCH] mips: cle... |
87 |
#ifdef CONFIG_64BIT |
69903d650 Fix typos and for... |
88 |
dsll k1, k1, 1 |
1da177e4c Linux-2.6.12-rc2 |
89 90 91 92 93 94 95 |
#endif .set pop PTR_L k0, exception_handlers(k1) jr k0 /* * Big shit, we now may have two dirty primary cache lines for the same |
69903d650 Fix typos and for... |
96 |
* physical address. We can safely invalidate the line pointed to by |
1da177e4c Linux-2.6.12-rc2 |
97 98 99 100 |
* c0_badvaddr because after return from this exception handler the * load / store will be re-executed. */ handle_vced: |
69903d650 Fix typos and for... |
101 |
MFC0 k0, CP0_BADVADDR |
1da177e4c Linux-2.6.12-rc2 |
102 103 104 |
li k1, -4 # Is this ... and k0, k1 # ... really needed? mtc0 zero, CP0_TAGLO |
69903d650 Fix typos and for... |
105 106 |
cache Index_Store_Tag_D, (k0) cache Hit_Writeback_Inv_SD, (k0) |
1da177e4c Linux-2.6.12-rc2 |
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
#ifdef CONFIG_PROC_FS PTR_LA k0, vced_count lw k1, (k0) addiu k1, 1 sw k1, (k0) #endif eret handle_vcei: MFC0 k0, CP0_BADVADDR cache Hit_Writeback_Inv_SD, (k0) # also cleans pi #ifdef CONFIG_PROC_FS PTR_LA k0, vcei_count lw k1, (k0) addiu k1, 1 sw k1, (k0) #endif eret .set pop END(except_vec3_r4000) |
e4ac58afd [MIPS] Rewrite al... |
127 |
__FINIT |
c65a5480f [MIPS] Fix potent... |
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
.align 5 /* 32 byte rollback region */ LEAF(r4k_wait) .set push .set noreorder /* start of rollback region */ LONG_L t0, TI_FLAGS($28) nop andi t0, _TIF_NEED_RESCHED bnez t0, 1f nop nop nop .set mips3 wait /* end of rollback region (the region size must be power of two) */ .set pop 1: jr ra END(r4k_wait) .macro BUILD_ROLLBACK_PROLOGUE handler FEXPORT(rollback_\handler) .set push .set noat MFC0 k0, CP0_EPC PTR_LA k1, r4k_wait ori k0, 0x1f /* 32 byte rollback region */ xori k0, 0x1f bne k0, k1, 9f MTC0 k0, CP0_EPC 9: .set pop .endm |
e4ac58afd [MIPS] Rewrite al... |
161 |
.align 5 |
c65a5480f [MIPS] Fix potent... |
162 |
BUILD_ROLLBACK_PROLOGUE handle_int |
e4ac58afd [MIPS] Rewrite al... |
163 |
NESTED(handle_int, PT_SIZE, sp) |
fe99f1b18 [MIPS] lockdep: D... |
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
#ifdef CONFIG_TRACE_IRQFLAGS /* * Check to see if the interrupted code has just disabled * interrupts and ignore this interrupt for now if so. * * local_irq_disable() disables interrupts and then calls * trace_hardirqs_off() to track the state. If an interrupt is taken * after interrupts are disabled but before the state is updated * it will appear to restore_all that it is incorrectly returning with * interrupts disabled */ .set push .set noat mfc0 k0, CP0_STATUS #if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX) and k0, ST0_IEP bnez k0, 1f |
c6563e85f [MIPS] Fix typo i... |
181 |
mfc0 k0, CP0_EPC |
fe99f1b18 [MIPS] lockdep: D... |
182 183 184 185 186 187 188 189 190 191 192 193 |
.set noreorder j k0 rfe #else and k0, ST0_IE bnez k0, 1f eret #endif 1: .set pop #endif |
e4ac58afd [MIPS] Rewrite al... |
194 195 |
SAVE_ALL CLI |
192ef3661 [MIPS] TRACE_IRQF... |
196 |
TRACE_IRQS_OFF |
e4ac58afd [MIPS] Rewrite al... |
197 |
|
937a80157 [MIPS] Complete f... |
198 199 |
LONG_L s0, TI_REGS($28) LONG_S sp, TI_REGS($28) |
f431baa55 [MIPS] ret_from_i... |
200 201 |
PTR_LA ra, ret_from_irq j plat_irq_dispatch |
e4ac58afd [MIPS] Rewrite al... |
202 203 204 |
END(handle_int) __INIT |
1da177e4c Linux-2.6.12-rc2 |
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
/* * Special interrupt vector for MIPS64 ISA & embedded MIPS processors. * This is a dedicated interrupt exception vector which reduces the * interrupt processing overhead. The jump instruction will be replaced * at the initialization time. * * Be careful when changing this, it has to be at most 128 bytes * to fit into space reserved for the exception handler. */ NESTED(except_vec4, 0, sp) 1: j 1b /* Dummy, will be replaced */ END(except_vec4) /* * EJTAG debug exception handler. * The EJTAG debug exception entry point is 0xbfc00480, which * normally is in the boot PROM, so the boot PROM must do a * unconditional jump to this vector. */ NESTED(except_vec_ejtag_debug, 0, sp) j ejtag_debug_handler END(except_vec_ejtag_debug) __FINIT /* |
e01402b11 More AP / SP bits... |
231 232 233 234 |
* Vectored interrupt handler. * This prototype is copied to ebase + n*IntCtl.VS and patched * to invoke the handler */ |
c65a5480f [MIPS] Fix potent... |
235 |
BUILD_ROLLBACK_PROLOGUE except_vec_vi |
e01402b11 More AP / SP bits... |
236 237 238 239 240 |
NESTED(except_vec_vi, 0, sp) SAVE_SOME SAVE_AT .set push .set noreorder |
41c594ab6 [MIPS] MT: Improv... |
241 242 243 244 245 246 |
#ifdef CONFIG_MIPS_MT_SMTC /* * To keep from blindly blocking *all* interrupts * during service by SMTC kernel, we also want to * pass the IM value to be cleared. */ |
7df424611 [MIPS] Export exc... |
247 |
FEXPORT(except_vec_vi_mori) |
41c594ab6 [MIPS] MT: Improv... |
248 249 |
ori a0, $0, 0 #endif /* CONFIG_MIPS_MT_SMTC */ |
7df424611 [MIPS] Export exc... |
250 |
FEXPORT(except_vec_vi_lui) |
e01402b11 More AP / SP bits... |
251 252 |
lui v0, 0 /* Patched */ j except_vec_vi_handler |
7df424611 [MIPS] Export exc... |
253 |
FEXPORT(except_vec_vi_ori) |
e01402b11 More AP / SP bits... |
254 255 256 257 258 259 260 261 262 263 264 265 |
ori v0, 0 /* Patched */ .set pop END(except_vec_vi) EXPORT(except_vec_vi_end) /* * Common Vectored Interrupt code * Complete the register saves and invoke the handler which is passed in $v0 */ NESTED(except_vec_vi_handler, 0, sp) SAVE_TEMP SAVE_STATIC |
41c594ab6 [MIPS] MT: Improv... |
266 267 268 269 270 271 272 273 274 275 276 277 |
#ifdef CONFIG_MIPS_MT_SMTC /* * SMTC has an interesting problem that interrupts are level-triggered, * and the CLI macro will clear EXL, potentially causing a duplicate * interrupt service invocation. So we need to clear the associated * IM bit of Status prior to doing CLI, and restore it after the * service routine has been invoked - we must assume that the * service routine will have cleared the state, and any active * level represents a new or otherwised unserviced event... */ mfc0 t1, CP0_STATUS and t0, a0, t1 |
0db34215c [MIPS] SMTC: Inte... |
278 |
#ifdef CONFIG_MIPS_MT_SMTC_IM_BACKSTOP |
41c594ab6 [MIPS] MT: Improv... |
279 |
mfc0 t2, CP0_TCCONTEXT |
8531a35e5 [MIPS] SMTC: Fix ... |
280 281 |
or t2, t0, t2 mtc0 t2, CP0_TCCONTEXT |
0db34215c [MIPS] SMTC: Inte... |
282 |
#endif /* CONFIG_MIPS_MT_SMTC_IM_BACKSTOP */ |
41c594ab6 [MIPS] MT: Improv... |
283 284 |
xor t1, t1, t0 mtc0 t1, CP0_STATUS |
4277ff5ee [MIPS] Fix use of... |
285 |
_ehb |
41c594ab6 [MIPS] MT: Improv... |
286 |
#endif /* CONFIG_MIPS_MT_SMTC */ |
e01402b11 More AP / SP bits... |
287 |
CLI |
8c3644350 [MIPS] VI: TRACE_... |
288 289 290 291 292 |
#ifdef CONFIG_TRACE_IRQFLAGS move s0, v0 #ifdef CONFIG_MIPS_MT_SMTC move s1, a0 #endif |
192ef3661 [MIPS] TRACE_IRQF... |
293 |
TRACE_IRQS_OFF |
8c3644350 [MIPS] VI: TRACE_... |
294 295 296 297 298 |
#ifdef CONFIG_MIPS_MT_SMTC move a0, s1 #endif move v0, s0 #endif |
937a80157 [MIPS] Complete f... |
299 300 301 |
LONG_L s0, TI_REGS($28) LONG_S sp, TI_REGS($28) |
23126692e [MIPS] Stacktrace... |
302 |
PTR_LA ra, ret_from_irq |
f431baa55 [MIPS] ret_from_i... |
303 |
jr v0 |
e01402b11 More AP / SP bits... |
304 305 306 |
END(except_vec_vi_handler) /* |
1da177e4c Linux-2.6.12-rc2 |
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 |
* EJTAG debug exception handler. */ NESTED(ejtag_debug_handler, PT_SIZE, sp) .set push .set noat MTC0 k0, CP0_DESAVE mfc0 k0, CP0_DEBUG sll k0, k0, 30 # Check for SDBBP. bgez k0, ejtag_return PTR_LA k0, ejtag_debug_buffer LONG_S k1, 0(k0) SAVE_ALL move a0, sp jal ejtag_exception_handler RESTORE_ALL PTR_LA k0, ejtag_debug_buffer LONG_L k1, 0(k0) ejtag_return: MFC0 k0, CP0_DESAVE .set mips32 deret .set pop END(ejtag_debug_handler) /* * This buffer is reserved for the use of the EJTAG debug * handler. */ .data EXPORT(ejtag_debug_buffer) .fill LONGSIZE .previous __INIT /* * NMI debug exception handler for MIPS reference boards. * The NMI debug exception entry point is 0xbfc00000, which * normally is in the boot PROM, so the boot PROM must do a * unconditional jump to this vector. */ NESTED(except_vec_nmi, 0, sp) j nmi_handler END(except_vec_nmi) __FINIT NESTED(nmi_handler, PT_SIZE, sp) .set push .set noat |
1da177e4c Linux-2.6.12-rc2 |
360 361 362 363 |
SAVE_ALL move a0, sp jal nmi_exception_handler RESTORE_ALL |
4f0638ba9 [MIPS] Remove str... |
364 |
.set mips3 |
1da177e4c Linux-2.6.12-rc2 |
365 366 367 368 369 370 371 372 |
eret .set pop END(nmi_handler) .macro __build_clear_none .endm .macro __build_clear_sti |
192ef3661 [MIPS] TRACE_IRQF... |
373 |
TRACE_IRQS_ON |
1da177e4c Linux-2.6.12-rc2 |
374 375 376 377 378 |
STI .endm .macro __build_clear_cli CLI |
192ef3661 [MIPS] TRACE_IRQF... |
379 |
TRACE_IRQS_OFF |
1da177e4c Linux-2.6.12-rc2 |
380 381 382 |
.endm .macro __build_clear_fpe |
25c300030 MIPS: Override as... |
383 384 385 |
.set push /* gas fails to assemble cfc1 for some archs (octeon).*/ \ .set mips1 |
1da177e4c Linux-2.6.12-rc2 |
386 387 388 389 |
cfc1 a1, fcr31 li a2, ~(0x3f << 12) and a2, a1 ctc1 a2, fcr31 |
25c300030 MIPS: Override as... |
390 |
.set pop |
192ef3661 [MIPS] TRACE_IRQF... |
391 |
TRACE_IRQS_ON |
1da177e4c Linux-2.6.12-rc2 |
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 |
STI .endm .macro __build_clear_ade MFC0 t0, CP0_BADVADDR PTR_S t0, PT_BVADDR(sp) KMODE .endm .macro __BUILD_silent exception .endm /* Gas tries to parse the PRINT argument as a string containing string escapes and emits bogus warnings if it believes to recognize an unknown escape code. So make the arguments start with an n and gas will believe is ok ... */ .macro __BUILD_verbose nexception LONG_L a1, PT_EPC(sp) |
766160c29 [PATCH] mips: fix... |
411 |
#ifdef CONFIG_32BIT |
1da177e4c Linux-2.6.12-rc2 |
412 413 |
PRINT("Got exception at %08lx\012") |
42a3b4f25 [PATCH] mips: nuk... |
414 |
#endif |
766160c29 [PATCH] mips: fix... |
415 |
#ifdef CONFIG_64BIT |
1da177e4c Linux-2.6.12-rc2 |
416 417 |
PRINT("Got exception at %016lx\012") |
42a3b4f25 [PATCH] mips: nuk... |
418 |
#endif |
1da177e4c Linux-2.6.12-rc2 |
419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 |
.endm .macro __BUILD_count exception LONG_L t0,exception_count_\exception LONG_ADDIU t0, 1 LONG_S t0,exception_count_\exception .comm exception_count\exception, 8, 8 .endm .macro __BUILD_HANDLER exception handler clear verbose ext .align 5 NESTED(handle_\exception, PT_SIZE, sp) .set noat SAVE_ALL FEXPORT(handle_\exception\ext) __BUILD_clear_\clear .set at __BUILD_\verbose \exception move a0, sp |
23126692e [MIPS] Stacktrace... |
438 439 |
PTR_LA ra, ret_from_exception j do_\handler |
1da177e4c Linux-2.6.12-rc2 |
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 |
END(handle_\exception) .endm .macro BUILD_HANDLER exception handler clear verbose __BUILD_HANDLER \exception \handler \clear \verbose _int .endm BUILD_HANDLER adel ade ade silent /* #4 */ BUILD_HANDLER ades ade ade silent /* #5 */ BUILD_HANDLER ibe be cli silent /* #6 */ BUILD_HANDLER dbe be cli silent /* #7 */ BUILD_HANDLER bp bp sti silent /* #9 */ BUILD_HANDLER ri ri sti silent /* #10 */ BUILD_HANDLER cpu cpu sti silent /* #11 */ BUILD_HANDLER ov ov sti silent /* #12 */ BUILD_HANDLER tr tr sti silent /* #13 */ BUILD_HANDLER fpe fpe fpe silent /* #15 */ BUILD_HANDLER mdmx mdmx sti silent /* #22 */ |
b67b2b703 MIPS: Watch excep... |
458 |
#ifdef CONFIG_HARDWARE_WATCHPOINTS |
8bc6d05b4 MIPS: Read watch ... |
459 460 461 462 463 |
/* * For watch, interrupts will be enabled after the watch * registers are read. */ BUILD_HANDLER watch watch cli silent /* #23 */ |
b67b2b703 MIPS: Watch excep... |
464 |
#else |
1da177e4c Linux-2.6.12-rc2 |
465 |
BUILD_HANDLER watch watch sti verbose /* #23 */ |
b67b2b703 MIPS: Watch excep... |
466 |
#endif |
1da177e4c Linux-2.6.12-rc2 |
467 |
BUILD_HANDLER mcheck mcheck cli verbose /* #24 */ |
e35a5e35e [MIPS] Less noise... |
468 |
BUILD_HANDLER mt mt sti silent /* #25 */ |
e50c0a8fa Support the MIPS3... |
469 |
BUILD_HANDLER dsp dsp sti silent /* #26 */ |
1da177e4c Linux-2.6.12-rc2 |
470 |
BUILD_HANDLER reserved reserved sti verbose /* others */ |
5b10496b6 [MIPS] Fast path ... |
471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 |
.align 5 LEAF(handle_ri_rdhwr_vivt) #ifdef CONFIG_MIPS_MT_SMTC PANIC_PIC("handle_ri_rdhwr_vivt called") #else .set push .set noat .set noreorder /* check if TLB contains a entry for EPC */ MFC0 k1, CP0_ENTRYHI andi k1, 0xff /* ASID_MASK */ MFC0 k0, CP0_EPC PTR_SRL k0, PAGE_SHIFT + 1 PTR_SLL k0, PAGE_SHIFT + 1 or k1, k0 MTC0 k1, CP0_ENTRYHI mtc0_tlbw_hazard tlbp tlb_probe_hazard mfc0 k1, CP0_INDEX .set pop bltz k1, handle_ri /* slow path */ /* fall thru */ #endif END(handle_ri_rdhwr_vivt) LEAF(handle_ri_rdhwr) .set push .set noat .set noreorder /* 0x7c03e83b: rdhwr v1,$29 */ MFC0 k1, CP0_EPC lui k0, 0x7c03 lw k1, (k1) ori k0, 0xe83b .set reorder bne k0, k1, handle_ri /* if not ours */ /* The insn is rdhwr. No need to check CAUSE.BD here. */ get_saved_sp /* k1 := current_thread_info */ .set noreorder MFC0 k0, CP0_EPC #if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX) ori k1, _THREAD_MASK xori k1, _THREAD_MASK LONG_L v1, TI_TP_VALUE(k1) LONG_ADDIU k0, 4 jr k0 rfe #else |
619b6e18f [MIPS] R4000/R440... |
520 |
#ifndef CONFIG_CPU_DADDI_WORKAROUNDS |
5b10496b6 [MIPS] Fast path ... |
521 |
LONG_ADDIU k0, 4 /* stall on $k0 */ |
619b6e18f [MIPS] R4000/R440... |
522 523 524 525 526 |
#else .set at=v1 LONG_ADDIU k0, 4 .set noat #endif |
5b10496b6 [MIPS] Fast path ... |
527 528 529 530 531 532 533 534 535 536 537 |
MTC0 k0, CP0_EPC /* I hope three instructions between MTC0 and ERET are enough... */ ori k1, _THREAD_MASK xori k1, _THREAD_MASK LONG_L v1, TI_TP_VALUE(k1) .set mips3 eret .set mips0 #endif .set pop END(handle_ri_rdhwr) |
875d43e72 [PATCH] mips: cle... |
538 |
#ifdef CONFIG_64BIT |
1da177e4c Linux-2.6.12-rc2 |
539 540 541 542 543 544 |
/* A temporary overflow handler used by check_daddi(). */ __INIT BUILD_HANDLER daddi_ov daddi_ov none silent /* #12 */ #endif |