diff --git a/arch/x86_64/boot.s b/arch/x86_64/boot.s index d1b548c..9866bf6 100644 --- a/arch/x86_64/boot.s +++ b/arch/x86_64/boot.s @@ -37,7 +37,7 @@ multiboot2_header: /* Framebuffer Request Tag (Type 5) - Requests UEFI GOP / VBE native @ 32bpp */ .align 8 .short 5 /* type = 5 (Framebuffer) */ - .short 0 /* flags = 0 */ + .short 1 /* flags = 1 (Optional - graceful fallback if exact 1080p unavailable) */ .long 20 /* size = 20 bytes */ .long 1920 /* width = 1920 (FHD Native for Acer Nitro V 15) */ .long 1080 /* height = 1080 (FHD Native for Acer Nitro V 15) */ @@ -106,7 +106,7 @@ _start: testl $(1 << 29), %edx jz no_long_mode - /* Build identity page tables for 128GB using 2MB huge pages */ + /* Build identity page tables for 512GB using 2MB huge pages */ /* PML4[0] -> PDPT */ movl $pml4_table, %eax movl $pdpt_table, %ebx @@ -114,7 +114,7 @@ _start: movl %ebx, (%eax) movl $0, 4(%eax) /* Upper 32 bits = 0 */ - /* PDPT[0..127] -> 128 Page Directories (128 * 1GB = 128GB) */ + /* PDPT[0..511] -> 512 Page Directories (512 * 1GB = 512GB) */ movl $pdpt_table, %eax movl $page_dir_table, %ebx orl $0x03, %ebx @@ -124,10 +124,10 @@ init_pdpt_loop: movl $0, 4(%eax, %ecx, 8) addl $4096, %ebx incl %ecx - cmpl $128, %ecx + cmpl $512, %ecx jne init_pdpt_loop - /* Identity map 65536 entries of 2MB = 128GB (0x00000000 .. 0x1FFFFFFFFF) */ + /* Identity map 262144 entries of 2MB = 512GB (0x00000000 .. 0x7FFFFFFFFF) */ movl $0, %ecx map_pd_loop: movl $0x200000, %eax /* 2MB */ @@ -137,7 +137,7 @@ map_pd_loop: movl %eax, (%ebx, %ecx, 8) movl %edx, 4(%ebx, %ecx, 8) incl %ecx - cmpl $65536, %ecx + cmpl $262144, %ecx jne map_pd_loop /* Load CR3 with physical address of PML4 */ @@ -221,7 +221,7 @@ pml4_table: pdpt_table: .skip 4096 page_dir_table: - .skip 524288 /* 128 Page Directories * 4096 = 512 KB = 128GB */ + .skip 2097152 /* 512 Page Directories * 4096 = 2MB = 512GB */ /* Kernel Stack (16KB) */ .align 16 diff --git a/drivers/vbe.c b/drivers/vbe.c index 6fca350..5960b1f 100644 --- a/drivers/vbe.c +++ b/drivers/vbe.c @@ -13,6 +13,11 @@ static uint32_t s_console_y = 60; #define VBE_MAX_PIXELS (1024 * 768) static uint32_t s_pixel_buffer[VBE_MAX_PIXELS]; +static inline void vbe_flush_cache(void) { + /* Forcibly flush CPU L1/L2/L3 cache lines to GPU physical VRAM (essential for Zen 3+ AMD Ryzen APUs) */ + __asm__ volatile ("wbinvd" ::: "memory"); +} + bool vbe_is_hardware_framebuffer(void) { return s_is_hardware; } @@ -97,6 +102,8 @@ void vbe_early_boot_splash(void) { } x0 += 8; } + + vbe_flush_cache(); } void vbe_console_clear(void) { @@ -110,6 +117,7 @@ void vbe_console_clear(void) { } s_console_x = 24; s_console_y = 60; + vbe_flush_cache(); } void vbe_console_putchar(char c, uint32_t color) { @@ -341,4 +349,5 @@ void vbe_swap_buffers(void) { src += row_bytes; } } + vbe_flush_cache(); } diff --git a/kernel/kmain.c b/kernel/kmain.c index a0a3326..3e0166b 100644 --- a/kernel/kmain.c +++ b/kernel/kmain.c @@ -67,7 +67,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 && fb_phys < (128ULL * 1024 * 1024 * 1024) && w >= 320 && h >= 200) { + if (fb_phys != 0 && fb_phys < (512ULL * 1024 * 1024 * 1024) && w >= 320 && h >= 200) { vbe_set_physical_framebuffer(fb_phys, w, h, pitch, (uint32_t)bpp); vbe_early_boot_splash(); serial_puts("[AIRLYS] UEFI GOP Framebuffer bound to physical display!\n"); @@ -87,13 +87,34 @@ void kernel_main(uint64_t magic, uint64_t addr) { uint32_t h = *(volatile uint32_t*)(addr + 104); uint8_t bpp = *(volatile uint8_t*)(addr + 108); - if (fb_phys != 0 && fb_phys < (128ULL * 1024 * 1024 * 1024) && w >= 320 && h >= 200) { + if (fb_phys != 0 && fb_phys < (512ULL * 1024 * 1024 * 1024) && w >= 320 && h >= 200) { vbe_set_physical_framebuffer(fb_phys, w, h, pitch, (uint32_t)bpp); vbe_early_boot_splash(); } } } + /* Fallback: Direct PCI Bus Display Controller probe if GOP not provided by bootloader */ + if (!vbe_is_hardware_framebuffer()) { + for (uint16_t bus = 0; bus < 8; bus++) { + for (uint8_t slot = 0; slot < 32; slot++) { + uint16_t vid = pci_read16((uint8_t)bus, slot, 0, 0x00); + if (vid == 0xFFFF || vid == 0x0000) continue; + uint8_t class_id = pci_read8((uint8_t)bus, slot, 0, 0x0B); + if (class_id == PCI_CLASS_DISPLAY) { + uint32_t bar0 = pci_read32((uint8_t)bus, slot, 0, 0x10) & 0xFFFFFFF0; + if (bar0 != 0) { + vbe_set_physical_framebuffer((uint64_t)bar0, 1920, 1080, 1920 * 4, 32); + vbe_early_boot_splash(); + serial_puts("[AIRLYS] PCI Display Controller Framebuffer bound!\n"); + break; + } + } + } + if (vbe_is_hardware_framebuffer()) break; + } + } + /* Step 1: Initialize hardware VGA terminal console (mirrors to active GOP display) */ vga_init(); diff --git a/scripts/build_iso.sh b/scripts/build_iso.sh index fa2ca71..7f7f82e 100755 --- a/scripts/build_iso.sh +++ b/scripts/build_iso.sh @@ -25,14 +25,24 @@ insmod all_video insmod efi_gop insmod efi_uga insmod font +insmod gfxterm -set gfxmode=1920x1080x32,1024x768x32,auto -set gfxpayload=keep +set gfxmode=1920x1080,1024x768,auto +set gfxpayload=1920x1080,1024x768,auto +terminal_output gfxterm set timeout=5 set default=0 -menuentry "Airlys Sovereign OS (Acer Nitro Bare Metal - Keep Active GOP)" { +menuentry "Airlys Sovereign OS (Acer Nitro FHD 1080p Native)" { + insmod all_video + insmod efi_gop + set gfxpayload=1920x1080,1024x768,auto + multiboot2 /boot/airlys.elf + boot +} + +menuentry "Airlys Sovereign OS (Acer Nitro - Keep Active GOP)" { insmod all_video insmod efi_gop set gfxpayload=keep @@ -40,18 +50,10 @@ menuentry "Airlys Sovereign OS (Acer Nitro Bare Metal - Keep Active GOP)" { boot } -menuentry "Airlys Sovereign OS (1920x1080 Native FHD Framebuffer)" { - insmod all_video - insmod efi_gop - set gfxpayload=1920x1080x32,keep,auto - multiboot2 /boot/airlys.elf - boot -} - menuentry "Airlys Sovereign OS (1024x768 TrueColor Framebuffer)" { insmod all_video insmod efi_gop - set gfxpayload=1024x768x32,keep,auto + set gfxpayload=1024x768,auto multiboot2 /boot/airlys.elf boot }