40 lines
960 B
C
40 lines
960 B
C
#include "../Common/bootinfo.h"
|
|
#include <Arch/DTB.h>
|
|
#include <Arch/Timer.h>
|
|
#include <Arch/CPU.h>
|
|
#include <Arch/GIC.h>
|
|
#include <IO/Serial.h>
|
|
#include <VM/PMM.h>
|
|
#include <VM/VMM.h>
|
|
#include <VM/Heap.h>
|
|
#include <OS/Log.h>
|
|
#include <OS/Panic.h>
|
|
#include <OS/Scheduler.h>
|
|
|
|
void KernelMain(Bootinfo* bootinfo) {
|
|
OSLog("Kernel started.\n");
|
|
if (bootinfo->magic != BOOTINFO_MAGIC) {
|
|
OSPanic("Invalid bootinfo magic");
|
|
}
|
|
|
|
VMBootMemoryMap bootMap = {0};
|
|
|
|
bootMap.reservedCount = 0;
|
|
DTBParse(bootinfo->dtb, &bootMap);
|
|
PMMInitialize(&bootMap);
|
|
VMMInitialize(&bootMap, bootinfo);
|
|
SerialUpdate(VMPhysToHHDM(bootMap.UART.base));
|
|
HeapInitialize();
|
|
|
|
GICInitialize(
|
|
(Pointer)VMPhysToHHDM(bootMap.GIC.GICD.base),
|
|
(Pointer)VMPhysToHHDM(bootMap.GIC.GICC.base)
|
|
);
|
|
TimerInitialize();
|
|
CPUEnableInterrupts();
|
|
SchedulerInitialize();
|
|
SchedulerYield(0);
|
|
|
|
OSLog("Kernel initialized.\n");
|
|
}
|