From d1e4bc55040d2738dbe303dc850bb06c8e579f37 Mon Sep 17 00:00:00 2001 From: apio Date: Sat, 29 Oct 2022 20:10:49 +0200 Subject: [PATCH] Kernel: Use framebuffer virtual address instead of physical address Just found out bootboot.fb_ptr was the physical address, not virtual. That explains why we were getting page faults while writing to the physical address of the framebuffer. (we were in a user address space when doing so) So this should probably make the system much more stable!! --- kernel/src/init/Init.cpp | 6 +++--- kernel/src/main.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/src/init/Init.cpp b/kernel/src/init/Init.cpp index 09cebe09..2ad47635 100644 --- a/kernel/src/init/Init.cpp +++ b/kernel/src/init/Init.cpp @@ -20,12 +20,13 @@ extern BOOTBOOT bootboot; extern "C" char environment[4096]; +extern uintptr_t fb; uintptr_t __stack_chk_guard = 0xfeff34; void Init::check_magic() { - ASSERT(strncmp((char*)bootboot.magic, BOOTBOOT_MAGIC, 4) == 0); + if (strncmp((char*)bootboot.magic, BOOTBOOT_MAGIC, 4) != 0) hang(); } void Init::disable_smp() @@ -43,8 +44,7 @@ void Init::early_init() asm_enable_sse(); - framebuffer0.init((void*)bootboot.fb_ptr, bootboot.fb_type, bootboot.fb_scanline, bootboot.fb_width, - bootboot.fb_height); + framebuffer0.init((void*)&fb, bootboot.fb_type, bootboot.fb_scanline, bootboot.fb_width, bootboot.fb_height); MemoryManager::init(); diff --git a/kernel/src/main.cpp b/kernel/src/main.cpp index b51e5127..ab5c3751 100644 --- a/kernel/src/main.cpp +++ b/kernel/src/main.cpp @@ -23,8 +23,8 @@ extern "C" void _start() { - Init::check_magic(); Init::disable_smp(); // Put all other cores except the bootstrap one in an infinite loop + Init::check_magic(); Init::early_init(); kinfoln("Starting Moon %s", moon_version());