diff options
author | Danny Holman <dholman@gymli.xyz> | 2021-01-20 22:51:46 -0600 |
---|---|---|
committer | Danny Holman <dholman@gymli.xyz> | 2021-01-20 22:51:46 -0600 |
commit | dd6656f7132d1727a055035ca94945fa4fbaae58 (patch) | |
tree | 4a9a7bf01d6fb582f1aaf7ead9de2af693aa2610 | |
parent | fd4bd4dabe8011b016e3f8e6c3de5cfe6bc1f41d (diff) |
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 <dholman@gymli.xyz>
-rw-r--r-- | arch/i386/serial.c | 7 | ||||
-rw-r--r-- | include/kernel/serial.h | 1 | ||||
-rw-r--r-- | kernel/init.c | 1 |
3 files changed, 9 insertions, 0 deletions
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 <kernel/serial.h> +#include <kernel/string.h> +#include <stddef.h> #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"); } |