From 9bc7a58b1d6cc713fd99af0df426d9433e25afb6 Mon Sep 17 00:00:00 2001 From: Travis Geiselbrecht Date: Mon, 18 Dec 2006 07:23:39 +0000 Subject: [PATCH] Fixes a nit: put a spinlock around the serial debug routines to keep multiple cpus from interleaving their output. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19548 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/arch/x86/arch_debug_console.c | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/system/kernel/arch/x86/arch_debug_console.c b/src/system/kernel/arch/x86/arch_debug_console.c index 359d02cdfd..eee557549c 100644 --- a/src/system/kernel/arch/x86/arch_debug_console.c +++ b/src/system/kernel/arch/x86/arch_debug_console.c @@ -97,6 +97,7 @@ static bool sKeyboardHandlerInstalled = false; static bool sBochsOutput = false; #endif +static spinlock sSerialOutputSpinlock = 0; static void put_char(const char c) @@ -280,8 +281,8 @@ arch_debug_serial_getchar(void) } -void -arch_debug_serial_putchar(const char c) +static void +_arch_debug_serial_putchar(const char c) { if (c == '\n') { put_char('\r'); @@ -290,14 +291,32 @@ arch_debug_serial_putchar(const char c) put_char(c); } +void +arch_debug_serial_putchar(const char c) +{ + cpu_status state = disable_interrupts(); + acquire_spinlock(&sSerialOutputSpinlock); + + _arch_debug_serial_putchar(c); + + release_spinlock(&sSerialOutputSpinlock); + restore_interrupts(state); +} + void arch_debug_serial_puts(const char *s) { + cpu_status state = disable_interrupts(); + acquire_spinlock(&sSerialOutputSpinlock); + while (*s != '\0') { - arch_debug_serial_putchar(*s); + _arch_debug_serial_putchar(*s); s++; } + + release_spinlock(&sSerialOutputSpinlock); + restore_interrupts(state); }