X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdevices%2Fserial.c;h=f64074a0d1482bec6654b34b8e5b5644c8a76fec;hb=53a7f5d0952a4595f252247f5ee3d017468eb57e;hp=92b00ef06eaa67513be6858101f41358b54bb291;hpb=837e5b7fb902bd749106309ef76a5276c73ca34c;p=pintos-anon diff --git a/src/devices/serial.c b/src/devices/serial.c index 92b00ef..f64074a 100644 --- a/src/devices/serial.c +++ b/src/devices/serial.c @@ -63,8 +63,8 @@ static intr_handler_func serial_interrupt; Polling mode busy-waits for the serial port to become free before writing to it. It's slow, but until interrupts have been initialized it's all we can do. */ -void -serial_init_poll (void) +static void +init_poll (void) { ASSERT (mode == UNINIT); outb (IER_REG, 0); /* Turn off all interrupts. */ @@ -83,6 +83,8 @@ serial_init_queue (void) { enum intr_level old_level; + if (mode == UNINIT) + init_poll (); ASSERT (mode == POLL); intr_register_ext (0x20 + 4, serial_interrupt, "serial"); @@ -98,10 +100,12 @@ serial_putc (uint8_t byte) { enum intr_level old_level = intr_disable (); - if (mode == POLL) + if (mode != QUEUE) { /* If we're not set up for interrupt-driven I/O yet, use dumb polling to transmit a byte. */ + if (mode == UNINIT) + init_poll (); putc_poll (byte); } else @@ -206,7 +210,7 @@ static void serial_interrupt (struct intr_frame *f UNUSED) { /* Inquire about interrupt in UART. Without this, we can - occasionally miss an interrupt running under qemu. */ + occasionally miss an interrupt running under QEMU. */ inb (IIR_REG); /* As long as we have room to receive a byte, and the hardware