diff options
author | benno <benno@FreeBSD.org> | 2002-02-28 12:06:49 +0000 |
---|---|---|
committer | benno <benno@FreeBSD.org> | 2002-02-28 12:06:49 +0000 |
commit | e2a5a67db8777be244cf99796905f93c34f9caad (patch) | |
tree | 0c96e380b9b8c6b8552d49086e8df6a454e5c537 /sys/powerpc | |
parent | 9ed9d1965de29b7d01580f5b6da265b86c2638f3 (diff) | |
download | FreeBSD-src-e2a5a67db8777be244cf99796905f93c34f9caad.zip FreeBSD-src-e2a5a67db8777be244cf99796905f93c34f9caad.tar.gz |
cpu_switch now works, for kthreads at least.
Diffstat (limited to 'sys/powerpc')
-rw-r--r-- | sys/powerpc/aim/swtch.S | 39 | ||||
-rw-r--r-- | sys/powerpc/powerpc/swtch.S | 39 | ||||
-rw-r--r-- | sys/powerpc/powerpc/swtch.s | 39 |
3 files changed, 78 insertions, 39 deletions
diff --git a/sys/powerpc/aim/swtch.S b/sys/powerpc/aim/swtch.S index 828c6cd..afa1ba5 100644 --- a/sys/powerpc/aim/swtch.S +++ b/sys/powerpc/aim/swtch.S @@ -71,45 +71,58 @@ * Find a runnable thread and switch to it. */ ENTRY(cpu_switch) - mflr %r30 - mfsprg %r3,%r0 /* Get the pcpu pointer */ + 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 */ stmw %r14,PCB_CONTEXT(%r3) /* Save the non-volatile GP regs */ - mfcr %r4 /* Save the condition register */ - stw %r4,PCB_CR(%r3) + mr %r14,%r3 /* Copy the curthread pointer */ + mr %r15,%r4 /* ... and the current pcb pointer */ + mfcr %r16 /* Save the condition register */ + stw %r16,PCB_CR(%r3) + mflr %r16 /* Save the link register */ + stw %r16,PCB_LR(%r3) + stw %r1,PCB_SP(%r3) /* Save the stack pointer */ +#if 0 lwz %r29,PCB_FLAGS(%r3) andi. %r9, %r29, 1 /* XXX - don't hard code */ beq .L1 - mr %r29, %r3 /* Save the PCB pointer */ bl save_fpu - mr %r3, %r29 /* and restore it */ +#endif .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 %r14,%r3 /* Save off the (struct thread *) */ + mr %r3,%r15 + bl pmap_deactivate /* Deactivate the current pmap */ + mr %r3,%r16 bl pmap_activate /* Activate the new address space */ - mtlr %r30 - mfsprg %r4,%r0 /* Get the pcpu pointer */ - stw %r14,PC_CURTHREAD(%r4) /* Store new current thread */ - lwz %r4,TD_PCB(%r14) /* Grab the new PCB */ + mfsprg %r4,0 /* Get the pcpu pointer */ + stw %r16,PC_CURTHREAD(%r4) /* Store new current thread */ + lwz %r4,TD_PCB(%r16) /* Grab the new PCB */ +#if 0 lwz %r29, PCB_FLAGS(%r4) /* Restore FPU regs if needed */ andi. %r9, %r29, 1 beq .L2 - mr %r29, %r4 + mr %r3, %r4 bl enable_fpu - mr %r4, %r29 +#endif .L2: lmw %r14,PCB_CONTEXT(%r4) /* Load the non-volatile GP regs */ lwz %r5,PCB_CR(%r4) /* Load the condition register */ mtcr %r5 + lwz %r5,PCB_LR(%r4) /* Load the link register */ + mtlr %r5 + lwz %r1,PCB_SP(%r4) /* Load the stack pointer */ blr /* diff --git a/sys/powerpc/powerpc/swtch.S b/sys/powerpc/powerpc/swtch.S index 828c6cd..afa1ba5 100644 --- a/sys/powerpc/powerpc/swtch.S +++ b/sys/powerpc/powerpc/swtch.S @@ -71,45 +71,58 @@ * Find a runnable thread and switch to it. */ ENTRY(cpu_switch) - mflr %r30 - mfsprg %r3,%r0 /* Get the pcpu pointer */ + 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 */ stmw %r14,PCB_CONTEXT(%r3) /* Save the non-volatile GP regs */ - mfcr %r4 /* Save the condition register */ - stw %r4,PCB_CR(%r3) + mr %r14,%r3 /* Copy the curthread pointer */ + mr %r15,%r4 /* ... and the current pcb pointer */ + mfcr %r16 /* Save the condition register */ + stw %r16,PCB_CR(%r3) + mflr %r16 /* Save the link register */ + stw %r16,PCB_LR(%r3) + stw %r1,PCB_SP(%r3) /* Save the stack pointer */ +#if 0 lwz %r29,PCB_FLAGS(%r3) andi. %r9, %r29, 1 /* XXX - don't hard code */ beq .L1 - mr %r29, %r3 /* Save the PCB pointer */ bl save_fpu - mr %r3, %r29 /* and restore it */ +#endif .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 %r14,%r3 /* Save off the (struct thread *) */ + mr %r3,%r15 + bl pmap_deactivate /* Deactivate the current pmap */ + mr %r3,%r16 bl pmap_activate /* Activate the new address space */ - mtlr %r30 - mfsprg %r4,%r0 /* Get the pcpu pointer */ - stw %r14,PC_CURTHREAD(%r4) /* Store new current thread */ - lwz %r4,TD_PCB(%r14) /* Grab the new PCB */ + mfsprg %r4,0 /* Get the pcpu pointer */ + stw %r16,PC_CURTHREAD(%r4) /* Store new current thread */ + lwz %r4,TD_PCB(%r16) /* Grab the new PCB */ +#if 0 lwz %r29, PCB_FLAGS(%r4) /* Restore FPU regs if needed */ andi. %r9, %r29, 1 beq .L2 - mr %r29, %r4 + mr %r3, %r4 bl enable_fpu - mr %r4, %r29 +#endif .L2: lmw %r14,PCB_CONTEXT(%r4) /* Load the non-volatile GP regs */ lwz %r5,PCB_CR(%r4) /* Load the condition register */ mtcr %r5 + lwz %r5,PCB_LR(%r4) /* Load the link register */ + mtlr %r5 + lwz %r1,PCB_SP(%r4) /* Load the stack pointer */ blr /* diff --git a/sys/powerpc/powerpc/swtch.s b/sys/powerpc/powerpc/swtch.s index 828c6cd..afa1ba5 100644 --- a/sys/powerpc/powerpc/swtch.s +++ b/sys/powerpc/powerpc/swtch.s @@ -71,45 +71,58 @@ * Find a runnable thread and switch to it. */ ENTRY(cpu_switch) - mflr %r30 - mfsprg %r3,%r0 /* Get the pcpu pointer */ + 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 */ stmw %r14,PCB_CONTEXT(%r3) /* Save the non-volatile GP regs */ - mfcr %r4 /* Save the condition register */ - stw %r4,PCB_CR(%r3) + mr %r14,%r3 /* Copy the curthread pointer */ + mr %r15,%r4 /* ... and the current pcb pointer */ + mfcr %r16 /* Save the condition register */ + stw %r16,PCB_CR(%r3) + mflr %r16 /* Save the link register */ + stw %r16,PCB_LR(%r3) + stw %r1,PCB_SP(%r3) /* Save the stack pointer */ +#if 0 lwz %r29,PCB_FLAGS(%r3) andi. %r9, %r29, 1 /* XXX - don't hard code */ beq .L1 - mr %r29, %r3 /* Save the PCB pointer */ bl save_fpu - mr %r3, %r29 /* and restore it */ +#endif .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 %r14,%r3 /* Save off the (struct thread *) */ + mr %r3,%r15 + bl pmap_deactivate /* Deactivate the current pmap */ + mr %r3,%r16 bl pmap_activate /* Activate the new address space */ - mtlr %r30 - mfsprg %r4,%r0 /* Get the pcpu pointer */ - stw %r14,PC_CURTHREAD(%r4) /* Store new current thread */ - lwz %r4,TD_PCB(%r14) /* Grab the new PCB */ + mfsprg %r4,0 /* Get the pcpu pointer */ + stw %r16,PC_CURTHREAD(%r4) /* Store new current thread */ + lwz %r4,TD_PCB(%r16) /* Grab the new PCB */ +#if 0 lwz %r29, PCB_FLAGS(%r4) /* Restore FPU regs if needed */ andi. %r9, %r29, 1 beq .L2 - mr %r29, %r4 + mr %r3, %r4 bl enable_fpu - mr %r4, %r29 +#endif .L2: lmw %r14,PCB_CONTEXT(%r4) /* Load the non-volatile GP regs */ lwz %r5,PCB_CR(%r4) /* Load the condition register */ mtcr %r5 + lwz %r5,PCB_LR(%r4) /* Load the link register */ + mtlr %r5 + lwz %r1,PCB_SP(%r4) /* Load the stack pointer */ blr /* |