+
+/* Update interrupt enable register.
+ If our transmit queue is empty, turn off transmit interrupt. */
+static void
+write_ier (void)
+{
+ outb (IER_REG, intq_empty (&txq) ? 0 : IER_XMIT);
+}
+
+
+/* Polls the serial port until it's ready,
+ and then transmits BYTE. */
+static void
+putc_poll (uint8_t byte)
+{
+ ASSERT (intr_get_level () == INTR_OFF);
+
+ while ((inb (LSR_REG) & LSR_THRE) == 0)
+ continue;
+ outb (THR_REG, byte);
+}
+
+/* Serial interrupt handler.
+ As long as we have a byte to transmit,
+ and the hardware is ready to accept a byte for transmission,
+ transmit a byte.
+ Then update interrupt enable register based on queue
+ status. */
+static void
+serial_interrupt (struct intr_frame *f UNUSED)
+{
+ while (!intq_empty (&txq) && (inb (LSR_REG) & LSR_THRE) != 0)
+ outb (THR_REG, intq_getc (&txq));
+ write_ier ();
+}