示例#1
0
        public static void Setup()
        {
            var addr = Initial_FindIFreePage();

            KernelMessage.Path("KernelMemoryMapManager", "Initial Page: {0:X}", addr);

            // 80KB should be enough
            // TODO: Check if really 80KB are available after this address.
            InitialMap = new KernelMemoryMap(addr, 0x1000 * 20, BootInfoMemoryType.KernelMemoryMap);
            Memory.InitialKernelProtect_MakeWritable_BySize(InitialMap.Start, InitialMap.Size);

            Header = (KernelMemoryMapHeader *)InitialMap.Start;

            var arrayOffset1 = 0x1000;
            var arrayOffset2 = 0x3000;

            Header->SystemUsable = new KernelMemoryMapArray((KernelMemoryMap *)(InitialMap.Start + arrayOffset1), 50);
            Header->Used         = new KernelMemoryMapArray((KernelMemoryMap *)(InitialMap.Start + arrayOffset2), 100);

            for (uint i = 0; i < BootInfo.Header->MemoryMapLength; i++)
            {
                var map  = BootInfo.Header->MemoryMapArray[i];
                var kmap = new KernelMemoryMap(map.Start, map.Size, map.Type);
                if (kmap.Type == BootInfoMemoryType.SystemUsable)
                {
                    Header->SystemUsable.Add(kmap);
                }
                else
                {
                    Header->Used.Add(kmap);
                }
            }
            Header->Used.Add(InitialMap);
            //Debug_FillAvailableMemory();
        }
示例#2
0
        /// <summary>
        /// Video Stage
        /// </summary>
        public unsafe static void InitFrameBuffer()
        {
            if (!BootInfo.Header->FBPresent || BootInfo.Header->VBEMode < 0x100)
            {
                KernelMessage.Path("fb", "not present");
                return;
            }

            KernelMessage.WriteLine("InitFrameBuffer");

            fb = new FrameBuffer(BootInfo.Header->FbInfo.FbAddr, BootInfo.Header->FbInfo.FbWidth, BootInfo.Header->FbInfo.FbHeight, BootInfo.Header->FbInfo.FbPitch, 8);
            fb.Init();

            FrameBufferTextScreen = new FrameBufferTextScreenDevice(fb);
            Console.SetOutputDevice(FrameBufferTextScreen);
        }
示例#3
0
        public static KernelMemoryMap Allocate(USize size, BootInfoMemoryType type)
        {
            var cnt = Header->Used.Count;

            for (uint i = 0; i < cnt; i++)
            {
                var map = Header->Used.Items[i];
                if (CheckPageIsUsableAfterMap(map, size))
                {
                    var newMap = new KernelMemoryMap(map.Start + map.Size, size, type);
                    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);
        }