X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pintos-anon;a=blobdiff_plain;f=src%2Fdevices%2Fserial.c;h=f64074a0d1482bec6654b34b8e5b5644c8a76fec;hp=f4d0de8114a6818d51730aadedfd116b1570cb40;hb=53a7f5d0952a4595f252247f5ee3d017468eb57e;hpb=e5439c03526c8e2881b0430ddbfe02812bee2e68 diff --git a/src/devices/serial.c b/src/devices/serial.c index f4d0de8..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