Example #1
0
        /// <summary>
        /// Setup the physical page manager
        /// </summary>
        public void Setup()
        {
            uint physMem = BootInfo.Header->InstalledPhysicalMemory;

            PageCount         = physMem / PageSize;
            kmap              = KernelMemoryMapManager.Allocate(PageCount * (uint)sizeof(Page), BootInfoMemoryType.PageFrameAllocator);
            PageArray         = (Page *)kmap.Start;
            lastAllocatedPage = PageArray;

            Memory.InitialKernelProtect_MakeWritable_BySize(kmap.Start, kmap.Size);
            MemoryOperation.Clear4(kmap.Start, kmap.Size);

            for (uint i = 0; i < PageCount; i++)
            {
                PageArray[i].PhysicalAddress = i * PageSize;
                if (i != 0)
                {
                    PageArray[i - 1].Next = &PageArray[i];
                }
            }

            SetupFreeMemory();

            for (uint i = 0; i < PageCount; i++)
            {
                if (!PageArray[i].Used)
                {
                    PageArray[i].Status = PageStatus.Free;
                }
            }
        }
Example #2
0
        /// <summary>
        /// allocate memory. The memory is set to zero.
        /// </summary>
        public static Addr AllocateCleared(USize n, GFP flags)
        {
            var addr = Allocate(n, flags);

            MemoryOperation.Clear(addr, n);
            return(addr);
        }
Example #3
0
        /// <summary>
        /// allocate memory for an array. The memory is set to zero.
        /// </summary>
        public static Addr AllocateArrayCleared(USize elements, USize size, GFP flags)
        {
            var total = elements * size;
            var addr  = Allocate(total, flags);

            MemoryOperation.Clear(addr, total);
            return(addr);
        }
Example #4
0
        /// <summary>
        /// Goto the next line.
        /// </summary>
        public static void NextLine()
        {
            Column = 0;
            if (row >= Rows - 1)
            {
                // Copy All rows one line up
                // TODO: Normally, Reading from mapped ROM is much slower
                // than reading from normal RAM. Consider using Offscreen Buffer
                MemoryOperation.Copy(ScreenMemoryAddress + Columns * 2, ScreenMemoryAddress, (Rows - 1) * Columns * 2);

                //Blank last line
                for (uint c = 0; c < Columns; c++)
                {
                    RawWrite(row, c, ' ', color);
                }
            }
            else
            {
                Row++;
            }
            UpdateCursor();
        }
Example #5
0
 public static void InitializeGCMemory()
 {
     // Wipe GCMemory from Bootloader
     Memory.InitialKernelProtect_MakeWritable_BySize(Address.GCInitialMemory, Address.GCInitialMemorySize);
     MemoryOperation.Clear4(Address.GCInitialMemory, Address.GCInitialMemorySize);
 }
Example #6
0
 unsafe static void SetupKernelSection()
 {
     // TODO: Respect section progream header adresses.
     // Currently, we can make a raw copy of ELF file
     MemoryOperation.Copy4(Address.OriginalKernelElfSection, Address.KernelElfSection, OriginalKernelElf.TotalFileSize);
 }