diff --git a/drivers/serial.c b/drivers/serial.c index 79947e5d..67d5bd80 100644 --- a/drivers/serial.c +++ b/drivers/serial.c @@ -150,6 +150,9 @@ void __text_init init_uart(uart_config_t *cfg) { mcr.rts = 1; mcr.aux = 2; outb(cfg->port + UART_MCR_REG_OFFSET, mcr.reg); + + if (com_ports[0] == NO_COM_PORT) + com_ports[0] = cfg->port; } void __text_init init_uart_input(uint8_t dst_cpus) { @@ -223,6 +226,9 @@ void uart_interrupt_handler(void) { com_port_t com_port = com_ports[i]; iir_t iir; + if (com_port == NO_COM_PORT) + continue; + iir.reg = inb(com_port + UART_IIR_REG_OFFSET); if (iir.event == UART_IIR_EVENT_RXD_AVAIL || iir.event == UART_IIR_EVENT_CHAR_TIMEOUT) { diff --git a/include/drivers/serial.h b/include/drivers/serial.h index 94c7e450..6145135b 100644 --- a/include/drivers/serial.h +++ b/include/drivers/serial.h @@ -37,6 +37,7 @@ enum com_idx { typedef enum com_idx com_idx_t; enum com_port { + NO_COM_PORT = 0x0, COM1_PORT = 0x3f8, COM2_PORT = 0x2f8, COM3_PORT = 0x3e8,