Beispiel #1
0
        public static void UnMap(this IPageTable table, Addr virtAddr, USize length, bool flush = false)
        {
            if (KConfig.Log.MemoryMapping && length > 4096)
            {
                KernelMessage.WriteLine("UnMap: virt={0:X8}, length={2:X8}", virtAddr, length);
            }

            var pages = KMath.DivCeil(length, 4096);

            for (var i = 0; i < pages; i++)
            {
                table.MapVirtualAddressToPhysical(virtAddr, 0, false);

                virtAddr += 4096;
            }
            if (flush)
            {
                table.Flush();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Sync specific mappings with another table.
        /// </summary>
        public static void MapCopy(this IPageTable table, IPageTable fromTable, Addr virtAddr, USize length, bool present = true, bool flush = false)
        {
            if (KConfig.Log.MemoryMapping && length > 4096)
            {
                KernelMessage.WriteLine("MapCopy: virt={0:X8}, length={1:X8}", virtAddr, length);
            }

            var pages = KMath.DivCeil(length, 4096);

            for (var i = 0; i < pages; i++)
            {
                var physAddr = fromTable.GetPhysicalAddressFromVirtual(virtAddr);
                table.MapVirtualAddressToPhysical(virtAddr, physAddr, present);

                virtAddr += 4096;
            }
            if (flush)
            {
                table.Flush();
            }
        }