Luna/kernel/src/boot/Init.cpp

47 lines
1.1 KiB
C++
Raw Normal View History

2022-11-19 16:59:49 +00:00
#include "boot/Init.h"
2022-11-30 12:29:28 +00:00
#include "Log.h"
2022-11-15 18:10:32 +00:00
#include "arch/CPU.h"
2022-11-19 16:59:49 +00:00
#include "boot/bootboot.h"
#include "fs/InitRD.h"
2022-11-19 16:59:49 +00:00
#include "memory/MemoryManager.h"
#include "video/Framebuffer.h"
#include <luna/CString.h>
2022-12-07 10:40:02 +00:00
#include <luna/Result.h>
2022-11-13 11:20:53 +00:00
extern const BOOTBOOT bootboot;
2022-11-13 11:20:53 +00:00
void Init::check_magic()
{
if (memcmp(bootboot.magic, BOOTBOOT_MAGIC, 4))
{
2022-11-30 16:16:36 +00:00
kerrorln("ERROR: Invalid magic value from bootloader");
CPU::efficient_halt();
2022-11-13 11:20:53 +00:00
}
// Stop all secondary processors for now
if (CPU::get_processor_id() != bootboot.bspid) { CPU::efficient_halt(); }
2022-11-13 11:20:53 +00:00
}
void Init::early_init()
{
2022-11-19 19:01:01 +00:00
CPU::disable_interrupts();
2022-11-13 11:20:53 +00:00
Framebuffer::init();
set_text_console_initialized();
2022-11-30 12:29:28 +00:00
#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);
2022-11-30 12:29:28 +00:00
CPU::platform_init();
MemoryManager::init();
InitRD::initialize();
2022-11-15 18:10:32 +00:00
mark_critical(MemoryManager::protect_kernel_sections(),
"Could not remap kernel data sections as non-executable / read-only");
2023-01-02 12:07:29 +00:00
}