feat(drivers): add port I/O helpers and serial COM1 driver

This commit is contained in:
dualfroz committed 2026-08-23 23:10:38 +02:00
1 parent c111550d0e
commit 803eeab7ec
3 files changed
+111

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
#include "serial.h"
#include "ports.h"
#define comPort1 0x3F8
static bool transmitEmpty(void)
{
return (inb(comPort1 + 5) & 0x20) != 0;
}
void serialInit(void)
{
outb(comPort1 + 1, 0x00);
outb(comPort1 + 3, 0x80);
outb(comPort1 + 0, 0x01);
outb(comPort1 + 1, 0x00);
outb(comPort1 + 3, 0x03);
outb(comPort1 + 2, 0xC7);
outb(comPort1 + 4, 0x0B);
}
void serialWrite(char c)
{
if (c == '\n') {
while (!transmitEmpty()) { }
outb(comPort1, '\r');
}
while (!transmitEmpty()) { }
outb(comPort1, (uint8)c);
}
void serialWriteString(const char* str)
{
while (*str)
serialWrite(*str++);
}