From 665e370d806b641b3916034d75f7325eff41ccf2 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 24 Jun 2020 16:21:30 +0200 Subject: Base: improved debug printing Previously keyboard input was not outputed to the serial port for debugging purposes. Now it is as we modified the putc() function. --- src/pOS/arch/x86/libc/stdio/printf.cpp | 14 +++----------- src/pOS/arch/x86/libc/stdio/putc.cpp | 3 +++ src/pOS/include/libc/stdio.h | 2 ++ 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/pOS/arch/x86/libc/stdio/printf.cpp b/src/pOS/arch/x86/libc/stdio/printf.cpp index dc880ac..c85c26e 100644 --- a/src/pOS/arch/x86/libc/stdio/printf.cpp +++ b/src/pOS/arch/x86/libc/stdio/printf.cpp @@ -1,23 +1,15 @@ #include -static bool serial_debug = false; +bool serial_debug = false; void Debug::set_serial_debug(bool state) { serial_debug = state; } -static void console_out(char c) -{ - if (serial_debug) - Serial::serial_putch(c); - - putc(c); -} - static void console_putch(char*&, char c) //wrapper so that we can sprintf { - console_out(c); + putc(c); } int printf(const char* fmt, ...) @@ -32,6 +24,6 @@ int printf(const char* fmt, ...) int print(const char* str, int len) { for (int i = 0; i < len; ++i) - console_out(str[i]); + putc(str[i]); return 0; } diff --git a/src/pOS/arch/x86/libc/stdio/putc.cpp b/src/pOS/arch/x86/libc/stdio/putc.cpp index ce01839..18fe95f 100644 --- a/src/pOS/arch/x86/libc/stdio/putc.cpp +++ b/src/pOS/arch/x86/libc/stdio/putc.cpp @@ -2,5 +2,8 @@ int putc(const char c) { + if (serial_debug) + Serial::serial_putch(c); + return TTY::tty_putc(c); } diff --git a/src/pOS/include/libc/stdio.h b/src/pOS/include/libc/stdio.h index 7b5f144..fa3a35e 100644 --- a/src/pOS/include/libc/stdio.h +++ b/src/pOS/include/libc/stdio.h @@ -9,6 +9,8 @@ #define EOF (-1) +extern bool serial_debug; + int printf(const char* format, ...); int sprintf(char* buf, const char* format, ...); int print(const char* str); -- cgit 1.4.1