summaryrefslogtreecommitdiffstats
path: root/sys/powerpc/aim
diff options
context:
space:
mode:
authorbenno <benno@FreeBSD.org>2002-06-29 09:39:44 +0000
committerbenno <benno@FreeBSD.org>2002-06-29 09:39:44 +0000
commit202c3a8b7c8fa87cee9aac4374a4fa73deecba73 (patch)
tree7742e164fb0233275f282f7e2d1901954d256323 /sys/powerpc/aim
parent588d2f5396f9a2be7f3ffde5854e4f5fd1b8ceb2 (diff)
downloadFreeBSD-src-202c3a8b7c8fa87cee9aac4374a4fa73deecba73.zip
FreeBSD-src-202c3a8b7c8fa87cee9aac4374a4fa73deecba73.tar.gz
To quote Peter:
The case in cpu_switch() where there isn't a higher priority thread (choosethread() == curthread) uses r4 as the PCB context pointer. However, the use of r4 after the label L2 is incorrect, since it was probably trashed by the call to choosethread, and in any case was set up to curthread at the start of the routine. This condition will occur when an interrupt thread schedules a netisr, which is a lower priority thread. Another (probably unnecessary) difference is that I was paranoid about register trashing, so I decided to save r2 and r13 as well. Submitted by: Peter Grehan <peterg@ptree32.com.au>
Diffstat (limited to 'sys/powerpc/aim')
-rw-r--r--sys/powerpc/aim/swtch.S25
1 files changed, 15 insertions, 10 deletions
diff --git a/sys/powerpc/aim/swtch.S b/sys/powerpc/aim/swtch.S
index a9df7ea..e02367a 100644
--- a/sys/powerpc/aim/swtch.S
+++ b/sys/powerpc/aim/swtch.S
@@ -75,9 +75,10 @@ ENTRY(cpu_switch)
lwz %r4,PC_CURTHREAD(%r3) /* Get the current thread */
lwz %r3,TD_PCB(%r4) /* Get a pointer to the PCB */
- stmw %r14,PCB_CONTEXT(%r3) /* Save the non-volatile GP regs */
- mr %r14,%r3 /* Copy the curthread pointer */
- mr %r15,%r4 /* ... and the current pcb pointer */
+ mr %r12,%r2
+ stmw %r12,PCB_CONTEXT(%r3) /* Save the non-volatile GP regs */
+ mr %r14,%r3 /* Copy the current pcb pointer */
+ mr %r15,%r4 /* ... and the curthread pointer */
mfcr %r16 /* Save the condition register */
stw %r16,PCB_CR(%r3)
mflr %r16 /* Save the link register */
@@ -106,9 +107,9 @@ ENTRY(cpu_switch)
mfsprg %r4,0 /* Get the pcpu pointer */
stw %r16,PC_CURTHREAD(%r4) /* Store new current thread */
- lwz %r16,TD_PCB(%r16) /* Grab the new PCB */
+ mr %r3,%r16 /* and save in r3 */
+ lwz %r16,TD_PCB(%r16) /* Store new current PCB */
stw %r16,PC_CURPCB(%r4)
- mr %r4,%r16
#if 0
lwz %r29, PCB_FLAGS(%r4) /* Restore FPU regs if needed */
@@ -118,13 +119,16 @@ ENTRY(cpu_switch)
bl enable_fpu
#endif
+ /* thread to restore is in r3 */
.L2:
- lmw %r14,PCB_CONTEXT(%r4) /* Load the non-volatile GP regs */
- lwz %r5,PCB_CR(%r4) /* Load the condition register */
+ lwz %r3, TD_PCB(%r3)
+ lmw %r12,PCB_CONTEXT(%r3) /* Load the non-volatile GP regs */
+ mr %r2,%r12
+ lwz %r5,PCB_CR(%r3) /* Load the condition register */
mtcr %r5
- lwz %r5,PCB_LR(%r4) /* Load the link register */
+ lwz %r5,PCB_LR(%r3) /* Load the link register */
mtlr %r5
- lwz %r1,PCB_SP(%r4) /* Load the stack pointer */
+ lwz %r1,PCB_SP(%r3) /* Load the stack pointer */
blr
/*
@@ -132,7 +136,8 @@ ENTRY(cpu_switch)
* Update pcb, saving current processor state
*/
ENTRY(savectx)
- stmw %r14,PCB_CONTEXT(%r3) /* Save the non-volatile GP regs */
+ mr %r12,%r2
+ stmw %r12,PCB_CONTEXT(%r3) /* Save the non-volatile GP regs */
mfcr %r4 /* Save the condition register */
stw %r4,PCB_CONTEXT(%r3)
blr
OpenPOWER on IntegriCloud