This commit is contained in:
2025-04-30 23:03:44 -07:00
parent a464e109cb
commit ecfa54e225
30 changed files with 584 additions and 1191 deletions

20
kernel/serial.c Normal file
View File

@@ -0,0 +1,20 @@
#include "io.h"
#define COM1 0x3F8
void serial_init(void) {
outb(COM1 + 1, 0x00); // Disable interrupts
outb(COM1 + 3, 0x80); // Enable DLAB
outb(COM1 + 0, 0x03); // Set baud rate to 38400
outb(COM1 + 1, 0x00);
outb(COM1 + 3, 0x03); // 8 bits, no parity, one stop bit
outb(COM1 + 2, 0xC7); // Enable FIFO, clear, 14-byte threshold
outb(COM1 + 4, 0x0B); // IRQs enabled, RTS/DSR set
}
void serial_write(const char *str) {
while (*str) {
while (!(inb(COM1 + 5) & 0x20)); // Wait for the transmitter holding register to be empty
outb(COM1, *str++);
}
}