cpu_switch now works, for kthreads at least.
This commit is contained in:
parent
0e1338662a
commit
677bcc872c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=91486
@ -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 %r14,%r3 /* Save off the (struct thread *) */
|
||||
mr %r16,%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
|
||||
|
||||
/*
|
||||
|
@ -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 %r14,%r3 /* Save off the (struct thread *) */
|
||||
mr %r16,%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
|
||||
|
||||
/*
|
||||
|
@ -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 %r14,%r3 /* Save off the (struct thread *) */
|
||||
mr %r16,%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
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user