Example #1
0
 public KernelMemoryMap(Addr start, USize size, BootInfoMemoryType type, AddressSpaceKind addressSpaceKind)
 {
     Start            = start;
     Size             = size;
     Type             = type;
     AddressSpaceKind = addressSpaceKind;
 }
Example #2
0
 public KernelMemoryMap *GetMap(BootInfoMemoryType type)
 {
     for (var i = 0; i < Count; i++)
     {
         if (Items[i].Type == type)
         {
             return(&Items[i]);
         }
     }
     return(null);
 }
Example #3
0
        /// <summary>
        /// Gets a known memory region by type
        /// </summary>
        public static unsafe BootInfoMemory *GetMap(BootInfoMemoryType type)
        {
            var mapLen = Header->MemoryMapLength;

            for (uint i = 0; i < mapLen; i++)
            {
                if (Header->MemoryMapArray[i].Type == type)
                {
                    return(&Header->MemoryMapArray[i]);
                }
            }
            return(null);
        }
Example #4
0
        public static BootInfoMemory AllocateMemoryMap(USize size, BootInfoMemoryType type)
        {
            var map = new BootInfoMemory();

            map.Start      = PageStartAddr;
            map.Size       = size;
            map.Type       = type;
            PageStartAddr += size;

            KernelMessage.WriteLine("Allocated MemoryMap of Type {0} at {1:X8} with Size {2:X8}", (uint)type, map.Start, map.Size);

            return(map);
        }
Example #5
0
        public static BootInfoMemory *GetMap(BootInfoMemoryType type)
        {
            var mapLen = Header->MemoryMapLength;

            //KernelMessage.WriteLine("Maps: {0}", mapLen);
            for (uint i = 0; i < mapLen; i++)
            {
                if (Header->MemoryMapArray[i].Type == type)
                {
                    return(&Header->MemoryMapArray[i]);
                }
            }
            return(null);
        }
Example #6
0
        public static KernelMemoryMap Allocate(USize size, BootInfoMemoryType type, AddressSpaceKind addressSpaceKind)
        {
            var cnt = Header->Used.Count;

            for (uint i = 0; i < cnt; i++)
            {
                var map = Header->Used.Items[i];
                if (CheckPageIsUsableAfterMap(map, size, addressSpaceKind))
                {
                    var newMap = new KernelMemoryMap(map.Start + map.Size, size, type, addressSpaceKind);
                    Header->Used.Add(newMap);
                    KernelMessage.Path("KernelMemoryMapManager", "Allocated: at {0:X8}, size {1:X8}, type {2}", newMap.Start, size, (uint)type);
                    return(newMap);
                }
            }
            return(KernelMemoryMap.Empty);
        }
Example #7
0
        public static BootInfoMemory AllocateMemoryMap(USize size, BootInfoMemoryType type, AddressSpaceKind addressSpaceKind)
        {
            var map = new BootInfoMemory
            {
                Start            = PageStartAddr,
                Size             = size,
                Type             = type,
                AddressSpaceKind = addressSpaceKind,
                PreMap           = true,
            };

            PageStartAddr += size;

            KernelMessage.WriteLine("Allocated MemoryMap of Type {0} at {1:X8} with Size {2:X8}", (uint)type, map.Start, map.Size);

            return(map);
        }
Example #8
0
 public KernelMemoryMap(Addr start, USize size, BootInfoMemoryType type)
 {
     Start = start;
     Size  = size;
     Type  = type;
 }
Example #9
0
        public static unsafe void SetExecutable(this IPageTable table, BootInfoMemoryType type)
        {
            var mm = BootInfo.GetMap(type);

            SetExecutable(table, mm->Start, mm->Size);
        }
Example #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);
        }
Example #11
0
        public unsafe static void InitialKernelProtect_MakeWritable_ByMapType(BootInfoMemoryType type)
        {
            var mm = BootInfo.GetMap(type);

            InitialKernelProtect_MakeWritable_BySize(mm->Start, mm->Size);
        }