From dd6656f7132d1727a055035ca94945fa4fbaae58 Mon Sep 17 00:00:00 2001 From: Danny Holman Date: Wed, 20 Jan 2021 22:51:46 -0600 Subject: serial: add serial_writestring as a function Add a function in the serial interface that writes an entire string to the serial line. Signed-off-by: Danny Holman --- arch/i386/serial.c | 7 +++++++ include/kernel/serial.h | 1 + kernel/init.c | 1 + 3 files changed, 9 insertions(+) diff --git a/arch/i386/serial.c b/arch/i386/serial.c index c1266bb..20bd8f9 100644 --- a/arch/i386/serial.c +++ b/arch/i386/serial.c @@ -1,4 +1,6 @@ #include +#include +#include #include "pic.h" #define PORT 0x3f8 @@ -38,3 +40,8 @@ void write_serial(char a) { while (is_transmit_empty() == 0); outb(PORT, a); } + +void serial_writestring(const char *str) { + for (size_t i = 0; i < strlen(str); i++) + write_serial(str[i]); +} diff --git a/include/kernel/serial.h b/include/kernel/serial.h index 79d856b..a815766 100644 --- a/include/kernel/serial.h +++ b/include/kernel/serial.h @@ -4,5 +4,6 @@ int serial_init(void); char read_serial(void); void write_serial(char a); +void serial_writestring(const char *str); #endif diff --git a/kernel/init.c b/kernel/init.c index b808122..a7a71d6 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -5,5 +5,6 @@ void kernel_main(void) { tty_init(); serial_init(); + serial_writestring("Hello world\n"); printf("Hello world\n"); } -- cgit v1.2.3