Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 Jul 2007 13:57:51 GMT
From:      Oleksandr Tymoshenko <gonzo@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 122954 for review
Message-ID:  <200707051357.l65Dvp18075538@repoman.freebsd.org>

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

Change 122954 by gonzo@gonzo_jeeves on 2007/07/05 13:57:25

	o Show fields and flags of cp0 status and cause registers on
	    panic.

Affected files ...

.. //depot/projects/mips2/src/sys/mips/mips/trap.c#22 edit

Differences ...

==== //depot/projects/mips2/src/sys/mips/mips/trap.c#22 (text+ko) ====

@@ -129,6 +129,26 @@
 	trapsignal(td, &ksi);
 }
 
+/*
+ *  Helper routines to explain content of fields/flags for cp0 registers
+ */
+#define PRINT_VAL(val, bit, size, name)		do {			\
+		if(coma)						\
+			printf(",");					\
+		printf("%s=%x", name,					\
+		    (((val) >> (bit)) & ((1 << ((size)+1))-1)));	\
+		coma = 1;						\
+	} while(0)
+
+#define PRINT_FLAG(val, bit, name)	do {				\
+		if(((val) >> (bit)) & 1) {				\
+			if(coma)					\
+				printf(",");				\
+			printf("%s", name);				\
+			coma = 1;					\
+		}							\
+	} while(0)
+
 void
 trap(struct trapframe * tf, u_int cause, void *badvaddr)
 {
@@ -138,6 +158,7 @@
 	struct trap_identifier *tid;
 	int code, kernelmode;
 	int ftype, error;
+	u_int coma = 0, status;
 
 	platform_trap_enter();
 
@@ -303,8 +324,40 @@
 	printf("program counter     = %#x\n", tf->tf_regs[TF_EPC]);
 	printf("return address      = %#x\n", tf->tf_regs[TF_RA]);
 	printf("bad virtual address = %p\n", badvaddr);
-	printf("cause               = %#x\n", cause);
-	printf("status              = %#x\n", tf->tf_regs[TF_SR]);
+
+	printf("cause               = %#x <", cause);
+	PRINT_VAL(cause, 2, 5, "ExcCode");
+	PRINT_VAL(cause, 8, 2, "IPSW");
+	PRINT_VAL(cause, 10, 2, "IPHW");
+	PRINT_FLAG(cause, 22, "WP");
+	PRINT_FLAG(cause, 23, "IV");
+	PRINT_VAL(cause, 28, 2, "CE");
+	PRINT_FLAG(cause, 31, "BD");
+	printf(">\n");
+
+	coma = 0;
+	status = tf->tf_regs[TF_SR];
+	printf("status              = %#x <", status);
+	PRINT_VAL(status, 28, 4, "CU");
+	PRINT_FLAG(status, 27, "RP");
+	PRINT_FLAG(status, 26, "FR");
+	PRINT_FLAG(status, 25, "RE");
+	PRINT_FLAG(status, 24, "MX");
+	PRINT_FLAG(status, 23, "PX");
+	PRINT_FLAG(status, 22, "BEV");
+	PRINT_FLAG(status, 21, "TS");
+	PRINT_FLAG(status, 20, "SR");
+	PRINT_FLAG(status, 19, "NMI");
+	PRINT_VAL(status, 8, 8, "IM");
+	PRINT_FLAG(status, 7, "KX");
+	PRINT_FLAG(status, 6, "SX");
+	PRINT_FLAG(status, 5, "UX");
+	PRINT_FLAG(status, 4, "UM");
+	PRINT_FLAG(status, 3, "RO");
+	PRINT_FLAG(status, 2, "ERL");
+	PRINT_FLAG(status, 1, "EXL");
+	PRINT_FLAG(status, 0, "IE");
+	printf(">\n");
 	printf("current thread      = %p\n", curthread);
 	if (curthread != NULL) {
 		printf("current process     = ");
@@ -339,6 +392,9 @@
 	platform_trap_exit();
 }
 
+#undef PRINT_FLAG
+#undef PRINT_VAL
+
 int
 check_address(void *addr)
 {



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