aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/kernel/cpu/sh3
diff options
context:
space:
mode:
authorMichael Trimarchi <trimarchi@gandalf.sssup.it>2009-04-03 13:32:33 -0400
committerPaul Mundt <lethal@linux-sh.org>2009-04-04 11:48:11 -0400
commit01ab10393c510342ec4ce85df11ccfa3df06bbb2 (patch)
treeebf0493fa7b53941f830f8b300037f834eb85e59 /arch/sh/kernel/cpu/sh3
parenta27873cd234b4248dda342721d6262943e5fa235 (diff)
sh: Fix up DSP context save/restore.
There were a number of issues with the DSP context save/restore code, mostly left-over relics from when it was introduced on SH3-DSP with little follow-up testing, resulting in things like task_pt_dspregs() referencing incorrect state on the stack. This follows the MIPS convention of tracking the DSP state in the thread_struct and handling the state save/restore in switch_to() and finish_arch_switch() respectively. The regset interface is also updated, which allows us to finally be rid of task_pt_dspregs() and the special cased task_pt_regs(). Signed-off-by: Michael Trimarchi <michael@evidence.eu.com> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh/kernel/cpu/sh3')
-rw-r--r--arch/sh/kernel/cpu/sh3/entry.S85
1 files changed, 6 insertions, 79 deletions
diff --git a/arch/sh/kernel/cpu/sh3/entry.S b/arch/sh/kernel/cpu/sh3/entry.S
index 55da0ff9848d..3cb531f233f2 100644
--- a/arch/sh/kernel/cpu/sh3/entry.S
+++ b/arch/sh/kernel/cpu/sh3/entry.S
@@ -254,40 +254,6 @@ restore_all:
254 254
255 lds k2, pr ! restore pr 255 lds k2, pr ! restore pr
256 ! 256 !
257#ifdef CONFIG_SH_DSP
258 mov.l @r15+, k0 ! DSP mode marker
259 mov.l 5f, k1
260 cmp/eq k0, k1 ! Do we have a DSP stack frame?
261 bf skip_restore
262
263 stc sr, k0 ! Enable CPU DSP mode
264 or k1, k0 ! (within kernel it may be disabled)
265 ldc k0, sr
266 mov r2, k0 ! Backup r2
267
268 ! Restore DSP registers from stack
269 mov r15, r2
270 movs.l @r2+, a1
271 movs.l @r2+, a0g
272 movs.l @r2+, a1g
273 movs.l @r2+, m0
274 movs.l @r2+, m1
275 mov r2, r15
276
277 lds.l @r15+, a0
278 lds.l @r15+, x0
279 lds.l @r15+, x1
280 lds.l @r15+, y0
281 lds.l @r15+, y1
282 lds.l @r15+, dsr
283 ldc.l @r15+, rs
284 ldc.l @r15+, re
285 ldc.l @r15+, mod
286
287 mov k0, r2 ! Restore r2
288skip_restore:
289#endif
290 !
291 ! Calculate new SR value 257 ! Calculate new SR value
292 mov k3, k2 ! original SR value 258 mov k3, k2 ! original SR value
293 mov #0xf0, k1 259 mov #0xf0, k1
@@ -358,7 +324,7 @@ general_exception:
358 add k0, k4 324 add k0, k4
3590: 3250:
360 ! Setup stack and save DSP context (k0 contains original r15 on return) 326 ! Setup stack and save DSP context (k0 contains original r15 on return)
361 bsr prepare_stack_save_dsp 327 bsr prepare_stack
362 nop 328 nop
363 329
364 ! Save registers / Switch to bank 0 330 ! Save registers / Switch to bank 0
@@ -374,15 +340,14 @@ general_exception:
3741: .long EXPEVT 3401: .long EXPEVT
375#endif 341#endif
376 342
377! prepare_stack_save_dsp() 343! prepare_stack()
378! - roll back gRB 344! - roll back gRB
379! - switch to kernel stack 345! - switch to kernel stack
380! - save DSP
381! k0 returns original sp (after roll back) 346! k0 returns original sp (after roll back)
382! k1 trashed 347! k1 trashed
383! k2 trashed 348! k2 trashed
384 349
385prepare_stack_save_dsp: 350prepare_stack:
386#ifdef CONFIG_GUSA 351#ifdef CONFIG_GUSA
387 ! Check for roll back gRB (User and Kernel) 352 ! Check for roll back gRB (User and Kernel)
388 mov r15, k0 353 mov r15, k0
@@ -416,47 +381,9 @@ prepare_stack_save_dsp:
416 mov k1, r15 ! change to kernel stack 381 mov k1, r15 ! change to kernel stack
417 ! 382 !
4181: 3831:
419#ifdef CONFIG_SH_DSP
420 ! Save DSP context if needed
421 stc sr, k1
422 mov #0x10, k2
423 shll8 k2 ! DSP=1 (0x00001000)
424 tst k2, k1 ! Check if in DSP mode (passed in k2)
425 bt/s skip_save
426 mov #0, k1 ! Set marker for no stack frame
427
428 mov k2, k1 ! Save has-frame marker
429
430 ! Save DSP registers on stack
431 stc.l mod, @-r15
432 stc.l re, @-r15
433 stc.l rs, @-r15
434 sts.l dsr, @-r15
435 sts.l y1, @-r15
436 sts.l y0, @-r15
437 sts.l x1, @-r15
438 sts.l x0, @-r15
439 sts.l a0, @-r15
440
441 ! GAS is broken, does not generate correct "movs.l Ds,@-As" instr.
442
443 ! FIXME: Make sure that this is still the case with newer toolchains,
444 ! as we're not at all interested in supporting ancient toolchains at
445 ! this point. -- PFM.
446
447 mov r15, k2
448 .word 0xf653 ! movs.l a1, @-r2
449 .word 0xf6f3 ! movs.l a0g, @-r2
450 .word 0xf6d3 ! movs.l a1g, @-r2
451 .word 0xf6c3 ! movs.l m0, @-r2
452 .word 0xf6e3 ! movs.l m1, @-r2
453 mov k2, r15
454
455skip_save:
456 mov.l k1, @-r15 ! Push DSP mode marker onto stack
457#endif
458 rts 384 rts
459 nop 385 nop
386
460! 387!
461! 0x400: Instruction and Data TLB miss exception vector 388! 0x400: Instruction and Data TLB miss exception vector
462! 389!
@@ -468,7 +395,7 @@ handle_exception:
468 mova exception_data, k0 395 mova exception_data, k0
469 396
470 ! Setup stack and save DSP context (k0 contains original r15 on return) 397 ! Setup stack and save DSP context (k0 contains original r15 on return)
471 bsr prepare_stack_save_dsp 398 bsr prepare_stack
472 PREF(k0) 399 PREF(k0)
473 400
474 ! Save registers / Switch to bank 0 401 ! Save registers / Switch to bank 0
@@ -572,7 +499,7 @@ ENTRY(handle_interrupt)
572 mova exception_data, k0 499 mova exception_data, k0
573 500
574 ! Setup stack and save DSP context (k0 contains original r15 on return) 501 ! Setup stack and save DSP context (k0 contains original r15 on return)
575 bsr prepare_stack_save_dsp 502 bsr prepare_stack
576 PREF(k0) 503 PREF(k0)
577 504
578 ! Save registers / Switch to bank 0 505 ! Save registers / Switch to bank 0