fix(baremetal): map 8GB physical address space and bind UEFI GOP framebuffer to physical LCD display

- arch/x86_64/boot.s: Expand identity-mapped page tables from 1GB to 8GB (4096 entries * 2MB)
- drivers/vbe.c: Implement vbe_set_physical_framebuffer to map physical GPU MMIO address directly
- kernel/kmain.c: Parse Multiboot 2 Framebuffer tag (type 16) and bind physical display
- kernel/kmain.c: Auto-render Desktop GUI frame immediately and continuously at 60 FPS
- Eliminates bare-metal black screen on Acer Nitro ANV15-41 modern laptops
This commit is contained in:
Adam Eehan committed 2026-10-24 00:23:39 +05:30
1 parent 5b7463be14
commit 6165197d0a
4 files changed
+109 -12

No files matched your search

+47 -2
View File
@@ -4,12 +4,46 @@
#include <airlys/printk.h>
static vbe_screen_t s_screen;
static bool s_is_hardware = false;
/* Static fallback buffer (1024 x 768 @ 32bpp) */
#define VBE_MAX_PIXELS (1024 * 768)
static uint32_t s_pixel_buffer[VBE_MAX_PIXELS];
bool vbe_is_hardware_framebuffer(void) {
return s_is_hardware;
}
void vbe_set_physical_framebuffer(uint64_t addr, uint32_t width, uint32_t height, uint32_t pitch, uint32_t bpp) {
if (width > 1920) width = 1920;
if (height > 1080) height = 1080;
if (width == 0) width = 1024;
if (height == 0) height = 768;
s_screen.width = width;
s_screen.height = height;
s_screen.pitch = (pitch > 0) ? pitch : width * 4;
s_screen.bpp = (bpp > 0) ? bpp : 32;
/* Point front_buffer directly to physical GPU MMIO memory */
s_screen.front_buffer = (uint32_t*)addr;
s_screen.back_buffer = (uint32_t*)kmalloc(width * height * sizeof(uint32_t));
if (!s_screen.back_buffer) {
s_screen.back_buffer = s_pixel_buffer;
}
s_screen.initialized = true;
s_is_hardware = true;
printk(KERN_INFO "vbe: Physical UEFI GOP Framebuffer mapped at 0x%lx (%ux%u, pitch: %u)\n",
addr, width, height, s_screen.pitch);
}
void vbe_init(uint32_t width, uint32_t height) {
if (s_is_hardware && s_screen.initialized) {
return; /* Keep real hardware framebuffer intact */
}
if (width > 1024) width = 1024;
if (height > 768) height = 768;
@@ -164,6 +198,17 @@ void vbe_swap_buffers(void) {
if (!s_screen.initialized || s_screen.front_buffer == s_screen.back_buffer) {
return;
}
uint32_t total = s_screen.width * s_screen.height;
kmemcpy(s_screen.front_buffer, s_screen.back_buffer, total * sizeof(uint32_t));
if (s_screen.pitch == s_screen.width * 4) {
uint32_t total = s_screen.width * s_screen.height;
kmemcpy(s_screen.front_buffer, s_screen.back_buffer, total * sizeof(uint32_t));
} else {
uint8_t* dst = (uint8_t*)s_screen.front_buffer;
uint8_t* src = (uint8_t*)s_screen.back_buffer;
uint32_t row_bytes = s_screen.width * 4;
for (uint32_t y = 0; y < s_screen.height; y++) {
kmemcpy(dst, src, row_bytes);
dst += s_screen.pitch;
src += row_bytes;
}
}
}