X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Farch%2Fx86_64%2Fmain.c;h=7d69368095a210e9dbdd07df657c17a5260942ac;hb=a1b7b0fcbf99e2c53dd6d7ee5961772bf29bdb2b;hp=6a1520a21d43159fbb38760ae937f3dd4e35cb09;hpb=c6061d381c0af2dcc7c971347d036dc17399887a;p=tpg%2Facess2.git diff --git a/Kernel/arch/x86_64/main.c b/Kernel/arch/x86_64/main.c index 6a1520a2..7d693680 100644 --- a/Kernel/arch/x86_64/main.c +++ b/Kernel/arch/x86_64/main.c @@ -2,25 +2,78 @@ * Acess2 x86_64 Project */ #include +#include // === IMPORTS === extern void Desctab_Init(void); extern void MM_InitVirt(void); +extern void Heap_Install(void); +extern void Threads_Init(void); +//extern void Time_Setup(void); +extern void System_Init(char *Commandline); + +extern void MM_InitPhys_Multiboot(tMBoot_Info *MBoot); // === PROTOTYPES === // === GLOBALS == +char *gsBootCmdLine = NULL; // === CODE === void kmain(Uint MbMagic, void *MbInfoPtr) { - *(Uint16*)(0xB8000) = 0x1F00|'A'; + tMBoot_Info *mbInfo; Desctab_Init(); + MM_InitVirt(); + *(Uint16*)(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); + Log("gsBootCmdLine = '%s'", gsBootCmdLine); + + 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*)(0xB8000) = 0x1F00|'D'; + Heap_Install(); + + *(Uint16*)(0xB8000) = 0x1F00|'E'; + Log_Log("Arch", "Starting threading..."); + Threads_Init(); + + //Time_Setup(); + *(Uint16*)(0xB8000) = 0x1F00|'F'; + + Log_Log("Arch", "Starting VFS..."); + // Load Virtual Filesystem + VFS_Init(); + + *(Uint16*)(0xB8000) = 0x1F00|'Z'; + *(Uint16*)(0xB8002) = 0x1F00|'Z'; + *(Uint16*)(0xB8004) = 0x1F00|'Z'; + *(Uint16*)(0xB8006) = 0x1F00|'Z'; + + // Pass on to Independent Loader + Log_Log("Arch", "Starting system"); + System_Init(gsBootCmdLine); + // Sleep forever (sleeping beauty) for(;;) - __asm__ __volatile__ ("hlt"); + Threads_Sleep(); } void Arch_LoadBootModules(void)