Switch to regiser prefixes. Also change numeric constants to symbolic ones.

This commit is contained in:
matt 2003-07-31 15:30:41 +00:00
parent f9c46681fd
commit d89b685a6e
1 changed files with 165 additions and 162 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: locore_subr.S,v 1.13 2003/06/23 11:01:36 martin Exp $ */ /* $NetBSD: locore_subr.S,v 1.14 2003/07/31 15:30:41 matt Exp $ */
/* /*
* Copyright (c) 2001 Wasabi Systems, Inc. * Copyright (c) 2001 Wasabi Systems, Inc.
@ -89,10 +89,10 @@ GLOBAL(powersave)
* When we get here, interrupts are off (MSR[EE]=0) and sched_lock is held. * When we get here, interrupts are off (MSR[EE]=0) and sched_lock is held.
*/ */
ASENTRY(Idle) ASENTRY(Idle)
lis 8,_C_LABEL(sched_whichqs)@ha lis %r8,_C_LABEL(sched_whichqs)@ha
lwz 9,_C_LABEL(sched_whichqs)@l(8) lwz %r9,_C_LABEL(sched_whichqs)@l(%r8)
or. 9,9,9 or. %r9,%r9,%r9
bne+ .Lsw1 /* at least one queue non-empty */ bne+ .Lsw1 /* at least one queue non-empty */
#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG) #if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
@ -102,23 +102,23 @@ ASENTRY(Idle)
#if defined(PPC_IBM4XX) #if defined(PPC_IBM4XX)
wrteei 1 /* reenable ints again */ wrteei 1 /* reenable ints again */
#else /* PPC_OEA */ #else /* PPC_OEA */
mfmsr 3 mfmsr %r3
ori 3,3,PSL_EE@l /* reenable ints again */ ori %r3,%r3,PSL_EE@l /* reenable ints again */
mtmsr 3 mtmsr %r3
isync isync
#endif #endif
/* Check if we can use power saving mode */ /* Check if we can use power saving mode */
lis 8,_C_LABEL(powersave)@ha lis %r8,_C_LABEL(powersave)@ha
lwz 9,_C_LABEL(powersave)@l(8) lwz %r9,_C_LABEL(powersave)@l(%r8)
add. 9,9,9 add. %r9,%r9,%r9
ble 1f ble 1f
#if defined(PPC_OEA) #if defined(PPC_OEA)
sync sync
oris 3,3,PSL_POW@h /* enter power saving mode */ oris %r3,%r3,PSL_POW@h /* enter power saving mode */
mtmsr 3 mtmsr %r3
isync isync
#endif /* PPC_OEA */ #endif /* PPC_OEA */
@ -127,9 +127,9 @@ ASENTRY(Idle)
wrteei 0 /* disable interrupts while wrteei 0 /* disable interrupts while
manipulating runque */ manipulating runque */
#else /* PPC_OEA */ #else /* PPC_OEA */
andi. 3,3,~PSL_EE@l /* disable interrupts while andi. %r3,%r3,~PSL_EE@l /* disable interrupts while
manipulating runque */ manipulating runque */
mtmsr 3 mtmsr %r3
#endif #endif
#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG) #if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
@ -143,19 +143,19 @@ ASENTRY(Idle)
*/ */
ENTRY(switch_exit) ENTRY(switch_exit)
/* First switch to the idle pcb/kernel stack */ /* First switch to the idle pcb/kernel stack */
GET_CPUINFO(7) GET_CPUINFO(%r7)
lwz 6,CI_IDLE_PCB(7) lwz %r6,CI_IDLE_PCB(%r7)
stw 6,CI_CURPCB(7) stw %r6,CI_CURPCB(%r7)
/* /*
* Adjust the stack to provide space for the callee to save LR. * Adjust the stack to provide space for the callee to save LR.
*/ */
addi 1,6,USPACE-16 addi %r1,%r6,USPACE-CALLFRAMELEN
/* /*
* Schedule the vmspace and stack to be freed (the proc arg is * Schedule the vmspace and stack to be freed (the proc arg is
* already in r3). Function to call is in r4. * already in r3). Function to call is in r4.
*/ */
mtctr 4 mtctr %r4
bctrl bctrl
#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG) #if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
@ -163,49 +163,53 @@ ENTRY(switch_exit)
#endif #endif
/* Fall through to cpu_switch to actually select another proc */ /* Fall through to cpu_switch to actually select another proc */
li 3,0 /* indicate exited process */ li %r3,0 /* indicate exited process */
/* /*
* void cpu_switch(struct lwp *l) * void cpu_switch(struct lwp *l)
* Find a runnable process and switch to it. * Find a runnable process and switch to it.
*/ */
ENTRY_NOPROFILE(cpu_switch) ENTRY_NOPROFILE(cpu_switch)
mflr 0 /* save lr */ mflr %r0 /* save lr */
stw 0,4(1) stw %r0,SZREG(%r1)
stwu 1,-16(1) stwu %r1,-CALLFRAMELEN(%r1)
stw 31,12(1) stw %r31,(3*SZREG)(%r1)
stw 30,8(1) stw %r30,(2*SZREG)(%r1)
mr 30,3 mr %r30,%r3
#if defined(MULTIPROCESSOR) #if defined(MULTIPROCESSOR)
/* Switch to the idle PCB unless we're already running on it. */ /* Switch to the idle PCB unless we're already running on it. */
GET_CPUINFO(7) GET_CPUINFO(%r7)
cmpwi 30,0 /* old process was exiting? */ cmpwi %r30,0 /* old process was exiting? */
beq 1f beq 1f
mfsr 10,USER_SR /* save USER_SR for copyin/copyout */ #if defined(PPC_OEA) && !defined(_LP64)
mfcr 11 /* save cr */ mfsr %r10,USER_SR /* save USER_SR for copyin/copyout */
mr 12,2 /* save r2 */ #else
stwu 1,-SFRAMELEN(1) /* still running on old stack */ li %r10,0 /* no USER_SR needed */
stmw 10,8(1) #endif
lwz 3,L_ADDR(30) mfcr %r11 /* save cr */
stw 1,PCB_SP(3) /* save SP */ mr %r12,%r2 /* save r2 */
stwu %r1,-SFRAMELEN(%r1) /* still running on old stack */
stmw %r10,(2*SZREG)(%r1) /* save USER_SR, CR, R2, non-volatile */
lwz %r3,L_ADDR(%r30) /* get PCB address */
stw %r1,PCB_SP(%r3) /* save SP */
lwz 6,CI_IDLE_PCB(7) lwz %r6,CI_IDLE_PCB(%r7)
addi 1,6,USPACE-16 /* 16 bytes are reserved at stack top */ addi %r1,%r6,USPACE-CALLFRAMELEN /* callframe rsvd at stack top */
1: 1:
li 31,0 li %r31,0
stw 31,CI_CURLWP(7) /* Zero to not accumulate cpu time */ stw %r31,CI_CURLWP(%r7) /* Zero to not accumulate cpu time */
lwz 31,CI_CURPCB(7) lwz %r31,CI_CURPCB(%r7)
lwz 3,CI_CPL(7) lwz %r3,CI_CPL(%r7)
stw 3,PCB_SPL(31) /* save spl */ stw %r3,PCB_SPL(%r31) /* save spl */
#else #else
GET_CPUINFO(3) GET_CPUINFO(%r3)
li 31,0 li %r31,0
stw 31,CI_CURLWP(3) /* Zero to not accumulate cpu time */ stw %r31,CI_CURLWP(%r3) /* Zero to not accumulate cpu time */
lwz 31,CI_CURPCB(3) lwz %r31,CI_CURPCB(%r3)
#endif #endif
#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG) #if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
@ -213,10 +217,10 @@ ENTRY_NOPROFILE(cpu_switch)
bl _C_LABEL(sched_unlock_idle) bl _C_LABEL(sched_unlock_idle)
#endif #endif
li 3,0 /* spl0() */ li %r3,0 /* spl0() */
bl _C_LABEL(lcsplx) bl _C_LABEL(lcsplx)
#if !defined(MULTIPROCESSOR) #if !defined(MULTIPROCESSOR)
stw 3,PCB_SPL(31) /* save spl */ stw %r3,PCB_SPL(%r31) /* save spl */
#endif #endif
/* Lock the scheduler. */ /* Lock the scheduler. */
@ -224,10 +228,10 @@ ENTRY_NOPROFILE(cpu_switch)
wrteei 0 /* disable interrupts while wrteei 0 /* disable interrupts while
manipulating runque */ manipulating runque */
#else /* PPC_OEA */ #else /* PPC_OEA */
mfmsr 3 mfmsr %r3
andi. 3,3,~PSL_EE@l /* disable interrupts while andi. %r3,%r3,~PSL_EE@l /* disable interrupts while
manipulating runque */ manipulating runque */
mtmsr 3 mtmsr %r3
isync isync
#endif #endif
#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG) #if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
@ -235,104 +239,99 @@ ENTRY_NOPROFILE(cpu_switch)
#endif #endif
/* Find a new process */ /* Find a new process */
lis 8,_C_LABEL(sched_whichqs)@ha lis %r8,_C_LABEL(sched_whichqs)@ha
lwz 9,_C_LABEL(sched_whichqs)@l(8) lwz %r9,_C_LABEL(sched_whichqs)@l(%r8)
or. 9,9,9 or. %r9,%r9,%r9
beq- _ASM_LABEL(Idle) /* all queues empty */ beq- _ASM_LABEL(Idle) /* all queues empty */
.Lsw1: .Lsw1:
cntlzw 10,9 cntlzw %r10,%r9
lis 4,_C_LABEL(sched_qs)@ha lis %r4,_C_LABEL(sched_qs)@ha
addi 4,4,_C_LABEL(sched_qs)@l addi %r4,%r4,_C_LABEL(sched_qs)@l
slwi 3,10,3 slwi %r3,%r10,3
add 3,3,4 /* select queue */ add %r3,%r3,%r4 /* select queue */
lwz 31,L_FORW(3) /* unlink first proc from queue */ lwz %r31,L_FORW(%r3) /* unlink first proc from queue */
lwz 4,L_FORW(31) lwz %r4,L_FORW(%r31)
stw 4,L_FORW(3) stw %r4,L_FORW(%r3)
stw 3,L_BACK(4) stw %r3,L_BACK(%r4)
cmpl 0,3,4 /* queue empty? */ cmpl %cr0,%r3,%r4 /* queue empty? */
bne 1f bne 1f
lis 3,0x80000000@h lis %r3,0x80000000@h
srw 3,3,10 srw %r3,%r3,%r10
andc 9,9,3 andc %r9,%r9,%r3
stw 9,_C_LABEL(sched_whichqs)@l(8) /* mark it empty */ stw %r9,_C_LABEL(sched_whichqs)@l(%r8) /* mark it empty */
switch_common: switch_common:
1: 1:
/* just did this resched thing */ /* just did this resched thing */
li 3,0 li %r3,0
GET_CPUINFO(4) GET_CPUINFO(%r4)
stw 3,CI_WANT_RESCHED(4) stw %r3,CI_WANT_RESCHED(%r4)
stw 3,L_BACK(31) /* probably superfluous */ stw %r3,L_BACK(%r31) /* probably superfluous */
#ifdef MULTIPROCESSOR #ifdef MULTIPROCESSOR
stw 4,L_CPU(31) /* l->l_cpu = curcpu() */ stw %r4,L_CPU(%r31) /* l->l_cpu = curcpu() */
#endif #endif
/* Process now running on a processor. */ /* Process now running on a processor. */
li 3,LSONPROC /* l->l_stat = LSONPROC */ li %r3,LSONPROC /* l->l_stat = LSONPROC */
stw 3,L_STAT(31) stw %r3,L_STAT(%r31)
/* record new process */ /* record new process */
stw 31,CI_CURLWP(4) stw %r31,CI_CURLWP(%r4)
lwz 4,L_ADDR(31) lwz %r4,L_ADDR(%r31)
#if !defined(MULTIPROCESSOR) /* XXX */ #if !defined(MULTIPROCESSOR) /* XXX */
li 3,0 /* if it is the same lwp, return 0 */ li %r3,0 /* if it is the same lwp, return 0 */
cmpl 0,31,30 /* is it the same lwp? */ cmpl %cr0,%r31,%r30 /* is it the same lwp? */
beq switch_return beq switch_return
or. 30,30,30 /* old lwp was exiting? */ or. %r30,%r30,%r30 /* old lwp was exiting? */
beq switch_exited beq switch_exited
#if defined(PPC_IBM4XX) #if defined(PPC_OEA) && !defined(_LP64)
li 10,0 /* no SR for 4xx CPUs */ mfsr %r10,USER_SR /* save USER_SR for copyin/copyout */
#else /* PPC_OEA */ #else /* PPC_OEA */
mfsr 10,USER_SR /* save USER_SR for copyin/copyout */ li %r10,0 /* no SR needed */
#endif #endif
mfcr 11 /* save cr */ mfcr %r11 /* save cr */
mr 12,2 /* save r2 */ mr %r12,%r2 /* save r2 */
stwu 1,-SFRAMELEN(1) /* still running on old stack */ stwu %r1,-SFRAMELEN(%r1) /* still running on old stack */
stmw 10,8(1) stmw %r10,(2*SZREG)(%r1)
lwz 3,L_ADDR(30) lwz %r3,L_ADDR(%r30)
stw 1,PCB_SP(3) /* save SP */ stw %r1,PCB_SP(%r3) /* save SP */
switch_exited: switch_exited:
#endif #endif
/* indicate new pcb */ /* indicate new pcb */
GET_CPUINFO(6) GET_CPUINFO(%r6)
stw 4,CI_CURPCB(6) stw %r4,CI_CURPCB(%r6)
/* save real pmap pointer for spill fill */ /* save real pmap pointer for spill fill */
lwz 5,PCB_PMR(4) lwz %r5,PCB_PMR(%r4)
stwu 5,CI_CURPM(6) stwu %r5,CI_CURPM(%r6)
stwcx. 5,0,6 /* clear possible reservation */ stwcx. %r5,%r0,%r6 /* clear possible reservation */
isync isync
lwz 1,PCB_SP(4) /* get new procs SP */ lwz %r1,PCB_SP(%r4) /* get new procs SP */
lmw 10,8(1) /* get other regs */ lmw %r10,(2*SZREG)(%r1) /* get non-volatile, CR, R2, USER_SR */
lwz 1,0(1) /* get saved SP */ lwz %r1,0(%r1) /* get saved SP */
mr 2,12 /* get saved r2 */ mr %r2,%r12 /* get saved r2 */
mtcr 11 /* get saved cr */ mtcr %r11 /* get saved cr */
isync isync
#if defined(PPC_IBM4XX) #if defined(PPC_OEA) && !defined(_LP64)
/* mtsr USER_SR,%r10 /* get saved USER_SR */
* Don't have to do anything here; TLB PID gets updated on
* return from trap.
*/
#else /* PPC_OEA */
mtsr USER_SR,10 /* get saved USER_SR */
isync isync
#endif #endif
li 3,1 /* switched lwps */ li %r3,1 /* switched lwps */
switch_return: switch_return:
mr 30,3 /* save return value */ mr %r30,%r3 /* save return value */
#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG) #if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
/* Unlock the sched_lock, but leave interrupts off, for now. */ /* Unlock the sched_lock, but leave interrupts off, for now. */
bl _C_LABEL(sched_unlock_idle) bl _C_LABEL(sched_unlock_idle)
@ -341,33 +340,33 @@ switch_return:
#if defined(PPC_IBM4XX) #if defined(PPC_IBM4XX)
wrteei 1 /* interrupts are okay again */ wrteei 1 /* interrupts are okay again */
#else /* PPC_OEA */ #else /* PPC_OEA */
mfmsr 3 mfmsr %r3
ori 3,3,PSL_EE@l /* interrupts are okay again */ ori %r3,%r3,PSL_EE@l /* interrupts are okay again */
mtmsr 3 mtmsr %r3
#endif #endif
lwz 3,PCB_SPL(4) lwz %r3,PCB_SPL(%r4)
bl _C_LABEL(lcsplx) bl _C_LABEL(lcsplx)
#if defined(PPC_IBM4XX) #if defined(PPC_IBM4XX)
0: 0:
GET_CPUINFO(3) GET_CPUINFO(%r3)
lwz 3,CI_CURPM(3) /* Do we need a context? */ lwz %r3,CI_CURPM(%r3) /* Do we need a context? */
lwz 4,PM_CTX(3) lwz %r4,PM_CTX(%r3)
cmpwi 4,0 cmpwi %r4,0
# mtspr SPR_SPR0,4 /* Always keep the current ctx here */ # mtspr SPR_SPR0,4 /* Always keep the current ctx here */
bne 1f bne 1f
bl _C_LABEL(ctx_alloc) bl _C_LABEL(ctx_alloc)
b 0b /* reload */ b 0b /* reload */
1: 1:
#endif #endif
mr 3,30 /* restore return value */ mr %r3,%r30 /* restore return value */
lwz 31,12(1) lwz %r31,(3*SZREG)(%r1)
lwz 30,8(1) lwz %r30,(2*SZREG)(%r1)
addi 1,1,16 addi %r1,1,CALLFRAMELEN
lwz 0,4(1) lwz %r0,SZREG(%r1)
mtlr 0 mtlr %r0
blr blr
/* /*
@ -379,46 +378,50 @@ switch_return:
* r4 - LWP to switch to * r4 - LWP to switch to
*/ */
ENTRY(cpu_switchto) ENTRY(cpu_switchto)
mflr 0 /* save lr */ mflr %r0 /* save lr */
stw 0,4(1) stw %r0,SZREG(%r1)
stwu 1,-16(1) stwu %r1,-CALLFRAMELEN(%r1)
stw 31,12(1) stw %r31,(3*SZREG)(%r1)
stw 30,8(1) stw %r30,(2*SZREG)(%r1)
stwu 1,-16(1) stwu %r1,-CALLFRAMELEN(%r1)
stw 29,8(1) stw %r29,(2*SZREG)(%r1)
mr 30,3 /* r30 = curlwp */ mr %r30,%r3 /* r30 = curlwp */
mr 29,4 /* r29 = newlwp */ mr %r29,%r4 /* r29 = newlwp */
#if defined(MULTIPROCESSOR) #if defined(MULTIPROCESSOR)
/* Switch to the idle PCB unless we're already running on it. */ /* Switch to the idle PCB unless we're already running on it. */
GET_CPUINFO(7) GET_CPUINFO(%r7)
cmpwi 30,0 /* old process was exiting? */ cmpwi %r30,0 /* old process was exiting? */
beq 1f beq 1f
mfsr 10,USER_SR /* save USER_SR for copyin/copyout */ #if defined(PPC_OEA) && !defined(_LP64)
mfcr 11 /* save cr */ mfsr %r10,USER_SR /* save USER_SR for copyin/copyout */
mr 12,2 /* save r2 */ #else
stwu 1,-SFRAMELEN(1) /* still running on old stack */ li %r10,0 /* USER_SR not needed */
stmw 10,8(1) #endif
lwz 3,L_ADDR(30) mfcr %r11 /* save cr */
stw 1,PCB_SP(3) /* save SP */ mr %r12,%r2 /* save r2 */
stwu %r1,-SFRAMELEN(%r1) /* still running on old stack */
stmw %r10,(2*SZREG)(%r1) /* save USER_SR, CR, R2, non-volatile */
lwz %r3,L_ADDR(%r30) /* get PCB */
stw %r1,PCB_SP(%r3) /* save SP */
lwz 6,CI_IDLE_PCB(7) lwz %r6,CI_IDLE_PCB(%r7)
addi 1,6,USPACE-16 /* 16 bytes are reserved at stack top */ addi %r1,%r6,USPACE-CALLFRAMELEN /* callframe rsvd at stack top */
1: 1:
li 31,0 li %r31,0
stw 31,CI_CURLWP(7) /* Zero to not accumulate cpu time */ stw %r31,CI_CURLWP(%r7) /* Zero to not accumulate cpu time */
lwz 31,CI_CURPCB(7) lwz %r31,CI_CURPCB(%r7)
lwz 3,CI_CPL(7) lwz %r3,CI_CPL(%r7)
stw 3,PCB_SPL(31) /* save spl */ stw %r3,PCB_SPL(%r31) /* save spl */
#else #else
GET_CPUINFO(3) GET_CPUINFO(%r3)
li 31,0 li %r31,0
stw 31,CI_CURLWP(3) /* Zero to not accumulate cpu time */ stw %r31,CI_CURLWP(%r3) /* Zero to not accumulate cpu time */
lwz 31,CI_CURPCB(3) lwz %r31,CI_CURPCB(%r3)
#endif #endif
#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG) #if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
@ -426,10 +429,10 @@ ENTRY(cpu_switchto)
bl _C_LABEL(sched_unlock_idle) bl _C_LABEL(sched_unlock_idle)
#endif #endif
li 3,0 li %r3,0
bl _C_LABEL(lcsplx) bl _C_LABEL(lcsplx)
#if !defined(MULTIPROCESSOR) #if !defined(MULTIPROCESSOR)
stw 3,PCB_SPL(31) /* save spl */ stw %r3,PCB_SPL(%r31) /* save spl */
#endif #endif
/* Lock the scheduler. */ /* Lock the scheduler. */
@ -437,10 +440,10 @@ ENTRY(cpu_switchto)
wrteei 0 /* disable interrupts while wrteei 0 /* disable interrupts while
manipulating runque */ manipulating runque */
#else /* PPC_OEA */ #else /* PPC_OEA */
mfmsr 3 mfmsr %r3
andi. 3,3,~PSL_EE@l /* disable interrupts while andi. %r3,%r3,~PSL_EE@l /* disable interrupts while
manipulating runque */ manipulating runque */
mtmsr 3 mtmsr %r3
isync isync
#endif #endif
#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG) #if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
@ -448,9 +451,9 @@ ENTRY(cpu_switchto)
#endif #endif
/* Make stack normal, r31 newlwp, r30 oldlwp */ /* Make stack normal, r31 newlwp, r30 oldlwp */
mr 31,29 mr %r31,%r29
lwz 29,8(1) lwz %r29,(2*SZREG)(%r1)
addi 1,1,16 addi %r1,%r1,CALLFRAMELEN
b switch_common b switch_common
/* NOTREACHED */ /* NOTREACHED */
@ -464,9 +467,9 @@ _C_LABEL(fork_trampoline):
#if defined(MULTIPROCESSOR) #if defined(MULTIPROCESSOR)
bl _C_LABEL(proc_trampoline_mp) bl _C_LABEL(proc_trampoline_mp)
#endif #endif
li 3,0 li %r3,0
bl _C_LABEL(lcsplx) bl _C_LABEL(lcsplx)
mtlr 31 mtlr %r31
mr 3,30 mr %r3,%r30
blrl /* jump indirect to r31 */ blrl /* jump indirect to r31 */
b trapexit b trapexit