+ tMBoot_MMapEnt *mmapStart;
+ tMBoot_MMapEnt *ent;
+ Uint64 maxAddr = 0;
+
+ // Scan the physical memory map
+ mmapStart = (void *)( KERNEL_BASE | MBoot->MMapAddr );
+ ent = mmapStart;
+ while( (Uint)ent < (Uint)mmapStart + MBoot->MMapLength )
+ {
+ // Adjust for the size of the entry
+ ent->Size += 4;
+
+ // If entry is RAM and is above `maxAddr`, change `maxAddr`
+ if(ent->Type == 1 && ent->Base + ent->Length > maxAddr)
+ maxAddr = ent->Base + ent->Length;
+ // Go to next entry
+ ent = (tMBoot_MMapEnt *)( (Uint)ent + ent->Size );
+ }
+
+ if(maxAddr == 0) {
+ giMaxPhysPage = (MBoot->HighMem >> 2) + 256; // HighMem is a kByte value
+ }
+ else {
+ giMaxPhysPage = maxAddr >> 12;
+ }