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 void System_Init(char *Commandline);
30 void Arch_LoadBootModules(void);
33 char *gsBootCmdLine = NULL;
38 } *gaArch_BootModules;
39 int giArch_NumBootModules = 0;
42 int kmain(Uint MbMagic, void *MbInfoPtr)
48 Log("MbMagic = %08x", MbMagic);
49 Log("MbInfoPtr = %p", MbInfoPtr);
51 // Set up non-boot info dependent stuff
52 Desctab_Install(); // Set up GDT and IDT
53 MM_PreinitVirtual(); // Initialise vital mappings
59 // Adjust Multiboot structure address
60 mbInfo = (void*)( (Uint)MbInfoPtr + KERNEL_BASE );
61 gsBootCmdLine = (char*)(mbInfo->CommandLine + KERNEL_BASE);
63 MM_Install( mbInfo ); // Set up physical memory manager
67 case MULTIBOOT2_MAGIC:
68 Warning("Multiboot 2 Not yet supported");
69 //MM_InstallMBoot2( MbInfo ); // Set up physical memory manager
74 Panic("Multiboot magic invalid %08x, expected %08x or %08x\n",
75 MbMagic, MULTIBOOT_MAGIC, MULTIBOOT2_MAGIC);
79 MM_InstallVirtual(); // Clean up virtual address space
80 Heap_Install(); // Create initial heap
82 //Log_Log("Arch", "Starting Multitasking...");
89 Log_Log("Arch", "Starting VFS...");
90 // Load Virtual Filesystem
93 // Load initial modules
94 mods = (void*)( mbInfo->Modules + KERNEL_BASE );
95 giArch_NumBootModules = mbInfo->ModuleCount;
96 gaArch_BootModules = malloc( giArch_NumBootModules * sizeof(*gaArch_BootModules) );
97 for( i = 0; i < mbInfo->ModuleCount; i ++ )
99 // Adjust into higher half
100 mods[i].Start += KERNEL_BASE;
101 mods[i].End += KERNEL_BASE;
102 mods[i].String += KERNEL_BASE;
104 gaArch_BootModules[i].Base = (void *)mods[i].Start;
105 gaArch_BootModules[i].Size = mods[i].End - mods[i].Start;
106 gaArch_BootModules[i].ArgString = (char *)mods[i].String;
109 // Pass on to Independent Loader
110 Log_Log("Arch", "Starting system");
111 System_Init(gsBootCmdLine);
113 // Sleep forever (sleeping beauty)
119 void Arch_LoadBootModules(void)
122 for( i = 0; i < giArch_NumBootModules; i ++ )
124 Log_Log("Arch", "Loading '%s'", gaArch_BootModules[i].ArgString);
126 if( !Module_LoadMem( gaArch_BootModules[i].Base, gaArch_BootModules[i].Size, gaArch_BootModules[i].ArgString ) )
128 Log_Warning("Arch", "Unable to load module\n");
131 Log_Log("Arch", "Boot modules loaded");
132 free( gaArch_BootModules );