diff options
author | jake <jake@FreeBSD.org> | 2003-04-03 16:36:01 +0000 |
---|---|---|
committer | jake <jake@FreeBSD.org> | 2003-04-03 16:36:01 +0000 |
commit | ffcfcc8152a16ce4eaf5f537dca60fae1e775fbc (patch) | |
tree | 154f0eb2b82eeb6f9e74c80f615500042226b29a /sys | |
parent | c115d3b2c07668311cdb9be1361e2f09457abe31 (diff) | |
download | FreeBSD-src-ffcfcc8152a16ce4eaf5f537dca60fae1e775fbc.zip FreeBSD-src-ffcfcc8152a16ce4eaf5f537dca60fae1e775fbc.tar.gz |
- Generally improve register usage in cpu_switch. Use the 'in' registers
for temporaries relating to the state of the new process instead of the
outs, so that functions can be called without fear of clobbering them.
- Use savefpctx instead of rolling our own.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/sparc64/sparc64/swtch.S | 134 |
1 files changed, 63 insertions, 71 deletions
diff --git a/sys/sparc64/sparc64/swtch.S b/sys/sparc64/sparc64/swtch.S index 21f5a9b..7cea5ee 100644 --- a/sys/sparc64/sparc64/swtch.S +++ b/sys/sparc64/sparc64/swtch.S @@ -42,9 +42,8 @@ ENTRY(cpu_throw) save %sp, -CCFSZ, %sp flushw - mov %i0, %l0 ba %xcc, .Lsw1 - mov %i1, %o0 + mov %i1, %i0 END(cpu_throw) /* @@ -52,40 +51,34 @@ END(cpu_throw) */ ENTRY(cpu_switch) save %sp, -CCFSZ, %sp - mov %i0, %l0 - mov %i1, %o0 + mov %i1, %i0 /* - * If the current thread was using floating point, save its context. + * If the current thread was using floating point in userland, save + * its context. */ - ldx [%l0 + TD_PCB], %l1 - ldx [%l0 + TD_FRAME], %l2 +1: sub PCB_REG, TF_SIZEOF, %l2 ldx [%l2 + TF_FPRS], %l3 andcc %l3, FPRS_FEF, %g0 - bz,a,pt %xcc, 1f + bz,a,pt %xcc, 2f nop - wr %g0, FPRS_FEF, %fprs - wr %g0, ASI_BLK_S, %asi - stda %f0, [%l1 + PCB_UFP + (0 * 64)] %asi - stda %f16, [%l1 + PCB_UFP + (1 * 64)] %asi - stda %f32, [%l1 + PCB_UFP + (2 * 64)] %asi - stda %f48, [%l1 + PCB_UFP + (3 * 64)] %asi - membar #Sync - wr %g0, 0, %fprs + call savefpctx + add PCB_REG, PCB_UFP, %o0 andn %l3, FPRS_FEF, %l3 stx %l3, [%l2 + TF_FPRS] - ldx [%l1 + PCB_FLAGS], %l3 + + ldx [PCB_REG + PCB_FLAGS], %l3 or %l3, PCB_FEF, %l3 - stx %l3, [%l1 + PCB_FLAGS] + stx %l3, [PCB_REG + PCB_FLAGS] /* * Flush the windows out to the stack and save the current frame * pointer and program counter. */ -1: flushw +2: flushw wrpr %g0, 0, %cleanwin - stx %fp, [%l1 + PCB_SP] - stx %i7, [%l1 + PCB_PC] + stx %fp, [PCB_REG + PCB_SP] + stx %i7, [PCB_REG + PCB_PC] /* * Load the new thread's frame pointer and program counter, and set @@ -95,42 +88,44 @@ ENTRY(cpu_switch) #if KTR_COMPILE & KTR_PROC CATR(KTR_PROC, "cpu_switch: new td=%p pc=%#lx fp=%#lx" , %g1, %g2, %g3, 7, 8, 9) - stx %o0, [%g1 + KTR_PARM1] - ldx [%o0 + TD_PCB], %g2 + stx %i0, [%g1 + KTR_PARM1] + ldx [%i0 + TD_PCB], %g2 ldx [%g2 + PCB_PC], %g3 stx %g3, [%g1 + KTR_PARM2] ldx [%g2 + PCB_SP], %g3 stx %g3, [%g1 + KTR_PARM3] 9: #endif - ldx [%o0 + TD_PCB], %o1 - ldx [%o1 + PCB_SP], %fp - ldx [%o1 + PCB_PC], %i7 - sub %fp, CCFSZ, %sp - stx %o0, [PCPU(CURTHREAD)] - stx %o1, [PCPU(CURPCB)] + ldx [%i0 + TD_PCB], %i1 - SET(sched_lock, %o3, %o2) - stx %o0, [%o2 + MTX_LOCK] + stx %i0, [PCPU(CURTHREAD)] + stx %i1, [PCPU(CURPCB)] wrpr %g0, PSTATE_NORMAL, %pstate - mov %o1, PCB_REG + mov %i1, PCB_REG wrpr %g0, PSTATE_ALT, %pstate - mov %o1, PCB_REG + mov %i1, PCB_REG wrpr %g0, PSTATE_KERNEL, %pstate + ldx [PCB_REG + PCB_SP], %fp + ldx [PCB_REG + PCB_PC], %i7 + sub %fp, CCFSZ, %sp + + SET(sched_lock, %i3, %i2) + stx %i0, [%i2 + MTX_LOCK] + /* * Point to the vmspaces of the new process, and of the last non-kernel * process to run. */ - ldx [%o0 + TD_PROC], %o2 + ldx [%i0 + TD_PROC], %i2 ldx [PCPU(VMSPACE)], %l2 - ldx [%o2 + P_VMSPACE], %o2 + ldx [%i2 + P_VMSPACE], %i2 #if KTR_COMPILE & KTR_PROC CATR(KTR_PROC, "cpu_switch: new vm=%p old vm=%p" , %g1, %g2, %g3, 7, 8, 9) - stx %o2, [%g1 + KTR_PARM1] + stx %i2, [%g1 + KTR_PARM1] stx %l2, [%g1 + KTR_PARM2] 9: #endif @@ -138,32 +133,32 @@ ENTRY(cpu_switch) /* * If they are the same we are done. */ - cmp %l2, %o2 - be,a,pn %xcc, 4f + cmp %l2, %i2 + be,a,pn %xcc, 5f nop /* * If the new process has nucleus context we are done. */ - lduw [PCPU(CPUID)], %o3 - sllx %o3, INT_SHIFT, %o3 - add %o2, VM_PMAP + PM_CONTEXT, %o4 - lduw [%o3 + %o4], %o5 + lduw [PCPU(CPUID)], %i3 + sllx %i3, INT_SHIFT, %i3 + add %i2, VM_PMAP + PM_CONTEXT, %i4 + lduw [%i3 + %i4], %i5 #if KTR_COMPILE & KTR_PROC CATR(KTR_PROC, "cpu_switch: ctx=%#lx" , %g1, %g2, %g3, 7, 8, 9) - stx %o5, [%g1 + KTR_PARM1] + stx %i5, [%g1 + KTR_PARM1] 9: #endif - brz,a,pn %o5, 4f + brz,a,pn %i5, 5f nop /* * If there was no non-kernel vmspace, don't try to deactivate it. */ - brz,a,pn %l2, 2f + brz,a,pn %l2, 3f nop /* @@ -188,31 +183,31 @@ ENTRY(cpu_switch) * Find the current free tlb context for this cpu and install it as * the new primary context. */ -2: lduw [PCPU(TLB_CTX)], %o5 - stw %o5, [%o3 + %o4] - mov AA_DMMU_PCXR, %o4 - stxa %o5, [%o4] ASI_DMMU +3: lduw [PCPU(TLB_CTX)], %i5 + stw %i5, [%i3 + %i4] + mov AA_DMMU_PCXR, %i4 + stxa %i5, [%i4] ASI_DMMU membar #Sync /* * See if we have run out of free contexts. */ - lduw [PCPU(TLB_CTX_MAX)], %o3 + lduw [PCPU(TLB_CTX_MAX)], %i3 #if KTR_COMPILE & KTR_PROC CATR(KTR_PROC, "cpu_switch: ctx=%#lx next=%#lx max=%#lx" , %g1, %g2, %g3, 7, 8, 9) - stx %o5, [%g1 + KTR_PARM1] - add %o5, 1, %g2 + stx %i5, [%g1 + KTR_PARM1] + add %i5, 1, %g2 stx %g2, [%g1 + KTR_PARM2] - stx %o3, [%g1 + KTR_PARM3] + stx %i3, [%g1 + KTR_PARM3] 9: #endif - add %o5, 1, %o5 - cmp %o3, %o5 - bne,a,pt %xcc, 3f - stw %o5, [PCPU(TLB_CTX)] + add %i5, 1, %i5 + cmp %i3, %i5 + bne,a,pt %xcc, 4f + stw %i5, [PCPU(TLB_CTX)] #if KTR_COMPILE & KTR_PROC CATR(KTR_PROC, "cpu_switch: context rollover" @@ -226,34 +221,31 @@ ENTRY(cpu_switch) */ call pmap_context_rollover nop - ldx [PCPU(CURTHREAD)], %o0 - ldx [%o0 + TD_PROC], %o2 - ldx [%o2 + P_VMSPACE], %o2 /* * Mark the pmap as active on this cpu. */ -3: lduw [%o2 + VM_PMAP + PM_ACTIVE], %o3 - lduw [PCPU(CPUMASK)], %o4 - or %o3, %o4, %o3 - stw %o3, [%o2 + VM_PMAP + PM_ACTIVE] +4: lduw [%i2 + VM_PMAP + PM_ACTIVE], %i3 + lduw [PCPU(CPUMASK)], %i4 + or %i3, %i4, %i3 + stw %i3, [%i2 + VM_PMAP + PM_ACTIVE] /* * Make note of the change in vmspace. */ - stx %o2, [PCPU(VMSPACE)] + stx %i2, [PCPU(VMSPACE)] /* * Load the tsb registers. */ - ldx [%o2 + VM_PMAP + PM_TSB], %o3 - mov AA_DMMU_TSB, %o4 - stxa %o3, [%o4] ASI_DMMU - mov AA_IMMU_TSB, %o4 - stxa %o3, [%o4] ASI_IMMU + ldx [%i2 + VM_PMAP + PM_TSB], %i3 + mov AA_DMMU_TSB, %i4 + stxa %i3, [%i4] ASI_DMMU + mov AA_IMMU_TSB, %i4 + stxa %i3, [%i4] ASI_IMMU membar #Sync -4: +5: #if KTR_COMPILE & KTR_PROC CATR(KTR_PROC, "cpu_switch: return" , %g1, %g2, %g3, 7, 8, 9) |