# HG changeset patch # User Jonathan Pevarnek # Date 1316723180 14400 # Node ID 03be5ed1f60929777b64f703a34f176dd579e4c1 # Parent cf569b2ab76cb2c7c5abdcd9785dfc7909970b00 Use a better method to end a program when an exception occurs diff -r cf569b2ab76c -r 03be5ed1f609 include/os/scall.h --- a/include/os/scall.h Thu Sep 22 16:12:27 2011 -0400 +++ b/include/os/scall.h Thu Sep 22 16:26:20 2011 -0400 @@ -6,6 +6,7 @@ PCB shellPCB; +void end_program(); u64 svc_handler(u64 callCode, u64 a, u64 b, u64 c, u64 d); #endif //__SCALL_H diff -r cf569b2ab76c -r 03be5ed1f609 src/os/except.c --- a/src/os/except.c Thu Sep 22 16:12:27 2011 -0400 +++ b/src/os/except.c Thu Sep 22 16:26:20 2011 -0400 @@ -3,7 +3,7 @@ #include #include #include -#include +#include extern void PROGINT(void); @@ -31,7 +31,7 @@ sPrint(buffer); if(oldPsw->p) { //was running in the program mode, switch back to shell - exit(); //not sure if this is the best way to do it... + end_program(); } //kill the machine diff -r cf569b2ab76c -r 03be5ed1f609 src/os/scall.c --- a/src/os/scall.c Thu Sep 22 16:12:27 2011 -0400 +++ b/src/os/scall.c Thu Sep 22 16:26:20 2011 -0400 @@ -4,13 +4,18 @@ #include #include #include -/* -#include -#include -*/ MemStack *ms = NULL; +void end_program() +{ + if(ms) { + msDestroy(ms, freeHeap); + ms = NULL; + } + setcontext_pcb(&shellPCB); +} + u64 svc_handler(u64 callCode, u64 a, u64 b, u64 c, u64 d) { PCB pcb; @@ -18,11 +23,7 @@ savecontext_pcb(&pcb); switch(callCode) { case SVC_EXIT: - if(ms) { - msDestroy(ms, freeHeap); //dynamic memory was used, kill it - ms = NULL; - } - setcontext_pcb(&shellPCB); + end_program(); break; case SVC_PRINT: //print pcb.registers[2] = putline((char*)a, (u32)b);