mirror of
https://github.com/janishutz/eth-summaries.git
synced 2026-03-14 17:00:05 +01:00
14 lines
558 B
C
14 lines
558 B
C
#define UART_BASE 0x3f8 // Registers specified by
|
|
#define UART_THR (UART_BASE + 0) // the device
|
|
#define UART_RBR (UART_BASE + 0)
|
|
#define UART_LSR (UART_BASE + 5)
|
|
|
|
void serial_putc(char c) {
|
|
while( (inb(UART_LSR) & 0x20)== 0); // Wait until FIFO can hold more chars
|
|
outb(UART_THR, c); // Write character to FIFO
|
|
}
|
|
|
|
char serial_getc() {
|
|
while( (inb(UART_LSR) & 0x01) == 0); // Wait until there is a char to read
|
|
return inb(UART_RBR); // Read from the receive FIFO
|
|
} |