2021-09-14 15:48:57 +00:00
|
|
|
#include "hal/hal.h"
|
|
|
|
#include "drivers/drivers.h"
|
|
|
|
#include <debugio.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <memory.h>
|
|
|
|
#include <multiboot.h>
|
2021-09-14 15:57:06 +00:00
|
|
|
#include <tasking.h>
|
2021-09-14 15:48:57 +00:00
|
|
|
|
|
|
|
extern uint32 _end;
|
|
|
|
|
2021-09-14 15:51:43 +00:00
|
|
|
extern void luxInitrdInstall (MultibootInfo* info);
|
|
|
|
|
2021-09-14 16:02:20 +00:00
|
|
|
void k_main(MultibootInfo* info, uint32 initial_stack)
|
2021-09-14 15:48:57 +00:00
|
|
|
{
|
2021-09-14 16:02:20 +00:00
|
|
|
TaskingSetInitialStack(initial_stack);
|
|
|
|
|
2021-09-14 15:48:57 +00:00
|
|
|
uint32 KernelEnd = (uint32)&_end;
|
|
|
|
|
2021-09-14 15:51:43 +00:00
|
|
|
// Find kernel's end
|
|
|
|
if (info->Flags & 0x8) {
|
|
|
|
|
|
|
|
uint32 i = 0;
|
|
|
|
MultibootModule* modules = (MultibootModule*) info->ModulesAddress;
|
|
|
|
|
|
|
|
for (i = 0; i < info->ModulesCount; i++)
|
|
|
|
KernelEnd = Max(KernelEnd, modules[i].ModuleEnd);
|
|
|
|
}
|
|
|
|
|
2021-09-14 15:48:57 +00:00
|
|
|
ConsoleClear();
|
2021-09-14 15:50:50 +00:00
|
|
|
MemoryTempInitialize(KernelEnd);
|
|
|
|
MemoryInitialize(info);
|
|
|
|
|
2021-09-14 16:02:20 +00:00
|
|
|
TaskingInitialize();
|
2021-09-14 15:57:06 +00:00
|
|
|
|
2021-09-14 15:48:57 +00:00
|
|
|
HalInitialize();
|
2021-09-14 15:51:43 +00:00
|
|
|
luxInitrdInstall(info);
|
|
|
|
|
2021-09-14 15:48:57 +00:00
|
|
|
DriversInstall();
|
|
|
|
|
|
|
|
// Set up memory manager
|
2021-09-14 15:51:43 +00:00
|
|
|
Log("Console", "All ready. Starting console...\n\n");
|
2021-09-14 15:48:57 +00:00
|
|
|
|
|
|
|
ConsoleMain();
|
|
|
|
}
|