From 74fdd267590bb8854406d3d652ebad6628feb7a9 Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Thu, 26 Jun 2025 06:22:16 +0200 Subject: [PATCH] Move uart into its own translation unit --- lib/uart.c | 9 +++++++++ lib/uart.h | 10 ++++++++++ start.c | 12 +----------- 3 files changed, 20 insertions(+), 11 deletions(-) create mode 100644 lib/uart.c create mode 100644 lib/uart.h 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).