diff options
author | grehan <grehan@FreeBSD.org> | 2003-03-20 10:28:20 +0000 |
---|---|---|
committer | grehan <grehan@FreeBSD.org> | 2003-03-20 10:28:20 +0000 |
commit | 68029e94a1631878f14f5dd4c7a84c7a6ee24104 (patch) | |
tree | c1412b9bb47cc500c1dca791fe28569e9d1f9267 /sys/powerpc/aim | |
parent | 99d692e01ffb8bb7b177b2a73a1d809bd6b6db93 (diff) | |
download | FreeBSD-src-68029e94a1631878f14f5dd4c7a84c7a6ee24104.zip FreeBSD-src-68029e94a1631878f14f5dd4c7a84c7a6ee24104.tar.gz |
Enable the FPU on first use per-thread and save state across context
switches. Not as lazy as it could be. Changing FPU state with sigcontext
still TODO.
fpu.c - convert some asm to inline C, and macroize fpu loads/stores
swtch.S - call out to save/restore fpu routines
trap.c - always call enable_fpu, since this shouldn't be called once
the FPU has been enabled for a thread
genassym.c - define for pcb fpu flag
Diffstat (limited to 'sys/powerpc/aim')
-rw-r--r-- | sys/powerpc/aim/swtch.S | 19 | ||||
-rw-r--r-- | sys/powerpc/aim/trap.c | 14 |
2 files changed, 11 insertions, 22 deletions
diff --git a/sys/powerpc/aim/swtch.S b/sys/powerpc/aim/swtch.S index 188d5cf..49e23c8 100644 --- a/sys/powerpc/aim/swtch.S +++ b/sys/powerpc/aim/swtch.S @@ -88,12 +88,11 @@ ENTRY(cpu_switch) stw %r16,PCB_USR(%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 */ + lwz %r5,PCB_FLAGS(%r3) /* Save FPU context if needed */ + andi. %r5, %r5, PCB_FPU beq .L1 + mr %r3,%r15 bl save_fpu -#endif .L1: bl choosethread /* Find a new thread to run */ @@ -111,16 +110,14 @@ ENTRY(cpu_switch) mfsprg %r4,0 /* Get the pcpu pointer */ stw %r16,PC_CURTHREAD(%r4) /* Store new current thread */ mr %r3,%r16 /* and save in r3 */ - lwz %r16,TD_PCB(%r16) /* Store new current PCB */ - stw %r16,PC_CURPCB(%r4) + lwz %r17,TD_PCB(%r16) /* Store new current PCB */ + stw %r17,PC_CURPCB(%r4) -#if 0 - lwz %r29, PCB_FLAGS(%r4) /* Restore FPU regs if needed */ - andi. %r9, %r29, 1 + lwz %r5, PCB_FLAGS(%r17) /* Restore FPU context if needed */ + andi. %r5, %r5, PCB_FPU beq .L2 - mr %r3, %r4 bl enable_fpu -#endif + mr %r3,%r16 /* Recover new curthread */ /* thread to restore is in r3 */ .L2: diff --git a/sys/powerpc/aim/trap.c b/sys/powerpc/aim/trap.c index 83f0b86..cd4a50b 100644 --- a/sys/powerpc/aim/trap.c +++ b/sys/powerpc/aim/trap.c @@ -150,7 +150,7 @@ trapname(u_int vector) void trap(struct trapframe *frame) { - struct thread *td, *fputhread; + struct thread *td; struct proc *p; int sig, type, user; u_int sticks, ucode; @@ -192,13 +192,9 @@ trap(struct trapframe *frame) break; case EXC_FPU: - if ((fputhread = PCPU_GET(fputhread)) != NULL) { - save_fpu(fputhread); - } - PCPU_SET(fputhread, td); - td->td_pcb->pcb_fpcpu = PCPU_GET(cpuid); + KASSERT((td->td_pcb->pcb_flags & PCB_FPU) != PCB_FPU, + ("FPU already enabled for thread")); enable_fpu(td); - frame->srr1 |= PSL_FP; break; #ifdef ALTIVEC @@ -253,10 +249,6 @@ trap(struct trapframe *frame) } } - if (td != PCPU_GET(fputhread) || - td->td_pcb->pcb_fpcpu != PCPU_GET(cpuid)) - frame->srr1 &= ~PSL_FP; - #ifdef ALTIVEC if (td != PCPU_GET(vecthread) || td->td_pcb->pcb_veccpu != PCPU_GET(cpuid)) |