示例#1
0
        protected override void *mmap(uint unknown, uint flags, size_t pages)
        {
            var bytes = pages * 4096;
            var ptr   = (byte *)VirtualPageManager.AllocatePages(pages, new AllocatePageOptions {
                DebugName = "KernelAllocator"
            });

            //KernelMessage.WriteLine("mmap: Pages: {0}, Addr: {1:X8}", pages, (uint)ptr);
            for (var i = 0; i < bytes; i++)
            {
                *(ptr + i) = 0;
            }

            return(ptr);
        }
示例#2
0
文件: Memory.cs 项目: djlw78/abanu
        public static unsafe void Setup()
        {
            kmallocAllocator = new KernelAllocator();

            var ptr = (byte *)VirtualPageManager.AllocatePages(KMath.AlignValueCeil(Allocator.headSize, 4096));

            for (var i = 0; i < Allocator.headSize; i++)
            {
                *(ptr + i) = 0;
            }
            kmallocAllocator.List_heads = (malloc_meta **)ptr;
            ManagedMemory.UseAllocator  = true;
            KernelMessage.WriteLine("EarlyBootBytesUsed: {0} bytes", ManagedMemory.EarlyBootBytesUsed);

            KernelMessage.WriteLine("Memory free: {0} MB", PhysicalPageManager.FreePages * 4096 / 1024 / 1024);
        }
示例#3
0
 protected override uint munmap(void *addr)
 {
     VirtualPageManager.FreeAddr(addr);
     return(0);
 }