private static void PrintMapArray(string name, KernelMemoryMapArray *mapArray) { KernelMessage.WriteLine("Items of MemoryMap Array [{0}]", name); for (var i = 0; i < mapArray->Count; i++) { var mm = &mapArray->Items[i]; KernelMessage.WriteLine("Map {0:X8}-{1:X8}, Size={2:X8}, Type={3}, AddrKind={4}", mm->Start, mm->Start + mm->Size - 1, mm->Size, (uint)mm->Type, (uint)mm->AddressSpaceKind); } }
private void SetInitialPageStatus(KernelMemoryMapArray *maps, PageStatus status) { for (var i = 0; i < maps->Count; i++) { var map = maps->Items[i]; if (map.Start >= BootInfo.Header->InstalledPhysicalMemory) { continue; } if ((map.AddressSpaceKind & AddressSpaceKind.Physical) == 0) { continue; } var mapPages = KMath.DivCeil(map.Size, 4096); var fistPageNum = KMath.DivFloor(map.Start, 4096); KernelMessage.WriteLine("Mark Pages from {0:X8}, Size {1:X8}, Type {2}, FirstPage {3}, Pages {4}, Status {5}", map.Start, map.Size, (uint)map.Type, (uint)fistPageNum, mapPages, (uint)status); for (var p = fistPageNum; p < fistPageNum + mapPages; p++) { var addr = p * 4096; if (!Region.Contains(addr)) { continue; } if (addr >= BootInfo.Header->InstalledPhysicalMemory) { KernelMessage.WriteLine("addr >= BootInfo.Header->InstalledPhysicalMemory"); break; } var page = GetPageByNum(p); Assert.IsSet(page, "page == null"); page->Status = status; } } }