Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 24 May 2003 16:39:48 -0700 (PDT)
From:      Juli Mallett <jmallett@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 31828 for review
Message-ID:  <200305242339.h4ONdm0C012735@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=31828

Change 31828 by jmallett@jmallett_dalek on 2003/05/24 16:39:26

	Beginnings of moving to new exception code.  Right now it only
	provides the generic exception vector, and saves registers then
	restores them, jumping to trap() in between.  This is enough to
	print out "Fatal trap ..." messages in a very minimal way.
	
	It resets on a double panic.  (After printing (some) state.)

Affected files ...

.. //depot/projects/mips/sys/conf/files.mips#18 edit
.. //depot/projects/mips/sys/mips/mips/genassym.c#8 edit
.. //depot/projects/mips/sys/mips/mips/machdep.c#26 edit
.. //depot/projects/mips/sys/mips/mips/trap.c#2 edit

Differences ...

==== //depot/projects/mips/sys/conf/files.mips#18 (text+ko) ====

@@ -12,6 +12,7 @@
 # This stanza is MIPS MD files.
 mips/mips/critical.c		standard
 mips/mips/elf_machdep.c		standard
+mips/mips/exception.S		standard
 mips/mips/locore.S		standard	no-obj
 mips/mips/locore_mips3.S	standard
 mips/mips/machdep.c		standard

==== //depot/projects/mips/sys/mips/mips/genassym.c#8 (text+ko) ====

@@ -148,6 +148,7 @@
 
 ASSYM(TF_BASE, offsetof(struct kernframe, cf_frame));
 
+ASSYM(TF_SIZE, sizeof(struct trapframe));
 ASSYM(TF_REG_AST, offsetof(struct trapframe, tf_regs[TF_AST]));
 ASSYM(TF_REG_V0, offsetof(struct trapframe, tf_regs[TF_V0]));
 ASSYM(TF_REG_V1, offsetof(struct trapframe, tf_regs[TF_V1]));

==== //depot/projects/mips/sys/mips/mips/machdep.c#26 (text+ko) ====

@@ -577,7 +577,7 @@
 mips64_vector_init(void)
 {
 	/* r4000 exception handler address and end */
-	extern char mips64_exception[], mips64_exceptionEnd[];
+	extern char ExceptionVector[], ExceptionVectorEnd[];
 
 	/* TLB miss handler address and end */
 	extern char mips64_TLBMiss[], mips64_TLBMissEnd[];
@@ -610,10 +610,10 @@
 	memcpy((void *)MIPS3_CACHE_ERR_EXC_VEC, mips64_cache,
 	      mips64_cacheEnd - mips64_cache);
 
-	if (mips64_exceptionEnd - mips64_exception > 0x80)
+	if (ExceptionVectorEnd - ExceptionVector > 0x80)
 		panic("startup: General exception vector code too large");
-	memcpy((void *)MIPS3_GEN_EXC_VEC, mips64_exception,
-	      mips64_exceptionEnd - mips64_exception);
+	memcpy((void *)MIPS3_GEN_EXC_VEC, ExceptionVector,
+	      ExceptionVectorEnd - ExceptionVector);
 
 #if 0	/* XXX - why doesn't mipsNN_intr() work? */
 	if (mips64_intrEnd - mips64_intr > 0x80)
@@ -621,8 +621,8 @@
 	memcpy((void *)MIPS3_INTR_EXC_VEC, mips64_intr,
 	      mips64_intrEnd - mips64_intr);
 #else
-	memcpy((void *)MIPS3_INTR_EXC_VEC, mips64_exception,
-	      mips64_exceptionEnd - mips64_exception);
+	memcpy((void *)MIPS3_INTR_EXC_VEC, ExceptionVector,
+	      ExceptionVectorEnd - ExceptionVector);
 #endif
 
 	/*

==== //depot/projects/mips/sys/mips/mips/trap.c#2 (text+ko) ====

@@ -30,9 +30,21 @@
 #include <sys/systm.h>
 
 #include <machine/frame.h>
+#include <machine/trap.h>
 
 void
-trap(unsigned status, unsigned cause, unsigned vaddr, unsigned opc, struct trapframe *fp)
+trap(struct trapframe *tf, u_int cause, void *badvaddr)
 {
-	panic("trap!!");
+	int code, kernelmode;
+
+	code = (cause & MIPS3_CR_EXC_CODE) >> MIPS_CR_EXC_CODE_SHIFT;
+	kernelmode = (tf->tf_regs[TF_SR] & MIPS_SR_KSU_USER) == 0;
+	printf("Fatal trap type %d in %s mode\n",
+	       code, kernelmode ? "kernel" : "user");
+	printf("EPC %lx, BadVAddr %p\n", tf->tf_regs[TF_EPC], badvaddr);
+	if (panicstr != NULL) {
+		printf("Double panic, resetting...\n");
+		cpu_reset();
+	}
+	panic("trap");
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200305242339.h4ONdm0C012735>