8 #include <multiboot2.h>
16 extern void Heap_Install(void);
17 extern void Desctab_Install(void);
18 extern void MM_PreinitVirtual(void);
19 extern void MM_Install(tMBoot_Info *MBoot);
20 extern void MM_InstallVirtual(void);
21 extern void Threads_Init(void);
22 extern int Time_Setup(void);
23 extern Uint Proc_Clone(Uint *Err, Uint Flags);
24 extern void Threads_Sleep(void);
25 extern void Threads_Exit(void);
27 extern int Modules_LoadBuiltins(void);
30 char *gsBootCmdLine = NULL;
33 int kmain(Uint MbMagic, void *MbInfoPtr)
39 Log("MbMagic = %08x", MbMagic);
40 Log("MbInfoPtr = %p", MbInfoPtr);
42 // Set up non-boot info dependent stuff
43 Desctab_Install(); // Set up GDT and IDT
44 MM_PreinitVirtual(); // Initialise vital mappings
50 // Adjust Multiboot structure address
51 mbInfo = (void*)( (Uint)MbInfoPtr + KERNEL_BASE );
52 gsBootCmdLine = (char*)(mbInfo->CommandLine + KERNEL_BASE);
54 MM_Install( mbInfo ); // Set up physical memory manager
58 case MULTIBOOT2_MAGIC:
59 Warning("Multiboot 2 Not yet supported");
60 //MM_InstallMBoot2( MbInfo ); // Set up physical memory manager
65 Panic("Multiboot magic invalid %08x, expected %08x or %08x\n",
66 MbMagic, MULTIBOOT_MAGIC, MULTIBOOT2_MAGIC);
70 MM_InstallVirtual(); // Clean up virtual address space
71 Heap_Install(); // Create initial heap
73 //Log_Log("Arch", "Starting Multitasking...");
80 Log_Log("Arch", "Starting VFS...");
81 // Load Virtual Filesystem
84 // Initialise builtin modules
85 Log_Log("Arch", "Initialising builtin modules...");
86 Modules_LoadBuiltins();
88 Log_Log("Arch", "Loading %i Modules...", mbInfo->ModuleCount);
90 // Load initial modules
91 mods = (void*)( mbInfo->Modules + KERNEL_BASE );
92 for( i = 0; i < mbInfo->ModuleCount; i ++ )
94 // Adjust into higher half
95 mods[i].Start += KERNEL_BASE;
96 mods[i].End += KERNEL_BASE;
97 mods[i].String += KERNEL_BASE;
99 Log_Log("Arch", "Loading '%s'", mods[i].String);
101 if( !Module_LoadMem( (void *)mods[i].Start, mods[i].End-mods[i].Start, (char *)mods[i].String ) )
103 Log_Warning("Arch", "Unable to load module\n");
107 // Pass on to Independent Loader
108 Log_Log("Arch", "Starting system");
109 System_Init( gsBootCmdLine );
111 // Sleep forever (sleeping beauty)