X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Fdebug.c;h=f78ea015fa91f32c35d579be91500c7b8d6afe84;hb=5c46f86c5a8ceaa63a1a9919cf1f4d2889c6c233;hp=854876ad707020ca695d028e87a7e0c60982aa1f;hpb=391af300bd045791b8aaf50cf44b2d503c763213;p=tpg%2Facess2.git diff --git a/Kernel/debug.c b/Kernel/debug.c index 854876ad..f78ea015 100644 --- a/Kernel/debug.c +++ b/Kernel/debug.c @@ -5,19 +5,42 @@ #include #include +#define DEBUG_TO_E9 1 +#define DEBUG_TO_SERIAL 1 +#define SERIAL_PORT 0x3F8 + // === IMPORTS === extern void Threads_Dump(); // === GLOBALS === int gDebug_Level = 0; int giDebug_KTerm = -1; + int gbDebug_SerialSetup = 0; // === CODE === static void E9(char ch) { if(giDebug_KTerm != -1) VFS_Write(giDebug_KTerm, 1, &ch); + + #if DEBUG_TO_SERIAL + if(!gbDebug_SerialSetup) { + outb(SERIAL_PORT + 1, 0x00); // Disable all interrupts + outb(SERIAL_PORT + 3, 0x80); // Enable DLAB (set baud rate divisor) + outb(SERIAL_PORT + 0, 0x03); // Set divisor to 3 (lo byte) 38400 baud + outb(SERIAL_PORT + 1, 0x00); // (hi byte) + outb(SERIAL_PORT + 3, 0x03); // 8 bits, no parity, one stop bit + outb(SERIAL_PORT + 2, 0xC7); // Enable FIFO with 14-byte threshold and clear it + outb(SERIAL_PORT + 4, 0x0B); // IRQs enabled, RTS/DSR set + gbDebug_SerialSetup = 1; + } + while( (inb(SERIAL_PORT + 5) & 0x20) == 0 ); + outb(SERIAL_PORT, ch); + #endif + + #if DEBUG_TO_E9 __asm__ __volatile__ ( "outb %%al, $0xe9" :: "a"(((Uint8)ch)) ); + #endif } static void E9_Str(char *Str) @@ -200,7 +223,7 @@ 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); + Log("Opened '%s' as %i\n", File, giDebug_KTerm); } void Debug_Enter(char *FuncName, char *ArgTypes, ...) @@ -330,6 +353,7 @@ void Debug_HexDump(char *Header, void *Data, Uint Length) } // --- EXPORTS --- +EXPORT(Log); EXPORT(Warning); EXPORT(Debug_Enter); EXPORT(Debug_Log);