diff --git a/k/serial.c b/k/serial.c index 1ef073d..79cab30 100644 --- a/k/serial.c +++ b/k/serial.c @@ -22,5 +22,15 @@ void serial_init(void) int write(const char *buf, size_t count) { - return 0; + int sent; + + for(sent = 0; sent < count; ++sent) + { + u8 line_status = inb(COM1 + 5); + if (!line_status & EMPTY_TRANSMITTER) + break; + outb(COM1, buf[sent]); + } + + return sent; } diff --git a/k/serial.h b/k/serial.h index d3b1f71..65e83c1 100644 --- a/k/serial.h +++ b/k/serial.h @@ -18,6 +18,8 @@ #define DLAB (0x1 << 7) +#define EMPTY_TRANSMITTER (0x1 << 5) + void serial_init(void); int write(const char *buf, size_t count);