Ejemplo n.º 1
0
        public static unsafe void SetExecutable(this IPageTable table, uint virtAddr, uint size)
        {
            if (!KConfig.UseKernelMemoryProtection)
            {
                return;
            }

            table.SetExecutable(virtAddr, size);
        }
Ejemplo n.º 2
0
        public static unsafe void Map(this IPageTable table, Addr virtAddr, Addr physAddr, IPageFrameAllocator physAllocator, bool present = true, bool flush = false)
        {
            var page  = physAllocator.GetPageByAddress(physAddr);
            var pAddr = physAllocator.GetAddress(page);

            while (true)
            {
                table.Map(virtAddr, pAddr, present, flush);
                page  = physAllocator.NextCompoundPage(page);
                pAddr = physAllocator.GetAddress(page);
                if (page == null || pAddr == physAddr)
                {
                    break;
                }
                virtAddr += 4096;
            }
        }
Ejemplo n.º 3
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();
            }
        }
Ejemplo n.º 4
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();
            }
        }
Ejemplo n.º 5
0
 public static void UnMap(this IPageTable table, Addr virtAddr, bool flush = false)
 {
     UnMap(table, virtAddr, 4096, flush);
 }
Ejemplo n.º 6
0
 public static void Map(this IPageTable table, Addr virtAddr, Addr physAddr, bool present = true, bool flush = false)
 {
     Map(table, virtAddr, physAddr, 4096, present, flush);
 }
Ejemplo n.º 7
0
 public static Addr GetPageTablePhysAddr(this IPageTable table)
 {
     return(PageTable.KernelTable.GetPhysicalAddressFromVirtual(table.VirtAddr));
 }
Ejemplo n.º 8
0
        public static unsafe void SetExecutable(this IPageTable table, BootInfoMemoryType type)
        {
            var mm = BootInfo.GetMap(type);

            SetExecutable(table, mm->Start, mm->Size);
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Sync specific mappings with another table.
 /// The virtual and physical Addresses in both table will be the same.
 /// </summary>
 public static void MapCopy(this IPageTable table, IPageTable fromTable, KernelMemoryMap *mm, bool present = true, bool flush = false)
 {
     table.MapCopy(fromTable, mm->Start, mm->Size, present, flush);
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Sync specific mappings with another table.
        /// The virtual and physical Addresses in both table will be the same.
        /// </summary>
        public static void MapCopy(this IPageTable table, IPageTable fromTable, BootInfoMemoryType type, bool present = true, bool flush = false)
        {
            var mm = BootInfo.GetMap(type);

            table.MapCopy(fromTable, mm->Start, mm->Size, present, flush);
        }
Ejemplo n.º 11
0
 public static void ConfigureType(PageTableType type)
 {
     KernelTable = CreateInstance(type);
 }