#define LOCK_DEBUG_OUTPUT 1
+#define TRACE_TO_KTERM 0
+
// === IMPORTS ===
extern void Threads_Dump(void);
extern void KernelPanic_SetMode(void);
// === PROTOTYPES ===
static void Debug_Putchar(char ch);
-static void Debug_Puts(int DbgOnly, const char *Str);
+static void Debug_Puts(int bUseKTerm, const char *Str);
void Debug_DbgOnlyFmt(const char *format, va_list args);
-void Debug_FmtS(const char *format, ...);
-void Debug_Fmt(const char *format, va_list args);
+void Debug_FmtS(int bUseKTerm, const char *format, ...);
+void Debug_Fmt(int bUseKTerm, const char *format, va_list args);
void Debug_SetKTerminal(const char *File);
// === GLOBALS ===
void Debug_DbgOnlyFmt(const char *format, va_list args)
{
- char buf[DEBUG_MAX_LINE_LEN];
- int len;
- buf[DEBUG_MAX_LINE_LEN-1] = 0;
- len = vsnprintf(buf, DEBUG_MAX_LINE_LEN-1, format, args);
- //if( len < DEBUG_MAX_LINE )
- // do something
- Debug_Puts(0, buf);
+ Debug_Fmt(0, format, args);
}
-void Debug_Fmt(const char *format, va_list args)
+void Debug_Fmt(int bUseKTerm, const char *format, va_list args)
{
char buf[DEBUG_MAX_LINE_LEN];
int len;
len = vsnprintf(buf, DEBUG_MAX_LINE_LEN-1, format, args);
//if( len < DEBUG_MAX_LINE )
// do something
- Debug_Puts(1, buf);
+ Debug_Puts(bUseKTerm, buf);
return ;
}
-void Debug_FmtS(const char *format, ...)
+void Debug_FmtS(int bUseKTerm, const char *format, ...)
{
va_list args;
va_start(args, format);
- Debug_Fmt(format, args);
+ Debug_Fmt(bUseKTerm, format, args);
va_end(args);
}
-void Debug_KernelPanic()
+void Debug_KernelPanic(void)
{
gbDebug_IsKPanic = 1;
KernelPanic_SetMode();
va_start(args, Fmt);
- Debug_Fmt(Fmt, args);
+ Debug_Fmt(1, Fmt, args);
va_end(args);
Debug_Puts(1, "Log: ");
va_start(args, Fmt);
- Debug_Fmt(Fmt, args);
+ Debug_Fmt(1, Fmt, args);
va_end(args);
- Debug_Putchar('\r');
- Debug_Putchar('\n');
+ Debug_Puts(1, "\r\n");
#if LOCK_DEBUG_OUTPUT
SHORTREL(&glDebug_Lock);
Debug_Puts(1, "Warning: ");
va_start(args, Fmt);
- Debug_Fmt(Fmt, args);
+ Debug_Fmt(1, Fmt, args);
va_end(args);
Debug_Putchar('\r');
Debug_Putchar('\n');
Debug_Puts(1, "Panic: ");
va_start(args, Fmt);
- Debug_Fmt(Fmt, args);
+ Debug_Fmt(1, Fmt, args);
va_end(args);
Debug_Putchar('\r');
Debug_Putchar('\n');
va_start(args, ArgTypes);
- LogF("%014lli ", now());
- while(i--) Debug_Putchar(' ');
+ Debug_FmtS(TRACE_TO_KTERM, "%014lli ", now());
+ while(i--) Debug_Puts(TRACE_TO_KTERM, " ");
- Debug_Puts(1, FuncName);
- Debug_FmtS("[%i]", tid);
- Debug_Puts(1, ": (");
+ Debug_Puts(TRACE_TO_KTERM, FuncName);
+ Debug_FmtS(TRACE_TO_KTERM, "[%i]", tid);
+ Debug_Puts(TRACE_TO_KTERM, ": (");
while(*ArgTypes)
{
pos = strpos(ArgTypes, ' ');
if(pos == -1 || pos > 1) {
if(pos == -1)
- Debug_Puts(1, ArgTypes+1);
+ Debug_Puts(TRACE_TO_KTERM, ArgTypes+1);
else {
- for( i = 1; i < pos; i ++ )
- Debug_Putchar(ArgTypes[i]);
+ Debug_FmtS(TRACE_TO_KTERM, "%.*s", pos-1, ArgTypes+1);
}
- Debug_Putchar('=');
+ Debug_Puts(TRACE_TO_KTERM, "=");
}
switch(*ArgTypes)
{
- case 'p': LogF("%p", va_arg(args, void*)); break;
- case 's': LogF("'%s'", va_arg(args, char*)); break;
- case 'i': LogF("%i", va_arg(args, int)); break;
- case 'u': LogF("%u", va_arg(args, Uint)); break;
- case 'x': LogF("0x%x", va_arg(args, Uint)); break;
- case 'b': LogF("0b%b", va_arg(args, Uint)); break;
- case 'X': LogF("0x%llx", va_arg(args, Uint64)); break; // Extended (64-Bit)
- case 'B': LogF("0b%llb", va_arg(args, Uint64)); break; // Extended (64-Bit)
+ case 'p': Debug_FmtS(TRACE_TO_KTERM, "%p", va_arg(args, void*)); break;
+ case 'P': Debug_FmtS(TRACE_TO_KTERM, "%P", va_arg(args, tPAddr)); break;
+ case 's': Debug_FmtS(TRACE_TO_KTERM, "'%s'", va_arg(args, char*)); break;
+ case 'i': Debug_FmtS(TRACE_TO_KTERM, "%i", va_arg(args, int)); break;
+ case 'u': Debug_FmtS(TRACE_TO_KTERM, "%u", va_arg(args, Uint)); break;
+ case 'x': Debug_FmtS(TRACE_TO_KTERM, "0x%x", va_arg(args, Uint)); break;
+ case 'b': Debug_FmtS(TRACE_TO_KTERM, "0b%b", va_arg(args, Uint)); break;
+ case 'X': Debug_FmtS(TRACE_TO_KTERM, "0x%llx", va_arg(args, Uint64)); break; // Extended (64-Bit)
+ case 'B': Debug_FmtS(TRACE_TO_KTERM, "0b%llb", va_arg(args, Uint64)); break; // Extended (64-Bit)
}
if(pos != -1) {
- Debug_Putchar(','); Debug_Putchar(' ');
+ Debug_Puts(TRACE_TO_KTERM, ", ");
}
if(pos == -1) break;
}
va_end(args);
- Debug_Putchar(')'); Debug_Putchar('\r'); Debug_Putchar('\n');
+ Debug_Puts(TRACE_TO_KTERM, ")\r\n");
#if LOCK_DEBUG_OUTPUT
SHORTREL(&glDebug_Lock);
SHORTLOCK(&glDebug_Lock);
#endif
- va_start(args, Fmt);
-
- LogF("%014lli ", now());
- while(i--) Debug_Putchar(' ');
+ Debug_FmtS(TRACE_TO_KTERM, "%014lli ", now());
+ while(i--) Debug_Puts(TRACE_TO_KTERM, " ");
- Debug_Puts(1, FuncName);
- Debug_FmtS("[%i]", tid);
- Debug_Puts(1, ": ");
- Debug_Fmt(Fmt, args);
+ Debug_Puts(TRACE_TO_KTERM, FuncName);
+ Debug_FmtS(TRACE_TO_KTERM, "[%i]", tid);
+ Debug_Puts(TRACE_TO_KTERM, ": ");
+ va_start(args, Fmt);
+ Debug_Fmt(TRACE_TO_KTERM, Fmt, args);
va_end(args);
- Debug_Putchar('\r');
- Debug_Putchar('\n');
+
+ Debug_Puts(TRACE_TO_KTERM, "\r\n");
#if LOCK_DEBUG_OUTPUT
SHORTREL(&glDebug_Lock);
gDebug_Level = 0;
i = 0;
}
- LogF("%014lli ", now());
+ Debug_FmtS(TRACE_TO_KTERM, "%014lli ", now());
// Indenting
- while(i--) Debug_Putchar(' ');
+ while(i--) Debug_Puts(TRACE_TO_KTERM, " ");
- Debug_Puts(1, FuncName);
- Debug_FmtS("[%i]", tid);
- Debug_Puts(1, ": RETURN");
+ Debug_Puts(TRACE_TO_KTERM, FuncName);
+ Debug_FmtS(TRACE_TO_KTERM, "[%i]", tid);
+ Debug_Puts(TRACE_TO_KTERM, ": RETURN");
// No Return
if(RetType == '-') {
- Debug_Putchar('\r');
- Debug_Putchar('\n');
+ Debug_Puts(TRACE_TO_KTERM, "\r\n");
#if LOCK_DEBUG_OUTPUT
SHORTREL(&glDebug_Lock);
#endif
return;
}
- Debug_Putchar(' ');
switch(RetType)
{
- case 'n': Debug_Puts(1, "NULL"); break;
- case 'p': Debug_Fmt("%p", args); break;
- case 's': Debug_Fmt("'%s'", args); break;
- case 'i': Debug_Fmt("%i", args); break;
- case 'u': Debug_Fmt("%u", args); break;
- case 'x': Debug_Fmt("0x%x", args); break;
+ case 'n': Debug_Puts(TRACE_TO_KTERM, " NULL"); break;
+ case 'p': Debug_Fmt(TRACE_TO_KTERM, " %p", args); break;
+ case 'P': Debug_Fmt(TRACE_TO_KTERM, " %P", args); break; // PAddr
+ case 's': Debug_Fmt(TRACE_TO_KTERM, " '%s'", args); break;
+ case 'i': Debug_Fmt(TRACE_TO_KTERM, " %i", args); break;
+ case 'u': Debug_Fmt(TRACE_TO_KTERM, " %u", args); break;
+ case 'x': Debug_Fmt(TRACE_TO_KTERM, " 0x%x", args); break;
// Extended (64-Bit)
- case 'X': Debug_Fmt("0x%llx", args); break;
+ case 'X': Debug_Fmt(TRACE_TO_KTERM, " 0x%llx", args); break;
}
- Debug_Putchar('\r');
- Debug_Putchar('\n');
+ Debug_Puts(TRACE_TO_KTERM, "\r\n");
va_end(args);