7 static void set_serial (int bps, int bits, enum parity_type parity, int stop);
9 /* Initializes the serial port device. */
13 outb (IER_REG, 0); /* Turn off all interrupts. */
14 outb (FCR_REG, 0); /* Disable FIFO. */
15 set_serial (9600, 8, NONE, 1);
16 outb (MCR_REG, 0); /* Turn off output lines. */
19 /* Sends BYTE to the serial port. */
21 serial_outb (uint8_t byte)
23 while ((inb (LSR_REG) & LSR_THRE) == 0)
28 /* Configures the first serial port for BPS bits per second,
29 BITS bits per byte, the given PARITY, and STOP stop bits. */
31 set_serial (int bps, int bits, enum parity_type parity, int stop)
33 int baud_base = 1843200 / 16; /* Base rate of 16550A. */
34 uint16_t divisor = baud_base / bps; /* Clock rate divisor. */
37 outb (LCR_REG, make_lcr (bits, parity, stop, false, true));
40 outb (LS_REG, divisor & 0xff);
41 outb (MS_REG, divisor >> 8);
44 outb (LCR_REG, make_lcr (bits, parity, stop, false, false));