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"
|
2023-04-28 13:55:06 +00:00
|
|
|
#include "fs/InitRD.h"
|
2022-11-19 16:59:49 +00:00
|
|
|
#include "memory/MemoryManager.h"
|
|
|
|
#include "video/Framebuffer.h"
|
2022-12-16 19:40:04 +00:00
|
|
|
#include <luna/CString.h>
|
2022-12-07 10:40:02 +00:00
|
|
|
#include <luna/Result.h>
|
2022-11-13 11:20:53 +00:00
|
|
|
|
2022-12-05 12:04:01 +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");
|
2022-12-30 17:36:22 +00:00
|
|
|
CPU::efficient_halt();
|
2022-11-13 11:20:53 +00:00
|
|
|
}
|
2023-04-22 10:25:43 +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();
|
2023-06-17 17:43:25 +00:00
|
|
|
set_text_console_initialized();
|
2022-11-30 12:29:28 +00:00
|
|
|
|
2023-02-27 15:23:51 +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
|
|
|
|
2022-12-26 11:12:55 +00:00
|
|
|
CPU::platform_init();
|
|
|
|
|
2022-11-13 13:29:59 +00:00
|
|
|
MemoryManager::init();
|
2022-12-23 10:33:23 +00:00
|
|
|
InitRD::initialize();
|
2022-11-15 18:10:32 +00:00
|
|
|
|
2023-06-17 17:43:25 +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
|
|
|
}
|