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);
26 extern void System_Init(char *Commandline);
29 void Arch_LoadBootModules(void);
32 char *gsBootCmdLine = NULL;
37 } *gaArch_BootModules;
38 int giArch_NumBootModules = 0;
41 int kmain(Uint MbMagic, void *MbInfoPtr)
47 Log("MbMagic = %08x", MbMagic);
48 Log("MbInfoPtr = %p", MbInfoPtr);
50 // Set up non-boot info dependent stuff
51 Desctab_Install(); // Set up GDT and IDT
52 MM_PreinitVirtual(); // Initialise virtual mappings
58 // Adjust Multiboot structure address
59 mbInfo = (void*)( (Uint)MbInfoPtr + KERNEL_BASE );
60 gsBootCmdLine = (char*)(mbInfo->CommandLine + KERNEL_BASE);
62 MM_Install( mbInfo ); // Set up physical memory manager
66 case MULTIBOOT2_MAGIC:
67 Warning("Multiboot 2 Not yet supported");
68 //MM_InstallMBoot2( MbInfo ); // Set up physical memory manager
73 Panic("Multiboot magic invalid %08x, expected %08x or %08x\n",
74 MbMagic, MULTIBOOT_MAGIC, MULTIBOOT2_MAGIC);
78 MM_InstallVirtual(); // Clean up virtual address space
79 Heap_Install(); // Create initial heap
81 //Log_Log("Arch", "Starting Multitasking...");
88 Log_Log("Arch", "Starting VFS...");
89 // Load Virtual Filesystem
92 // Load initial modules
93 mods = (void*)( mbInfo->Modules + KERNEL_BASE );
94 giArch_NumBootModules = mbInfo->ModuleCount;
95 gaArch_BootModules = malloc( giArch_NumBootModules * sizeof(*gaArch_BootModules) );
96 for( i = 0; i < mbInfo->ModuleCount; i ++ )
98 // Adjust into higher half
99 mods[i].Start += KERNEL_BASE;
100 mods[i].End += KERNEL_BASE;
101 mods[i].String += KERNEL_BASE;
103 gaArch_BootModules[i].Base = (void *)mods[i].Start;
104 gaArch_BootModules[i].Size = mods[i].End - mods[i].Start;
105 gaArch_BootModules[i].ArgString = (char *)mods[i].String;
108 // Pass on to Independent Loader
109 Log_Log("Arch", "Starting system");
110 System_Init(gsBootCmdLine);
112 // Sleep forever (sleeping beauty)
118 void Arch_LoadBootModules(void)
121 for( i = 0; i < giArch_NumBootModules; i ++ )
123 Log_Log("Arch", "Loading '%s'", gaArch_BootModules[i].ArgString);
125 if( !Module_LoadMem( gaArch_BootModules[i].Base, gaArch_BootModules[i].Size, gaArch_BootModules[i].ArgString ) )
127 Log_Warning("Arch", "Unable to load module");
130 Log_Log("Arch", "Boot modules loaded");
131 free( gaArch_BootModules );