From: Jack Lange Date: Fri, 19 Dec 2008 07:29:55 +0000 (-0600) Subject: added halt to infinite loops X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=commitdiff_plain;h=dff5e69505c2893d062acf50f2268b3528c9556f;p=palacios.git added halt to infinite loops --- diff --git a/geekos/include/geekos/kassert.h b/geekos/include/geekos/kassert.h index 434a8a8..65e2db3 100644 --- a/geekos/include/geekos/kassert.h +++ b/geekos/include/geekos/kassert.h @@ -19,6 +19,7 @@ extern struct Kernel_Thread* g_currentThread; #define KASSERT(cond) \ do { \ + extern void Halt(); \ if (!(cond)) { \ Set_Current_Attr(ATTRIB(RED, GRAY|BRIGHT)); \ Print("Failed assertion in %s: %s at %s, line %d, RA=%lx, thread=%p\n",\ @@ -26,16 +27,17 @@ do { \ (ulong_t) __builtin_return_address(0), \ g_currentThread); \ while (1) \ - ; \ + Halt(); \ } \ } while (0) #define TODO(message) \ -do { \ + do { \ + extern void Halt(); \ Set_Current_Attr(ATTRIB(BLUE, GRAY|BRIGHT)); \ Print("Unimplemented feature: %s\n", (message)); \ while (1) \ - ; \ + Halt(); \ } while (0) /* @@ -66,7 +68,7 @@ do { \ * Its behavior does not depend on whether or not this * is a debug build. */ -#define STOP() while (1) +#define STOP() while (1) {Halt();} /* * Panic function. @@ -75,7 +77,7 @@ do { \ do { \ Set_Current_Attr(ATTRIB(RED, GRAY|BRIGHT)); \ Print(args); \ - while (1) ; \ + while (1) Halt(); \ } while (0) #endif /* GEEKOS_KASSERT_H */ diff --git a/geekos/src/geekos/lowlevel.asm b/geekos/src/geekos/lowlevel.asm index 2c64e8a..c8d0b8d 100644 --- a/geekos/src/geekos/lowlevel.asm +++ b/geekos/src/geekos/lowlevel.asm @@ -160,6 +160,9 @@ EXPORT Get_ESP ; EBP EXPORT Get_EBP +; Halt machine +EXPORT Halt + ; Virtual memory support. EXPORT Enable_Paging EXPORT Set_PDBR @@ -381,6 +384,11 @@ Get_MSR: align 8 +Halt: + hlt + + +align 8 Get_CR2: mov eax, cr2 ret diff --git a/geekos/src/geekos/main.c b/geekos/src/geekos/main.c index 5d71341..1fbd1c9 100644 --- a/geekos/src/geekos/main.c +++ b/geekos/src/geekos/main.c @@ -47,11 +47,12 @@ +extern void Halt(); void Spin() { // hack - competing thread - while (1) {}; + while (1) {Halt();}; } @@ -276,7 +277,7 @@ void Main(struct Boot_Info* bootInfo) SerialPrint("RunVMM returned, spinning\n"); - while (1) {} + while (1) {Halt();} TODO("Write a Virtual Machine Monitor");