diff --git a/lib/uart.c b/lib/uart.c new file mode 100644 index 0000000..864840a --- /dev/null +++ b/lib/uart.c @@ -0,0 +1,9 @@ +/* QEMU memory maps a UART device here. */ +#define UART_BASE ((volatile char *)0x10000000) + +void uart_putc(char c) { *UART_BASE = c; } + +void uart_puts(const char *s) { + while (*s) uart_putc(*s++); +} + diff --git a/lib/uart.h b/lib/uart.h new file mode 100644 index 0000000..953c5f6 --- /dev/null +++ b/lib/uart.h @@ -0,0 +1,10 @@ +#ifndef UART_KERNEL_H +#define UART_KERNEL_H + +/** Send a single character to the UART device */ +void uart_putc(char c); + +/** Send a **NULL TERMINATED** string to the UART device */ +void uart_puts(const char *s); + +#endif diff --git a/start.c b/start.c index 0a9ca9b..425059a 100644 --- a/start.c +++ b/start.c @@ -2,17 +2,7 @@ #include #include #include - -/* QEMU memory maps a UART device here. */ -#define UART_BASE ((volatile char *)0x10000000) - -/** Send a single character to the UART device */ -void uart_putc(char c) { *UART_BASE = c; } - -/** Send a **NULL TERMINATED** string to the UART device */ -void uart_puts(const char *s) { - while (*s) uart_putc(*s++); -} +#include /** * Allocate one stack per CPU (hart).