From 94c45a949d17f61aac24dfba36c5489ccdf05ce5 Mon Sep 17 00:00:00 2001 From: Adam Eehan Date: Sat, 24 Oct 2026 02:23:48 +0530 Subject: [PATCH] fix(boot): force high-res gfxpayload in GRUB, restore rock-solid 8GB 2MB paging & add MB1 fallback --- arch/x86_64/boot.s | 15 --------------- kernel/kmain.c | 19 +++++++++++++++++-- scripts/build_iso.sh | 12 +++++------- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/arch/x86_64/boot.s b/arch/x86_64/boot.s index 7e3fa7d..6cf9cb0 100644 --- a/arch/x86_64/boot.s +++ b/arch/x86_64/boot.s @@ -122,21 +122,6 @@ map_pd_loop: cmpl $4096, %ecx jne map_pd_loop - /* Identity map entries 8..511 of PDPT using 1GB huge pages (8GB .. 512GB) */ - movl $8, %ecx -map_1gb_loop: - movl %ecx, %eax - shll $30, %eax - orl $0x83, %eax /* Present + Writable + Huge 1GB Page (bit 7) */ - movl %ecx, %edx - shrl $2, %edx - movl $pdpt_table, %ebx - movl %eax, (%ebx, %ecx, 8) - movl %edx, 4(%ebx, %ecx, 8) - incl %ecx - cmpl $512, %ecx - jne map_1gb_loop - /* Load CR3 with physical address of PML4 */ movl $pml4_table, %eax movl %eax, %cr3 diff --git a/kernel/kmain.c b/kernel/kmain.c index c186a82..a26c3b9 100644 --- a/kernel/kmain.c +++ b/kernel/kmain.c @@ -45,7 +45,7 @@ static void aira_sentinel_task(void) { } void kernel_main(uint64_t magic, uint64_t addr) { - /* Step 0: Extract Hardware Framebuffer immediately (UEFI GOP / VBE Tag 16) */ + /* Step 0: Extract Hardware Framebuffer immediately (UEFI GOP / VBE Tag 16 / MB1) */ if (magic == 0x36D76289 && addr != 0) { uint32_t total_size = *(volatile uint32_t*)addr; uint8_t* tag_ptr = (uint8_t*)(addr + 8); @@ -63,7 +63,7 @@ void kernel_main(uint64_t magic, uint64_t addr) { uint32_t h = *(volatile uint32_t*)(tag_ptr + 24); uint8_t bpp = *(volatile uint8_t*)(tag_ptr + 28); - if (fb_phys != 0 && w >= 640 && h >= 480) { + if (fb_phys != 0 && w >= 320 && h >= 200) { vbe_set_physical_framebuffer(fb_phys, w, h, pitch, (uint32_t)bpp); vbe_early_boot_splash(); break; @@ -72,6 +72,21 @@ void kernel_main(uint64_t magic, uint64_t addr) { tag_ptr += (tag_size + 7) & ~7; } + } else if (magic == 0x2BADB002 && addr != 0) { + /* Multiboot 1 Framebuffer Tag Parsing */ + uint32_t mb1_flags = *(volatile uint32_t*)addr; + if (mb1_flags & (1 << 12)) { + uint64_t fb_phys = *(volatile uint64_t*)(addr + 88); + uint32_t pitch = *(volatile uint32_t*)(addr + 96); + uint32_t w = *(volatile uint32_t*)(addr + 100); + uint32_t h = *(volatile uint32_t*)(addr + 104); + uint8_t bpp = *(volatile uint8_t*)(addr + 108); + + if (fb_phys != 0 && w >= 320 && h >= 200) { + vbe_set_physical_framebuffer(fb_phys, w, h, pitch, (uint32_t)bpp); + vbe_early_boot_splash(); + } + } } /* Step 1: Initialize hardware VGA terminal console (mirrors to active GOP display) */ diff --git a/scripts/build_iso.sh b/scripts/build_iso.sh index fe50433..7c979ac 100755 --- a/scripts/build_iso.sh +++ b/scripts/build_iso.sh @@ -27,7 +27,7 @@ insmod efi_uga insmod font set gfxmode=1920x1080x32,1024x768x32,auto -set gfxpayload=keep +set gfxpayload=1920x1080x32,1024x768x32,auto set timeout=5 set default=0 @@ -35,15 +35,14 @@ set default=0 menuentry "Airlys Sovereign OS (Acer Nitro Bare Metal & UEFI GOP)" { insmod all_video insmod efi_gop - set gfxpayload=keep + set gfxpayload=1920x1080x32,1024x768x32,auto multiboot2 /boot/airlys.elf boot } menuentry "Airlys Sovereign OS (1024x768 TrueColor Framebuffer)" { insmod all_video - set gfxmode=1024x768x32,auto - set gfxpayload=1024x768x32,keep + set gfxpayload=1024x768x32,auto multiboot2 /boot/airlys.elf boot } @@ -51,15 +50,14 @@ menuentry "Airlys Sovereign OS (1024x768 TrueColor Framebuffer)" { menuentry "Airlys Sovereign OS (1920x1080 Native FHD Framebuffer)" { insmod all_video insmod efi_gop - set gfxmode=1920x1080x32,auto - set gfxpayload=1920x1080x32,keep + set gfxpayload=1920x1080x32,auto multiboot2 /boot/airlys.elf boot } menuentry "Airlys Sovereign OS (Fallback Multiboot 1)" { insmod all_video - set gfxpayload=keep + set gfxpayload=auto multiboot /boot/airlys.elf boot }