Luna/kernel/src/boot/Init.cpp

47 lines
1.1 KiB
C++

#include "boot/Init.h"
#include "Log.h"
#include "arch/CPU.h"
#include "boot/bootboot.h"
#include "fs/InitRD.h"
#include "memory/MemoryManager.h"
#include "video/Framebuffer.h"
#include <luna/CString.h>
#include <luna/Result.h>
extern const BOOTBOOT bootboot;
void Init::check_magic()
{
if (memcmp(bootboot.magic, BOOTBOOT_MAGIC, 4))
{
kerrorln("ERROR: Invalid magic value from bootloader");
CPU::efficient_halt();
}
// Stop all secondary processors for now
if (CPU::get_processor_id() != bootboot.bspid) { CPU::efficient_halt(); }
}
void Init::early_init()
{
CPU::disable_interrupts();
Framebuffer::init();
set_text_console_initialized();
#ifdef DEBUG_MODE
constexpr bool should_log_console = true;
#else
constexpr bool should_log_console = false;
#endif
setup_log(log_debug_enabled(), log_serial_enabled(), should_log_console);
CPU::platform_init();
MemoryManager::init();
InitRD::initialize();
mark_critical(MemoryManager::protect_kernel_sections(),
"Could not remap kernel data sections as non-executable / read-only");
}