A_OBJ = start.ao main.o lib.o desctab.ao errors.o irq.o
A_OBJ += mm_phys.o mm_virt.o
A_OBJ += proc.o time.o vm8086.o
-#A_OBJ += gdb_stub.o
+A_OBJ += kpanic.o
return ;
}
+ Debug_KernelPanic();
Warning("CPU Error %i - %s, Code: 0x%x",
Regs->int_num, csaERROR_NAMES[Regs->int_num], Regs->err_code);
Warning(" CS:EIP = 0x%04x:%08x", Regs->cs, Regs->eip);
--- /dev/null
+/*
+ * Acess 2 Kernel
+ * By John Hodge (thePowersGang)
+ * - x86 Kernel Panic Handler
+ */
+
+#include <acess.h>
+
+#define FB ((Uint16 *)(KERNEL_BASE|0xB8000))
+
+ int giKP_Pos = 0;
+
+/**
+ * \brief Sets the screen mode for a kernel panic
+ */
+void KernelPanic_SetMode()
+{
+ int i;
+ // Restore VGA 0xB8000 text mode
+
+ // Clear Screen
+ for( i = 0; i < 80*25; i++ )
+ {
+ FB[i] = 0x4F00;
+ }
+}
+
+void KernelPanic_PutChar(char Ch)
+{
+ if( giKP_Pos > 80*25 ) return ;
+ switch(Ch)
+ {
+ case '\t':
+ do {
+ FB[giKP_Pos] &= 0xFF00;
+ FB[giKP_Pos++] |= ' ';
+ } while(giKP_Pos & 7);
+ break;
+
+ case '\n':
+ giKP_Pos += 80;
+ case '\r':
+ giKP_Pos -= giKP_Pos % 80;
+ break;
+
+ default:
+ if(' ' <= Ch && Ch < 0x7F)
+ {
+ FB[giKP_Pos] &= 0xFF00;
+ FB[giKP_Pos] |= Ch;
+ }
+ giKP_Pos ++;
+ break;
+ }
+}
return ;
}
+ Debug_KernelPanic();
+
// -- Check Error Code --
if(ErrorCode & 8)
Warning("Reserved Bits Trashed!");
#define GDB_SERIAL_PORT 0x2F8
// === IMPORTS ===
-extern void Threads_Dump();
+extern void Threads_Dump(void);
+extern void KernelPanic_SetMode(void);
+extern void KernelPanic_PutChar(char Ch);
// === GLOBALS ===
int gDebug_Level = 0;
int giDebug_KTerm = -1;
int gbDebug_SerialSetup = 0;
int gbGDB_SerialSetup = 0;
+ int gbDebug_IsKPanic = 0;
// === CODE ===
int putDebugChar(char ch)
outb(SERIAL_PORT, ch);
#endif
- if(gbInPutChar) return ;
- gbInPutChar = 1;
- if(giDebug_KTerm != -1)
- VFS_Write(giDebug_KTerm, 1, &ch);
- gbInPutChar = 0;
+ if( !gbDebug_IsKPanic )
+ {
+ if(gbInPutChar) return ;
+ gbInPutChar = 1;
+ if(giDebug_KTerm != -1)
+ VFS_Write(giDebug_KTerm, 1, &ch);
+ gbInPutChar = 0;
+ }
+ else
+ KernelPanic_PutChar(ch);
}
static void Debug_Puts(char *Str)
}
}
+void Debug_KernelPanic()
+{
+ gbDebug_IsKPanic = 1;
+ KernelPanic_SetMode();
+}
+
/**
* \fn void LogF(char *Msg, ...)
*/
void Panic(char *Fmt, ...)
{
va_list args;
+
+ Debug_KernelPanic();
+
Debug_Puts("Panic: ");
va_start(args, Fmt);
Debug_Fmt(Fmt, &args);
* \name Debugging and Errors
* \{
*/
-extern void Panic(char *Msg, ...);
-extern void Warning(char *Msg, ...);
-extern void Log(char *Fmt, ...);
-extern void LogV(char *Fmt, va_list Args);
-extern void LogF(char *Fmt, ...);
+extern void Debug_KernelPanic(); //!< Initiate a kernel panic
+extern void Panic(char *Msg, ...); //!< Print a panic message (initiates a kernel panic)
+extern void Warning(char *Msg, ...); //!< Print a warning message
+extern void LogF(char *Fmt, ...); //!< Print a log message without a trailing newline
+extern void Log(char *Fmt, ...); //!< Print a log message
+extern void LogV(char *Fmt, va_list Args); //!< va_list Log message
extern void Debug_Enter(char *FuncName, char *ArgTypes, ...);
extern void Debug_Log(char *FuncName, char *Fmt, ...);
extern void Debug_Leave(char *FuncName, char RetType, ...);