From 073d53728b01c9f5284c13c643933cfebc2e68da Mon Sep 17 00:00:00 2001 From: Malo Lecomte Date: Tue, 13 Jul 2021 04:47:32 +0200 Subject: [PATCH] feat: add k_init function --- k/k.c | 8 ++++++-- k/serial.c | 4 +++- k/serial.h | 1 - 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/k/k.c b/k/k.c index eea9dae..3fce470 100644 --- a/k/k.c +++ b/k/k.c @@ -27,6 +27,11 @@ #include "stdio.h" #include "serial.h" +static void k_init(void) +{ + init_serial(); +} + void k_main(unsigned long magic, multiboot_info_t *info) { (void)magic; @@ -35,8 +40,7 @@ void k_main(unsigned long magic, multiboot_info_t *info) char star[4] = "|/-\\"; char *fb = (void *)0xb8000; - set_baud_rate(); - init_serial(); + k_init(); printf("bonjour\r\n"); for (unsigned i = 0; ; ) { diff --git a/k/serial.c b/k/serial.c index 9877f6f..d18469c 100644 --- a/k/serial.c +++ b/k/serial.c @@ -3,7 +3,7 @@ #include "serial.h" #include "io.h" -void set_baud_rate(void) +static void set_baud_rate(void) { u8 line_control_register = inb(COM1 + 3); outb(COM1 + 3, DLAB | line_control_register); @@ -14,6 +14,8 @@ void set_baud_rate(void) void init_serial(void) { + set_baud_rate(); + outb(COM1 + 3, NO_PARITY | EIGHT_BITS_LENGTH); outb(COM1 + 2, FIFO | TRIGGER_LVL_14 | CLEAR_TRANSMIT_FIFO | CLEAR_RECEIVE_FIFO); diff --git a/k/serial.h b/k/serial.h index 0422f65..e193f8d 100644 --- a/k/serial.h +++ b/k/serial.h @@ -20,7 +20,6 @@ #define EMPTY_TRANSMITTER (0x1 << 5) -void set_baud_rate(void); void init_serial(void); int write(const char *buf, size_t count);