diff --git a/src/Interrupts.cc b/src/Interrupts.cc index 4ae6a89..a2b278f 100644 --- a/src/Interrupts.cc +++ b/src/Interrupts.cc @@ -162,7 +162,6 @@ InterruptHandler::doKeyboardInterrupt() { // Quick 'n dirty read the scancode. unsigned int c = 0; - auto& console = kernel::Console::systemConsole(); do { c = kernel::io::inw(0x60); kstd::printFormat("Key! (scancode 0x%02X)\n", c); diff --git a/src/Kernel.cc b/src/Kernel.cc index af9866f..292d221 100644 --- a/src/Kernel.cc +++ b/src/Kernel.cc @@ -44,7 +44,7 @@ Kernel::initialize(const StartupInformation& startupInformation) { mConsole.clear(kernel::Console::Color::Blue); - kstd::printString("Loading Polka...\n"); + kstd::printFormat("Loading Polka...\n"); kstd::printFormat("Kernel image: start = 0x%08lX, end = 0x%08lX, size = %ld bytes\n", startupInformation.kernelStart, startupInformation.kernelEnd, @@ -76,7 +76,7 @@ Kernel::panic(const char* msg, { mConsole.clear(Console::Color::Magenta); - kstd::printString("PANIC! PANIC! PANIC! :-(\n"); + kstd::printFormat("PANIC! PANIC! PANIC! :-(\n"); va_list args; va_start(args, msg); diff --git a/src/kstd/PrintFormat.cc b/src/kstd/PrintFormat.cc index 3291621..0f31c29 100644 --- a/src/kstd/PrintFormat.cc +++ b/src/kstd/PrintFormat.cc @@ -197,6 +197,8 @@ printFormat(const char* format, Size } state = Default; + auto& cons = kernel::Kernel::systemKernel().console(); + int nchars = 0; Spec spec; @@ -207,14 +209,14 @@ printFormat(const char* format, state = Percent; spec.clear(); } else { - printChar(*p); + cons.printChar(*p); nchars++; } break; case Percent: if (*p == '%') { state = Default; - printChar(*p); + cons.printChar(*p); nchars++; } else if (Char::isDigit(*p)) { if (*p == '0' && !spec.zeroPadded) { @@ -247,7 +249,7 @@ printFormat(const char* format, } break; default: - printChar(*p); + cons.printChar(*p); nchars++; break; } @@ -317,7 +319,7 @@ printFormat(const char* format, spec.type = Spec::Type::String; break; } - nchars += spec.print(kernel::systemKernel().console()); + nchars += spec.print(cons); continue; } diff --git a/src/kstd/PrintFormat.hh b/src/kstd/PrintFormat.hh index d82b855..9be0580 100644 --- a/src/kstd/PrintFormat.hh +++ b/src/kstd/PrintFormat.hh @@ -15,8 +15,8 @@ namespace kstd { * @return Number of characters printed * @{ */ -int printFormat(const char* format, ...) PRINTF(2,3); +int printFormat(const char* format, ...) PRINTF(1,2); int printFormat(const char* format, va_list args); /** @} */ - + } /* namespace kstd */ diff --git a/src/memory/Memory.cc b/src/memory/Memory.cc index 7045ac0..f850a24 100644 --- a/src/memory/Memory.cc +++ b/src/memory/Memory.cc @@ -7,6 +7,7 @@ */ #include "Memory.hh" +#include "kstd/PrintFormat.hh" namespace kernel { @@ -15,10 +16,10 @@ namespace kernel { */ void -MemoryManager::initialize(Console& console) +MemoryManager::initialize() { initializeGDT(); - console.printString("GDT loaded\n"); + kstd::printFormat("GDT loaded\n"); } /* diff --git a/src/memory/Memory.hh b/src/memory/Memory.hh index 6557196..bac9852 100644 --- a/src/memory/Memory.hh +++ b/src/memory/Memory.hh @@ -17,7 +17,7 @@ namespace kernel { struct MemoryManager { - void initialize(Console& console); + void initialize(); private: x86::GDT mGDT;