/// <summary> /// Setup the physical page manager /// </summary> public void Setup() { uint physMem = BootInfo.Header->InstalledPhysicalMemory; PageCount = physMem / PageSize; kmap = KernelMemoryMapManager.Allocate(PageCount * (uint)sizeof(Page), BootInfoMemoryType.PageFrameAllocator); PageArray = (Page *)kmap.Start; lastAllocatedPage = PageArray; Memory.InitialKernelProtect_MakeWritable_BySize(kmap.Start, kmap.Size); MemoryOperation.Clear4(kmap.Start, kmap.Size); for (uint i = 0; i < PageCount; i++) { PageArray[i].PhysicalAddress = i * PageSize; if (i != 0) { PageArray[i - 1].Next = &PageArray[i]; } } SetupFreeMemory(); for (uint i = 0; i < PageCount; i++) { if (!PageArray[i].Used) { PageArray[i].Status = PageStatus.Free; } } }
public static void InitializeGCMemory() { // Wipe GCMemory from Bootloader Memory.InitialKernelProtect_MakeWritable_BySize(Address.GCInitialMemory, Address.GCInitialMemorySize); MemoryOperation.Clear4(Address.GCInitialMemory, Address.GCInitialMemorySize); }