2022-09-07 13:02:23 +00:00
|
|
|
#define MODULE "main"
|
|
|
|
|
2022-09-05 14:13:51 +00:00
|
|
|
#include "acpi/RSDT.h"
|
2022-09-07 13:02:54 +00:00
|
|
|
#include "config.h"
|
2022-09-05 14:13:51 +00:00
|
|
|
#include "cpu/CPU.h"
|
|
|
|
#include "gdt/GDT.h"
|
|
|
|
#include "init/Init.h"
|
|
|
|
#include "interrupts/IDT.h"
|
|
|
|
#include "interrupts/Install.h"
|
|
|
|
#include "interrupts/Interrupts.h"
|
|
|
|
#include "io/PIC.h"
|
|
|
|
#include "log/Log.h"
|
2022-09-06 16:08:15 +00:00
|
|
|
#include "memory/KernelMemoryManager.h"
|
2022-09-05 15:13:12 +00:00
|
|
|
#include "memory/Memory.h"
|
2022-09-07 17:41:08 +00:00
|
|
|
#include "memory/MemoryMap.h"
|
2022-09-06 11:21:54 +00:00
|
|
|
#include "memory/RangeAllocator.h"
|
2022-09-05 14:13:51 +00:00
|
|
|
#include "panic/hang.h"
|
2022-09-07 17:41:08 +00:00
|
|
|
#include "power/reboot.h"
|
2022-09-10 16:42:40 +00:00
|
|
|
#include "render/Framebuffer.h"
|
2022-09-05 14:13:51 +00:00
|
|
|
#include "scheduling/PIT.h"
|
|
|
|
#include "std/stdio.h"
|
|
|
|
#include "std/stdlib.h"
|
|
|
|
#include "std/string.h"
|
|
|
|
|
|
|
|
extern "C" void _start()
|
|
|
|
{
|
|
|
|
Init::check_magic();
|
|
|
|
Init::disable_smp(); // Put all other cores except the bootstrap one in an infinite loop
|
|
|
|
Init::early_init();
|
|
|
|
|
2022-09-07 17:41:08 +00:00
|
|
|
kinfoln("Starting Moon %d.%d%s", MOON_MAJOR, MOON_MINOR, MOON_SUFFIX);
|
|
|
|
|
|
|
|
CPU::log_cpu_information();
|
|
|
|
|
|
|
|
Memory::walk_memory_map();
|
2022-09-05 14:13:51 +00:00
|
|
|
|
2022-09-08 15:03:17 +00:00
|
|
|
kdbgln("System memory: %ld KB", Memory::get_system() / 1024);
|
|
|
|
kdbgln(" Free memory : %ld KB", kernelPMM.get_free() / 1024);
|
|
|
|
kdbgln(" Used memory : %ld KB", kernelPMM.get_used() / 1024);
|
|
|
|
kdbgln(" Reserved memory : %ld KB", kernelPMM.get_reserved() / 1024);
|
2022-09-07 18:01:44 +00:00
|
|
|
|
2022-09-05 14:13:51 +00:00
|
|
|
GDT::load();
|
|
|
|
|
|
|
|
kinfoln("Loaded GDT");
|
|
|
|
|
|
|
|
Interrupts::install();
|
|
|
|
|
|
|
|
IDT::load();
|
|
|
|
|
|
|
|
kinfoln("Loaded IDT");
|
|
|
|
|
|
|
|
PIC::remap();
|
|
|
|
PIC::enable_master(0b11111100); // enable keyboard and PIT
|
|
|
|
PIC::enable_slave(0b11111111);
|
|
|
|
|
|
|
|
kinfoln("Prepared PIC");
|
|
|
|
|
2022-09-07 18:01:44 +00:00
|
|
|
PIT::initialize(200); // 200 times per second
|
2022-09-05 14:13:51 +00:00
|
|
|
|
|
|
|
kinfoln("Prepared PIT");
|
|
|
|
|
|
|
|
Interrupts::enable();
|
|
|
|
|
|
|
|
kinfoln("Interrupts enabled");
|
|
|
|
|
2022-09-07 17:41:08 +00:00
|
|
|
ACPI::SDTHeader* rootSDT = ACPI::GetRSDTOrXSDT();
|
2022-09-10 16:42:40 +00:00
|
|
|
bool isXSDT = ACPI::IsXSDT();
|
2022-09-07 17:41:08 +00:00
|
|
|
if (!ACPI::ValidateRSDTOrXSDT(rootSDT)) kerrorln("Invalid %s", isXSDT ? "XSDT" : "RSDT");
|
2022-09-07 08:33:22 +00:00
|
|
|
|
2022-09-10 16:42:40 +00:00
|
|
|
framebuffer0.clear(Color::Cyan);
|
|
|
|
|
2022-09-07 13:02:54 +00:00
|
|
|
sleep(2500);
|
2022-09-07 17:41:08 +00:00
|
|
|
reboot();
|
2022-09-06 09:48:06 +00:00
|
|
|
|
2022-09-05 14:13:51 +00:00
|
|
|
while (1) halt();
|
|
|
|
}
|