diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2004-06-08 22:00:26 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2004-06-08 22:00:26 +0000 |
commit | d0908d395d6af71775d2da9a48a1f5fb7dd912a5 (patch) | |
tree | 0cae3c68b2d5a5a6e14a914edd5155df273d714a /sys/arch | |
parent | 22bb92adea4e8ab5ea342fc914a4533d54095e68 (diff) |
always create a stack frame in cpu_switch() and put a stub
for doing page idle zeroing.
store the kernele stack pointer into pcb instead of trapframe
for debuggers doing stack traces; from kettenis@
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/hppa/hppa/genassym.cf | 6 | ||||
-rw-r--r-- | sys/arch/hppa/hppa/locore.S | 147 | ||||
-rw-r--r-- | sys/arch/hppa/hppa/vm_machdep.c | 18 | ||||
-rw-r--r-- | sys/arch/hppa/include/pcb.h | 3 |
4 files changed, 96 insertions, 78 deletions
diff --git a/sys/arch/hppa/hppa/genassym.cf b/sys/arch/hppa/hppa/genassym.cf index 35626288f50..ee718b10e25 100644 --- a/sys/arch/hppa/hppa/genassym.cf +++ b/sys/arch/hppa/hppa/genassym.cf @@ -1,4 +1,4 @@ -# $OpenBSD: genassym.cf,v 1.24 2003/07/15 18:15:41 mickey Exp $ +# $OpenBSD: genassym.cf,v 1.25 2004/06/08 22:00:25 mickey Exp $ # # Copyright (c) 1982, 1990, 1993 @@ -148,10 +148,14 @@ member pcb_fpregs member pcb_onfault member pcb_space member pcb_uva +member pcb_ksp struct user member u_pcb +struct uvm +member page_idle_zero + # system calls export SYSCALLGATE export SYS_exit diff --git a/sys/arch/hppa/hppa/locore.S b/sys/arch/hppa/hppa/locore.S index 3bd089e3632..883c4d3eab8 100644 --- a/sys/arch/hppa/hppa/locore.S +++ b/sys/arch/hppa/hppa/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.132 2004/05/25 22:14:02 mickey Exp $ */ +/* $OpenBSD: locore.S,v 1.133 2004/06/08 22:00:25 mickey Exp $ */ /* * Copyright (c) 1998-2004 Michael Shalayeff @@ -2708,40 +2708,55 @@ EXIT(remrunqueue) ENTRY(cpu_switch,128) ldil L%cpl, t1 ldw R%cpl(t1), ret0 - stw ret0, HPPA_FRAME_SL(sp) + copy r3, r1 stw rp, HPPA_FRAME_CRP(sp) + copy sp, r3 + stw ret0, HPPA_FRAME_SL(sp) + stwm r1, HPPA_FRAME_SIZE+20*4(sp) /* * Clear curproc so that we don't accumulate system time while idle. */ ldil L%curproc, t1 ldw R%curproc(t1), arg2 + b switch_search stw r0, R%curproc(t1) /* remain on the old (curproc)'s stack until we have a better choice */ +cpu_idle + copy r0, arg0 + break HPPA_BREAK_KERNEL, HPPA_BREAK_SPLLOWER + .import uvm, data + ldil L%(uvm + PAGE_IDLE_ZERO), t3 + ldw R%(uvm + PAGE_IDLE_ZERO)(t3), t4 + sub,<> r0, t4, r0 + b cpu_loop + + stw arg2, 4(r3) + ldil L%uvm_pageidlezero, t1 + ldo R%uvm_pageidlezero(t1), t2 + .call + ble 0(sr0, t2) + copy r31, rp + + ldw HPPA_FRAME_SL(r3), ret0 + ldw 4(r3), arg2 + +cpu_loop + ldil L%cpl, arg0 + stw ret0, R%cpl(arg0) + +switch_search /* * t1: &whichqs * arg2: old curproc * */ - -switch_search ldil L%whichqs, t1 ldw R%whichqs(t1), t3 - comb,<> r0, t3, gotprocs - nop - + comb,=,n r0, t3, cpu_idle copy r0, arg0 - break HPPA_BREAK_KERNEL, HPPA_BREAK_SPLLOWER - - /* XXX do idle work here */ - nop ! nop ! nop ! nop ! nop ! nop ! nop ! nop - - ldil L%cpl, arg0 - b switch_search - stw ret0, R%cpl(arg0) -gotprocs ldi 0, t4 getbit mtsar t4 @@ -2797,9 +2812,8 @@ link_ok * the new process' kernel stack must be reasonable. */ comb,=,n arg1, arg2, kstack_ok - ldw P_MD_REGS(arg1), t1 ldw P_ADDR(arg1), arg0 - ldw TF_R30(t1), t1 + ldw U_PCB+PCB_KSP(arg0), t1 ldo NBPG(arg0), arg0 comb,>>,n arg0, t1, switch_error copy arg1, t2 @@ -2821,30 +2835,27 @@ kstack_ok * * arg2: old proc */ - ldw P_MD_REGS(arg2), t1 - ldw TF_R30(t1), t3 - copy sp, t2 - stw,ma r3, HPPA_FRAME_SIZE+20*4(sp) - stw sp, TF_R30(t1) - stw t2, HPPA_FRAME_PSP(sp) - stw t3, HPPA_FRAME_ARG(0)(sp) /* real user's stack */ - fdc r0(t1) + ldw P_ADDR(arg2), t1 /* save callee-save registers */ - stw r4, 1*4(t2) - stw r5, 2*4(t2) - stw r6, 3*4(t2) - stw r7, 4*4(t2) - stw r8, 5*4(t2) - stw r9, 6*4(t2) - stw r10, 7*4(t2) - stw r11, 8*4(t2) - stw r12, 9*4(t2) - stw r13, 10*4(t2) - stw r14, 11*4(t2) - stw r15, 12*4(t2) - stw r16, 13*4(t2) - stw r17, 14*4(t2) - stw r18, 15*4(t2) + stw r4, 1*4(r3) + stw sp, U_PCB+PCB_KSP(t1) + stw r5, 2*4(r3) + stw r6, 3*4(r3) + stw r7, 4*4(r3) + stw r8, 5*4(r3) + stw r9, 6*4(r3) + stw r10, 7*4(r3) + stw r11, 8*4(r3) + stw r12, 9*4(r3) + stw r13, 10*4(r3) + stw r14, 11*4(r3) + stw r15, 12*4(r3) + stw r16, 13*4(r3) + stw r17, 14*4(r3) + stw r18, 15*4(r3) + fdc r0(t1) + stw r0, HPPA_FRAME_ARG(1)(sp) /* say no trampoline */ + sync /* don't need old curproc (arg2) starting from here */ switch_exited @@ -2853,44 +2864,46 @@ switch_exited * * arg1: new proc */ - mtctl r0, ccr /* disable FPU */ + ldw P_ADDR(arg1), t2 ldw P_MD_REGS(arg1), t1 + ldw U_PCB+PCB_KSP(t2), sp + mtctl r0, ccr /* disable FPU */ ldw TF_CR30(t1), t2 - ldw TF_R30(t1), sp ldw TF_CR9(t1), t3 mtctl t2, cr30 mtctl t3, pidr2 - ldw HPPA_FRAME_PSP(sp), t2 - ldw HPPA_FRAME_ARG(0)(sp), t3 + ldo -(HPPA_FRAME_SIZE+20*4)(sp), r3 + ldw HPPA_FRAME_ARG(0)(sp), arg0 ldw HPPA_FRAME_ARG(1)(sp), t4 /* in case we're on trampoline */ - ldw HPPA_FRAME_ARG(2)(sp), arg0 - ldw HPPA_FRAME_SL(t2), ret0 - ldw HPPA_FRAME_CRP(t2), rp - ldw 0*4(t2), r3 - ldw 1*4(t2), r4 - ldw 2*4(t2), r5 - ldw 3*4(t2), r6 - ldw 4*4(t2), r7 - ldw 5*4(t2), r8 - ldw 6*4(t2), r9 - ldw 7*4(t2), r10 - ldw 8*4(t2), r11 - ldw 9*4(t2), r12 - ldw 10*4(t2), r13 - ldw 11*4(t2), r14 - ldw 12*4(t2), r15 - ldw 13*4(t2), r16 - ldw 14*4(t2), r17 - ldw 15*4(t2), r18 - stw t3, TF_R30(t1) - copy t2, sp + sub,= r0, t4, r0 + b switch_gonnajump + ldw 1*4(r3), r4 + ldw 2*4(r3), r5 + ldw 3*4(r3), r6 + ldw 4*4(r3), r7 + ldw 5*4(r3), r8 + ldw 6*4(r3), r9 + ldw 7*4(r3), r10 + ldw 8*4(r3), r11 + ldw 9*4(r3), r12 + ldw 10*4(r3), r13 + ldw 11*4(r3), r14 + ldw 12*4(r3), r15 + ldw 13*4(r3), r16 + ldw 14*4(r3), r17 + ldw 15*4(r3), r18 +switch_gonnajump + ldw HPPA_FRAME_SL(r3), ret0 ldil L%cpl, t1 stw ret0, R%cpl(t1) + sync switch_return ldil L%curproc, t1 - bv 0(rp) stw arg1, R%curproc(t1) + ldw HPPA_FRAME_CRP(r3), rp + bv 0(rp) + ldwm -(HPPA_FRAME_SIZE+20*4)(sp), r3 EXIT(cpu_switch) ENTRY(switch_trampoline,0) diff --git a/sys/arch/hppa/hppa/vm_machdep.c b/sys/arch/hppa/hppa/vm_machdep.c index 90259aacc68..c16b394c608 100644 --- a/sys/arch/hppa/hppa/vm_machdep.c +++ b/sys/arch/hppa/hppa/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.53 2004/04/21 23:09:30 mickey Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.54 2004/06/08 22:00:25 mickey Exp $ */ /* * Copyright (c) 1999-2004 Michael Shalayeff @@ -206,18 +206,18 @@ cpu_fork(p1, p2, stack, stacksize, func, arg) tf->tf_sp = (register_t)stack; /* - * Build a stack frame for the cpu_switch & co. + * Build stack frames for the cpu_switch & co. */ osp = sp + HPPA_FRAME_SIZE; - sp += 2*HPPA_FRAME_SIZE + 20*4; /* std frame + calee-save registers */ - *HPPA_FRAME_CARG(0, sp) = tf->tf_sp; - *HPPA_FRAME_CARG(1, sp) = KERNMODE(func); - *HPPA_FRAME_CARG(2, sp) = (register_t)arg; - *(register_t*)(osp) = (sp - HPPA_FRAME_SIZE); - *(register_t*)(sp + HPPA_FRAME_PSP) = osp; + *(register_t*)(osp - HPPA_FRAME_SIZE) = 0; *(register_t*)(osp + HPPA_FRAME_CRP) = (register_t)&switch_trampoline; *(register_t*)(osp + HPPA_FRAME_SL) = 0; /* cpl */ - tf->tf_sp = sp; + *(register_t*)(osp) = (osp - HPPA_FRAME_SIZE); + + sp = osp + HPPA_FRAME_SIZE + 20*4; /* frame + calee-save registers */ + *HPPA_FRAME_CARG(0, sp) = (register_t)arg; + *HPPA_FRAME_CARG(1, sp) = KERNMODE(func); + pcbp->pcb_ksp = sp; fdcache(HPPA_SID_KERNEL, (vaddr_t)p2->p_addr, sp - (vaddr_t)p2->p_addr); } diff --git a/sys/arch/hppa/include/pcb.h b/sys/arch/hppa/include/pcb.h index 7d2c62bb708..16da7dd0053 100644 --- a/sys/arch/hppa/include/pcb.h +++ b/sys/arch/hppa/include/pcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pcb.h,v 1.8 2004/04/07 18:24:19 mickey Exp $ */ +/* $OpenBSD: pcb.h,v 1.9 2004/06/08 22:00:25 mickey Exp $ */ /* * Copyright (c) 1999-2004 Michael Shalayeff @@ -37,6 +37,7 @@ struct pcb { u_int pcb_onfault; /* SW copy fault handler */ pa_space_t pcb_space; /* copy pmap_space, for asm's sake */ vaddr_t pcb_uva; /* KVA for U-area */ + u_int pcb_ksp; /* kernel sp for ctxsw */ }; struct md_coredump { |