#include "io.h"
#include "timer.h"
-static void
-set_serial (int bps, int bits, enum parity_type parity, int stop)
-{
- int baud_base = 1843200 / 16; /* Base rate of 16550A. */
- uint16_t divisor = baud_base / bps; /* Clock rate divisor. */
-
- /* Enable DLAB. */
- outb (LCR_REG, make_lcr (bits, parity, stop, false, true));
-
- /* Set baud rate. */
- outb (LS_REG, divisor & 0xff);
- outb (MS_REG, divisor >> 8);
-
- /* Reset DLAB. */
- outb (LCR_REG, make_lcr (bits, parity, stop, false, false));
-}
+static void set_serial (int bps, int bits, enum parity_type parity, int stop);
+/* Initializes the serial port device. */
void
serial_init (void)
{
outb (MCR_REG, 0); /* Turn off output lines. */
}
+/* Sends BYTE to the serial port. */
void
serial_outb (uint8_t byte)
{
continue;
outb (THR_REG, byte);
}
+
+/* Configures the first serial port for BPS bits per second,
+ BITS bits per byte, the given PARITY, and STOP stop bits. */
+static void
+set_serial (int bps, int bits, enum parity_type parity, int stop)
+{
+ int baud_base = 1843200 / 16; /* Base rate of 16550A. */
+ uint16_t divisor = baud_base / bps; /* Clock rate divisor. */
+
+ /* Enable DLAB. */
+ outb (LCR_REG, make_lcr (bits, parity, stop, false, true));
+
+ /* Set baud rate. */
+ outb (LS_REG, divisor & 0xff);
+ outb (MS_REG, divisor >> 8);
+
+ /* Reset DLAB. */
+ outb (LCR_REG, make_lcr (bits, parity, stop, false, false));
+}