diff --git a/libkern/stdio.c b/libkern/stdio.c index 3e54032a..3410a2d8 100644 --- a/libkern/stdio.c +++ b/libkern/stdio.c @@ -36,6 +36,7 @@ #ifdef CONFIG_VGA static uint32_t early_print = VGA_EARLY_PRINT; +static spinlock_irqsave_t vga_lock = SPINLOCK_IRQSAVE_INIT; #elif defined(CONFIG_UART) static uint32_t early_print = UART_EARLY_PRINT; #else @@ -156,8 +157,11 @@ int kputchar(int c) pos = atomic_int32_inc(&kmsg_counter); kmessages[pos % KMSG_SIZE] = (unsigned char) c; #ifdef CONFIG_VGA - if (early_print == VGA_EARLY_PRINT) + if (early_print == VGA_EARLY_PRINT) { + spinlock_irqsave_lock(&vga_lock); vga_putchar(c); + spinlock_irqsave_unlock(&vga_lock); + } #endif #ifdef CONFIG_UART if (early_print == UART_EARLY_PRINT) @@ -169,8 +173,12 @@ int kputchar(int c) int kputs(const char *str) { - int pos; - int i; + int pos, i; + +#ifdef CONFIG_VGA + if (early_print == VGA_EARLY_PRINT) + spinlock_irqsave_lock(&vga_lock); +#endif for(i=0; str[i] != '\0'; i++) { pos = atomic_int32_inc(&kmsg_counter); @@ -185,6 +193,11 @@ int kputs(const char *str) #endif } +#ifdef CONFIG_VGA + if (early_print == VGA_EARLY_PRINT) + spinlock_irqsave_unlock(&vga_lock); +#endif + return i; }