#include "init/Init.h" #include "assert.h" #include "bootboot.h" #include "cpu/CPU.h" #include "init/InitRD.h" #include "interrupts/Interrupts.h" #include "io/Serial.h" #include "log/Log.h" #include "memory/KernelMemoryManager.h" #include "memory/RangeAllocator.h" #include "memory/VMM.h" #include "misc/hang.h" #include "rand/Init.h" #include "rand/Mersenne.h" #include "render/Framebuffer.h" #include "render/TextRenderer.h" #include "std/string.h" extern BOOTBOOT bootboot; extern "C" char environment[4096]; uintptr_t __stack_chk_guard = 0xfeff34; void Init::check_magic() { ASSERT(strncmp((char*)bootboot.magic, BOOTBOOT_MAGIC, 4) == 0); } void Init::disable_smp() { if (CPU::get_initial_apic_id() != bootboot.bspid) { hang(); } return; } void Init::early_init() { Interrupts::disable(); asm volatile("cld"); framebuffer0.init((void*)bootboot.fb_ptr, bootboot.fb_type, bootboot.fb_scanline, bootboot.fb_width, bootboot.fb_height); kernelPMM.init_from_mmap(); kernelVMM.init(); KernelMemoryManager::init(); InitRD::init(); ASSERT(TextRenderer::try_initialize()); if (strstr(environment, "quiet=1")) { KernelLog::toggle_log_level(LogLevel::DEBUG); KernelLog::toggle_log_level(LogLevel::INFO); } else if (!strstr(environment, "verbose=1")) { KernelLog::toggle_log_level(LogLevel::DEBUG); } Mersenne::init(); __stack_chk_guard = Mersenne::get(); }