X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=blobdiff_plain;f=test%2Fgeekos_test_vm%2Fsrc%2Fgeekos%2Ftrap.c;fp=test%2Fgeekos_test_vm%2Fsrc%2Fgeekos%2Ftrap.c;h=7932c9aa2084dc505969ce54c4eaa2866b2dfbe0;hp=0000000000000000000000000000000000000000;hb=a70930549d1b741704dd7af4e6bb0e89f6f8a519;hpb=afb634a80f946634454a5d067a92aa600227bd93 diff --git a/test/geekos_test_vm/src/geekos/trap.c b/test/geekos_test_vm/src/geekos/trap.c new file mode 100644 index 0000000..7932c9a --- /dev/null +++ b/test/geekos_test_vm/src/geekos/trap.c @@ -0,0 +1,45 @@ +/* + * Trap handlers + * Copyright (c) 2001,2003,2004 David H. Hovemeyer + * $Revision: 1.1 $ + * + * This is free software. You are permitted to use, + * redistribute, and modify it as specified in the file "COPYING". + */ + +#include +#include +#include +#include +#include + +/* + * 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... */ + PrintBoth("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 */ +}