diff options
author | Per Fogelstrom <pefo@cvs.openbsd.org> | 1998-09-15 10:53:56 +0000 |
---|---|---|
committer | Per Fogelstrom <pefo@cvs.openbsd.org> | 1998-09-15 10:53:56 +0000 |
commit | 84e4f39da42d6960834a60df1a8b384d35b0f388 (patch) | |
tree | fa0673bd8c760a9945900b273d0ddaeb89c2e7b7 | |
parent | 8811594d2793d27a5f0997ba7f687030b6910809 (diff) |
Real trapframe and no more __FORK_BRAINDAMAGE
-rw-r--r-- | sys/arch/pmax/conf/GENERIC | 4 | ||||
-rw-r--r-- | sys/arch/pmax/include/cpu.h | 3 | ||||
-rw-r--r-- | sys/arch/pmax/pmax/genassym.cf | 6 | ||||
-rw-r--r-- | sys/arch/pmax/pmax/locore.S | 45 | ||||
-rw-r--r-- | sys/arch/pmax/pmax/locore_r2000.S | 182 | ||||
-rw-r--r-- | sys/arch/pmax/pmax/machdep.c | 67 | ||||
-rw-r--r-- | sys/arch/pmax/pmax/process_machdep.c | 2 | ||||
-rw-r--r-- | sys/arch/pmax/pmax/trap.c | 343 | ||||
-rw-r--r-- | sys/arch/pmax/pmax/vm_machdep.c | 70 |
9 files changed, 380 insertions, 342 deletions
diff --git a/sys/arch/pmax/conf/GENERIC b/sys/arch/pmax/conf/GENERIC index 1a36aeefaf4..f5ac502beed 100644 --- a/sys/arch/pmax/conf/GENERIC +++ b/sys/arch/pmax/conf/GENERIC @@ -44,8 +44,8 @@ option SYSVSHM # sysv shared memory # ktrace support option KTRACE # ktrace(1) support # debugging stuff -#option DIAGNOSTIC # extra kernel debugging checks -#option DEBUG # extra kernel debugging support +option DIAGNOSTIC # extra kernel debugging checks +option DEBUG # extra kernel debugging support #option KGDB # support for kernel gdb #option "KGDBRATE=19200" # kernel gdb port rate (default 9600) #option "KGDBDEV=15*256+0" # device for kernel gdb diff --git a/sys/arch/pmax/include/cpu.h b/sys/arch/pmax/include/cpu.h index 75a88148245..20d24b24b66 100644 --- a/sys/arch/pmax/include/cpu.h +++ b/sys/arch/pmax/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.8 1998/06/04 03:49:48 jason Exp $ */ +/* $OpenBSD: cpu.h,v 1.9 1998/09/15 10:53:54 pefo Exp $ */ /* $NetBSD: cpu.h,v 1.15 1996/03/23 20:28:19 jonathan Exp $ */ /*- @@ -72,7 +72,6 @@ extern int cpu_arch; * referenced in generic code */ #define cpu_wait(p) /* nothing */ -#define cpu_set_init_frame(p, fp) /* nothing */ #define cpu_swapout(p) panic("cpu_swapout: can't get here"); /* diff --git a/sys/arch/pmax/pmax/genassym.cf b/sys/arch/pmax/pmax/genassym.cf index b18f96d7507..3d2f699e4f6 100644 --- a/sys/arch/pmax/pmax/genassym.cf +++ b/sys/arch/pmax/pmax/genassym.cf @@ -1,4 +1,4 @@ -# $OpenBSD: genassym.cf,v 1.1 1997/05/02 22:09:46 graichen Exp $ +# $OpenBSD: genassym.cf,v 1.2 1998/09/15 10:53:54 pefo Exp $ # # Copyright (c) 1982, 1990 The Regents of the University of California. # All rights reserved. @@ -51,8 +51,8 @@ define P_ADDR offsetof(struct proc, p_addr) define P_UPTE offsetof(struct proc, p_md.md_upte) # u_pcb fields -define U_PCB_REGS offsetof(struct user, u_pcb.pcb_regs) -define U_PCB_FPREGS offsetof(struct user, u_pcb.pcb_regs[F0]) +define U_PCB_REGS offsetof(struct user, u_pcb.pcb_regs.zero) +define U_PCB_FPREGS offsetof(struct user, u_pcb.pcb_regs.f0) define U_PCB_CONTEXT offsetof(struct user, u_pcb.pcb_context) define U_PCB_ONFAULT offsetof(struct user, u_pcb.pcb_onfault) define U_PCB_SEGTAB offsetof(struct user, u_pcb.pcb_segtab) diff --git a/sys/arch/pmax/pmax/locore.S b/sys/arch/pmax/pmax/locore.S index 0afc4b82c5b..01b344e8db1 100644 --- a/sys/arch/pmax/pmax/locore.S +++ b/sys/arch/pmax/pmax/locore.S @@ -133,22 +133,22 @@ * Don't ask why, I don't konw. */ #define RESTORE_KERN_REGISTERS(offset) \ - lw v1, offset + 8(sp) ; \ - lw a0, offset + 12(sp) ; \ - lw a1, offset + 16(sp) ; \ - lw a2, offset + 20(sp) ; \ - lw a3, offset + 24(sp) ; \ - lw t0, offset + 28(sp) ; \ - lw t1, offset + 32(sp) ; \ - lw t2, offset + 36(sp) ; \ - lw t3, offset + 40(sp) ; \ - lw t4, offset + 44(sp) ; \ - lw t5, offset + 48(sp) ; \ - lw t6, offset + 52(sp) ; \ - lw t7, offset + 56(sp) ; \ - lw t8, offset + 60(sp) ; \ - lw t9, offset + 64(sp) ; \ - lw ra, offset + 68(sp) + lw v1, offset + (V1 * 4)(sp) ; \ + lw a0, offset + (A0 * 4)(sp) ; \ + lw a1, offset + (A1 * 4)(sp) ; \ + lw a2, offset + (A2 * 4)(sp) ; \ + lw a3, offset + (A3 * 4)(sp) ; \ + lw t0, offset + (T0 * 4)(sp) ; \ + lw t1, offset + (T1 * 4)(sp) ; \ + lw t2, offset + (T2 * 4)(sp) ; \ + lw t3, offset + (T3 * 4)(sp) ; \ + lw t4, offset + (T4 * 4)(sp) ; \ + lw t5, offset + (T5 * 4)(sp) ; \ + lw t6, offset + (T6 * 4)(sp) ; \ + lw t7, offset + (T7 * 4)(sp) ; \ + lw t8, offset + (T8 * 4)(sp) ; \ + lw t9, offset + (T9 * 4)(sp) ; \ + lw ra, offset + (RA * 4)(sp) @@ -213,16 +213,20 @@ start: sw t1, _C_LABEL(fpu_id) # save FPU ID register jal _C_LABEL(main) # main(regs) move a0, zero + PANIC("Startup failed!") /* - * proc[1] == /etc/init now running here. - * Restore user registers and return. + * Setup for and return to user. */ +LEAF(proc_trampoline) + jal s0 + move a0,s1 # set up for return to user. + .set noat - li v0, PSL_USERSET - mtc0 v0, MIPS_COP_0_STATUS_REG # switch to user mode + lw k0, UADDR+U_PCB_REGS+(SR * 4) lw a0, UADDR+U_PCB_REGS+(SR * 4) lw t0, UADDR+U_PCB_REGS+(MULLO * 4) lw t1, UADDR+U_PCB_REGS+(MULHI * 4) + mtc0 k0, MIPS_COP_0_STATUS_REG # switch to user mode mtlo t0 mthi t1 lw k0, UADDR+U_PCB_REGS+(PC * 4) @@ -258,6 +262,7 @@ start: j k0 rfe .set at +END(proc_trampoline) /* * This code is copied the user's stack for returning from signal handlers diff --git a/sys/arch/pmax/pmax/locore_r2000.S b/sys/arch/pmax/pmax/locore_r2000.S index cd0a66fc243..3a9fbac3e53 100644 --- a/sys/arch/pmax/pmax/locore_r2000.S +++ b/sys/arch/pmax/pmax/locore_r2000.S @@ -183,18 +183,15 @@ mips1_SlowFault: */ /* - * The kernel exception stack contains 18 saved general registers, + * The kernel exception stack contains 32 saved general registers, * the status register and the multiply lo and high registers. * In addition, we set this up for linkage conventions. */ -#define KERN_REG_SIZE (18 * 4) +#define KERN_REG_SIZE (NUMSAVEREGS * 4) #define KERN_REG_OFFSET (STAND_FRAME_SIZE) -#define KERN_SR_OFFSET (STAND_FRAME_SIZE + KERN_REG_SIZE) -#define KERN_MULT_LO_OFFSET (STAND_FRAME_SIZE + KERN_REG_SIZE + 4) -#define KERN_MULT_HI_OFFSET (STAND_FRAME_SIZE + KERN_REG_SIZE + 8) -#define KERN_EXC_FRAME_SIZE (STAND_FRAME_SIZE + KERN_REG_SIZE + 12) +#define KERN_TRAP_FRAME_SIZE (STAND_FRAME_SIZE + KERN_REG_SIZE + 12) -NNON_LEAF(mips1_KernGenException, KERN_EXC_FRAME_SIZE, ra) +NNON_LEAF(mips1_KernGenException, KERN_TRAP_FRAME_SIZE, ra) .set noat #ifdef KADB la k0, kdbpcb # save registers for kadb @@ -210,63 +207,66 @@ NNON_LEAF(mips1_KernGenException, KERN_EXC_FRAME_SIZE, ra) sw gp, (GP * 4)(k0) sw sp, (SP * 4)(k0) #endif - subu sp, sp, KERN_EXC_FRAME_SIZE - .mask 0x80000000, (STAND_RA_OFFSET - KERN_EXC_FRAME_SIZE) + subu sp, sp, KERN_TRAP_FRAME_SIZE + .mask 0x80000000, (STAND_RA_OFFSET - KERN_TRAP_FRAME_SIZE) /* * Save the relevant kernel registers onto the stack. * We don't need to save s0 - s8, sp and gp because * the compiler does it for us. */ - sw AT, KERN_REG_OFFSET + 0(sp) - sw v0, KERN_REG_OFFSET + 4(sp) - sw v1, KERN_REG_OFFSET + 8(sp) - sw a0, KERN_REG_OFFSET + 12(sp) + sw AT, KERN_REG_OFFSET + (AST * 4)(sp) + sw v0, KERN_REG_OFFSET + (V0 * 4)(sp) + sw v1, KERN_REG_OFFSET + (V1 * 4)(sp) + sw a0, KERN_REG_OFFSET + (A0 * 4)(sp) mflo v0 mfhi v1 - sw a1, KERN_REG_OFFSET + 16(sp) - sw a2, KERN_REG_OFFSET + 20(sp) - sw a3, KERN_REG_OFFSET + 24(sp) - sw t0, KERN_REG_OFFSET + 28(sp) + sw a1, KERN_REG_OFFSET + (A1 * 4)(sp) + sw a2, KERN_REG_OFFSET + (A2 * 4)(sp) + sw a3, KERN_REG_OFFSET + (A3 * 4)(sp) + sw t0, KERN_REG_OFFSET + (T0 * 4)(sp) mfc0 a0, MIPS_COP_0_STATUS_REG # First arg is the status reg. - sw t1, KERN_REG_OFFSET + 32(sp) - sw t2, KERN_REG_OFFSET + 36(sp) - sw t3, KERN_REG_OFFSET + 40(sp) - sw t4, KERN_REG_OFFSET + 44(sp) + sw t1, KERN_REG_OFFSET + (T1 * 4)(sp) + sw t2, KERN_REG_OFFSET + (T2 * 4)(sp) + sw t3, KERN_REG_OFFSET + (T3 * 4)(sp) + sw t4, KERN_REG_OFFSET + (T4 * 4)(sp) mfc0 a1, MIPS_COP_0_CAUSE_REG # Second arg is the cause reg. - sw t5, KERN_REG_OFFSET + 48(sp) - sw t6, KERN_REG_OFFSET + 52(sp) - sw t7, KERN_REG_OFFSET + 56(sp) - sw t8, KERN_REG_OFFSET + 60(sp) + sw t5, KERN_REG_OFFSET + (T5 * 4)(sp) + sw t6, KERN_REG_OFFSET + (T6 * 4)(sp) + sw t7, KERN_REG_OFFSET + (T7 * 4)(sp) + sw t8, KERN_REG_OFFSET + (T8 * 4)(sp) mfc0 a2, MIPS_COP_0_BAD_VADDR # Third arg is the fault addr. - sw t9, KERN_REG_OFFSET + 64(sp) - sw ra, KERN_REG_OFFSET + 68(sp) - sw v0, KERN_MULT_LO_OFFSET(sp) - sw v1, KERN_MULT_HI_OFFSET(sp) + sw t9, KERN_REG_OFFSET + (T9 * 4)(sp) + sw ra, KERN_REG_OFFSET + (RA * 4)(sp) + sw v0, KERN_REG_OFFSET + (MULLO * 4)(sp) + sw v1, KERN_REG_OFFSET + (MULHI * 4)(sp) mfc0 a3, MIPS_COP_0_EXC_PC # Fourth arg is the pc. - sw a0, KERN_SR_OFFSET(sp) + sw a0, KERN_REG_OFFSET + (SR * 4)(sp) + sw a1, KERN_REG_OFFSET + (CAUSE * 4)(sp) + sw a2, KERN_REG_OFFSET + (BADVADDR * 4)(sp) + sw a3, KERN_REG_OFFSET + (PC * 4)(sp) /* * Call the exception handler. */ + addu a0, sp, KERN_REG_OFFSET jal _C_LABEL(trap) sw a3, STAND_RA_OFFSET(sp) # for debugging /* * Restore registers and return from the exception. * v0 contains the return address. */ - lw a0, KERN_SR_OFFSET(sp) - lw t0, KERN_MULT_LO_OFFSET(sp) - lw t1, KERN_MULT_HI_OFFSET(sp) + lw a0, KERN_REG_OFFSET + (SR * 4)(sp) + lw t0, KERN_REG_OFFSET + (MULLO * 4)(sp) + lw t1, KERN_REG_OFFSET + (MULHI * 4)(sp) mtc0 a0, MIPS_COP_0_STATUS_REG # Restore the SR, disable intrs mtlo t0 mthi t1 move k0, v0 - - lw AT, KERN_REG_OFFSET + 0(sp) - lw v0, KERN_REG_OFFSET + 4(sp) + lw AT, KERN_REG_OFFSET + (AST * 4)(sp) + lw v0, KERN_REG_OFFSET + (V0 * 4)(sp) RESTORE_KERN_REGISTERS(KERN_REG_OFFSET) - addu sp, sp, KERN_EXC_FRAME_SIZE + addu sp, sp, KERN_TRAP_FRAME_SIZE j k0 # Now return from the rfe # exception. .set at @@ -296,45 +296,47 @@ NNON_LEAF(mips1_UserGenException, STAND_FRAME_SIZE, ra) sw v0, UADDR+U_PCB_REGS+(V0 * 4) sw v1, UADDR+U_PCB_REGS+(V1 * 4) sw a0, UADDR+U_PCB_REGS+(A0 * 4) - mflo v0 sw a1, UADDR+U_PCB_REGS+(A1 * 4) sw a2, UADDR+U_PCB_REGS+(A2 * 4) sw a3, UADDR+U_PCB_REGS+(A3 * 4) sw t0, UADDR+U_PCB_REGS+(T0 * 4) - mfhi v1 sw t1, UADDR+U_PCB_REGS+(T1 * 4) sw t2, UADDR+U_PCB_REGS+(T2 * 4) sw t3, UADDR+U_PCB_REGS+(T3 * 4) sw t4, UADDR+U_PCB_REGS+(T4 * 4) - mfc0 a0, MIPS_COP_0_STATUS_REG # First arg is the status reg. sw t5, UADDR+U_PCB_REGS+(T5 * 4) sw t6, UADDR+U_PCB_REGS+(T6 * 4) sw t7, UADDR+U_PCB_REGS+(T7 * 4) sw s0, UADDR+U_PCB_REGS+(S0 * 4) - mfc0 a1, MIPS_COP_0_CAUSE_REG # Second arg is the cause reg. sw s1, UADDR+U_PCB_REGS+(S1 * 4) sw s2, UADDR+U_PCB_REGS+(S2 * 4) sw s3, UADDR+U_PCB_REGS+(S3 * 4) sw s4, UADDR+U_PCB_REGS+(S4 * 4) - mfc0 a2, MIPS_COP_0_BAD_VADDR # Third arg is the fault addr sw s5, UADDR+U_PCB_REGS+(S5 * 4) sw s6, UADDR+U_PCB_REGS+(S6 * 4) sw s7, UADDR+U_PCB_REGS+(S7 * 4) sw t8, UADDR+U_PCB_REGS+(T8 * 4) - mfc0 a3, MIPS_COP_0_EXC_PC # Fourth arg is the pc. sw t9, UADDR+U_PCB_REGS+(T9 * 4) sw gp, UADDR+U_PCB_REGS+(GP * 4) sw sp, UADDR+U_PCB_REGS+(SP * 4) sw s8, UADDR+U_PCB_REGS+(S8 * 4) + mflo v0 + mfhi v1 + mfc0 a0, MIPS_COP_0_STATUS_REG # First arg is the status reg. + mfc0 a1, MIPS_COP_0_CAUSE_REG # Second arg is the cause reg. + mfc0 a2, MIPS_COP_0_BAD_VADDR # Third arg is the fault addr + mfc0 a3, MIPS_COP_0_EXC_PC # Fourth arg is the pc. li sp, KERNELSTACK - STAND_FRAME_SIZE # switch to kernel SP sw ra, UADDR+U_PCB_REGS+(RA * 4) sw v0, UADDR+U_PCB_REGS+(MULLO * 4) sw v1, UADDR+U_PCB_REGS+(MULHI * 4) sw a0, UADDR+U_PCB_REGS+(SR * 4) + sw a1, UADDR+U_PCB_REGS+(CAUSE * 4) + sw a2, UADDR+U_PCB_REGS+(BADVADDR * 4) + sw a3, UADDR+U_PCB_REGS+(PC * 4) #ifdef __GP_SUPPORT__ la gp, _C_LABEL(_gp) # switch to kernel GP #endif - sw a3, UADDR+U_PCB_REGS+(PC * 4) sw a3, STAND_RA_OFFSET(sp) # for debugging .set at and t0, a0, ~MIPS_SR_COP_1_BIT # Turn off the FPU. @@ -342,6 +344,7 @@ NNON_LEAF(mips1_UserGenException, STAND_FRAME_SIZE, ra) /* * Call the exception handler. */ + li a0, UADDR+U_PCB_REGS jal _C_LABEL(trap) mtc0 t0, MIPS_COP_0_STATUS_REG /* @@ -380,73 +383,66 @@ END(mips1_UserGenException) * *---------------------------------------------------------------------------- */ -#define KINTR_REG_OFFSET (STAND_FRAME_SIZE) -#define KINTR_SR_OFFSET (STAND_FRAME_SIZE + KERN_REG_SIZE) -#define KINTR_MULT_LO_OFFSET (STAND_FRAME_SIZE + KERN_REG_SIZE + 4) -#define KINTR_MULT_HI_OFFSET (STAND_FRAME_SIZE + KERN_REG_SIZE + 8) -#define KINTR_GP_OFFSET (STAND_FRAME_SIZE + KERN_REG_SIZE + 12) -#define KINTR_FRAME_SIZE (STAND_FRAME_SIZE + KERN_REG_SIZE + 16) - -NNON_LEAF(mips1_KernIntr, KINTR_FRAME_SIZE, ra) + +NNON_LEAF(mips1_KernIntr, KERN_TRAP_FRAME_SIZE, ra) .set noat - subu sp, sp, KINTR_FRAME_SIZE # allocate stack frame - .mask 0x80000000, (STAND_RA_OFFSET - KINTR_FRAME_SIZE) + subu sp, sp, KERN_TRAP_FRAME_SIZE # allocate stack frame + .mask 0x80000000, (STAND_RA_OFFSET - KERN_TRAP_FRAME_SIZE) /* * Save the relevant kernel registers onto the stack. * We don't need to save s0 - s8 and sp because * the compiler does it for us. */ - sw AT, KINTR_REG_OFFSET + 0(sp) - sw v0, KINTR_REG_OFFSET + 4(sp) - sw v1, KINTR_REG_OFFSET + 8(sp) - sw a0, KINTR_REG_OFFSET + 12(sp) + sw AT, KERN_REG_OFFSET + (AST * 4)(sp) + sw v0, KERN_REG_OFFSET + (V0 * 4)(sp) + sw v1, KERN_REG_OFFSET + (V1 * 4)(sp) + sw a0, KERN_REG_OFFSET + (A0 * 4)(sp) mflo v0 mfhi v1 - sw a1, KINTR_REG_OFFSET + 16(sp) - sw a2, KINTR_REG_OFFSET + 20(sp) - sw a3, KINTR_REG_OFFSET + 24(sp) - sw t0, KINTR_REG_OFFSET + 28(sp) - mfc0 a0, MIPS_COP_0_STATUS_REG # First arg is the status reg. - sw t1, KINTR_REG_OFFSET + 32(sp) - sw t2, KINTR_REG_OFFSET + 36(sp) - sw t3, KINTR_REG_OFFSET + 40(sp) - sw t4, KINTR_REG_OFFSET + 44(sp) - mfc0 a1, MIPS_COP_0_CAUSE_REG # Second arg is the cause reg. - sw t5, KINTR_REG_OFFSET + 48(sp) - sw t6, KINTR_REG_OFFSET + 52(sp) - sw t7, KINTR_REG_OFFSET + 56(sp) - sw t8, KINTR_REG_OFFSET + 60(sp) - mfc0 a2, MIPS_COP_0_EXC_PC # Third arg is the pc. - sw t9, KINTR_REG_OFFSET + 64(sp) - sw ra, KINTR_REG_OFFSET + 68(sp) - sw v0, KINTR_MULT_LO_OFFSET(sp) - sw v1, KINTR_MULT_HI_OFFSET(sp) - sw a0, KINTR_SR_OFFSET(sp) - sw gp, KINTR_GP_OFFSET(sp) -#ifdef __GP_SUPPORT__ - la gp, _C_LABEL(_gp) # switch to kernel GP -#endif + sw a1, KERN_REG_OFFSET + (A1 * 4)(sp) + sw a2, KERN_REG_OFFSET + (A2 * 4)(sp) + sw a3, KERN_REG_OFFSET + (A3 * 4)(sp) + sw t0, KERN_REG_OFFSET + (T0 * 4)(sp) + mfc0 a0, MIPS_COP_0_STATUS_REG + sw t1, KERN_REG_OFFSET + (T1 * 4)(sp) + sw t2, KERN_REG_OFFSET + (T2 * 4)(sp) + sw t3, KERN_REG_OFFSET + (T3 * 4)(sp) + sw t4, KERN_REG_OFFSET + (T4 * 4)(sp) + mfc0 a1, MIPS_COP_0_CAUSE_REG + sw t5, KERN_REG_OFFSET + (T5 * 4)(sp) + sw t6, KERN_REG_OFFSET + (T6 * 4)(sp) + sw t7, KERN_REG_OFFSET + (T7 * 4)(sp) + sw t8, KERN_REG_OFFSET + (T8 * 4)(sp) + sw t9, KERN_REG_OFFSET + (T9 * 4)(sp) + sw ra, KERN_REG_OFFSET + (RA * 4)(sp) + sw v0, KERN_REG_OFFSET + (MULLO * 4)(sp) + sw v1, KERN_REG_OFFSET + (MULHI * 4)(sp) + mfc0 a2, MIPS_COP_0_EXC_PC + sw a0, KERN_REG_OFFSET + (SR * 4)(sp) + sw a1, KERN_REG_OFFSET + (CAUSE * 4)(sp) + sw a2, KERN_REG_OFFSET + (PC * 4)(sp) /* * Call the interrupt handler. */ + addu a0, sp, KERN_REG_OFFSET jal _C_LABEL(interrupt) - sw a2, STAND_RA_OFFSET(sp) # for debugging + sw a2, STAND_RA_OFFSET(sp) /* * Restore registers and return from the interrupt. */ - lw a0, KINTR_SR_OFFSET(sp) - lw t0, KINTR_MULT_LO_OFFSET(sp) - lw t1, KINTR_MULT_HI_OFFSET(sp) + lw a0, KERN_REG_OFFSET + (SR * 4)(sp) + lw t0, KERN_REG_OFFSET + (MULLO * 4)(sp) + lw t1, KERN_REG_OFFSET + (MULHI * 4)(sp) mtc0 a0, MIPS_COP_0_STATUS_REG # Restore the SR, disable intrs mtlo t0 mthi t1 - lw k0, STAND_RA_OFFSET(sp) - lw AT, KINTR_REG_OFFSET + 0(sp) - lw v0, KINTR_REG_OFFSET + 4(sp) + lw k0, KERN_REG_OFFSET + (PC * 4)(sp) + lw AT, KERN_REG_OFFSET + (AST * 4)(sp) + lw v0, KERN_REG_OFFSET + (V0 * 4)(sp) - RESTORE_KERN_REGISTERS(KINTR_REG_OFFSET) + RESTORE_KERN_REGISTERS(KERN_REG_OFFSET) - addu sp, sp, KINTR_FRAME_SIZE + addu sp, sp, KERN_TRAP_FRAME_SIZE j k0 # Now return from the rfe # interrupt. .set at @@ -508,6 +504,7 @@ NNON_LEAF(mips1_UserIntr, STAND_FRAME_SIZE, ra) sw v0, UADDR+U_PCB_REGS+(MULLO * 4) sw v1, UADDR+U_PCB_REGS+(MULHI * 4) sw a0, UADDR+U_PCB_REGS+(SR * 4) + sw a1, UADDR+U_PCB_REGS+(CAUSE * 4) sw a2, UADDR+U_PCB_REGS+(PC * 4) #ifdef __GP_SUPPORT__ la gp, _C_LABEL(_gp) # switch to kernel GP @@ -519,8 +516,9 @@ NNON_LEAF(mips1_UserIntr, STAND_FRAME_SIZE, ra) /* * Call the interrupt handler. */ + li a0, UADDR+U_PCB_REGS jal _C_LABEL(interrupt) - sw a2, STAND_RA_OFFSET(sp) # for debugging + sw a2, STAND_RA_OFFSET(sp) # debugging /* * Restore registers and return from the interrupt. */ diff --git a/sys/arch/pmax/pmax/machdep.c b/sys/arch/pmax/pmax/machdep.c index c104d16a6f5..7a416f179e1 100644 --- a/sys/arch/pmax/pmax/machdep.c +++ b/sys/arch/pmax/pmax/machdep.c @@ -79,7 +79,8 @@ #include <vm/vm_kern.h> #include <machine/cpu.h> -#include <machine/reg.h> +#include <machine/regnum.h> +#include <machine/frame.h> #include <machine/psl.h> #include <machine/pte.h> #include <machine/dc7085cons.h> @@ -347,7 +348,7 @@ mach_init(argc, argv, code, cv) */ start = v; curproc->p_addr = proc0paddr = (struct user *)v; - curproc->p_md.md_regs = proc0paddr->u_pcb.pcb_regs; + curproc->p_md.md_regs = &proc0paddr->u_pcb.pcb_regs; firstaddr = MIPS_KSEG0_TO_PHYS(v); for (i = 0; i < UPAGES; i++) { MachTLBWriteIndexed(i, @@ -364,7 +365,7 @@ mach_init(argc, argv, code, cv) * This could be used for an idle process. */ nullproc.p_addr = (struct user *)v; - nullproc.p_md.md_regs = nullproc.p_addr->u_pcb.pcb_regs; + nullproc.p_md.md_regs = &nullproc.p_addr->u_pcb.pcb_regs; bcopy("nullproc", nullproc.p_comm, sizeof("nullproc")); for (i = 0; i < UPAGES; i++) { nullproc.p_md.md_upte[i] = firstaddr | PG_V | PG_M; @@ -946,10 +947,10 @@ setregs(p, pack, stack, retval) extern struct proc *machFPCurProcPtr; bzero((caddr_t)p->p_md.md_regs, (FSR + 1) * sizeof(int)); - p->p_md.md_regs[SP] = stack; - p->p_md.md_regs[PC] = pack->ep_entry & ~3; - p->p_md.md_regs[T9] = pack->ep_entry & ~3; /* abicall requirement */ - p->p_md.md_regs[PS] = PSL_USERSET; + p->p_md.md_regs->sp = stack; + p->p_md.md_regs->pc = pack->ep_entry & ~3; + p->p_md.md_regs->t9 = pack->ep_entry & ~3; /* abicall requirement */ + p->p_md.md_regs->sr = PSL_USERSET; p->p_md.md_flags & ~MDP_FPUSED; if (machFPCurProcPtr == p) machFPCurProcPtr = (struct proc *)0; @@ -987,9 +988,9 @@ sendsig(catcher, sig, mask, code, type, val) int type; union sigval val; { - register struct proc *p = curproc; - register struct sigframe *fp; - register int *regs; + struct proc *p = curproc; + struct sigframe *fp; + struct trap_frame *regs; register struct sigacts *psp = p->p_sigacts; int oonstack, fsize; struct sigcontext ksc; @@ -1014,7 +1015,7 @@ sendsig(catcher, sig, mask, code, type, val) psp->ps_sigstk.ss_size - fsize); psp->ps_sigstk.ss_flags |= SS_ONSTACK; } else - fp = (struct sigframe *)(regs[SP] - fsize); + fp = (struct sigframe *)(regs->sp - fsize); if ((unsigned)fp <= USRSTACK - ctob(p->p_vmspace->vm_ssize)) (void)grow(p, (unsigned)fp); #ifdef DEBUG @@ -1028,11 +1029,11 @@ sendsig(catcher, sig, mask, code, type, val) */ ksc.sc_onstack = oonstack; ksc.sc_mask = mask; - ksc.sc_pc = regs[PC]; - ksc.mullo = regs [MULLO]; - ksc.mulhi = regs [MULHI]; + ksc.sc_pc = regs->pc; + ksc.mullo = regs->mullo; + ksc.mulhi = regs->mulhi; ksc.sc_regs[ZERO] = 0xACEDBADE; /* magic number */ - bcopy((caddr_t)®s[1], (caddr_t)&ksc.sc_regs[1], + bcopy((caddr_t)®s->ast, (caddr_t)&ksc.sc_regs[1], sizeof(ksc.sc_regs) - sizeof(int)); ksc.sc_fpused = p->p_md.md_flags & MDP_FPUSED; if (ksc.sc_fpused) { @@ -1041,7 +1042,7 @@ sendsig(catcher, sig, mask, code, type, val) /* if FPU has current state, save it first */ if (p == machFPCurProcPtr) MachSaveCurFPState(p); - bcopy((caddr_t)&p->p_md.md_regs[F0], (caddr_t)ksc.sc_fpregs, + bcopy((caddr_t)&p->p_md.md_regs->f0, (caddr_t)ksc.sc_fpregs, sizeof(ksc.sc_fpregs)); } @@ -1070,18 +1071,18 @@ bail: /* * Build the argument list for the signal handler. */ - regs[A0] = sig; - regs[A1] = (psp->ps_siginfo & sigmask(sig)) ? (int)&fp->sf_si : NULL; - regs[A2] = (int)&fp->sf_sc; - regs[A3] = (int)catcher; - - regs[PC] = (int)catcher; - regs[T9] = (int)catcher; - regs[SP] = (int)fp; + regs->a0 = sig; + regs->a1 = (psp->ps_siginfo & sigmask(sig)) ? (int)&fp->sf_si : NULL; + regs->a2 = (int)&fp->sf_sc; + regs->a3 = (int)catcher; + + regs->pc = (int)catcher; + regs->t9 = (int)catcher; + regs->sp = (int)fp; /* * Signal trampoline code is at base of user stack. */ - regs[RA] = (int)PS_STRINGS - (esigcode - sigcode); + regs->ra = (int)PS_STRINGS - (esigcode - sigcode); #ifdef DEBUG if ((sigdebug & SDB_FOLLOW) || (sigdebug & SDB_KSTACK) && p->p_pid == sigpid) @@ -1110,8 +1111,8 @@ sys_sigreturn(p, v, retval) struct sys_sigreturn_args /* { syscallarg(struct sigcontext *) sigcntxp; } */ *uap = v; - register struct sigcontext *scp; - register int *regs; + struct sigcontext *scp; + struct trap_frame *regs; struct sigcontext ksc; int error; @@ -1131,7 +1132,7 @@ sys_sigreturn(p, v, retval) if (!(sigdebug & SDB_FOLLOW)) printf("sigreturn: pid %d, scp %x\n", p->p_pid, scp); printf(" old sp %x ra %x pc %x\n", - regs[SP], regs[RA], regs[PC]); + regs->sp, regs->ra, regs->pc); printf(" new sp %x ra %x pc %x err %d z %x\n", ksc.sc_regs[SP], ksc.sc_regs[RA], ksc.sc_regs[PC], error, ksc.sc_regs[ZERO]); @@ -1147,13 +1148,13 @@ sys_sigreturn(p, v, retval) else p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; p->p_sigmask = scp->sc_mask &~ sigcantmask; - regs[PC] = scp->sc_pc; - regs[MULLO] = scp->mullo; - regs[MULHI] = scp->mulhi; - bcopy((caddr_t)&scp->sc_regs[1], (caddr_t)®s[1], + regs->pc = scp->sc_pc; + regs->mullo = scp->mullo; + regs->mulhi = scp->mulhi; + bcopy((caddr_t)&scp->sc_regs[1], (caddr_t)®s->ast, sizeof(scp->sc_regs) - sizeof(int)); if (scp->sc_fpused) - bcopy((caddr_t)scp->sc_fpregs, (caddr_t)&p->p_md.md_regs[F0], + bcopy((caddr_t)scp->sc_fpregs, (caddr_t)&p->p_md.md_regs->f0, sizeof(scp->sc_fpregs)); return (EJUSTRETURN); } diff --git a/sys/arch/pmax/pmax/process_machdep.c b/sys/arch/pmax/pmax/process_machdep.c index 7c6b5cd1de6..a62e98f656a 100644 --- a/sys/arch/pmax/pmax/process_machdep.c +++ b/sys/arch/pmax/pmax/process_machdep.c @@ -113,7 +113,7 @@ process_set_pc(p, addr) struct proc *p; caddr_t addr; { - p->p_md.md_regs[PC] = (int)addr; + p->p_md.md_regs->pc = (int)addr; return (0); } diff --git a/sys/arch/pmax/pmax/trap.c b/sys/arch/pmax/pmax/trap.c index 803b7107945..ad431289bb0 100644 --- a/sys/arch/pmax/pmax/trap.c +++ b/sys/arch/pmax/pmax/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.14 1998/05/18 00:28:31 millert Exp $ */ +/* $OpenBSD: trap.c,v 1.15 1998/09/15 10:53:55 pefo Exp $ */ /* $NetBSD: trap.c,v 1.50 1996/10/13 21:37:49 jonathan Exp $ */ /* @@ -65,7 +65,8 @@ #include <machine/trap.h> #include <machine/psl.h> -#include <machine/reg.h> +#include <machine/regnum.h> +#include <machine/frame.h> #include <machine/cpu.h> #include <machine/locore.h> #include <machine/pte.h> @@ -331,7 +332,7 @@ void cpu_getregs __P((int *regs)); /* * Other forward declarations. */ -u_int MachEmulateBranch __P((unsigned *regsPtr, +u_int MachEmulateBranch __P((struct trap_frame *, unsigned instPC, unsigned fpcCSR, int allowNonBranch)); @@ -345,8 +346,8 @@ extern int splhigh __P((void)); extern void MachSwitchFPState __P((struct proc *from, struct user *to)); /* only called by locore */ -extern u_int trap __P((u_int status, u_int cause, u_int vaddr, u_int pc, - int args)); +extern u_int trap __P((struct trap_frame *)); +void child_return __P((struct proc *p)); #ifdef DEBUG /* stack trace code, also useful to DDB one day */ @@ -400,11 +401,8 @@ typedef enum { * ((struct pcb *)UADDR)->pcb_onfault is set, otherwise, return old pc. */ u_int -trap(statusReg, causeReg, vadr, pc, args) - unsigned statusReg; /* status register at time of the exception */ - unsigned causeReg; /* cause register at time of exception */ - unsigned vadr; /* address (if any) the fault occured on */ - unsigned pc; /* program counter where to continue */ +trap(trapframe) + struct trap_frame *trapframe; { register int type, i; unsigned ucode = 0; @@ -416,21 +414,21 @@ trap(statusReg, causeReg, vadr, pc, args) union sigval sv; #ifdef DEBUG - trp->status = statusReg; - trp->cause = causeReg; - trp->vadr = vadr; - trp->pc = pc; - trp->ra = !USERMODE(statusReg) ? ((int *)&args)[19] : - p->p_md.md_regs[RA]; - trp->sp = (int)&args; + trp->status = trapframe->sr; + trp->cause = trapframe->cause; + trp->vadr = trapframe->badvaddr; + trp->pc = trapframe->pc; + trp->ra = !USERMODE(trapframe->sr) ? trapframe->pc : + p->p_md.md_regs->ra; + trp->sp = (int)trapframe; trp->code = 0; if (++trp == &trapdebug[TRAPSIZE]) trp = trapdebug; #endif cnt.v_trap++; - type = (causeReg & MIPS1_CR_EXC_CODE) >> MIPS_CR_EXC_CODE_SHIFT; - if (USERMODE(statusReg)) { + type = (trapframe->cause & MIPS1_CR_EXC_CODE) >> MIPS_CR_EXC_CODE_SHIFT; + if (USERMODE(trapframe->sr)) { type |= T_USER; sticks = p->p_sticks; } @@ -439,32 +437,32 @@ trap(statusReg, causeReg, vadr, pc, args) * Enable hardware interrupts if they were on before. * We only respond to software interrupts when returning to user mode. */ - if (statusReg & MIPS_SR_INT_ENA_PREV) - splx((statusReg & MIPS_HARD_INT_MASK) | MIPS_SR_INT_IE); + if (trapframe->sr & MIPS_SR_INT_ENA_PREV) + splx((trapframe->sr & MIPS_HARD_INT_MASK) | MIPS_SR_INT_IE); switch (type) { case T_TLB_MOD: /* check for kernel address */ - if ((int)vadr < 0) { + if ((int)trapframe->badvaddr < 0) { register pt_entry_t *pte; register unsigned entry; register vm_offset_t pa; - pte = kvtopte(vadr); + pte = kvtopte(trapframe->badvaddr); entry = pte->pt_entry; #ifdef DIAGNOSTIC if (!(entry & PG_V) || (entry & PG_M)) panic("trap: ktlbmod: invalid pte"); #endif - if (PAGE_IS_RDONLY(entry, vadr)) { + if (PAGE_IS_RDONLY(entry, trapframe->badvaddr)) { /* write to read only page in the kernel */ ftype = VM_PROT_WRITE; goto kernel_fault; } entry |= PG_M; pte->pt_entry = entry; - vadr &= ~PGOFSET; - MachTLBUpdate(vadr, entry); + trapframe->badvaddr &= ~PGOFSET; + MachTLBUpdate(trapframe->badvaddr, entry); pa = PTE_TO_PADDR(entry); #ifdef ATTR pmap_attributes[atop(pa)] |= PMAP_ATTR_MOD; @@ -473,7 +471,7 @@ trap(statusReg, causeReg, vadr, pc, args) panic("trap: ktlbmod: unmanaged page"); PHYS_TO_VM_PAGE(pa)->flags &= ~PG_CLEAN; #endif - return (pc); + return (trapframe->pc); } /* FALLTHROUGH */ @@ -484,25 +482,25 @@ trap(statusReg, causeReg, vadr, pc, args) register vm_offset_t pa; pmap_t pmap = &p->p_vmspace->vm_pmap; - if (!(pte = pmap_segmap(pmap, vadr))) + if (!(pte = pmap_segmap(pmap, trapframe->badvaddr))) panic("trap: utlbmod: invalid segmap"); - pte += (vadr >> PGSHIFT) & (NPTEPG - 1); + pte += (trapframe->badvaddr >> PGSHIFT) & (NPTEPG - 1); entry = pte->pt_entry; #ifdef DIAGNOSTIC if (!(entry & PG_V) || (entry & PG_M)) { panic("trap: utlbmod: invalid pte"); } #endif - if (PAGE_IS_RDONLY(entry, vadr)) { + if (PAGE_IS_RDONLY(entry, trapframe->badvaddr)) { /* write to read only page */ ftype = VM_PROT_WRITE; goto dofault; } entry |= PG_M; pte->pt_entry = entry; - vadr = (vadr & ~PGOFSET) | + trapframe->badvaddr = (trapframe->badvaddr & ~PGOFSET) | (pmap->pm_tlbpid << MIPS_TLB_PID_SHIFT); - MachTLBUpdate(vadr, entry); + MachTLBUpdate(trapframe->badvaddr, entry); pa = PTE_TO_PADDR(entry); #ifdef ATTR pmap_attributes[atop(pa)] |= PMAP_ATTR_MOD; @@ -512,8 +510,8 @@ trap(statusReg, causeReg, vadr, pc, args) } PHYS_TO_VM_PAGE(pa)->flags &= ~PG_CLEAN; #endif - if (!USERMODE(statusReg)) - return (pc); + if (!USERMODE(trapframe->sr)) + return (trapframe->pc); goto out; } @@ -521,16 +519,16 @@ trap(statusReg, causeReg, vadr, pc, args) case T_TLB_ST_MISS: ftype = (type == T_TLB_ST_MISS) ? VM_PROT_WRITE : VM_PROT_READ; /* check for kernel address */ - if ((int)vadr < 0) { + if ((int)trapframe->badvaddr < 0) { register vm_offset_t va; int rv; kernel_fault: kernelfaults++; - va = trunc_page((vm_offset_t)vadr); + va = trunc_page((vm_offset_t)trapframe->badvaddr); rv = vm_fault(kernel_map, va, ftype, FALSE); if (rv == KERN_SUCCESS) - return (pc); + return (trapframe->pc); if ((i = ((struct pcb *)UADDR)->pcb_onfault) != 0) { ((struct pcb *)UADDR)->pcb_onfault = 0; return (onfault_table[i]); @@ -563,11 +561,11 @@ trap(statusReg, causeReg, vadr, pc, args) vm = p->p_vmspace; map = &vm->vm_map; - va = trunc_page((vm_offset_t)vadr); + va = trunc_page((vm_offset_t)trapframe->badvaddr); rv = vm_fault(map, va, ftype, FALSE); #ifdef VMFAULT_TRACE printf("vm_fault(%x (pmap %x), %x (%x), %x, %d) -> %x at pc %x\n", - map, &vm->vm_pmap, va, vadr, ftype, FALSE, rv, pc); + map, &vm->vm_pmap, va, trapframe->badvaddr, ftype, FALSE, rv, trapframe->pc); #endif /* * If this was a stack access we keep track of the maximum @@ -587,11 +585,11 @@ trap(statusReg, causeReg, vadr, pc, args) rv = KERN_INVALID_ADDRESS; } if (rv == KERN_SUCCESS) { - if (!USERMODE(statusReg)) - return (pc); + if (!USERMODE(trapframe->sr)) + return (trapframe->pc); goto out; } - if (!USERMODE(statusReg)) { + if (!USERMODE(trapframe->sr)) { if ((i = ((struct pcb *)UADDR)->pcb_onfault) != 0) { ((struct pcb *)UADDR)->pcb_onfault = 0; return (onfault_table[i]); @@ -619,8 +617,8 @@ trap(statusReg, causeReg, vadr, pc, args) case T_SYSCALL+T_USER: { - register int *locr0 = p->p_md.md_regs; - register struct sysent *callp; + struct trap_frame *locr0 = p->p_md.md_regs; + struct sysent *callp; unsigned int code; int numsys; struct args { @@ -630,35 +628,35 @@ trap(statusReg, causeReg, vadr, pc, args) cnt.v_syscall++; /* compute next PC after syscall instruction */ - if ((int)causeReg < 0) - locr0[PC] = MachEmulateBranch(locr0, pc, 0, 0); + if ((int)trapframe->cause < 0) + locr0->pc = MachEmulateBranch(locr0, trapframe->pc, 0, 0); else - locr0[PC] += 4; + locr0->pc += 4; callp = p->p_emul->e_sysent; numsys = p->p_emul->e_nsysent; - code = locr0[V0]; + code = locr0->v0; switch (code) { case SYS_syscall: /* * Code is first argument, followed by actual args. */ - code = locr0[A0]; + code = locr0->a0; if (code >= numsys) callp += p->p_emul->e_nosys; /* (illegal) */ else callp += code; i = callp->sy_argsize / sizeof(int); - args.i[0] = locr0[A1]; - args.i[1] = locr0[A2]; - args.i[2] = locr0[A3]; + args.i[0] = locr0->a1; + args.i[1] = locr0->a2; + args.i[2] = locr0->a3; if (i > 3) { - i = copyin((caddr_t)(locr0[SP] + + i = copyin((caddr_t)(locr0->sp + 4 * sizeof(int)), (caddr_t)&args.i[3], (u_int)(i - 3) * sizeof(int)); if (i) { - locr0[V0] = i; - locr0[A3] = 1; + locr0->v0 = i; + locr0->a3 = 1; #ifdef SYSCALL_DEBUG scdebug_call(p, code, args.i); #endif @@ -678,22 +676,27 @@ trap(statusReg, causeReg, vadr, pc, args) * Like syscall, but code is a quad, so as to maintain * quad alignment for the rest of the arguments. */ - code = locr0[A0 + _QUAD_LOWWORD]; + if(_QUAD_LOWWORD == 0) { + code = locr0->a0; + } + else { + code = locr0->a1; + } if (code >= numsys) callp += p->p_emul->e_nosys; /* (illegal) */ else callp += code; i = callp->sy_argsize / sizeof(int); - args.i[0] = locr0[A2]; - args.i[1] = locr0[A3]; + args.i[0] = locr0->a2; + args.i[1] = locr0->a3; if (i > 2) { - i = copyin((caddr_t)(locr0[SP] + + i = copyin((caddr_t)(locr0->sp + 4 * sizeof(int)), (caddr_t)&args.i[2], (u_int)(i - 2) * sizeof(int)); if (i) { - locr0[V0] = i; - locr0[A3] = 1; + locr0->v0 = i; + locr0->a3 = 1; #ifdef SYSCALL_DEBUG scdebug_call(p, code, args.i); #endif @@ -714,18 +717,18 @@ trap(statusReg, causeReg, vadr, pc, args) else callp += code; i = callp->sy_narg; - args.i[0] = locr0[A0]; - args.i[1] = locr0[A1]; - args.i[2] = locr0[A2]; - args.i[3] = locr0[A3]; + args.i[0] = locr0->a0; + args.i[1] = locr0->a1; + args.i[2] = locr0->a2; + args.i[3] = locr0->a3; if (i > 4) { - i = copyin((caddr_t)(locr0[SP] + + i = copyin((caddr_t)(locr0->sp + 4 * sizeof(int)), (caddr_t)&args.i[4], (u_int)(i - 4) * sizeof(int)); if (i) { - locr0[V0] = i; - locr0[A3] = 1; + locr0->v0 = i; + locr0->a3 = 1; #ifdef SYSCALL_DEBUG scdebug_call(p, code, args.i); #endif @@ -747,7 +750,7 @@ trap(statusReg, causeReg, vadr, pc, args) ktrsyscall(p->p_tracep, code, callp->sy_argsize, args.i); #endif rval[0] = 0; - rval[1] = locr0[V1]; + rval[1] = locr0->v1; #ifdef DEBUG if (trp == trapdebug) trapdebug[TRAPSIZE - 1].code = code; @@ -764,11 +767,11 @@ trap(statusReg, causeReg, vadr, pc, args) #ifdef DEBUG { int s; s = splhigh(); - trp->status = statusReg; - trp->cause = causeReg; - trp->vadr = locr0[SP]; - trp->pc = locr0[PC]; - trp->ra = locr0[RA]; + trp->status = trapframe->sr; + trp->cause = trapframe->cause; + trp->vadr = locr0->sp; + trp->pc = locr0->pc; + trp->ra = locr0->ra; /*trp->sp = (int)&args;*/ trp->code = -code; if (++trp == &trapdebug[TRAPSIZE]) @@ -778,21 +781,21 @@ trap(statusReg, causeReg, vadr, pc, args) #endif switch (i) { case 0: - locr0[V0] = rval[0]; - locr0[V1] = rval[1]; - locr0[A3] = 0; + locr0->v0 = rval[0]; + locr0->v1 = rval[1]; + locr0->a3 = 0; break; case ERESTART: - locr0[PC] = pc; + locr0->pc = trapframe->pc; break; case EJUSTRETURN: break; /* nothing to do */ default: - locr0[V0] = i; - locr0[A3] = 1; + locr0->v0 = i; + locr0->a3 = 1; } /* @@ -817,15 +820,15 @@ trap(statusReg, causeReg, vadr, pc, args) register unsigned va, instr; /* compute address of break instruction */ - va = pc; - if ((int)causeReg < 0) + va = trapframe->pc; + if ((int)trapframe->cause < 0) va += 4; /* read break instruction */ instr = fuiword((caddr_t)va); #if 0 printf("trap: %s (%d) breakpoint %x at %x: (adr %x ins %x)\n", - p->p_comm, p->p_pid, instr, pc, + p->p_comm, p->p_pid, instr, trapframe->pc, p->p_md.md_ss_addr, p->p_md.md_ss_instr); /* XXX */ #endif #ifdef KADB @@ -870,7 +873,7 @@ trap(statusReg, causeReg, vadr, pc, args) break; case T_COP_UNUSABLE+T_USER: - if ((causeReg & MIPS_CR_COP_ERR) != 0x10000000) { + if ((trapframe->cause & MIPS_CR_COP_ERR) != 0x10000000) { i = SIGILL; /* only FPU instructions allowed */ typ = ILL_ILLOPC; break; @@ -878,7 +881,7 @@ trap(statusReg, causeReg, vadr, pc, args) MachSwitchFPState(machFPCurProcPtr, (struct user*)p->p_md.md_regs); machFPCurProcPtr = p; - p->p_md.md_regs[PS] |= MIPS_SR_COP_1_BIT; + p->p_md.md_regs->sr |= MIPS_SR_COP_1_BIT; p->p_md.md_flags |= MDP_FPUSED; goto out; @@ -887,12 +890,12 @@ trap(statusReg, causeReg, vadr, pc, args) trapDump("fpintr"); #else printf("FPU Trap: PC %x CR %x SR %x\n", - pc, causeReg, statusReg); + trapframe->pc, trapframe->cause, trapframe->sr); goto err; #endif case T_FPE+T_USER: - MachFPTrap(statusReg, causeReg, pc); + MachFPTrap(trapframe->sr, trapframe->cause, trapframe->pc); goto out; case T_OVFLOW+T_USER: @@ -915,36 +918,36 @@ trap(statusReg, causeReg, vadr, pc, args) { extern struct pcb kdbpcb; - if (USERMODE(statusReg)) + if (USERMODE(trapframe->sr)) kdbpcb = p->p_addr->u_pcb; else { - kdbpcb.pcb_regs[ZERO] = 0; - kdbpcb.pcb_regs[AST] = ((int *)&args)[2]; - kdbpcb.pcb_regs[V0] = ((int *)&args)[3]; - kdbpcb.pcb_regs[V1] = ((int *)&args)[4]; - kdbpcb.pcb_regs[A0] = ((int *)&args)[5]; - kdbpcb.pcb_regs[A1] = ((int *)&args)[6]; - kdbpcb.pcb_regs[A2] = ((int *)&args)[7]; - kdbpcb.pcb_regs[A3] = ((int *)&args)[8]; - kdbpcb.pcb_regs[T0] = ((int *)&args)[9]; - kdbpcb.pcb_regs[T1] = ((int *)&args)[10]; - kdbpcb.pcb_regs[T2] = ((int *)&args)[11]; - kdbpcb.pcb_regs[T3] = ((int *)&args)[12]; - kdbpcb.pcb_regs[T4] = ((int *)&args)[13]; - kdbpcb.pcb_regs[T5] = ((int *)&args)[14]; - kdbpcb.pcb_regs[T6] = ((int *)&args)[15]; - kdbpcb.pcb_regs[T7] = ((int *)&args)[16]; - kdbpcb.pcb_regs[T8] = ((int *)&args)[17]; - kdbpcb.pcb_regs[T9] = ((int *)&args)[18]; - kdbpcb.pcb_regs[RA] = ((int *)&args)[19]; - kdbpcb.pcb_regs[MULLO] = ((int *)&args)[21]; - kdbpcb.pcb_regs[MULHI] = ((int *)&args)[22]; - kdbpcb.pcb_regs[PC] = pc; - kdbpcb.pcb_regs[SR] = statusReg; - bzero((caddr_t)&kdbpcb.pcb_regs[F0], 33 * sizeof(int)); + kdbpcb.pcb_regs->zero = 0; + kdbpcb.pcb_regs->ast = ((int *)&args)[2]; + kdbpcb.pcb_regs->v0 = ((int *)&args)[3]; + kdbpcb.pcb_regs->v1 = ((int *)&args)[4]; + kdbpcb.pcb_regs->a0 = ((int *)&args)[5]; + kdbpcb.pcb_regs->a1 = ((int *)&args)[6]; + kdbpcb.pcb_regs->a2 = ((int *)&args)[7]; + kdbpcb.pcb_regs->a3 = ((int *)&args)[8]; + kdbpcb.pcb_regs->t0 = ((int *)&args)[9]; + kdbpcb.pcb_regs->t1 = ((int *)&args)[10]; + kdbpcb.pcb_regs->t2 = ((int *)&args)[11]; + kdbpcb.pcb_regs->t3 = ((int *)&args)[12]; + kdbpcb.pcb_regs->t4 = ((int *)&args)[13]; + kdbpcb.pcb_regs->t5 = ((int *)&args)[14]; + kdbpcb.pcb_regs->t6 = ((int *)&args)[15]; + kdbpcb.pcb_regs->t7 = ((int *)&args)[16]; + kdbpcb.pcb_regs->t8 = ((int *)&args)[17]; + kdbpcb.pcb_regs->t9 = ((int *)&args)[18]; + kdbpcb.pcb_regs->ra = ((int *)&args)[19]; + kdbpcb.pcb_regs->mullo = ((int *)&args)[21]; + kdbpcb.pcb_regs->mulhi = ((int *)&args)[22]; + kdbpcb.pcb_regs->pc = trapframe->pc; + kdbpcb.pcb_regs->sr = trapframe->sr; + bzero((caddr_t)&kdbpcb.pcb_regs->f0, 33 * sizeof(int)); } - if (kdb(causeReg, vadr, p, !USERMODE(statusReg))) - return (kdbpcb.pcb_regs[PC]); + if (kdb(trapframe->cause, trapframe->badvaddr, p, !USERMODE(trapframe->sr))) + return (kdbpcb.pcb_regs->pc); } #else #ifdef DEBUG @@ -954,10 +957,10 @@ trap(statusReg, causeReg, vadr, pc, args) #endif panic("trap"); } - p->p_md.md_regs [PC] = pc; - p->p_md.md_regs [CAUSE] = causeReg; - p->p_md.md_regs [BADVADDR] = vadr; - sv.sival_int = vadr; + p->p_md.md_regs->pc = trapframe->pc; + p->p_md.md_regs->cause = trapframe->cause; + p->p_md.md_regs->badvaddr = trapframe->badvaddr; + sv.sival_int = trapframe->badvaddr; trapsignal(p, i, ucode, typ, sv); out: /* @@ -994,11 +997,64 @@ out: if (p->p_flag & P_PROFIL) { extern int psratio; - addupc_task(p, pc, (int)(p->p_sticks - sticks) * psratio); + addupc_task(p, trapframe->pc, (int)(p->p_sticks - sticks) * psratio); } curpriority = p->p_priority; - return (pc); + return (trapframe->pc); +} + +void +child_return(p) + struct proc *p; +{ + struct trap_frame *trapframe; + int i; + + trapframe = p->p_md.md_regs; + trapframe->v0 = 0; + trapframe->v1 = 1; + trapframe->a3 = 0; + + /* take pending signals */ + while ((i = CURSIG(p)) != 0) + postsig(i); + p->p_priority = p->p_usrpri; + astpending = 0; + if (want_resched) { + int s; + + /* + * Since we are curproc, clock will normally just change + * our priority without moving us from one queue to another + * (since the running process is not on a queue.) + * If that happened after we put ourselves on the run queue + * but before we switched, we might not be on the queue + * indicated by our priority. + */ + s = splstatclock(); + setrunqueue(p); + p->p_stats->p_ru.ru_nivcsw++; + mi_switch(); + splx(s); + while ((i = CURSIG(p)) != 0) + postsig(i); + } + +#if 0 /* Need sticks */ + if (p->p_flag & P_PROFIL) { + extern int psratio; + + addupc_task(p, trapframe->pc, (int)(p->p_sticks - sticks) * psratio); + } +#endif + + curpriority = p->p_priority; + +#ifdef KTRACE + if (KTRPOINT(p, KTR_SYSRET)) + ktrsysret(p->p_tracep, SYS_fork, 0, 0); +#endif } /* @@ -1007,19 +1063,17 @@ out: * Note: curproc might be NULL. */ void -interrupt(statusReg, causeReg, pc /* XXX what, args */ ) - unsigned statusReg; /* status register at time of the exception */ - unsigned causeReg; /* cause register at time of exception */ - unsigned pc; /* program counter where to continue */ +interrupt(trapframe) + struct trap_frame *trapframe; { register unsigned mask; /*struct clockframe cf;*/ #ifdef DEBUG - trp->status = statusReg; - trp->cause = causeReg; + trp->status = trapframe->sr; + trp->cause = trapframe->cause; trp->vadr = 0; - trp->pc = pc; + trp->pc = trapframe->pc; trp->ra = 0; trp->sp = /* (int)&args */ 0; /* XXX pass args in */ trp->code = 0; @@ -1028,26 +1082,26 @@ interrupt(statusReg, causeReg, pc /* XXX what, args */ ) #endif cnt.v_intr++; - mask = causeReg & statusReg; /* pending interrupts & enable mask */ + mask = trapframe->cause & trapframe->sr; /* pending interrupts & enable mask */ if (mips_hardware_intr) - splx((*mips_hardware_intr)(mask, pc, statusReg, causeReg)); + splx((*mips_hardware_intr)(mask, trapframe->pc, trapframe->sr, trapframe->cause)); if (mask & MIPS_INT_MASK_5) { intrcnt[FPU_INTR]++; - if (!USERMODE(statusReg)) { + if (!USERMODE(trapframe->sr)) { #ifdef DEBUG trapDump("fpintr"); #else printf("FPU interrupt: PC %x CR %x SR %x\n", - pc, causeReg, statusReg); + trapframe->pc, trapframe->cause, trapframe->sr); #endif } else - MachFPInterrupt(statusReg, causeReg, pc); + MachFPInterrupt(trapframe->sr, trapframe->cause, trapframe->pc); } /* process network interrupt if we trapped or will very soon */ /* XXX fixme: operator precedence botch? */ if ((mask & MIPS_SOFT_INT_MASK_1) || - netisr && (statusReg & MIPS_SOFT_INT_MASK_1)) { + netisr && (trapframe->sr & MIPS_SOFT_INT_MASK_1)) { clearsoftnet(); cnt.v_soft++; intrcnt[SOFTNET_INTR]++; @@ -1191,8 +1245,8 @@ GetBranchDest(InstPtr) * Return the resulting PC as if the branch was executed. */ unsigned -MachEmulateBranch(regsPtr, instPC, fpcCSR, allowNonBranch) - unsigned *regsPtr; +MachEmulateBranch(frame, instPC, fpcCSR, allowNonBranch) + struct trap_frame *frame; unsigned instPC; unsigned fpcCSR; int allowNonBranch; @@ -1200,6 +1254,7 @@ MachEmulateBranch(regsPtr, instPC, fpcCSR, allowNonBranch) InstFmt inst; unsigned retAddr; int condition; + u_int *regsPtr = (u_int *)frame; inst.word = (instPC < MIPS_KSEG0_START) ? fuiword((caddr_t)instPC) : *(unsigned*)instPC; @@ -1337,13 +1392,13 @@ int cpu_singlestep(p) register struct proc *p; { - register unsigned va; - register int *locr0 = p->p_md.md_regs; + unsigned va; + struct trap_frame *locr0 = p->p_md.md_regs; int i; #if notanymore /* compute next address after current location */ - va = MachEmulateBranch(locr0, locr0[PC], locr0[FSR], 1); + va = MachEmulateBranch(locr0, locr0->pc, locr0[FSR], 1); if (p->p_md.md_ss_addr || p->p_md.md_ss_addr == va || !useracc((caddr_t)va, 4, B_READ)) { printf("SS %s (%d): breakpoint already set at %x (va %x)\n", @@ -1380,7 +1435,7 @@ cpu_singlestep(p) iov.iov_len = sizeof(int); uio.uio_iov = &iov; uio.uio_iovcnt = 1; - uio.uio_offset = (off_t)locr0[PC]; + uio.uio_offset = (off_t)locr0->pc; uio.uio_resid = sizeof(int); uio.uio_segflg = UIO_SYSSPACE; uio.uio_rw = UIO_READ; @@ -1389,10 +1444,10 @@ cpu_singlestep(p) /* compute next address after current location */ if(curinstr != 0) { - va = MachEmulateBranch(locr0, locr0[PC], locr0[FSR], curinstr); + va = MachEmulateBranch(locr0, locr0->pc, locr0->fsr, curinstr); } else { - va = locr0[PC] + 4; + va = locr0->pc + 4; } if (p->p_md.md_ss_addr) { printf("SS %s (%d): breakpoint already set at %x (va %x)\n", @@ -1435,7 +1490,7 @@ cpu_singlestep(p) #if 0 printf("SS %s (%d): breakpoint set at %x: %x (pc %x) br %x\n", p->p_comm, p->p_pid, p->p_md.md_ss_addr, - p->p_md.md_ss_instr, locr0[PC], fuword((caddr_t)va)); /* XXX */ + p->p_md.md_ss_instr, locr0->pc, fuword((caddr_t)va)); /* XXX */ #endif return (0); } @@ -1457,7 +1512,7 @@ kdbpeek(addr) /* forward */ char *fn_name(unsigned addr); -void stacktrace_subr __P((int, int, int, int, void (*)(const char*, ...))); +void stacktrace_subr __P((int, int, int, int, int (*)(const char*, ...))); /* * Print a stack backtrace. @@ -1479,7 +1534,7 @@ logstacktrace(a0, a1, a2, a3) void stacktrace_subr(a0, a1, a2, a3, printfn) int a0, a1, a2, a3; - void (*printfn) __P((const char*, ...)); + int (*printfn) __P((const char*, ...)); { unsigned pc, sp, fp, ra, va, subr; unsigned instr, mask; diff --git a/sys/arch/pmax/pmax/vm_machdep.c b/sys/arch/pmax/pmax/vm_machdep.c index 079b33bc47f..d9a15f4e1c2 100644 --- a/sys/arch/pmax/pmax/vm_machdep.c +++ b/sys/arch/pmax/pmax/vm_machdep.c @@ -69,70 +69,50 @@ extern int switch_exit __P((void)); /* XXX never returns? */ extern vm_offset_t kvtophys __P((vm_offset_t kva)); /* XXX */ +extern void child_return __P((struct proc *)); +extern void proc_trampoline __P((void)); + /* * Finish a fork operation, with process p2 nearly set up. - * Copy and update the kernel stack and pcb, making the child - * ready to run, and marking it so that it can return differently - * than the parent. Returns 1 in the child process, 0 in the parent. - * We currently double-map the user area so that the stack is at the same - * address in each process; in the future we will probably relocate - * the frame pointers on the stack after copying. */ -int +void cpu_fork(p1, p2) - register struct proc *p1, *p2; + struct proc *p1, *p2; { - register struct user *up = p2->p_addr; - register pt_entry_t *pte; - register int i; + pt_entry_t *pte; + struct pcb *pcb; + int i; extern struct proc *machFPCurProcPtr; - p2->p_md.md_regs = up->u_pcb.pcb_regs; + p2->p_md.md_regs = &p2->p_addr->u_pcb.pcb_regs; p2->p_md.md_flags = p1->p_md.md_flags & MDP_FPUSED; - /* - * Cache the PTEs for the user area in the machine dependent - * part of the proc struct so cpu_switch() can quickly map in - * the user struct and kernel stack. Note: if the virtual address - * translation changes (e.g. swapout) we have to update this. - */ - pte = kvtopte(up); + pte = kvtopte(p2->p_addr); for (i = 0; i < UPAGES; i++) { p2->p_md.md_upte[i] = pte->pt_entry & ~PG_G; pte++; } - /* - * Copy floating point state from the FP chip if this process - * has state stored there. - */ if (p1 == machFPCurProcPtr) MachSaveCurFPState(p1); - /* - * Copy pcb and stack from proc p1 to p2. - * We do this as cheaply as possible, copying only the active - * part of the stack. The stack and pcb need to agree; - */ + pcb = &p2->p_addr->u_pcb; p2->p_addr->u_pcb = p1->p_addr->u_pcb; - /* cache segtab for ULTBMiss() */ - p2->p_addr->u_pcb.pcb_segtab = (void *)p2->p_vmspace->vm_map.pmap->pm_segtab; - /* - * Arrange for a non-local goto when the new process - * is started, to resume here, returning nonzero from setjmp. - */ -#ifdef DIAGNOSTIC - if (p1 != curproc) - panic("cpu_fork: curproc"); -#endif - if (copykstack(up)) { - /* - * Return 1 in child. - */ - return (1); - } - return (0); + pcb->pcb_segtab = (void *)p2->p_vmspace->vm_map.pmap->pm_segtab; + + pcb->pcb_context.val[10] = (int)proc_trampoline; + pcb->pcb_context.val[8] = (int)(KERNELSTACK - 24); + pcb->pcb_context.val[0] = (int)child_return; + pcb->pcb_context.val[1] = (int)p2; +} + +void +cpu_set_kpc(p, pc) + struct proc *p; + void (*pc) __P((struct proc *)); +{ + p->p_addr->u_pcb.pcb_context.val[0] = (int)pc; } /* |