Cleanups & Implementations to allow IPStack to compile
[tpg/acess2.git] / Kernel / debug.c
index 8df3609..854876a 100644 (file)
@@ -5,16 +5,21 @@
 #include <common.h>
 #include <stdarg.h>
 
-// === MACROS ===
-#define E9(ch) __asm__ __volatile__ ("outb %%al, $0xe9"::"a"(((Uint8)ch)))
-
 // === IMPORTS ===
-extern void Proc_DumpThreads();
+extern void Threads_Dump();
 
 // === GLOBALS ===
  int   gDebug_Level = 0;
+ int   giDebug_KTerm = -1;
 
 // === CODE ===
+static void E9(char ch)
+{
+       if(giDebug_KTerm != -1)
+               VFS_Write(giDebug_KTerm, 1, &ch);
+       __asm__ __volatile__ ( "outb %%al, $0xe9" :: "a"(((Uint8)ch)) );
+}
+
 static void E9_Str(char *Str)
 {
        while(*Str)     E9(*Str++);
@@ -183,13 +188,21 @@ void Panic(char *Fmt, ...)
        va_end(args);
        E9('\n');
        
-       Proc_DumpThreads();
+       Threads_Dump();
        
        __asm__ __volatile__ ("xchg %bx, %bx");
        __asm__ __volatile__ ("cli;\n\thlt");
        for(;;) __asm__ __volatile__ ("hlt");
 }
 
+void Debug_SetKTerminal(char *File)
+{
+       if(giDebug_KTerm != -1)
+               VFS_Close(giDebug_KTerm);
+       giDebug_KTerm = VFS_Open(File, VFS_OPENFLAG_WRITE);
+       Log("Opend '%s' as %i\n", File, giDebug_KTerm);
+}
+
 void Debug_Enter(char *FuncName, char *ArgTypes, ...)
 {
        va_list args;
@@ -311,10 +324,9 @@ void Debug_HexDump(char *Header, void *Data, Uint Length)
                Uint    byte = *cdat;
                LogF("%02x ", byte);
                Length--;
-               cdat --;
+               cdat ++;
        }
        E9('\n');
-       
 }
 
 // --- EXPORTS ---

UCC git Repository :: git.ucc.asn.au