summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorgrehan <grehan@FreeBSD.org>2003-08-14 03:56:24 +0000
committergrehan <grehan@FreeBSD.org>2003-08-14 03:56:24 +0000
commite6a3a6744e57438f2763932260c770036f4119be (patch)
tree887c4c2e54678a6aa7dbf858b636ef6f69ab1870 /sys
parent52d14db571f7adb4f8901fe88346f5dea10ac336 (diff)
downloadFreeBSD-src-e6a3a6744e57438f2763932260c770036f4119be.zip
FreeBSD-src-e6a3a6744e57438f2763932260c770036f4119be.tar.gz
Update powerpc to use the (old thread,new thread) calling convention
for cpu_throw() and cpu_switch().
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_kse.c4
-rw-r--r--sys/kern/kern_synch.c6
-rw-r--r--sys/kern/kern_thr.c4
-rw-r--r--sys/kern/kern_thread.c4
-rw-r--r--sys/powerpc/aim/swtch.S63
-rw-r--r--sys/powerpc/aim/vm_machdep.c4
-rw-r--r--sys/powerpc/powerpc/swtch.S63
-rw-r--r--sys/powerpc/powerpc/vm_machdep.c4
-rw-r--r--sys/sys/proc.h5
9 files changed, 60 insertions, 97 deletions
diff --git a/sys/kern/kern_kse.c b/sys/kern/kern_kse.c
index a5a294d..2f93b1e 100644
--- a/sys/kern/kern_kse.c
+++ b/sys/kern/kern_kse.c
@@ -1289,11 +1289,7 @@ thread_exit(void)
}
/* XXX Shouldn't cpu_throw() here. */
mtx_assert(&sched_lock, MA_OWNED);
-#if !defined(__powerpc__)
cpu_throw(td, choosethread());
-#else
- cpu_throw();
-#endif
panic("I'm a teapot!");
/* NOTREACHED */
}
diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c
index 7525f3a..a80a712 100644
--- a/sys/kern/kern_synch.c
+++ b/sys/kern/kern_synch.c
@@ -459,9 +459,7 @@ mi_switch(void)
{
struct bintime new_switchtime;
struct thread *td;
-#if !defined(__powerpc__)
struct thread *newtd;
-#endif
struct proc *p;
u_int sched_nest;
@@ -517,13 +515,9 @@ mi_switch(void)
thread_switchout(td);
sched_switchout(td);
-#if !defined(__powerpc__)
newtd = choosethread();
if (td != newtd)
cpu_switch(td, newtd); /* SHAZAM!! */
-#else
- cpu_switch(); /* SHAZAM!!*/
-#endif
sched_lock.mtx_recurse = sched_nest;
sched_lock.mtx_lock = (uintptr_t)td;
diff --git a/sys/kern/kern_thr.c b/sys/kern/kern_thr.c
index 4cb4df4..eef25ac 100644
--- a/sys/kern/kern_thr.c
+++ b/sys/kern/kern_thr.c
@@ -111,11 +111,7 @@ thr_exit1(void)
sched_exit_thread(TAILQ_NEXT(td, td_kglist), td);
thread_stash(td);
-#if !defined(__powerpc__)
cpu_throw(td, choosethread());
-#else
- cpu_throw();
-#endif
}
#define RANGEOF(type, start, end) (offsetof(type, end) - offsetof(type, start))
diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c
index a5a294d..2f93b1e 100644
--- a/sys/kern/kern_thread.c
+++ b/sys/kern/kern_thread.c
@@ -1289,11 +1289,7 @@ thread_exit(void)
}
/* XXX Shouldn't cpu_throw() here. */
mtx_assert(&sched_lock, MA_OWNED);
-#if !defined(__powerpc__)
cpu_throw(td, choosethread());
-#else
- cpu_throw();
-#endif
panic("I'm a teapot!");
/* NOTREACHED */
}
diff --git a/sys/powerpc/aim/swtch.S b/sys/powerpc/aim/swtch.S
index 49e23c8..6e3bfdd 100644
--- a/sys/powerpc/aim/swtch.S
+++ b/sys/powerpc/aim/swtch.S
@@ -67,61 +67,54 @@
#include <machine/asm.h>
/*
- * void cpu_switch()
- * Find a runnable thread and switch to it.
+ * void cpu_switch(struct thread *old, struct thread *new)
+ *
+ * Switch to a new thread saving the current state in the old thread.
*/
ENTRY(cpu_switch)
- mfsprg %r3,0 /* Get the pcpu pointer */
- lwz %r4,PC_CURTHREAD(%r3) /* Get the current thread */
- lwz %r3,TD_PCB(%r4) /* Get a pointer to the PCB */
+ lwz %r5,TD_PCB(%r3) /* Get the old thread's PCB ptr */
+
+ mr %r12,%r2
+ stmw %r12,PCB_CONTEXT(%r5) /* Save the non-volatile GP regs.
+ These can now be used for scratch */
- 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)
+ stw %r16,PCB_CR(%r5)
mflr %r16 /* Save the link register */
- stw %r16,PCB_LR(%r3)
+ stw %r16,PCB_LR(%r5)
mfsr %r16,USER_SR /* Save USER_SR for copyin/out */
isync
- stw %r16,PCB_USR(%r3)
- stw %r1,PCB_SP(%r3) /* Save the stack pointer */
-
- lwz %r5,PCB_FLAGS(%r3) /* Save FPU context if needed */
- andi. %r5, %r5, PCB_FPU
+ stw %r16,PCB_USR(%r5)
+ stw %r1,PCB_SP(%r5) /* Save the stack pointer */
+
+ mr %r14,%r3 /* Copy the old thread ptr... */
+ mr %r15,%r4 /* and the new thread ptr in scratch */
+
+ lwz %r6,PCB_FLAGS(%r5) /* Save FPU context if needed */
+ andi. %r6, %r6, PCB_FPU
beq .L1
- mr %r3,%r15
bl save_fpu
-
+ mr %r3,%r14 /* restore old thread ptr */
.L1:
- bl choosethread /* Find a new thread to run */
- cmplw 0,%r3,%r15 /* Compare to curthread */
- beq .L2 /* If it's the same, we're done */
-
- mr %r16,%r3 /* Save off the (struct thread *) */
-
- mr %r3,%r15
bl pmap_deactivate /* Deactivate the current pmap */
- mr %r3,%r16
+ mr %r3,%r15 /* Get new thread ptr */
bl pmap_activate /* Activate the new address space */
- mfsprg %r4,0 /* Get the pcpu pointer */
- stw %r16,PC_CURTHREAD(%r4) /* Store new current thread */
- mr %r3,%r16 /* and save in r3 */
- lwz %r17,TD_PCB(%r16) /* Store new current PCB */
- stw %r17,PC_CURPCB(%r4)
+ mfsprg %r7,0 /* Get the pcpu pointer */
+ stw %r15,PC_CURTHREAD(%r7) /* Store new current thread */
+ lwz %r17,TD_PCB(%r15) /* Store new current PCB */
+ stw %r17,PC_CURPCB(%r7)
- lwz %r5, PCB_FLAGS(%r17) /* Restore FPU context if needed */
- andi. %r5, %r5, PCB_FPU
+ lwz %r6, PCB_FLAGS(%r17) /* Restore FPU context if needed */
+ andi. %r6, %r6, PCB_FPU
beq .L2
+ mr %r3,%r15 /* Pass curthread to enable_fpu */
bl enable_fpu
- mr %r3,%r16 /* Recover new curthread */
/* thread to restore is in r3 */
.L2:
- lwz %r3, TD_PCB(%r3)
+ mr %r3,%r17 /* Recover PCB ptr */
lmw %r12,PCB_CONTEXT(%r3) /* Load the non-volatile GP regs */
mr %r2,%r12
lwz %r5,PCB_CR(%r3) /* Load the condition register */
diff --git a/sys/powerpc/aim/vm_machdep.c b/sys/powerpc/aim/vm_machdep.c
index b067b32..ead7511 100644
--- a/sys/powerpc/aim/vm_machdep.c
+++ b/sys/powerpc/aim/vm_machdep.c
@@ -203,10 +203,10 @@ cpu_sched_exit(td)
/* Temporary helper */
void
-cpu_throw(void)
+cpu_throw(struct thread *old, struct thread *new)
{
- cpu_switch();
+ cpu_switch(old, new);
panic("cpu_throw() didn't");
}
diff --git a/sys/powerpc/powerpc/swtch.S b/sys/powerpc/powerpc/swtch.S
index 49e23c8..6e3bfdd 100644
--- a/sys/powerpc/powerpc/swtch.S
+++ b/sys/powerpc/powerpc/swtch.S
@@ -67,61 +67,54 @@
#include <machine/asm.h>
/*
- * void cpu_switch()
- * Find a runnable thread and switch to it.
+ * void cpu_switch(struct thread *old, struct thread *new)
+ *
+ * Switch to a new thread saving the current state in the old thread.
*/
ENTRY(cpu_switch)
- mfsprg %r3,0 /* Get the pcpu pointer */
- lwz %r4,PC_CURTHREAD(%r3) /* Get the current thread */
- lwz %r3,TD_PCB(%r4) /* Get a pointer to the PCB */
+ lwz %r5,TD_PCB(%r3) /* Get the old thread's PCB ptr */
+
+ mr %r12,%r2
+ stmw %r12,PCB_CONTEXT(%r5) /* Save the non-volatile GP regs.
+ These can now be used for scratch */
- 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)
+ stw %r16,PCB_CR(%r5)
mflr %r16 /* Save the link register */
- stw %r16,PCB_LR(%r3)
+ stw %r16,PCB_LR(%r5)
mfsr %r16,USER_SR /* Save USER_SR for copyin/out */
isync
- stw %r16,PCB_USR(%r3)
- stw %r1,PCB_SP(%r3) /* Save the stack pointer */
-
- lwz %r5,PCB_FLAGS(%r3) /* Save FPU context if needed */
- andi. %r5, %r5, PCB_FPU
+ stw %r16,PCB_USR(%r5)
+ stw %r1,PCB_SP(%r5) /* Save the stack pointer */
+
+ mr %r14,%r3 /* Copy the old thread ptr... */
+ mr %r15,%r4 /* and the new thread ptr in scratch */
+
+ lwz %r6,PCB_FLAGS(%r5) /* Save FPU context if needed */
+ andi. %r6, %r6, PCB_FPU
beq .L1
- mr %r3,%r15
bl save_fpu
-
+ mr %r3,%r14 /* restore old thread ptr */
.L1:
- bl choosethread /* Find a new thread to run */
- cmplw 0,%r3,%r15 /* Compare to curthread */
- beq .L2 /* If it's the same, we're done */
-
- mr %r16,%r3 /* Save off the (struct thread *) */
-
- mr %r3,%r15
bl pmap_deactivate /* Deactivate the current pmap */
- mr %r3,%r16
+ mr %r3,%r15 /* Get new thread ptr */
bl pmap_activate /* Activate the new address space */
- mfsprg %r4,0 /* Get the pcpu pointer */
- stw %r16,PC_CURTHREAD(%r4) /* Store new current thread */
- mr %r3,%r16 /* and save in r3 */
- lwz %r17,TD_PCB(%r16) /* Store new current PCB */
- stw %r17,PC_CURPCB(%r4)
+ mfsprg %r7,0 /* Get the pcpu pointer */
+ stw %r15,PC_CURTHREAD(%r7) /* Store new current thread */
+ lwz %r17,TD_PCB(%r15) /* Store new current PCB */
+ stw %r17,PC_CURPCB(%r7)
- lwz %r5, PCB_FLAGS(%r17) /* Restore FPU context if needed */
- andi. %r5, %r5, PCB_FPU
+ lwz %r6, PCB_FLAGS(%r17) /* Restore FPU context if needed */
+ andi. %r6, %r6, PCB_FPU
beq .L2
+ mr %r3,%r15 /* Pass curthread to enable_fpu */
bl enable_fpu
- mr %r3,%r16 /* Recover new curthread */
/* thread to restore is in r3 */
.L2:
- lwz %r3, TD_PCB(%r3)
+ mr %r3,%r17 /* Recover PCB ptr */
lmw %r12,PCB_CONTEXT(%r3) /* Load the non-volatile GP regs */
mr %r2,%r12
lwz %r5,PCB_CR(%r3) /* Load the condition register */
diff --git a/sys/powerpc/powerpc/vm_machdep.c b/sys/powerpc/powerpc/vm_machdep.c
index b067b32..ead7511 100644
--- a/sys/powerpc/powerpc/vm_machdep.c
+++ b/sys/powerpc/powerpc/vm_machdep.c
@@ -203,10 +203,10 @@ cpu_sched_exit(td)
/* Temporary helper */
void
-cpu_throw(void)
+cpu_throw(struct thread *old, struct thread *new)
{
- cpu_switch();
+ cpu_switch(old, new);
panic("cpu_throw() didn't");
}
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index 21b5e33..a7b222a 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -865,13 +865,8 @@ int sigonstack(size_t sp);
void sleepinit(void);
void stopevent(struct proc *, u_int, u_int);
void cpu_idle(void);
-#if !defined(__powerpc__)
void cpu_switch(struct thread *old, struct thread *new);
void cpu_throw(struct thread *old, struct thread *new) __dead2;
-#else
-void cpu_switch(void);
-void cpu_throw(void) __dead2;
-#endif
void unsleep(struct thread *);
void userret(struct thread *, struct trapframe *, u_int);
OpenPOWER on IntegriCloud