X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FKernel%2Farch%2Fx86%2Fmboot.c;h=08331a10a6134912c559e7a6948ac11cfc13a3e6;hb=344c700061dfe97b5e96211ec9257671fd5a7f33;hp=7403f387236ad246a2255041d5d6c85a8678b8a5;hpb=8c2139762f72576650cb5d07f5d9152b781e2643;p=tpg%2Facess2.git diff --git a/KernelLand/Kernel/arch/x86/mboot.c b/KernelLand/Kernel/arch/x86/mboot.c index 7403f387..08331a10 100644 --- a/KernelLand/Kernel/arch/x86/mboot.c +++ b/KernelLand/Kernel/arch/x86/mboot.c @@ -13,8 +13,6 @@ int Multiboot_LoadMemoryMap(tMBoot_Info *MBInfo, tVAddr MapOffset, tPMemMapEnt *Map, const int MapSize, tPAddr KStart, tPAddr KEnd) { int nPMemMapEnts = 0; - tMBoot_MMapEnt *ent = (void*)((tVAddr)MBInfo->MMapAddr + MapOffset); - tMBoot_MMapEnt *last = (void*)((tVAddr)ent + MBInfo->MMapLength); ENTER("pMBInfo pMapOffset pMap iMapSize PKStart PKEnd", MBInfo, MapOffset, Map, MapSize, KStart, KEnd); @@ -22,6 +20,8 @@ int Multiboot_LoadMemoryMap(tMBoot_Info *MBInfo, tVAddr MapOffset, tPMemMapEnt * // Check that the memory map is present if( MBInfo->Flags & (1 << 6) ) { + tMBoot_MMapEnt *ent = (void*)((tVAddr)MBInfo->MMapAddr + MapOffset); + tMBoot_MMapEnt *last = (void*)((tVAddr)ent + MBInfo->MMapLength); // Build up memory map nPMemMapEnts = 0; while( ent < last && nPMemMapEnts < MapSize ) @@ -48,10 +48,16 @@ int Multiboot_LoadMemoryMap(tMBoot_Info *MBInfo, tVAddr MapOffset, tPMemMapEnt * nPMemMapEnts ++; ent = (void*)( (tVAddr)ent + ent->Size + 4 ); } + if( ent < last ) + { + Log_Warning("MBoot", "Memory map has >%i entries, internal version is truncated", + MapSize); + } } else if( MBInfo->Flags & (1 << 0) ) { Log_Warning("MBoot", "No memory map passed, using mem_lower and mem_upper"); + ASSERT(MapSize >= 2); nPMemMapEnts = 2; Map[0].Start = 0; Map[0].Length = MBInfo->LowMem * 1024;