summaryrefslogtreecommitdiff
path: root/sys/arch/pmax
diff options
context:
space:
mode:
authorimp <imp@cvs.openbsd.org>1998-10-15 21:30:18 +0000
committerimp <imp@cvs.openbsd.org>1998-10-15 21:30:18 +0000
commit1aa92a9167e8428a77915dade77b1340f3d4dbcd (patch)
tree5571bd9bb30621c8996660ad778e1c6b8e84b0bb /sys/arch/pmax
parentbc6606f5be9a546bea943ee33ca9dfef98a004fa (diff)
Back out PEFO's trap change. It breaks everybody, it seems.
Diffstat (limited to 'sys/arch/pmax')
-rw-r--r--sys/arch/pmax/conf/GENERIC4
-rw-r--r--sys/arch/pmax/include/cpu.h3
-rw-r--r--sys/arch/pmax/pmax/genassym.cf6
-rw-r--r--sys/arch/pmax/pmax/locore.S45
-rw-r--r--sys/arch/pmax/pmax/locore_r2000.S182
-rw-r--r--sys/arch/pmax/pmax/process_machdep.c2
-rw-r--r--sys/arch/pmax/pmax/trap.c345
-rw-r--r--sys/arch/pmax/pmax/vm_machdep.c70
8 files changed, 309 insertions, 348 deletions
diff --git a/sys/arch/pmax/conf/GENERIC b/sys/arch/pmax/conf/GENERIC
index f5ac502beed..1a36aeefaf4 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 20d24b24b66..b0ed6edb324 100644
--- a/sys/arch/pmax/include/cpu.h
+++ b/sys/arch/pmax/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.9 1998/09/15 10:53:54 pefo Exp $ */
+/* $OpenBSD: cpu.h,v 1.10 1998/10/15 21:30:16 imp Exp $ */
/* $NetBSD: cpu.h,v 1.15 1996/03/23 20:28:19 jonathan Exp $ */
/*-
@@ -72,6 +72,7 @@ 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 3d2f699e4f6..67bd16a3518 100644
--- a/sys/arch/pmax/pmax/genassym.cf
+++ b/sys/arch/pmax/pmax/genassym.cf
@@ -1,4 +1,4 @@
-# $OpenBSD: genassym.cf,v 1.2 1998/09/15 10:53:54 pefo Exp $
+# $OpenBSD: genassym.cf,v 1.3 1998/10/15 21:30:16 imp 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.zero)
-define U_PCB_FPREGS offsetof(struct user, u_pcb.pcb_regs.f0)
+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_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 01b344e8db1..0afc4b82c5b 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 + (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)
+ 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)
@@ -213,20 +213,16 @@ start:
sw t1, _C_LABEL(fpu_id) # save FPU ID register
jal _C_LABEL(main) # main(regs)
move a0, zero
- PANIC("Startup failed!")
/*
- * Setup for and return to user.
+ * proc[1] == /etc/init now running here.
+ * Restore user registers and return.
*/
-LEAF(proc_trampoline)
- jal s0
- move a0,s1 # set up for return to user.
-
.set noat
- lw k0, UADDR+U_PCB_REGS+(SR * 4)
+ li v0, PSL_USERSET
+ mtc0 v0, MIPS_COP_0_STATUS_REG # switch to user mode
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)
@@ -262,7 +258,6 @@ LEAF(proc_trampoline)
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 3a9fbac3e53..cd0a66fc243 100644
--- a/sys/arch/pmax/pmax/locore_r2000.S
+++ b/sys/arch/pmax/pmax/locore_r2000.S
@@ -183,15 +183,18 @@ mips1_SlowFault:
*/
/*
- * The kernel exception stack contains 32 saved general registers,
+ * The kernel exception stack contains 18 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 (NUMSAVEREGS * 4)
+#define KERN_REG_SIZE (18 * 4)
#define KERN_REG_OFFSET (STAND_FRAME_SIZE)
-#define KERN_TRAP_FRAME_SIZE (STAND_FRAME_SIZE + KERN_REG_SIZE + 12)
+#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)
-NNON_LEAF(mips1_KernGenException, KERN_TRAP_FRAME_SIZE, ra)
+NNON_LEAF(mips1_KernGenException, KERN_EXC_FRAME_SIZE, ra)
.set noat
#ifdef KADB
la k0, kdbpcb # save registers for kadb
@@ -207,66 +210,63 @@ NNON_LEAF(mips1_KernGenException, KERN_TRAP_FRAME_SIZE, ra)
sw gp, (GP * 4)(k0)
sw sp, (SP * 4)(k0)
#endif
- subu sp, sp, KERN_TRAP_FRAME_SIZE
- .mask 0x80000000, (STAND_RA_OFFSET - KERN_TRAP_FRAME_SIZE)
+ subu sp, sp, KERN_EXC_FRAME_SIZE
+ .mask 0x80000000, (STAND_RA_OFFSET - KERN_EXC_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 + (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)
+ 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)
mflo v0
mfhi v1
- 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)
+ 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)
mfc0 a0, MIPS_COP_0_STATUS_REG # First arg is the 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)
+ 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)
mfc0 a1, MIPS_COP_0_CAUSE_REG # Second arg is the 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 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)
mfc0 a2, MIPS_COP_0_BAD_VADDR # Third arg is the fault addr.
- 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)
+ 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)
mfc0 a3, MIPS_COP_0_EXC_PC # Fourth arg is the pc.
- 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)
+ sw a0, KERN_SR_OFFSET(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_REG_OFFSET + (SR * 4)(sp)
- lw t0, KERN_REG_OFFSET + (MULLO * 4)(sp)
- lw t1, KERN_REG_OFFSET + (MULHI * 4)(sp)
+ lw a0, KERN_SR_OFFSET(sp)
+ lw t0, KERN_MULT_LO_OFFSET(sp)
+ lw t1, KERN_MULT_HI_OFFSET(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 + (AST * 4)(sp)
- lw v0, KERN_REG_OFFSET + (V0 * 4)(sp)
+
+ lw AT, KERN_REG_OFFSET + 0(sp)
+ lw v0, KERN_REG_OFFSET + 4(sp)
RESTORE_KERN_REGISTERS(KERN_REG_OFFSET)
- addu sp, sp, KERN_TRAP_FRAME_SIZE
+ addu sp, sp, KERN_EXC_FRAME_SIZE
j k0 # Now return from the
rfe # exception.
.set at
@@ -296,47 +296,45 @@ 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.
@@ -344,7 +342,6 @@ 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
/*
@@ -383,66 +380,73 @@ END(mips1_UserGenException)
*
*----------------------------------------------------------------------------
*/
-
-NNON_LEAF(mips1_KernIntr, KERN_TRAP_FRAME_SIZE, ra)
+#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)
.set noat
- subu sp, sp, KERN_TRAP_FRAME_SIZE # allocate stack frame
- .mask 0x80000000, (STAND_RA_OFFSET - KERN_TRAP_FRAME_SIZE)
+ subu sp, sp, KINTR_FRAME_SIZE # allocate stack frame
+ .mask 0x80000000, (STAND_RA_OFFSET - KINTR_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, 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)
+ 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)
mflo v0
mfhi v1
- 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)
+ 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
/*
* Call the interrupt handler.
*/
- addu a0, sp, KERN_REG_OFFSET
jal _C_LABEL(interrupt)
- sw a2, STAND_RA_OFFSET(sp)
+ sw a2, STAND_RA_OFFSET(sp) # for debugging
/*
* Restore registers and return from the interrupt.
*/
- lw a0, KERN_REG_OFFSET + (SR * 4)(sp)
- lw t0, KERN_REG_OFFSET + (MULLO * 4)(sp)
- lw t1, KERN_REG_OFFSET + (MULHI * 4)(sp)
+ lw a0, KINTR_SR_OFFSET(sp)
+ lw t0, KINTR_MULT_LO_OFFSET(sp)
+ lw t1, KINTR_MULT_HI_OFFSET(sp)
mtc0 a0, MIPS_COP_0_STATUS_REG # Restore the SR, disable intrs
mtlo t0
mthi t1
- lw k0, KERN_REG_OFFSET + (PC * 4)(sp)
- lw AT, KERN_REG_OFFSET + (AST * 4)(sp)
- lw v0, KERN_REG_OFFSET + (V0 * 4)(sp)
+ lw k0, STAND_RA_OFFSET(sp)
+ lw AT, KINTR_REG_OFFSET + 0(sp)
+ lw v0, KINTR_REG_OFFSET + 4(sp)
- RESTORE_KERN_REGISTERS(KERN_REG_OFFSET)
+ RESTORE_KERN_REGISTERS(KINTR_REG_OFFSET)
- addu sp, sp, KERN_TRAP_FRAME_SIZE
+ addu sp, sp, KINTR_FRAME_SIZE
j k0 # Now return from the
rfe # interrupt.
.set at
@@ -504,7 +508,6 @@ 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
@@ -516,9 +519,8 @@ 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) # debugging
+ sw a2, STAND_RA_OFFSET(sp) # for debugging
/*
* Restore registers and return from the interrupt.
*/
diff --git a/sys/arch/pmax/pmax/process_machdep.c b/sys/arch/pmax/pmax/process_machdep.c
index a62e98f656a..7c6b5cd1de6 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 c93e11327b5..adb1b44517c 100644
--- a/sys/arch/pmax/pmax/trap.c
+++ b/sys/arch/pmax/pmax/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.16 1998/09/30 12:38:44 pefo Exp $ */
+/* $OpenBSD: trap.c,v 1.17 1998/10/15 21:30:17 imp Exp $ */
/* $NetBSD: trap.c,v 1.50 1996/10/13 21:37:49 jonathan Exp $ */
/*
@@ -65,8 +65,7 @@
#include <machine/trap.h>
#include <machine/psl.h>
-#include <machine/regnum.h>
-#include <machine/frame.h>
+#include <machine/reg.h>
#include <machine/cpu.h>
#include <machine/locore.h>
#include <machine/pte.h>
@@ -332,7 +331,7 @@ void cpu_getregs __P((int *regs));
/*
* Other forward declarations.
*/
-u_int MachEmulateBranch __P((struct trap_frame *,
+u_int MachEmulateBranch __P((unsigned *regsPtr,
unsigned instPC,
unsigned fpcCSR,
int allowNonBranch));
@@ -346,8 +345,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((struct trap_frame *));
-void child_return __P((struct proc *p));
+extern u_int trap __P((u_int status, u_int cause, u_int vaddr, u_int pc,
+ int args));
#ifdef DEBUG /* stack trace code, also useful to DDB one day */
@@ -401,8 +400,11 @@ typedef enum {
* ((struct pcb *)UADDR)->pcb_onfault is set, otherwise, return old pc.
*/
u_int
-trap(trapframe)
- struct trap_frame *trapframe;
+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 */
{
register int type, i;
unsigned ucode = 0;
@@ -414,21 +416,21 @@ trap(trapframe)
union sigval sv;
#ifdef DEBUG
- 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->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->code = 0;
if (++trp == &trapdebug[TRAPSIZE])
trp = trapdebug;
#endif
cnt.v_trap++;
- type = (trapframe->cause & MIPS1_CR_EXC_CODE) >> MIPS_CR_EXC_CODE_SHIFT;
- if (USERMODE(trapframe->sr)) {
+ type = (causeReg & MIPS1_CR_EXC_CODE) >> MIPS_CR_EXC_CODE_SHIFT;
+ if (USERMODE(statusReg)) {
type |= T_USER;
sticks = p->p_sticks;
}
@@ -437,32 +439,32 @@ trap(trapframe)
* Enable hardware interrupts if they were on before.
* We only respond to software interrupts when returning to user mode.
*/
- if (trapframe->sr & MIPS_SR_INT_ENA_PREV)
- splx((trapframe->sr & MIPS_HARD_INT_MASK) | MIPS_SR_INT_IE);
+ if (statusReg & MIPS_SR_INT_ENA_PREV)
+ splx((statusReg & MIPS_HARD_INT_MASK) | MIPS_SR_INT_IE);
switch (type) {
case T_TLB_MOD:
/* check for kernel address */
- if ((int)trapframe->badvaddr < 0) {
+ if ((int)vadr < 0) {
register pt_entry_t *pte;
register unsigned entry;
register vm_offset_t pa;
- pte = kvtopte(trapframe->badvaddr);
+ pte = kvtopte(vadr);
entry = pte->pt_entry;
#ifdef DIAGNOSTIC
if (!(entry & PG_V) || (entry & PG_M))
panic("trap: ktlbmod: invalid pte");
#endif
- if (PAGE_IS_RDONLY(entry, trapframe->badvaddr)) {
+ if (PAGE_IS_RDONLY(entry, vadr)) {
/* write to read only page in the kernel */
ftype = VM_PROT_WRITE;
goto kernel_fault;
}
entry |= PG_M;
pte->pt_entry = entry;
- trapframe->badvaddr &= ~PGOFSET;
- MachTLBUpdate(trapframe->badvaddr, entry);
+ vadr &= ~PGOFSET;
+ MachTLBUpdate(vadr, entry);
pa = PTE_TO_PADDR(entry);
#ifdef ATTR
pmap_attributes[atop(pa)] |= PMAP_ATTR_MOD;
@@ -471,7 +473,7 @@ trap(trapframe)
panic("trap: ktlbmod: unmanaged page");
PHYS_TO_VM_PAGE(pa)->flags &= ~PG_CLEAN;
#endif
- return (trapframe->pc);
+ return (pc);
}
/* FALLTHROUGH */
@@ -482,25 +484,25 @@ trap(trapframe)
register vm_offset_t pa;
pmap_t pmap = &p->p_vmspace->vm_pmap;
- if (!(pte = pmap_segmap(pmap, trapframe->badvaddr)))
+ if (!(pte = pmap_segmap(pmap, vadr)))
panic("trap: utlbmod: invalid segmap");
- pte += (trapframe->badvaddr >> PGSHIFT) & (NPTEPG - 1);
+ pte += (vadr >> 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, trapframe->badvaddr)) {
+ if (PAGE_IS_RDONLY(entry, vadr)) {
/* write to read only page */
ftype = VM_PROT_WRITE;
goto dofault;
}
entry |= PG_M;
pte->pt_entry = entry;
- trapframe->badvaddr = (trapframe->badvaddr & ~PGOFSET) |
+ vadr = (vadr & ~PGOFSET) |
(pmap->pm_tlbpid << MIPS_TLB_PID_SHIFT);
- MachTLBUpdate(trapframe->badvaddr, entry);
+ MachTLBUpdate(vadr, entry);
pa = PTE_TO_PADDR(entry);
#ifdef ATTR
pmap_attributes[atop(pa)] |= PMAP_ATTR_MOD;
@@ -510,8 +512,8 @@ trap(trapframe)
}
PHYS_TO_VM_PAGE(pa)->flags &= ~PG_CLEAN;
#endif
- if (!USERMODE(trapframe->sr))
- return (trapframe->pc);
+ if (!USERMODE(statusReg))
+ return (pc);
goto out;
}
@@ -519,16 +521,16 @@ trap(trapframe)
case T_TLB_ST_MISS:
ftype = (type == T_TLB_ST_MISS) ? VM_PROT_WRITE : VM_PROT_READ;
/* check for kernel address */
- if ((int)trapframe->badvaddr < 0) {
+ if ((int)vadr < 0) {
register vm_offset_t va;
int rv;
kernel_fault:
kernelfaults++;
- va = trunc_page((vm_offset_t)trapframe->badvaddr);
+ va = trunc_page((vm_offset_t)vadr);
rv = vm_fault(kernel_map, va, ftype, FALSE);
if (rv == KERN_SUCCESS)
- return (trapframe->pc);
+ return (pc);
if ((i = ((struct pcb *)UADDR)->pcb_onfault) != 0) {
((struct pcb *)UADDR)->pcb_onfault = 0;
return (onfault_table[i]);
@@ -561,11 +563,11 @@ trap(trapframe)
vm = p->p_vmspace;
map = &vm->vm_map;
- va = trunc_page((vm_offset_t)trapframe->badvaddr);
+ va = trunc_page((vm_offset_t)vadr);
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, trapframe->badvaddr, ftype, FALSE, rv, trapframe->pc);
+ map, &vm->vm_pmap, va, vadr, ftype, FALSE, rv, pc);
#endif
/*
* If this was a stack access we keep track of the maximum
@@ -585,11 +587,11 @@ trap(trapframe)
rv = KERN_INVALID_ADDRESS;
}
if (rv == KERN_SUCCESS) {
- if (!USERMODE(trapframe->sr))
- return (trapframe->pc);
+ if (!USERMODE(statusReg))
+ return (pc);
goto out;
}
- if (!USERMODE(trapframe->sr)) {
+ if (!USERMODE(statusReg)) {
if ((i = ((struct pcb *)UADDR)->pcb_onfault) != 0) {
((struct pcb *)UADDR)->pcb_onfault = 0;
return (onfault_table[i]);
@@ -617,10 +619,9 @@ trap(trapframe)
case T_SYSCALL+T_USER:
{
- struct trap_frame *locr0 = p->p_md.md_regs;
- struct sysent *callp;
+ register int *locr0 = p->p_md.md_regs;
+ register struct sysent *callp;
unsigned int code;
- unsigned int tpc;
int numsys;
struct args {
int i[8];
@@ -629,36 +630,35 @@ trap(trapframe)
cnt.v_syscall++;
/* compute next PC after syscall instruction */
- tpc = trapframe->pc; /* Remember if restarted! */
- if ((int)trapframe->cause < 0)
- locr0->pc = MachEmulateBranch(locr0, trapframe->pc, 0, 0);
+ if ((int)causeReg < 0)
+ locr0[PC] = MachEmulateBranch(locr0, 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,27 +678,22 @@ trap(trapframe)
* Like syscall, but code is a quad, so as to maintain
* quad alignment for the rest of the arguments.
*/
- if(_QUAD_LOWWORD == 0) {
- code = locr0->a0;
- }
- else {
- code = locr0->a1;
- }
+ code = locr0[A0 + _QUAD_LOWWORD];
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
@@ -719,18 +714,18 @@ trap(trapframe)
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
@@ -752,7 +747,7 @@ trap(trapframe)
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;
@@ -769,11 +764,11 @@ trap(trapframe)
#ifdef DEBUG
{ int s;
s = splhigh();
- trp->status = trapframe->sr;
- trp->cause = trapframe->cause;
- trp->vadr = locr0->sp;
- trp->pc = locr0->pc;
- trp->ra = locr0->ra;
+ trp->status = statusReg;
+ trp->cause = causeReg;
+ trp->vadr = locr0[SP];
+ trp->pc = locr0[PC];
+ trp->ra = locr0[RA];
/*trp->sp = (int)&args;*/
trp->code = -code;
if (++trp == &trapdebug[TRAPSIZE])
@@ -783,21 +778,21 @@ trap(trapframe)
#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 = tpc;
+ locr0[PC] = pc;
break;
case EJUSTRETURN:
break; /* nothing to do */
default:
- locr0->v0 = i;
- locr0->a3 = 1;
+ locr0[V0] = i;
+ locr0[A3] = 1;
}
/*
@@ -822,15 +817,15 @@ trap(trapframe)
register unsigned va, instr;
/* compute address of break instruction */
- va = trapframe->pc;
- if ((int)trapframe->cause < 0)
+ va = pc;
+ if ((int)causeReg < 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, trapframe->pc,
+ p->p_comm, p->p_pid, instr, pc,
p->p_md.md_ss_addr, p->p_md.md_ss_instr); /* XXX */
#endif
#ifdef KADB
@@ -875,7 +870,7 @@ trap(trapframe)
break;
case T_COP_UNUSABLE+T_USER:
- if ((trapframe->cause & MIPS_CR_COP_ERR) != 0x10000000) {
+ if ((causeReg & MIPS_CR_COP_ERR) != 0x10000000) {
i = SIGILL; /* only FPU instructions allowed */
typ = ILL_ILLOPC;
break;
@@ -883,7 +878,7 @@ trap(trapframe)
MachSwitchFPState(machFPCurProcPtr,
(struct user*)p->p_md.md_regs);
machFPCurProcPtr = p;
- p->p_md.md_regs->sr |= MIPS_SR_COP_1_BIT;
+ p->p_md.md_regs[PS] |= MIPS_SR_COP_1_BIT;
p->p_md.md_flags |= MDP_FPUSED;
goto out;
@@ -892,12 +887,12 @@ trap(trapframe)
trapDump("fpintr");
#else
printf("FPU Trap: PC %x CR %x SR %x\n",
- trapframe->pc, trapframe->cause, trapframe->sr);
+ pc, causeReg, statusReg);
goto err;
#endif
case T_FPE+T_USER:
- MachFPTrap(trapframe->sr, trapframe->cause, trapframe->pc);
+ MachFPTrap(statusReg, causeReg, pc);
goto out;
case T_OVFLOW+T_USER:
@@ -920,36 +915,36 @@ trap(trapframe)
{
extern struct pcb kdbpcb;
- if (USERMODE(trapframe->sr))
+ if (USERMODE(statusReg))
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 = trapframe->pc;
- kdbpcb.pcb_regs->sr = trapframe->sr;
- 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] = pc;
+ kdbpcb.pcb_regs[SR] = statusReg;
+ bzero((caddr_t)&kdbpcb.pcb_regs[F0], 33 * sizeof(int));
}
- if (kdb(trapframe->cause, trapframe->badvaddr, p, !USERMODE(trapframe->sr)))
- return (kdbpcb.pcb_regs->pc);
+ if (kdb(causeReg, vadr, p, !USERMODE(statusReg)))
+ return (kdbpcb.pcb_regs[PC]);
}
#else
#ifdef DEBUG
@@ -959,10 +954,10 @@ trap(trapframe)
#endif
panic("trap");
}
- 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;
+ 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;
trapsignal(p, i, ucode, typ, sv);
out:
/*
@@ -999,64 +994,11 @@ out:
if (p->p_flag & P_PROFIL) {
extern int psratio;
- addupc_task(p, trapframe->pc, (int)(p->p_sticks - sticks) * psratio);
+ addupc_task(p, pc, (int)(p->p_sticks - sticks) * psratio);
}
curpriority = p->p_priority;
- 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
+ return (pc);
}
/*
@@ -1065,17 +1007,19 @@ child_return(p)
* Note: curproc might be NULL.
*/
void
-interrupt(trapframe)
- struct trap_frame *trapframe;
+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 */
{
register unsigned mask;
/*struct clockframe cf;*/
#ifdef DEBUG
- trp->status = trapframe->sr;
- trp->cause = trapframe->cause;
+ trp->status = statusReg;
+ trp->cause = causeReg;
trp->vadr = 0;
- trp->pc = trapframe->pc;
+ trp->pc = pc;
trp->ra = 0;
trp->sp = /* (int)&args */ 0; /* XXX pass args in */
trp->code = 0;
@@ -1084,26 +1028,26 @@ interrupt(trapframe)
#endif
cnt.v_intr++;
- mask = trapframe->cause & trapframe->sr; /* pending interrupts & enable mask */
+ mask = causeReg & statusReg; /* pending interrupts & enable mask */
if (mips_hardware_intr)
- splx((*mips_hardware_intr)(mask, trapframe->pc, trapframe->sr, trapframe->cause));
+ splx((*mips_hardware_intr)(mask, pc, statusReg, causeReg));
if (mask & MIPS_INT_MASK_5) {
intrcnt[FPU_INTR]++;
- if (!USERMODE(trapframe->sr)) {
+ if (!USERMODE(statusReg)) {
#ifdef DEBUG
trapDump("fpintr");
#else
printf("FPU interrupt: PC %x CR %x SR %x\n",
- trapframe->pc, trapframe->cause, trapframe->sr);
+ pc, causeReg, statusReg);
#endif
} else
- MachFPInterrupt(trapframe->sr, trapframe->cause, trapframe->pc);
+ MachFPInterrupt(statusReg, causeReg, pc);
}
/* process network interrupt if we trapped or will very soon */
/* XXX fixme: operator precedence botch? */
if ((mask & MIPS_SOFT_INT_MASK_1) ||
- netisr && (trapframe->sr & MIPS_SOFT_INT_MASK_1)) {
+ netisr && (statusReg & MIPS_SOFT_INT_MASK_1)) {
clearsoftnet();
cnt.v_soft++;
intrcnt[SOFTNET_INTR]++;
@@ -1247,8 +1191,8 @@ GetBranchDest(InstPtr)
* Return the resulting PC as if the branch was executed.
*/
unsigned
-MachEmulateBranch(frame, instPC, fpcCSR, allowNonBranch)
- struct trap_frame *frame;
+MachEmulateBranch(regsPtr, instPC, fpcCSR, allowNonBranch)
+ unsigned *regsPtr;
unsigned instPC;
unsigned fpcCSR;
int allowNonBranch;
@@ -1256,7 +1200,6 @@ MachEmulateBranch(frame, 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;
@@ -1394,13 +1337,13 @@ int
cpu_singlestep(p)
register struct proc *p;
{
- unsigned va;
- struct trap_frame *locr0 = p->p_md.md_regs;
+ register unsigned va;
+ register int *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",
@@ -1437,7 +1380,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;
@@ -1446,10 +1389,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",
@@ -1492,7 +1435,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);
}
@@ -1514,7 +1457,7 @@ kdbpeek(addr)
/* forward */
char *fn_name(unsigned addr);
-void stacktrace_subr __P((int, int, int, int, int (*)(const char*, ...)));
+void stacktrace_subr __P((int, int, int, int, void (*)(const char*, ...)));
/*
* Print a stack backtrace.
@@ -1536,7 +1479,7 @@ logstacktrace(a0, a1, a2, a3)
void
stacktrace_subr(a0, a1, a2, a3, printfn)
int a0, a1, a2, a3;
- int (*printfn) __P((const char*, ...));
+ void (*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 d9a15f4e1c2..079b33bc47f 100644
--- a/sys/arch/pmax/pmax/vm_machdep.c
+++ b/sys/arch/pmax/pmax/vm_machdep.c
@@ -69,50 +69,70 @@ 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.
*/
-void
+int
cpu_fork(p1, p2)
- struct proc *p1, *p2;
+ register struct proc *p1, *p2;
{
- pt_entry_t *pte;
- struct pcb *pcb;
- int i;
+ register struct user *up = p2->p_addr;
+ register pt_entry_t *pte;
+ register int i;
extern struct proc *machFPCurProcPtr;
- p2->p_md.md_regs = &p2->p_addr->u_pcb.pcb_regs;
+ p2->p_md.md_regs = up->u_pcb.pcb_regs;
p2->p_md.md_flags = p1->p_md.md_flags & MDP_FPUSED;
- pte = kvtopte(p2->p_addr);
+ /*
+ * 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);
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);
- pcb = &p2->p_addr->u_pcb;
+ /*
+ * 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;
+ */
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;
- 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;
+ /*
+ * 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);
}
/*