From: John Hodge Date: Wed, 6 Nov 2013 04:00:34 +0000 (+0800) Subject: Kernel - Replaced for(;;); in panic with HALT_CPU macro X-Git-Tag: rel0.15~98 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=6b5fe5c5491e925bb1dd0d0650eeafd363538b1a;p=tpg%2Facess2.git Kernel - Replaced for(;;); in panic with HALT_CPU macro --- diff --git a/KernelLand/Kernel/arch/x86/include/arch.h b/KernelLand/Kernel/arch/x86/include/arch.h index 65868452..14742695 100644 --- a/KernelLand/Kernel/arch/x86/include/arch.h +++ b/KernelLand/Kernel/arch/x86/include/arch.h @@ -66,6 +66,8 @@ struct sShortSpinlock { * \brief Fire a magic breakpoint (bochs) */ #define MAGIC_BREAK() __asm__ __volatile__ ("xchg %bx, %bx") +// TODO: SMP halt request too +#define HALT_CPU() for(;;) { __asm__ __volatile__ ("cli; hlt"); } // === TYPES === typedef unsigned int Uint; // Unsigned machine native integer diff --git a/KernelLand/Kernel/debug.c b/KernelLand/Kernel/debug.c index a378ae81..70f503aa 100644 --- a/KernelLand/Kernel/debug.c +++ b/KernelLand/Kernel/debug.c @@ -123,7 +123,7 @@ void Debug_KernelPanic(void) } // 5 nested panics? Fuck it if( gbDebug_IsKPanic > 5 ) - for(;;); + HALT_CPU(); gbDebug_IsKPanic ++; KernelPanic_SetMode(); } @@ -254,7 +254,7 @@ void Panic(const char *Fmt, ...) //Threads_Dump(); //Heap_Dump(); - for(;;) ; + HALT_CPU(); } void Debug_SetKTerminal(const char *File) diff --git a/KernelLand/Kernel/include/acess.h b/KernelLand/Kernel/include/acess.h index 8c5e454a..a43e5c02 100644 --- a/KernelLand/Kernel/include/acess.h +++ b/KernelLand/Kernel/include/acess.h @@ -12,6 +12,10 @@ #include #include +#ifndef HALT_CPU +# define HALT_CPU() for(;;); +#endif + //! Pack a structure #define PACKED __attribute__((packed)) //! Mark a function as not returning