From: Tulio A M Mendes Date: Thu, 12 Feb 2026 06:25:39 +0000 (-0300) Subject: fix: add timeout to UART busy-wait in hal_uart_putc() X-Git-Url: https://projects.tadryanom.me/docs/static/gitweb.js?a=commitdiff_plain;h=1e63ba62292dd82777cdb8fcd83cc13ab3f81043;p=AdrOS.git fix: add timeout to UART busy-wait in hal_uart_putc() 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). --- diff --git a/src/hal/x86/uart.c b/src/hal/x86/uart.c index 05458a5..c256cf0 100644 --- a/src/hal/x86/uart.c +++ b/src/hal/x86/uart.c @@ -16,6 +16,7 @@ void hal_uart_init(void) { } 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); }