2
* arch/sh/kernel/cpu/sh5/switchto.S
6
* Copyright (C) 2004 Richard Curnow
8
* This file is subject to the terms and conditions of the GNU General Public
9
* License. See the file "COPYING" in the main directory of this archive
13
.section .text..SHmedia32,"ax"
18
.type sh64_switch_to,@function
19
.global sh64_switch_to
20
.global __sh64_switch_to_end
30
r2 - last (=prev) : this just stays in r2 throughout
32
Want to create a full (struct pt_regs) on the stack to allow backtracing
33
functions to work. However, we only need to populate the callee-save
34
register slots in this structure; since we're a function our ancestors must
35
have themselves preserved all caller saved state in the stack. This saves
36
some wasted effort since we won't need to look at the values.
38
In particular, all caller-save registers are immediately available for
43
#define FRAME_SIZE (76*8 + 8)
47
! Do normal-style register save to support backtrace
49
st.l r15, 0, r18 ! save link reg
50
st.l r15, 4, r14 ! save fp
51
add.l r15, r63, r14 ! setup frame pointer
53
! hopefully this looks normal to the backtrace now.
55
addi.l r15, 8, r1 ! base of pt_regs
56
addi.l r1, 24, r0 ! base of pt_regs.regs
57
addi.l r0, (63*8), r8 ! base of pt_regs.trregs
59
/* Note : to be fixed?
60
struct pt_regs is really designed for holding the state on entry
61
to an exception, i.e. pc,sr,regs etc. However, for the context
62
switch state, some of this is not required. But the unwinder takes
63
struct pt_regs * as an arg so we have to build this structure
64
to allow unwinding switched tasks in show_state() */
71
st.q r0, (14*8), r14 ! for unwind, want to look as though we took a trap at
72
! the point where the process is left in suspended animation, i.e. current
73
! fp here, not the saved one.
106
! do this early as pta->gettr has no pipeline forwarding (=> 5 cycle latency)
107
! Use a local label to avoid creating a symbol that will confuse the !
120
st.l r3, 0, r15 ! prev->thread.sp
121
st.l r3, 8, r1 ! prev->thread.kregs
122
st.l r3, 4, r9 ! prev->thread.pc
123
st.q r1, 0, r9 ! save prev->thread.pc into pt_regs->pc
125
! Load PC for next task (init value or save_pc later)
126
ld.l r5, 4, r18 ! next->thread.pc
128
ld.l r5, 0, r15 ! next->thread.sp
132
ld.l r4, 4, r9 ! next->thread_info (2nd element of next task_struct)
133
putcon r9, kcr0 ! current = next->thread_info
135
! go to save_pc for a reschedule, or the initial thread.pc for a new process
138
! Restore (when we come back to a previously saved task)
140
addi.l r15, 32, r0 ! r0 = next's regs
141
addi.l r0, (63*8), r8 ! r8 = next's tr_regs
195
__sh64_switch_to_end:
197
.size sh64_switch_to,.LFE1-sh64_switch_to