X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Farch%2Fx86_64%2Fmain.c;h=3532c8091e1f6c6bcbdf8ca2c3e78d4279d0f7eb;hb=6d5880d56afb2c6a900e480c891fb40e05457ea3;hp=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391;hpb=3234a52a913609230ffc140c27542d421bb1b7d3;p=tpg%2Facess2.git diff --git a/Kernel/arch/x86_64/main.c b/Kernel/arch/x86_64/main.c index e69de29b..3532c809 100644 --- a/Kernel/arch/x86_64/main.c +++ b/Kernel/arch/x86_64/main.c @@ -0,0 +1,86 @@ +/* + * Acess2 x86_64 Project + */ +#include +#include +#include + +// === IMPORTS === +extern void Desctab_Init(void); +extern void MM_InitVirt(void); +extern void Heap_Install(void); +extern void Threads_Init(void); +extern int Time_Setup(void); +extern void System_Init(char *Commandline); + +extern void MM_InitPhys_Multiboot(tMBoot_Info *MBoot); + +// === PROTOTYPES === +void kmain(Uint MbMagic, void *MbInfoPtr); + +// === GLOBALS == +char *gsBootCmdLine = NULL; + +// === CODE === +void kmain(Uint MbMagic, void *MbInfoPtr) +{ + tMBoot_Info *mbInfo; + + LogF("Acess2 x86_64 v"EXPAND_STR(KERNEL_VERSION)"\n"); + LogF(" Build %i, Git Hash %s\n", BUILD_NUM, gsGitHash); + + Desctab_Init(); + + MM_InitVirt(); + *(Uint16*)(KERNEL_BASE|0xB8000) = 0x1F00|'C'; + + switch(MbMagic) + { + // Multiboot 1 + case MULTIBOOT_MAGIC: + // Adjust Multiboot structure address + mbInfo = (void*)( (Uint)MbInfoPtr + KERNEL_BASE ); + gsBootCmdLine = (char*)( (Uint)mbInfo->CommandLine + KERNEL_BASE); + MM_InitPhys_Multiboot( mbInfo ); // Set up physical memory manager + break; + default: + Panic("Multiboot magic invalid %08x, expected %08x\n", + MbMagic, MULTIBOOT_MAGIC); + return ; + } + + Log("gsBootCmdLine = '%s'", gsBootCmdLine); + + *(Uint16*)(KERNEL_BASE|0xB8000) = 0x1F00|'D'; + Heap_Install(); + + *(Uint16*)(KERNEL_BASE|0xB8000) = 0x1F00|'E'; + Threads_Init(); + + Time_Setup(); + *(Uint16*)(KERNEL_BASE|0xB8000) = 0x1F00|'F'; + + // Load Virtual Filesystem + Log_Log("Arch", "Starting VFS..."); + VFS_Init(); + + *(Uint16*)(KERNEL_BASE|0xB8000) = 0x1F00|'Z'; + + // Pass on to Independent Loader + Log_Log("Arch", "Starting system"); + System_Init(gsBootCmdLine); + + // Sleep forever (sleeping beauty) + for(;;) + Threads_Sleep(); +} + +void Arch_LoadBootModules(void) +{ + +} + +void StartupPrint(const char *String) +{ + +}