x86_64: add temporary serial driver for printk
This commit is contained in:
30
arch/x86_64/serial.c
Normal file
30
arch/x86_64/serial.c
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user