diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e4d38cd --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.o +*.d +*.a +*.iso +iso/ + +k/k + +roms/chichehunter/hunter +roms/chichepong/pong +roms/chichevaders/vaders +roms/perrodlauncher/perrod +roms/skate/skate +roms/yakanoid/yakanoid diff --git a/k/Makefile b/k/Makefile index d7daeaa..52aacbd 100644 --- a/k/Makefile +++ b/k/Makefile @@ -30,6 +30,7 @@ OBJS = \ libvga.o \ list.o \ memory.o \ + serial.o DEPS = $(OBJS:.o=.d) diff --git a/k/k.c b/k/k.c index d361b01..6b26173 100644 --- a/k/k.c +++ b/k/k.c @@ -24,6 +24,7 @@ #include #include "multiboot.h" +#include "stdio.h" void k_main(unsigned long magic, multiboot_info_t *info) @@ -34,6 +35,7 @@ void k_main(unsigned long magic, multiboot_info_t *info) char star[4] = "|/-\\"; char *fb = (void *)0xb8000; + printf("bonjour\r\n"); for (unsigned i = 0; ; ) { *fb = star[i++ % 4]; } diff --git a/k/serial.c b/k/serial.c new file mode 100644 index 0000000..1ef073d --- /dev/null +++ b/k/serial.c @@ -0,0 +1,26 @@ +#include + +#include "serial.h" +#include "io.h" + +void set_baud_rate(void) +{ + u8 line_control_register = inb(COM1 + 3); + outb(COM1 + 3, DLAB | line_control_register); + outb(COM1, 3); + outb(COM1 + 1, 0); + outb(COM1 + 3, line_control_register); +} + +void serial_init(void) +{ + outb(COM1 + 3, NO_PARITY | EIGHT_BITS_LENGTH); + outb(COM1 + 2, FIFO | TRIGGER_LVL_14 | CLEAR_TRANSMIT_FIFO + | CLEAR_RECEIVE_FIFO); + outb(COM1 + 1, ENABLE_TRANSMITTER); +} + +int write(const char *buf, size_t count) +{ + return 0; +} diff --git a/k/serial.h b/k/serial.h new file mode 100644 index 0000000..d3b1f71 --- /dev/null +++ b/k/serial.h @@ -0,0 +1,24 @@ +#ifndef SERIAL_H +#define SERIAL_H + +#define COM1 0x3f8 +#define COM2 0x2f8 +#define COM3 0x3e8 +#define COM4 0x2e8 + +#define ENABLE_TRANSMITTER (0x1 << 1) + +#define FIFO 0x1 +#define TRIGGER_LVL_14 (0x3 << 6) +#define CLEAR_TRANSMIT_FIFO (0x1 << 2) +#define CLEAR_RECEIVE_FIFO (0x1 << 1) + +#define NO_PARITY 0x0 +#define EIGHT_BITS_LENGTH 0x3 + +#define DLAB (0x1 << 7) + +void serial_init(void); +int write(const char *buf, size_t count); + +#endif /* SERIAL_H */