add UART support

This commit is contained in:
Stefan Lankes 2011-07-02 13:04:26 -07:00
parent e5c0e2b037
commit e08f6a9d53
3 changed files with 19 additions and 1 deletions

View file

@ -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

View file

@ -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

View file

@ -24,15 +24,19 @@
#include <metalsvm/semaphore.h>
#include <asm/atomic.h>
#include <asm/processor.h>
#include <asm/io.h>
#ifdef CONFIG_VGA
#include <asm/vga.h>
#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
}