Added support for setting up a serial port. This first serial driver appears to only work correctly in QEMU.

This commit is contained in:
2020-05-24 03:24:25 -05:00
parent cf88cb98fb
commit b409b3e9d2
11 changed files with 113 additions and 27 deletions
+23
View File
@@ -0,0 +1,23 @@
#ifndef SERIAL_H
#define SERIAL_H
/* All the I/O ports are calculated relative to the data port. This is
because all serial ports have their ports in the same order but they
start at different values.
*/
#define COM1_PORT 0x3F8
#define SERIAL_DATA_PORT(base) (base)
#define SERIAL_FIFO_COMMAND_PORT(base) (base + 2)
#define SERIAL_LINE_COMMAND_PORT(base) (base + 3)
#define SERIAL_MODEM_COMMAND_PORT(base) (base + 4)
#define SERIAL_LINE_STATUS_PORT(base) (base + 5)
// Tells the serial port to expect the highest 8 bits on the data port first,
// followed by the lowest 8 bits.
#define SERIAL_LINE_ENABLE_DLAB 0x80
void set_serial_baud_rate(unsigned short, unsigned short);
void configure_serial_line(unsigned short);
int serial_transmit_fifo_empty(unsigned int);
#endif