mirror of
https://github.com/gbowne1/ClassicOS.git
synced 2025-10-13 21:25:07 -07:00
adding and fixing some missing things and some undefined
This commit is contained in:
@@ -1,20 +1,39 @@
|
||||
#include "io.h"
|
||||
#include "serial.h"
|
||||
|
||||
#define COM1 0x3F8
|
||||
#define COM2 0x2F8
|
||||
#define COM3 0x3E8
|
||||
#define COM4 0x2E8
|
||||
|
||||
void serial_init_port(uint16_t port) {
|
||||
outb(port + 1, 0x00);
|
||||
outb(port + 3, 0x80);
|
||||
outb(port + 0, 0x03);
|
||||
outb(port + 1, 0x00);
|
||||
outb(port + 3, 0x03);
|
||||
outb(port + 2, 0xC7);
|
||||
outb(port + 4, 0x0B);
|
||||
}
|
||||
|
||||
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
|
||||
serial_init_port(COM1);
|
||||
serial_init_port(COM2);
|
||||
serial_init_port(COM3);
|
||||
serial_init_port(COM4);
|
||||
}
|
||||
|
||||
void serial_write_char(char c) {
|
||||
while (!(inb(COM1 + 5) & 0x20));
|
||||
outb(COM1, c);
|
||||
}
|
||||
|
||||
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++);
|
||||
serial_write_char(*str++);
|
||||
}
|
||||
}
|
||||
|
||||
void serial_write_string(const char* str) {
|
||||
serial_write(str);
|
||||
}
|
||||
|
Reference in New Issue
Block a user