diff --git a/build.mak b/build.mak index deb99d44de9b6e3bbb72b35a1ac22e9be52bfe23..7b8494ca38b80b7a1173b1e77a277a76488095c0 100644 --- a/build.mak +++ b/build.mak @@ -94,7 +94,7 @@ fs += fs/ramfs/ramfs_vfsops.o \ fs += fs/devfs/devfs_vnops.o \ fs/devfs/device.o -drivers = drivers/vga.o drivers/console.o drivers/isa-serial.o +drivers = drivers/vga.o drivers/isa-serial.o drivers += $(fs) drivers += mmu.o drivers += elf.o diff --git a/debug.cc b/debug.cc index 95ca67b6139625009aa5a034f7c81b35937ac5c1..3af1d3a6b279d125b646594eda4bf6b293e37295 100644 --- a/debug.cc +++ b/debug.cc @@ -1,3 +1,4 @@ +#include <cstring> #include <iostream> #include <iomanip> #include "drivers/isa-serial.hh" @@ -8,9 +9,13 @@ using namespace std; Debug* Debug::pinstance = 0; -void Debug::out(const char* msg, bool lf) { - if (!_console) return; - (lf)? _console->writeln(msg):_console->write(msg); +void Debug::out(const char* msg, bool lf) +{ + if (!_console) + return; + _console->write(msg, strlen(msg)); + if (lf) + _console->newline(); } void debug(const char *msg, bool lf) diff --git a/drivers/console.cc b/drivers/console.cc deleted file mode 100644 index 67a0b47c2c259d9d1d826f3175df71140ea80894..0000000000000000000000000000000000000000 --- a/drivers/console.cc +++ /dev/null @@ -1,21 +0,0 @@ -#include "console.hh" - -void Console::write(const boost::format& fmt) -{ - return write(fmt.str()); -} - -void Console::writeln(const boost::format& fmt) -{ - return writeln(fmt.str()); -} - -void Console::write(std::string str) -{ - return write(str.c_str()); -} - -void Console::writeln(std::string str) -{ - return writeln(str.c_str()); -} diff --git a/drivers/console.hh b/drivers/console.hh index 895ac047472b83b1f6f5af56912c00628935308c..d9392fa0cffbcc63826044a52861e926cbacc341 100644 --- a/drivers/console.hh +++ b/drivers/console.hh @@ -6,13 +6,8 @@ class Console { public: virtual ~Console() {} - virtual void write(const char *str) = 0; + virtual void write(const char *str, size_t len) = 0; virtual void newline() = 0; - void writeln(const char *str) { write(str); newline(); } - void write(std::string str); - void writeln(std::string str); - void write(const boost::format& fmt); - void writeln(const boost::format& fmt); }; #endif diff --git a/drivers/isa-serial.cc b/drivers/isa-serial.cc index f0ee36d0dee9f090f60a835ca2045114dc21c311..7777f47ad51d2ceebd2c077793a7a0f92cc21604 100644 --- a/drivers/isa-serial.cc +++ b/drivers/isa-serial.cc @@ -4,12 +4,12 @@ IsaSerialConsole::IsaSerialConsole() { reset(); } -void IsaSerialConsole::write(const char *str) +void IsaSerialConsole::write(const char *str, size_t len) { - while (*str) { + while (len > 0) { writeByte(*str++); + len--; } - } void IsaSerialConsole::writeByte(const char letter) diff --git a/drivers/isa-serial.hh b/drivers/isa-serial.hh index f5b9a5d6fba45788a8f421ffccc8d694f7c0058b..c9e8b00215d3ae7e2441ddda5271d859a19326d5 100644 --- a/drivers/isa-serial.hh +++ b/drivers/isa-serial.hh @@ -8,7 +8,7 @@ class IsaSerialConsole : public Console { public: IsaSerialConsole(); - virtual void write(const char *str); + virtual void write(const char *str, size_t len); virtual void newline(); private: static const u16 ioport = 0x3f8;