feat: add k_init function

This commit is contained in:
Malo Lecomte 2021-07-13 04:47:32 +02:00
parent 5e3155aebf
commit 073d53728b
3 changed files with 9 additions and 4 deletions

8
k/k.c

@ -27,6 +27,11 @@
#include "stdio.h" #include "stdio.h"
#include "serial.h" #include "serial.h"
static void k_init(void)
{
init_serial();
}
void k_main(unsigned long magic, multiboot_info_t *info) void k_main(unsigned long magic, multiboot_info_t *info)
{ {
(void)magic; (void)magic;
@ -35,8 +40,7 @@ void k_main(unsigned long magic, multiboot_info_t *info)
char star[4] = "|/-\\"; char star[4] = "|/-\\";
char *fb = (void *)0xb8000; char *fb = (void *)0xb8000;
set_baud_rate(); k_init();
init_serial();
printf("bonjour\r\n"); printf("bonjour\r\n");
for (unsigned i = 0; ; ) { for (unsigned i = 0; ; ) {

@ -3,7 +3,7 @@
#include "serial.h" #include "serial.h"
#include "io.h" #include "io.h"
void set_baud_rate(void) static void set_baud_rate(void)
{ {
u8 line_control_register = inb(COM1 + 3); u8 line_control_register = inb(COM1 + 3);
outb(COM1 + 3, DLAB | line_control_register); outb(COM1 + 3, DLAB | line_control_register);
@ -14,6 +14,8 @@ void set_baud_rate(void)
void init_serial(void) void init_serial(void)
{ {
set_baud_rate();
outb(COM1 + 3, NO_PARITY | EIGHT_BITS_LENGTH); outb(COM1 + 3, NO_PARITY | EIGHT_BITS_LENGTH);
outb(COM1 + 2, FIFO | TRIGGER_LVL_14 | CLEAR_TRANSMIT_FIFO outb(COM1 + 2, FIFO | TRIGGER_LVL_14 | CLEAR_TRANSMIT_FIFO
| CLEAR_RECEIVE_FIFO); | CLEAR_RECEIVE_FIFO);

@ -20,7 +20,6 @@
#define EMPTY_TRANSMITTER (0x1 << 5) #define EMPTY_TRANSMITTER (0x1 << 5)
void set_baud_rate(void);
void init_serial(void); void init_serial(void);
int write(const char *buf, size_t count); int write(const char *buf, size_t count);