コード例 #1
0
ファイル: VirtMemManager.cs プロジェクト: kztao/FlingOS
 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;
 }
コード例 #2
0
ファイル: VirtMemManager.cs プロジェクト: kztao/FlingOS
        /// <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();
        }
コード例 #3
0
ファイル: VirtMemManager.cs プロジェクト: rmhasan/FlingOS
        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;
        }
コード例 #4
0
ファイル: VirtMemManager.cs プロジェクト: kztao/FlingOS
 /// <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);
 }
コード例 #5
0
ファイル: VirtMemManager.cs プロジェクト: kztao/FlingOS
 /// <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;
     }
 }
コード例 #6
0
ファイル: VirtMemManager.cs プロジェクト: rmhasan/FlingOS
 public static void* MapFreePage(VirtMemImpl.PageFlags flags)
 {
     return MapFreePages(flags, 1);
 }