2023-05-17 20:20:53 -07:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2023-05-17 21:41:08 -07:00
|
|
|
#include "common/gdt.h"
|
2023-05-17 20:42:59 -07:00
|
|
|
#include "debug/debug.h"
|
2023-05-17 22:54:37 -07:00
|
|
|
#include "interrupt/interrupt.h"
|
2023-05-29 21:52:01 -07:00
|
|
|
#include "interrupt/timer.h"
|
2023-05-29 00:32:54 -07:00
|
|
|
#include "loader/init_loader.h"
|
2023-05-18 09:46:41 -07:00
|
|
|
#include "memory/kernel_heap.h"
|
2023-05-30 21:27:20 -07:00
|
|
|
#include "memory/kernel_stack_manager.h"
|
2023-05-18 01:18:51 -07:00
|
|
|
#include "memory/paging_util.h"
|
2023-05-18 11:00:05 -07:00
|
|
|
#include "memory/physical_memory.h"
|
2023-05-29 23:35:44 -07:00
|
|
|
#include "scheduler/process_manager.h"
|
2023-05-18 12:43:53 -07:00
|
|
|
#include "scheduler/scheduler.h"
|
2023-05-18 16:03:09 -07:00
|
|
|
#include "syscall/syscall.h"
|
2023-05-17 20:20:53 -07:00
|
|
|
|
|
|
|
extern "C" void zion() {
|
2023-05-29 22:32:50 -07:00
|
|
|
dbgln("[boot] Init GDT & IDT.");
|
2023-05-17 21:41:08 -07:00
|
|
|
InitGdt();
|
2023-05-17 22:54:37 -07:00
|
|
|
InitIdt();
|
2023-05-29 22:32:50 -07:00
|
|
|
|
|
|
|
dbgln("[boot] Init Physical Memory Manager.");
|
2023-05-18 11:00:05 -07:00
|
|
|
phys_mem::InitBootstrapPageAllocation();
|
2023-05-18 09:46:41 -07:00
|
|
|
KernelHeap heap(0xFFFFFFFF'40000000, 0xFFFFFFFF'80000000);
|
2023-05-18 11:34:45 -07:00
|
|
|
phys_mem::InitPhysicalMemoryManager();
|
2023-05-18 12:43:53 -07:00
|
|
|
|
2023-05-30 21:27:20 -07:00
|
|
|
dbgln("[boot] Memory allocations available now.");
|
|
|
|
|
|
|
|
dbgln("[boot] Init Kernel Stack Manager.");
|
|
|
|
KernelStackManager::Init();
|
|
|
|
|
2023-05-29 22:32:50 -07:00
|
|
|
dbgln("[boot] Init syscalls.");
|
2023-05-18 16:03:09 -07:00
|
|
|
InitSyscall();
|
|
|
|
|
2023-05-29 22:32:50 -07:00
|
|
|
dbgln("[boot] Init scheduler.");
|
2023-05-29 23:35:44 -07:00
|
|
|
ProcessManager::Init();
|
2023-05-29 23:48:32 -07:00
|
|
|
Scheduler::Init();
|
2023-05-29 22:17:56 -07:00
|
|
|
// Schedule every 50ms.
|
|
|
|
SetFrequency(/* hertz= */ 20);
|
2023-05-29 00:32:54 -07:00
|
|
|
|
2023-05-29 22:32:50 -07:00
|
|
|
dbgln("[boot] Loading sys init program.");
|
2023-05-29 00:32:54 -07:00
|
|
|
LoadInitProgram();
|
2023-05-29 22:32:50 -07:00
|
|
|
|
|
|
|
dbgln("[boot] Init finished, yielding.");
|
2023-05-29 23:48:32 -07:00
|
|
|
gScheduler->Enable();
|
|
|
|
gScheduler->Yield();
|
2023-05-17 20:20:53 -07:00
|
|
|
|
2023-05-18 11:00:05 -07:00
|
|
|
dbgln("Sleeping!");
|
2023-05-17 20:20:53 -07:00
|
|
|
while (1)
|
|
|
|
;
|
|
|
|
}
|