mirror of
https://github.com/gbowne1/ClassicOS.git
synced 2025-10-13 21:25:07 -07:00
new OS
This commit is contained in:
20
kernel/serial.c
Normal file
20
kernel/serial.c
Normal 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++);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user