diff --git a/sys/arch/sun3/sun3/trap.c b/sys/arch/sun3/sun3/trap.c index 92f772eb0c7b..56c6fe5db359 100644 --- a/sys/arch/sun3/sun3/trap.c +++ b/sys/arch/sun3/sun3/trap.c @@ -130,8 +130,9 @@ trap(type, code, v, frame) unsigned ncode; int s; - printf("trap type %d, code = %x, v = %x\n", type, code, v); cnt.v_trap++; + if (!p) + p = &proc0; syst = p->p_stime; if (USERMODE(frame.f_sr)) { type |= T_USER; @@ -151,6 +152,7 @@ dopanic: case T_BUSERR: /* kernel bus error */ if (!p->p_addr->u_pcb.pcb_onfault) goto dopanic; + /* * If we have arranged to catch this fault in any of the * copy to/from user space routines, set PC to return to @@ -158,6 +160,7 @@ dopanic: * that it may need to clean up stack frame. */ copyfault: + frame.f_stackadj = exframesize[frame.f_format]; frame.f_format = frame.f_vector = 0; frame.f_pc = (int) p->p_addr->u_pcb.pcb_onfault; @@ -290,7 +293,6 @@ copyfault: break; case T_ASTFLT: /* system async trap, cannot happen */ - printf("system async trap\n"); goto dopanic; case T_ASTFLT|T_USER: /* user async trap */ @@ -303,21 +305,17 @@ copyfault: * check. Note that we ensure that we are at least at SIR * IPL while processing the SIR. */ - printf("user async trap\n"); spl1(); /* fall into... */ case T_SSIR: /* software interrupt */ case T_SSIR|T_USER: - printf("software interrupt\n"); if (ssir & SIR_NET) { - printf("soft interrupt: network\n"); siroff(SIR_NET); cnt.v_soft++; netintr(); } if (ssir & SIR_CLOCK) { - printf("soft interrupt: clock\n"); siroff(SIR_CLOCK); cnt.v_soft++; softclock((caddr_t)frame.f_pc, (int)frame.f_sr); @@ -326,13 +324,10 @@ copyfault: * If this was not an AST trap, we are all done. */ if (type != (T_ASTFLT|T_USER)) { - printf("soft interrupt: NOT AST\n"); cnt.v_trap--; return; } - printf("soft interrupt: before spl0\n"); spl0(); - printf("soft interrupt: after spl0\n"); #ifndef PROFTIMER if ((p->p_flag&SOWEUPC) && p->p_stats->p_prof.pr_scale) { addupc(frame.f_pc, &p->p_stats->p_prof, 1); @@ -379,6 +374,12 @@ copyfault: } #endif rv = vm_fault(map, va, ftype, FALSE); +#if VMFAULT_TRACE + printf("vm_fault(%x, %x, %x, 0) -> %x in context %d\n", + map, va, ftype, rv, get_context()); + printf(" type %x, code [mmu,,ssw]: %x\n", + type, code); +#endif /* * If this was a stack access we keep track of the maximum * accessed stack size. Also, if vm_fault gets a protection @@ -397,8 +398,13 @@ copyfault: rv = KERN_INVALID_ADDRESS; } if (rv == KERN_SUCCESS) { - if (type == T_MMUFLT) + if (type == T_MMUFLT) { +#if VMFAULT_TRACE + printf("vm_fault resolved access to map %x va %x type ftype %d\n", + map, va, ftype); +#endif return; + } goto out; } if (type == T_MMUFLT) { @@ -436,8 +442,6 @@ out: p->p_stats->p_ru.ru_nivcsw++; swtch(); splx(s); - printf("trap: survived the switch\n"); - tracedump(); while (i = CURSIG(p)) psig(i); } @@ -483,6 +487,7 @@ syscall(code, frame) extern int hpuxnsysent, notimp(); #endif + printf("entered syscall()\n"); cnt.v_syscall++; syst = p->p_stime; if (!USERMODE(frame.f_sr)) diff --git a/sys/arch/sun3/sun3/trap.s b/sys/arch/sun3/sun3/trap.s index b588e31c71aa..33170030f673 100644 --- a/sys/arch/sun3/sun3/trap.s +++ b/sys/arch/sun3/sun3/trap.s @@ -50,6 +50,10 @@ * of the memory error register is necessary */ +.globl _buserr, _addrerr, _illinst, _zerodiv, _chkinst, _trapvinst +.globl _privinst, _trace, _fpfline, _badtrap, _coperr, _fmterr, _trap0, +.globl _trap1, _trap2, _trap15 +.globl _fpunsupp .globl _trap, _nofault, _longjmp _buserr: @@ -104,6 +108,20 @@ Lbe10: andw #0x0FFF,d0 | clear out frame format cmpw #12,d0 | address error vector? jeq Lisaerr | yes, go to it +/* + * the sun3 specific code + * + * our mission: figure out whether what we are looking at is + * bus error in the UNIX sense, or + * a memory error i.e a page fault + * + * [this code replaces similarly mmu specific code in the hp300 code] + */ +sun3_mmu_specific: + clrl d0 | make sure top bits are cleard too + movsb BUSERR_REG, d0 | get value of bus error register + btst #5, d0 | test to timeout bit + jne Lisberr | if bus error, do it Lismerr: movl #T_MMUFLT,sp@- | show that we are an MMU fault jra Ltrapnstkadj | and deal with it @@ -134,6 +152,9 @@ Lstkadj: movl sp@,sp | and our SP jra rei | all done +/* unchanged from hp300 */ + + /* * FP exceptions. */ @@ -149,6 +170,7 @@ _fpunsupp: * and may cause signal delivery, we need to test for stack adjustment * after the trap call. */ +.globl _fpfault _fpfault: #ifdef FPCOPROC clrw sp@- | pad SR to longword @@ -292,20 +314,6 @@ _trap2: jeq _trace | no, trap2 is breakpoint jra sigreturn | yes, trap2 is sigreturn -/* - * Trap 12 is the entry point for the cachectl "syscall" (both HPUX & BSD) - * cachectl(command, addr, length) - * command in d0, addr in a1, length in d1 - */ - .globl _cachectl -_trap12: - movl d1,sp@- | push length - movl a1,sp@- | push addr - movl d0,sp@- | push command - jbsr _cachectl | do it - lea sp@(12),sp | pop args - jra rei | all done - /* * Trap 15 is used for: * - KGDB traps diff --git a/sys/arch/sun3/sun3/vector.c b/sys/arch/sun3/sun3/vector.c index c8b287a22ffd..aeca7bae2f8f 100644 --- a/sys/arch/sun3/sun3/vector.c +++ b/sys/arch/sun3/sun3/vector.c @@ -28,7 +28,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Header: /cvsroot/src/sys/arch/sun3/sun3/Attic/vector.c,v 1.3 1993/08/28 15:38:34 glass Exp $ + * $Header: /cvsroot/src/sys/arch/sun3/sun3/Attic/vector.c,v 1.4 1993/10/12 05:28:14 glass Exp $ */ #include "sys/systm.h" @@ -38,32 +38,49 @@ COPY_ENTRY, COPY_ENTRY, COPY_ENTRY, COPY_ENTRY, \ COPY_ENTRY, COPY_ENTRY, COPY_ENTRY, COPY_ENTRY, \ COPY_ENTRY, COPY_ENTRY, COPY_ENTRY, COPY_ENTRY +#define BADTRAP16 badtrap, badtrap, badtrap, badtrap, \ + badtrap, badtrap, badtrap, badtrap, \ + badtrap, badtrap, badtrap, badtrap, \ + badtrap, badtrap, badtrap, badtrap -unsigned int vector_table[NVECTORS] = { +void addrerr(), badtrap(), buserr(), chkinst(), coperr(), fmterr(), + fpfline(), fpunsupp(), illinst(), privinst(), trace(), trap0(), + trap1(), trap12(), trap15(), trap2(), trapvinst(), zerodiv(), fpfault(); + + +#define fpbsun fpfault +#define fpdz fpfault +#define fpinex fpfault +#define fpoperr fpfault +#define fpovfl fpfault +#define fpsnan fpfault +#define fpunfl fpfault + +void (*vector_table[NVECTORS])() = { COPY_ENTRY, /* 0: jmp 0x400:w (unused reset SSP)*/ COPY_ENTRY, /* 1: NOT USED (reset PC) */ - COPY_ENTRY, /* 2: bus error */ - COPY_ENTRY, /* 3: address error */ - COPY_ENTRY, /* 4: illegal instruction */ - COPY_ENTRY, /* 5: zero divide */ - COPY_ENTRY, /* 6: CHK instruction */ - COPY_ENTRY, /* 7: TRAPV instruction */ - COPY_ENTRY, /* 8: privilege violation */ - COPY_ENTRY, /* 9: trace */ - COPY_ENTRY, /* 10: line 1010 emulator */ - COPY_ENTRY, /* 11: line 1111 emulator */ - COPY_ENTRY, /* 12: unassigned, reserved */ - COPY_ENTRY, /* 13: coprocessor protocol violatio */ - COPY_ENTRY, /* 14: format error */ - COPY_ENTRY, /* 15: uninitialized interrupt vecto */ - COPY_ENTRY, /* 16: unassigned, reserved */ - COPY_ENTRY, /* 17: unassigned, reserved */ - COPY_ENTRY, /* 18: unassigned, reserved */ - COPY_ENTRY, /* 19: unassigned, reserved */ - COPY_ENTRY, /* 20: unassigned, reserved */ - COPY_ENTRY, /* 21: unassigned, reserved */ - COPY_ENTRY, /* 22: unassigned, reserved */ - COPY_ENTRY, /* 23: unassigned, reserved */ + buserr, /* 2: bus error */ + addrerr, /* 3: address error */ + illinst, /* 4: illegal instruction */ + zerodiv, /* 5: zero divide */ + chkinst, /* 6: CHK instruction */ + trapvinst, /* 7: TRAPV instruction */ + privinst, /* 8: privilege violation */ + trace, /* 9: trace */ + illinst, /* 10: line 1010 emulator */ + fpfline, /* 11: line 1111 emulator */ + badtrap, /* 12: unassigned, reserved */ + coperr, /* 13: coprocessor protocol violatio */ + fmterr, /* 14: format error */ + badtrap, /* 15: uninitialized interrupt vecto */ + badtrap, /* 16: unassigned, reserved */ + badtrap, /* 17: unassigned, reserved */ + badtrap, /* 18: unassigned, reserved */ + badtrap, /* 19: unassigned, reserved */ + badtrap, /* 20: unassigned, reserved */ + badtrap, /* 21: unassigned, reserved */ + badtrap, /* 22: unassigned, reserved */ + badtrap, /* 23: unassigned, reserved */ COPY_ENTRY, /* 24: spurious interrupt */ COPY_ENTRY, /* 25: level 1 interrupt autovector */ COPY_ENTRY, /* 26: level 2 interrupt autovector */ @@ -72,53 +89,53 @@ unsigned int vector_table[NVECTORS] = { COPY_ENTRY, /* 29: level 5 interrupt autovector */ COPY_ENTRY, /* 30: level 6 interrupt autovector */ COPY_ENTRY, /* 31: level 7 interrupt autovector */ - COPY_ENTRY, /* 32: syscalls (at least on hp300) - COPY_ENTRY, /* 33: sigreturn syscall or breakpoi */ - COPY_ENTRY, /* 34: breakpoint or sigreturn sysca */ - COPY_ENTRY, /* 35: TRAP instruction vector */ - COPY_ENTRY, /* 36: TRAP instruction vector */ - COPY_ENTRY, /* 37: TRAP instruction vector */ - COPY_ENTRY, /* 38: TRAP instruction vector */ - COPY_ENTRY, /* 39: TRAP instruction vector */ - COPY_ENTRY, /* 40: TRAP instruction vector */ - COPY_ENTRY, /* 41: TRAP instruction vector */ - COPY_ENTRY, /* 42: TRAP instruction vector */ - COPY_ENTRY, /* 43: TRAP instruction vector */ - COPY_ENTRY, /* 44: TRAP instruction vector */ - COPY_ENTRY, /* 45: TRAP instruction vector */ - COPY_ENTRY, /* 46: TRAP instruction vector */ - COPY_ENTRY, /* 47: TRAP instruction vector */ - COPY_ENTRY, /* 48: FPCP branch/set on unordered */ - COPY_ENTRY, /* 49: FPCP inexact result */ - COPY_ENTRY, /* 50: FPCP divide by zero */ - COPY_ENTRY, /* 51: FPCP underflow */ - COPY_ENTRY, /* 52: FPCP operand error */ - COPY_ENTRY, /* 53: FPCP overflow */ - COPY_ENTRY, /* 54: FPCP signalling NAN */ - COPY_ENTRY, /* 55: FPCP unimplemented data type */ - COPY_ENTRY, /* 56: unassigned, reserved */ - COPY_ENTRY, /* 57: unassigned, reserved */ - COPY_ENTRY, /* 58: unassigned, reserved */ - COPY_ENTRY, /* 59: unassigned, reserved */ - COPY_ENTRY, /* 60: unassigned, reserved */ - COPY_ENTRY, /* 61: unassigned, reserved */ - COPY_ENTRY, /* 62: unassigned, reserved */ - COPY_ENTRY, /* 63: unassigned, reserved */ + trap0, /* 32: syscalls (at least on hp300) */ + trap1, /* 33: sigreturn syscall or breakpoi */ + trap2, /* 34: breakpoint or sigreturn sysca */ + illinst, /* 35: TRAP instruction vector */ + illinst, /* 36: TRAP instruction vector */ + illinst, /* 37: TRAP instruction vector */ + illinst, /* 38: TRAP instruction vector */ + illinst, /* 39: TRAP instruction vector */ + illinst, /* 40: TRAP instruction vector */ + illinst, /* 41: TRAP instruction vector */ + illinst, /* 42: TRAP instruction vector */ + illinst, /* 43: TRAP instruction vector */ + COPY_ENTRY, /* 44: TRAP instruction vector */ + illinst, /* 45: TRAP instruction vector */ + illinst, /* 46: TRAP instruction vector */ + trap15, /* 47: TRAP instruction vector */ + fpbsun, /* 48: FPCP branch/set on unordered */ + fpinex, /* 49: FPCP inexact result */ + fpdz, /* 50: FPCP divide by zero */ + fpunfl, /* 51: FPCP underflow */ + fpoperr, /* 52: FPCP operand error */ + fpovfl, /* 53: FPCP overflow */ + fpsnan, /* 54: FPCP signalling NAN */ + fpunsupp, /* 55: FPCP unimplemented data type */ + badtrap, /* 56: unassigned, reserved */ + badtrap, /* 57: unassigned, reserved */ + badtrap, /* 58: unassigned, reserved */ + badtrap, /* 59: unassigned, reserved */ + badtrap, /* 60: unassigned, reserved */ + badtrap, /* 61: unassigned, reserved */ + badtrap, /* 62: unassigned, reserved */ + badtrap, /* 63: unassigned, reserved */ - COPY_ENTRY16, /* 64-79 */ - COPY_ENTRY16, /* 80-95 */ - COPY_ENTRY16, /* 96-111 */ - COPY_ENTRY16, /* 112-127 */ + BADTRAP16, /* 64-79 */ + BADTRAP16, /* 80-95 */ + BADTRAP16, /* 96-111 */ + BADTRAP16, /* 112-127 */ - COPY_ENTRY16, /* 128-143 */ - COPY_ENTRY16, /* 144-159 */ - COPY_ENTRY16, /* 160-175 */ - COPY_ENTRY16, /* 176-191 */ + BADTRAP16, /* 128-143 */ + BADTRAP16, /* 144-159 */ + BADTRAP16, /* 160-175 */ + BADTRAP16, /* 176-191 */ - COPY_ENTRY16, /* 192-207 */ - COPY_ENTRY16, /* 208-223 */ - COPY_ENTRY16, /* 224-239 */ - COPY_ENTRY16 /* 240-255 */ + BADTRAP16, /* 192-207 */ + BADTRAP16, /* 208-223 */ + BADTRAP16, /* 224-239 */ + BADTRAP16 /* 240-255 */ }; @@ -128,7 +145,7 @@ void set_vector_entry(entry, handler) { if ((entry <0) || (entry >= NVECTORS)) panic("set_vector_entry: setting vector too high or low\n"); - vector_table[entry] = (unsigned int) handler; + vector_table[entry] = handler; } unsigned int get_vector_entry(entry) @@ -136,5 +153,6 @@ unsigned int get_vector_entry(entry) { if ((entry <0) || (entry >= NVECTORS)) panic("get_vector_entry: setting vector too high or low\n"); - return vector_table[entry]; + return (unsigned int) vector_table[entry]; } + diff --git a/sys/arch/sun3/sun3/vector.h b/sys/arch/sun3/sun3/vector.h index ac07431a060c..60466ff53ce7 100644 --- a/sys/arch/sun3/sun3/vector.h +++ b/sys/arch/sun3/sun3/vector.h @@ -28,7 +28,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Header: /cvsroot/src/sys/arch/sun3/sun3/Attic/vector.h,v 1.3 1993/08/28 15:38:38 glass Exp $ + * $Header: /cvsroot/src/sys/arch/sun3/sun3/Attic/vector.h,v 1.4 1993/10/12 05:28:26 glass Exp $ */ #define COPY_ENTRY 0 @@ -37,7 +37,7 @@ #define VEC_INTERRUPT_BASE 0x18 #define VEC_LEVEL_7_INT 0x1F -extern unsigned int vector_table[]; +extern void (*vector_table[])(); void set_vector_entry __P((int, void (*handler)())); unsigned int get_vector_entry __P((int)); diff --git a/sys/arch/sun3/sun3/vm_machdep.c b/sys/arch/sun3/sun3/vm_machdep.c index 907918ad3443..9a131fac0852 100644 --- a/sys/arch/sun3/sun3/vm_machdep.c +++ b/sys/arch/sun3/sun3/vm_machdep.c @@ -88,7 +88,7 @@ cpu_fork(p1, p2) offset = getsp() - kstack; bcopy((caddr_t)kstack + offset, (caddr_t)p2->p_addr + offset, (unsigned) ctob(UPAGES) - offset); - + save_u_area(&p2->p_addr->u_pcb, p2->p_addr); PMAP_ACTIVATE(&p2->p_vmspace->vm_pmap, &up->u_pcb, 0); /*