From 6b5fe5c5491e925bb1dd0d0650eeafd363538b1a Mon Sep 17 00:00:00 2001 From: John Hodge Date: Wed, 6 Nov 2013 12:00:34 +0800 Subject: [PATCH] Kernel - Replaced for(;;); in panic with HALT_CPU macro --- KernelLand/Kernel/arch/x86/include/arch.h | 2 ++ KernelLand/Kernel/debug.c | 4 ++-- KernelLand/Kernel/include/acess.h | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) 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 -- 2.20.1