Luna/kernel/src/init/Init.cpp

72 lines
1.6 KiB
C++
Raw Normal View History

#define MODULE "init"
2022-09-05 14:13:51 +00:00
#include "init/Init.h"
#include "bootboot.h"
#include "cpu/CPU.h"
2022-09-19 15:06:08 +00:00
#include "init/InitRD.h"
2022-09-05 14:13:51 +00:00
#include "interrupts/Interrupts.h"
#include "io/Serial.h"
2022-09-15 16:42:59 +00:00
#include "log/Log.h"
#include "memory/MemoryManager.h"
#include "memory/PMM.h"
2022-09-06 11:49:17 +00:00
#include "memory/VMM.h"
2022-09-21 15:56:53 +00:00
#include "misc/hang.h"
2022-09-14 16:54:40 +00:00
#include "rand/Init.h"
#include "rand/Mersenne.h"
2022-09-10 16:42:40 +00:00
#include "render/Framebuffer.h"
2022-09-05 14:13:51 +00:00
#include "render/TextRenderer.h"
#include "std/assert.h"
2022-09-15 16:42:59 +00:00
#include "std/string.h"
2022-09-05 14:13:51 +00:00
extern BOOTBOOT bootboot;
2022-09-15 16:42:59 +00:00
extern "C" char environment[4096];
2022-09-05 14:13:51 +00:00
2022-09-14 16:54:40 +00:00
uintptr_t __stack_chk_guard = 0xfeff34;
2022-09-05 14:13:51 +00:00
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;
}
extern "C" void asm_enable_sse();
2022-09-05 14:13:51 +00:00
void Init::early_init()
{
Interrupts::disable();
asm volatile("cld");
asm_enable_sse();
2022-09-10 16:42:40 +00:00
framebuffer0.init((void*)bootboot.fb_ptr, bootboot.fb_type, bootboot.fb_scanline, bootboot.fb_width,
bootboot.fb_height);
MemoryManager::init();
2022-09-14 16:54:40 +00:00
2022-09-15 16:42:59 +00:00
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); }
InitRD::init();
2022-09-14 16:54:40 +00:00
Mersenne::init();
kdbgln("Page bitmap uses %ld bytes of memory", PMM::get_bitmap_size());
2022-09-14 16:54:40 +00:00
__stack_chk_guard = Mersenne::get();
}
void Init::finish_kernel_boot()
{
KernelLog::toggle_log_backend(Backend::Console);
framebuffer0.clear(Color::Black);
TextRenderer::reset();
2022-09-05 14:13:51 +00:00
}