Ejemplo n.º 1
0
        internal unsafe VirtualMemoryRange(UIntPtr baseAddr,
                                           UIntPtr limitAddr,
                                           ProtectionDomain inDomain)
        {
            DebugStub.Assert(inDomain != null);
            this.parentDomain = inDomain;

            range = new VirtualMemoryRange_struct(baseAddr, limitAddr,
                                                  baseAddr, limitAddr,
                                                  inDomain);
            this.indirect = false;
            // never use this.pRange
        }
Ejemplo n.º 2
0
        /////////////////////////////////////
        // PUBLIC METHODS
        /////////////////////////////////////

        internal static void Initialize()
        {
            DebugStub.WriteLine("Initializing memory subsystem...");

            // Only allow paging in HALs which support running in Ring 0
            // but always force paging in the HIP builds for compatibility
#if !PAGING
            useAddressTranslation = UseAddressTranslationInCmdLine();
#else
            useAddressTranslation = true;
#endif

            if (useAddressTranslation)
            {
                DebugStub.WriteLine("Using address translation...\n");
                Platform p = Platform.ThePlatform;

                // Set up the hardware-pages table and reserve a range for
                // I/O memory

                IOMemoryBaseAddr = PhysicalPages.Initialize(Platform.IO_MEMORY_SIZE);

                // Set up the I/O memory heap
                KernelIOMemoryHeap = new PhysicalHeap((UIntPtr)IOMemoryBaseAddr.Value,
                                                      (UIntPtr)(IOMemoryBaseAddr.Value + Platform.IO_MEMORY_SIZE));

                // Set up virtual memory. ** This enables paging ** !
                VMManager.Initialize();

                // Set up the kernel's memory ranges.
                //
                // The kernel's general-purpose range is special because
                // it *describes* low memory as well as the GC range proper
                // so the kernel's GC doesn't get confused by pointers to
                // static data in the kernel image.
                KernelRange = new VirtualMemoryRange_struct(
                    VMManager.KernelHeapBase,
                    VMManager.KernelHeapLimit,
                    UIntPtr.Zero,
                    VMManager.KernelHeapLimit,
                    null); // no concurrent access to page descriptors yet

                // Mark the kernel's special areas. First, record the kernel memory.
                if (p.KernelDllSize != 0)
                {
                    UIntPtr kernelDllLimit = p.KernelDllBase + p.KernelDllSize;

                    KernelRange.SetRange(p.KernelDllBase, kernelDllLimit,
                                         MemoryManager.KernelPageNonGC);
                }

                // Record the boot allocated kernel memory.
                if (p.BootAllocatedMemorySize != 0)
                {
                    UIntPtr bootAllocatedMemoryLimit = p.BootAllocatedMemory + p.BootAllocatedMemorySize;

                    KernelRange.SetRange(p.BootAllocatedMemory, bootAllocatedMemoryLimit,
                                         MemoryManager.KernelPageNonGC);
                }

                // Set stack page for CPU 0
                KernelRange.SetRange(Platform.BootCpu.KernelStackLimit,
                                     (Platform.BootCpu.KernelStackBegin - Platform.BootCpu.KernelStackLimit),
                                     MemoryManager.KernelPageStack);

                DebugStub.WriteLine("MemoryManager initialized with {0} physical pages still free",
                                    __arglist(PhysicalPages.GetFreePageCount()));
                KernelRange.Dump("Initialized");

                isInitialized = true;
            }
            else
            {
                FlatPages.Initialize();
                DebugStub.WriteLine("KernelBaseAddr: {0:x8} KernelLimitAddr {1:x8}",
                                    __arglist(KernelBaseAddr,
                                              KernelBaseAddr + BytesFromPages(KernelPageCount)));
            }
        }