From c3c01049bf857541f8162dd1a527ec8b148ca17f Mon Sep 17 00:00:00 2001 From: AI Date: Mon, 23 Feb 2026 13:44:54 +0000 Subject: [PATCH] Force text mode when GRUB reports RGB but display is text mode On UTM/Mac, GRUB may report a RGB framebuffer while the actual display is in VGA text mode (0xB8000). The early VGA canary confirms text mode works. Override fb_info to EGA_TEXT before init_drivers() so vga_init() uses the correct text buffer instead of writing to an invisible pixel framebuffer. Also add EARLY_PRINT markers for SYSCALL, KBD, PROC, DRV stages. --- src/kernel.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/kernel.c b/src/kernel.c index ec7b180..a8d24e0 100644 --- a/src/kernel.c +++ b/src/kernel.c @@ -252,15 +252,33 @@ void kernel_main(uint32_t magic, uint32_t addr) { offset_print("TSS initialized\n"); init_syscalls(); + EARLY_PRINT("SYSCALL "); offset_print("Syscalls initialized\n"); keyboard_init(); + EARLY_PRINT("KBD "); offset_print("Keyboard initialized\n"); init_process(); + EARLY_PRINT("PROC "); offset_print("Process subsystem initialized\n"); + /* If the early VGA canary at 0xB8000 was visible, the display is + * definitely in text mode, regardless of what the GRUB framebuffer + * tag says. Force text mode so vga_init doesn't try to use a + * pixel framebuffer that isn't actually being displayed. */ + if (fb_info.type == FB_TYPE_RGB) { + offset_print(" Overriding fb type from RGB to EGA_TEXT (early VGA visible)\n"); + fb_info.type = FB_TYPE_EGA_TEXT; + fb_info.addr = 0x000B8000; + fb_info.width = 80; + fb_info.height = 25; + fb_info.bpp = 16; + fb_info.pitch = 80 * 2; + } + init_drivers(); + EARLY_PRINT("DRV "); offset_print("Drivers initialized\n"); /* At this point the VGA driver has been initialized and taken over