Ejemplo n.º 1
0
 public static void* MapFreePage(VirtMemImpl.PageFlags flags)
 {
     uint physAddr = impl.FindFreePhysPageAddr();
     uint virtAddr = impl.FindFreeVirtPageAddr();
     //BasicConsole.WriteLine(((FOS_System.String)"Mapping free page. physAddr=") + physAddr + ", virtAddr=" + virtAddr);
     Map(physAddr, virtAddr, 4096, flags);
     return (void*)virtAddr;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Initialises the virtual memory manager.
        /// </summary>
        public static void Init()
        {
            impl = new x86();

            // Map in the kernel pages.
            //   - Technically this has already been done in "VirtMemInit.x86_32.asm", however,
            //     from the C# code perspective it has no idea so the mapping done here is to
            //     get the high level code's view of the memory up to speed with the actual
            //     state
            impl.MapKernel();
        }
Ejemplo n.º 3
0
        public static void* MapFreePages(VirtMemImpl.PageFlags flags, int numPages)
        {
            uint virtAddrsStart = 0xDEADBEEF;
            try
            {
                MapFreePagesLock.Enter();

                //BasicConsole.WriteLine("Mapping free pages:");

                uint physAddrsStart = impl.FindFreePhysPageAddrs(numPages);
                virtAddrsStart = impl.FindFreeVirtPageAddrs(numPages);
                //BasicConsole.Write(" -- Phys start: ");
                //BasicConsole.WriteLine(physAddrsStart);
                //BasicConsole.Write(" -- Virt start: ");
                //BasicConsole.WriteLine(virtAddrsStart);
                //BasicConsole.Write(" -- Num pages: ");
                //BasicConsole.WriteLine(numPages);
                for (uint i = 0; i < numPages; i++)
                {
                    Map(physAddrsStart + (i * 4096), virtAddrsStart + (i * 4096), 4096, flags);
                }
            }
            finally
            {
                MapFreePagesLock.Exit();
            }

            if (virtAddrsStart == 0xDEADBEEF)
            {
                BasicConsole.WriteLine("!!! PANIC !!!");
                BasicConsole.WriteLine("VirtMemManager.MapFreePages returning 0xDEADBEEF!");
                BasicConsole.WriteLine("!-!-!-!-!-!-!");
            }

            return (void*)virtAddrsStart;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Maps the specified amount of memory.
 /// </summary>
 /// <param name="pAddr">The physical address to start mapping at (must be 4KiB aligned).</param>
 /// <param name="vAddr">The virtual address to start mapping at (must be 4KiB aligned).</param>
 /// <param name="size">The amount of memory (in bytes) to map (must be a multiple of 4KiB)</param>
 public static void Map(uint pAddr, void* vAddr, uint size, VirtMemImpl.PageFlags flags, UpdateUsedPagesFlags UpdateUsedPages = UpdateUsedPagesFlags.Both)
 {
     Map(pAddr, (uint)vAddr, size, flags, UpdateUsedPages);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Maps the specified amount of memory.
 /// </summary>
 /// <param name="pAddr">The physical address to start mapping at (must be 4KiB aligned).</param>
 /// <param name="vAddr">The virtual address to start mapping at (must be 4KiB aligned).</param>
 /// <param name="size">The amount of memory (in bytes) to map (must be a multiple of 4KiB)</param>
 public static void Map(uint pAddr, uint vAddr, uint size, VirtMemImpl.PageFlags flags, UpdateUsedPagesFlags UpdateUsedPages = UpdateUsedPagesFlags.Both)
 {
     flags |= VirtMemImpl.PageFlags.Present | VirtMemImpl.PageFlags.Writeable;
     while (size > 0)
     {
         impl.Map(pAddr, vAddr, flags, UpdateUsedPages);
         size -= 4096;
         pAddr += 4096;
         vAddr += 4096;
     }
 }
Ejemplo n.º 6
0
 public static void* MapFreePage(VirtMemImpl.PageFlags flags)
 {
     return MapFreePages(flags, 1);
 }