The UART transmit loop now gives up after ~100k iterations instead
of spinning forever. This prevents the kernel from hanging with
the console spinlock held if the UART hardware is unresponsive,
which would otherwise deadlock all CPUs attempting kprintf (including
panic and debug output paths).
}
void hal_uart_putc(char c) {
- while ((inb(UART_BASE + 5) & 0x20) == 0) { }
+ int timeout = 100000;
+ while ((inb(UART_BASE + 5) & 0x20) == 0 && --timeout > 0) { }
outb(UART_BASE, (uint8_t)c);
}