diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h index 8443ec0a..8765b7cc 100644 --- a/arch/x86/include/asm/io.h +++ b/arch/x86/include/asm/io.h @@ -93,6 +93,11 @@ inline static void outportl(unsigned short _port, unsigned int _data) asm volatile("outl %1, %0"::"dN"(_port), "a"(_data)); } +inline static void uart_putchar(unsigned char _data) +{ + outportb(0x2F8, _data); +} + #ifdef __cplusplus } #endif diff --git a/include/metalsvm/config.h.example b/include/metalsvm/config.h.example index 34a2717a..a9e94864 100644 --- a/include/metalsvm/config.h.example +++ b/include/metalsvm/config.h.example @@ -52,6 +52,7 @@ extern "C" { #define CONFIG_PCI #define CONFIG_LWIP #define CONFIG_VGA +//#define CONFIG_UART #define CONFIG_KEYBOARD #define CONFIG_MULTIBOOT //#define CONFIG_ROCKCREEK diff --git a/libkern/stdio.c b/libkern/stdio.c index a8bdc9de..281fe11d 100644 --- a/libkern/stdio.c +++ b/libkern/stdio.c @@ -24,15 +24,19 @@ #include #include #include +#include #ifdef CONFIG_VGA #include #endif #define NO_EARLY_PRINT 0 #define VGA_EARLY_PRINT 1 +#define UART_EARLY_PRINT 2 #ifdef CONFIG_VGA static uint32_t early_print = VGA_EARLY_PRINT; +#elif defined(CONFIG_UART) +static uint32_t early_print = UART_EARLY_PRINT; #else static uint32_t early_print = NO_EARLY_PRINT; #endif @@ -56,8 +60,12 @@ int kputchar(int c) kmessages[pos % KMSG_SIZE] = (unsigned char) c; #ifdef CONFIG_VGA if (early_print == VGA_EARLY_PRINT) - vga_putchar(c); + vga_putchar(c); #endif +#ifdef CONFIG_UART + if (early_print == UART_EARLY_PRINT) + uart_putchar(c); +#endif return 1; } @@ -73,6 +81,10 @@ int kputs(const char *str) #ifdef CONFIG_VGA if (early_print == VGA_EARLY_PRINT) vga_putchar(str[i]); +#endif +#ifdef CONFIG_UART + if (early_print == UART_EARLY_PRINT) + uart_putchar(str[i]); #endif }