X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FKernel%2Farch%2Fx86_64%2Fmain.c;h=24f58915225f3dc40af2addf05144a0a26aa71e0;hb=9edb6f7c288a93d9f9ce3f7233b577a601471071;hp=0348de689b2654f608258a7e1c331a1672d46c64;hpb=e1a5a15ff663d68e107edf0ad0a2bc878c0670d5;p=tpg%2Facess2.git diff --git a/KernelLand/Kernel/arch/x86_64/main.c b/KernelLand/Kernel/arch/x86_64/main.c index 0348de68..24f58915 100644 --- a/KernelLand/Kernel/arch/x86_64/main.c +++ b/KernelLand/Kernel/arch/x86_64/main.c @@ -14,11 +14,11 @@ // === CONSTANTS === #define KERNEL_LOAD 0x100000 #define MAX_PMEMMAP_ENTS 16 +#define MAX_ARGSTR_POS (0x200000-0x2000) // === IMPORTS === extern void Desctab_Init(void); extern void MM_InitVirt(void); -extern void Heap_Install(void); extern int Time_Setup(void); extern char gKernelEnd[]; @@ -28,6 +28,8 @@ void kmain(Uint MbMagic, void *MbInfoPtr); // === GLOBALS == char *gsBootCmdLine = NULL; +tBootModule *gaArch_BootModules; + int giArch_NumBootModules = 0; // === CODE === void kmain(Uint MbMagic, void *MbInfoPtr) @@ -63,6 +65,13 @@ void kmain(Uint MbMagic, void *MbInfoPtr) MM_InitPhys( nPMemMapEnts, pmemmap ); // Set up physical memory manager Log("gsBootCmdLine = '%s'", gsBootCmdLine); + switch(MbMagic) + { + case MULTIBOOT_MAGIC: + MM_RefPhys( mbInfo->CommandLine ); + break; + } + *(Uint16*)(KERNEL_BASE|0xB8000) = 0x1F00|'D'; Heap_Install(); @@ -76,6 +85,10 @@ void kmain(Uint MbMagic, void *MbInfoPtr) Log_Log("Arch", "Starting VFS..."); VFS_Init(); + // Multiboot_InitFramebuffer(mbInfo); + + gaArch_BootModules = Multiboot_LoadModules(mbInfo, KERNEL_BASE, &giArch_NumBootModules); + *(Uint16*)(KERNEL_BASE|0xB8000) = 0x1F00|'Z'; // Pass on to Independent Loader @@ -89,7 +102,32 @@ void kmain(Uint MbMagic, void *MbInfoPtr) void Arch_LoadBootModules(void) { - + int i, j, numPages; + Log("gsBootCmdLine = '%s'", gsBootCmdLine); + for( i = 0; i < giArch_NumBootModules; i ++ ) + { + Log_Log("Arch", "Loading '%s'", gaArch_BootModules[i].ArgString); + + if( !Module_LoadMem( gaArch_BootModules[i].Base, + gaArch_BootModules[i].Size, gaArch_BootModules[i].ArgString + ) ) + { + Log_Warning("Arch", "Unable to load module"); + } + + // Unmap and free + numPages = (gaArch_BootModules[i].Size + ((Uint)gaArch_BootModules[i].Base&0xFFF) + 0xFFF) >> 12; + MM_UnmapHWPages( (tVAddr)gaArch_BootModules[i].Base, numPages ); + + for( j = 0; j < numPages; j++ ) + MM_DerefPhys( gaArch_BootModules[i].PBase + (j << 12) ); + + if( (tVAddr) gaArch_BootModules[i].ArgString < KERNEL_BASE ) + MM_UnmapHWPages( (tVAddr)gaArch_BootModules[i].ArgString, 2 ); + } + Log_Log("Arch", "Boot modules loaded"); + if( gaArch_BootModules ) + free( gaArch_BootModules ); } void StartupPrint(const char *String)