Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Release 1.0
[palacios.git] / geekos / src / geekos / trap.c
diff --git a/geekos/src/geekos/trap.c b/geekos/src/geekos/trap.c
new file mode 100644 (file)
index 0000000..6b8629d
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Trap handlers
+ * Copyright (c) 2001,2003,2004 David H. Hovemeyer <daveho@cs.umd.edu>
+ * $Revision: 1.3 $
+ * 
+ * This is free software.  You are permitted to use,
+ * redistribute, and modify it as specified in the file "COPYING".
+ */
+
+#include <geekos/idt.h>
+#include <geekos/kthread.h>
+#include <geekos/defs.h>
+#include <geekos/trap.h>
+#include <geekos/serial.h>
+#include <geekos/debug.h>
+/*
+ * TODO: need to add handlers for other exceptions (such as bounds
+ * check, debug, etc.)
+ */
+
+/*
+ * Handler for general protection faults and other bad errors.
+ * Kill the current thread (which caused the fault).
+ */
+static void GPF_Handler(struct Interrupt_State* state)
+{
+    /* Send the thread to the reaper... */
+  SerialPrintLevel(1000,"VMM: Exception %d received, killing thread %p\n",state->intNum, g_currentThread);
+  Dump_Interrupt_State(state);
+  
+  Exit(-1);
+  
+  /* We will never get here */
+  KASSERT(false);
+}
+
+/*
+ * Initialize handlers for processor traps.
+ */
+void Init_Traps(void)
+{
+  PrintBoth("Initializing Traps\n");
+  Install_Interrupt_Handler(12, &GPF_Handler);  /* stack exception */
+  Install_Interrupt_Handler(13, &GPF_Handler);  /* general protection fault */
+}