]> hydra-www.ietfng.org Git - xv6-public/commitdiff
Add prepanic() function to prepare for panic
authorNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Sat, 7 Nov 2015 05:35:25 +0000 (00:35 -0500)
committerNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Wed, 11 Nov 2015 04:42:27 +0000 (23:42 -0500)
console.c
defs.h
trap.c

index c2319be7ce4a6af8ceff39218c6879032bfe008b..5d70b499aa6b5b22d6ccb004bf3a67802521755d 100644 (file)
--- a/console.c
+++ b/console.c
@@ -102,14 +102,20 @@ cprintf(char *fmt, ...)
     release(&cons.lock);
 }
 
+void
+prepanic(void)
+{
+  cli();
+  cons.locking = 0;
+}
+
 void
 panic(char *s)
 {
   int i;
   uint pcs[10];
-  
-  cli();
-  cons.locking = 0;
+
+  prepanic();
   cprintf("cpu%d: panic: ", cpu->id);
   cprintf(s);
   cprintf("\n");
diff --git a/defs.h b/defs.h
index e43788ed6065c0d57397e57eb28ee60c89fbb3f1..1db4fcc3d4087abea51c95a7037775285ae6150a 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -25,6 +25,7 @@ void            cmostime(struct rtcdate *r);
 void            consoleinit(void);
 void            cprintf(char*, ...);
 void            consoleintr(int(*)(void));
+void            prepanic(void);
 void            panic(char*) __attribute__((noreturn));
 
 // debug.c
diff --git a/trap.c b/trap.c
index 043c9e4f54aaf3ef63af3421b55fc7067b4160b5..ae36a2eff9271b7ff1a0fdb0da05a04c38edbc6c 100644 (file)
--- a/trap.c
+++ b/trap.c
@@ -87,6 +87,7 @@ trap(struct trapframe *tf)
   //PAGEBREAK: 13
   default:
     if(proc == 0 || (tf->cs&3) == 0){
+      prepanic();
       // In kernel, it must be our mistake.
       cprintf("unexpected trap %d from cpu %d eip %x (cr2=0x%x)\n",
               tf->trapno, cpu->id, tf->eip, rcr2());