From 00cf51252203dc0d26f1fb20665b216ff6d753e9 Mon Sep 17 00:00:00 2001 From: Ali Mashtizadeh Date: Wed, 2 Jul 2014 14:06:00 -0700 Subject: [PATCH] Build cleanup and implemented support for qemu debug logging --- sys/SConscript | 6 ++++-- sys/dev/console.c | 28 ++++++++++++++++++++++++++++ sys/dev/console.h | 10 +++------- sys/dev/x86/debugcons.c | 28 ++++++++++++++++++++++++++++ sys/dev/x86/debugcons.h | 9 +++++++++ 5 files changed, 72 insertions(+), 9 deletions(-) create mode 100644 sys/dev/console.c create mode 100644 sys/dev/x86/debugcons.c create mode 100644 sys/dev/x86/debugcons.h diff --git a/sys/SConscript b/sys/SConscript index 6030ea3..4b69600 100644 --- a/sys/SConscript +++ b/sys/SConscript @@ -19,14 +19,16 @@ src_amd64 = [ "amd64/lapic.c", "amd64/ioapic.c", "dev/x86/vgacons.c", - "dev/ahci.c", - "dev/pci.c", + "dev/x86/debugcons.c", ] src_common = [ "kern/libc.c", "kern/palloc.c", "kern/printf.c", + "dev/ahci.c", + "dev/console.c", + "dev/pci.c", ] if (env["ARCH"] == "amd64"): diff --git a/sys/dev/console.c b/sys/dev/console.c new file mode 100644 index 0000000..23bd2a5 --- /dev/null +++ b/sys/dev/console.c @@ -0,0 +1,28 @@ + +#include + +#include "console.h" +#include "x86/vgacons.h" +#include "x86/debugcons.h" + +void +Console_Init() +{ + VGA_Init(); + DebugConsole_Init(); +} + +void +Console_Putc(char ch) +{ + VGA_Putc(ch); + DebugConsole_Putc(ch); +} + +void +Console_Puts(const char *str) +{ + VGA_Puts(str); + DebugConsole_Puts(str); +} + diff --git a/sys/dev/console.h b/sys/dev/console.h index 918c710..b7511ca 100644 --- a/sys/dev/console.h +++ b/sys/dev/console.h @@ -2,13 +2,9 @@ #ifndef __CONSOLE_H__ #define __CONSOLE_H__ -#include "x86/vgacons.h" - -// Placeholder until a proper console driver is made - -#define Console_Init VGA_Init -#define Console_Putc VGA_Putc -#define Console_Puts VGA_Puts +void Console_Init(); +void Console_Putc(char ch); +void Console_Puts(const char *str); #endif /* __CONSOLE_H__ */ diff --git a/sys/dev/x86/debugcons.c b/sys/dev/x86/debugcons.c new file mode 100644 index 0000000..40a4847 --- /dev/null +++ b/sys/dev/x86/debugcons.c @@ -0,0 +1,28 @@ + +/* + * Debug Console for QEmu compatible port 0xe9 + */ + +#include + +#include + +#include "../../amd64/amd64.h" +#include "../../amd64/amd64op.h" + +void DebugConsole_Init() +{ +} + +void DebugConsole_Putc(short c) +{ + outb(0xe9, (uint8_t)c); +} + +void DebugConsole_Puts(const char *str) +{ + const char *p = str; + while (*p != '\0') + DebugConsole_Putc(*p++); +} + diff --git a/sys/dev/x86/debugcons.h b/sys/dev/x86/debugcons.h new file mode 100644 index 0000000..a9a10c0 --- /dev/null +++ b/sys/dev/x86/debugcons.h @@ -0,0 +1,9 @@ +#ifndef __DEBUGCONS_H__ +#define __DEBUGCONS_H__ + +void DebugConsole_Init(void); +void DebugConsole_Putc(char ch); +void DebugConsole_Puts(const char *str); + +#endif /* __DEBUGCONS_H__ */ +