From 6e68d940806c6f7b2bca5134a15b7d88e97678a5 Mon Sep 17 00:00:00 2001 From: Matthias Kruk Date: Tue, 31 Dec 2019 15:00:34 +0900 Subject: [PATCH] Disable output from dbg_printf() once the init process has been spawned --- kernel/arch/debug.c | 11 +++++++++++ kernel/core/main.c | 10 +++++++++- kernel/include/debug.h | 1 + 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/kernel/arch/debug.c b/kernel/arch/debug.c index 5775006..68cf0f2 100644 --- a/kernel/arch/debug.c +++ b/kernel/arch/debug.c @@ -58,6 +58,7 @@ static const char nullstr[] = "(null)"; static u16_t* const vga_buffer = VGA_BUFFER_ADDR; static u16_t vga_attrs = VGA_FONT(VGA_LIGHT_GRAY) | VGA_BACKGROUND(VGA_BLACK); static i32_t vga_offset = VGA_BUFFER_SIZE; +static int _early_printf_disable = 0; #define VGA_SET_FONT(c) vga_attrs = (vga_attrs & 0xf0ff) | VGA_FONT(c) #define VGA_SET_BACKGROUND(c) vga_attrs = (vga_attrs & 0x0fff) | VGA_BACKGROUND(c) @@ -158,6 +159,12 @@ static void _putchar(int c) return; } +void dbg_printf_disable(void) +{ + _early_printf_disable = 1; + return; +} + int dbg_printf(const char *format, ...) { int n; @@ -169,6 +176,10 @@ int dbg_printf(const char *format, ...) int pad; const char *fmt; + if(_early_printf_disable) { + return(-1); + } + #define MODE_NORMAL 0 #define MODE_CONV 1 #define FLAG_SIGN (1 << 31) diff --git a/kernel/core/main.c b/kernel/core/main.c index 96a016b..8bf0c9d 100644 --- a/kernel/core/main.c +++ b/kernel/core/main.c @@ -141,12 +141,13 @@ static void _init(void) /* FIXME: Handle error */ } + #if 0 struct cxmsg msg; char *hw = "Hello, world\n"; memcpy(msg.cm_data, hw, 13); cxsendrecv(vgapid, &msg); - + #endif wait(NULL); return; @@ -240,6 +241,13 @@ int corax(void *mb_info, u32_t magic) PANIC("Could not spawn init process\n"); } + /* + * Disable early printf - all further output should + * be printed through the VGA process that is spawned + * by init. + */ + dbg_printf_disable(); + sched_tick(); dbg_printf("This should not get printed\n"); diff --git a/kernel/include/debug.h b/kernel/include/debug.h index d642963..b03c3dc 100644 --- a/kernel/include/debug.h +++ b/kernel/include/debug.h @@ -30,5 +30,6 @@ i64_t _i64mod(i64_t, i64_t); int dbg_printf(const char*, ...); void dbg_panic(const char*, const char*, i32_t, const char*); +void dbg_printf_disable(void); #endif /* __DEBUG_H */ -- 2.47.3