x86_64: add temporary serial driver for printk

This commit is contained in:
2023-02-08 21:28:14 +00:00
parent 56578dda38
commit b0b557d919
3 changed files with 50 additions and 0 deletions

30
arch/x86_64/serial.c Normal file
View File

@@ -0,0 +1,30 @@
#include <arch/serial.h>
#include <arch/ports.h>
static int transmit_empty(int device)
{
return inportb(device + 5) & 0x20;
}
void serial_send_byte(int device, char out)
{
unsigned int _count = 0;
while (!transmit_empty(device)) {
_count++;
}
outportb(device, out);
while (!transmit_empty(device)) {
_count++;
}
}
void serial_putchar(int port, char ch)
{
if (ch == '\n') {
serial_send_byte(port, '\r');
}
serial_send_byte(port, ch);
}