コード例 #1
0
ファイル: MemoryManager.cs プロジェクト: Paul1nh0/Singularity
        internal static UIntPtr UserAllocate(UIntPtr numPages,
                                             Process process,
                                             uint extra,
                                             PageType type)
        {
            UIntPtr result = UIntPtr.Zero;

            if (useAddressTranslation)
            {
                result = ProtectionDomain.CurrentDomain.UserRange.Allocate(
                    numPages, process, extra, type);
            }
            else
            {
                result = FlatPages.Allocate(BytesFromPages(numPages),
                                            UIntPtr.Zero,
                                            MemoryManager.PageSize,
                                            process, extra, type);
            }

            if (result == UIntPtr.Zero)
            {
                UserMemoryFailure();
            }

            return(result);
        }
コード例 #2
0
ファイル: MemoryManager.cs プロジェクト: Paul1nh0/Singularity
        internal static UIntPtr KernelAllocate(UIntPtr numPages, Process process,
                                               uint extra, PageType type)
        {
            UIntPtr result = UIntPtr.Zero;

            if (useAddressTranslation)
            {
                if (KernelRangeWrapper != null)
                {
                    result = KernelRangeWrapper.Allocate(numPages, process, extra, type);
                }
                else
                {
                    // Very early in the initialization sequence; ASSUME there is not
                    // yet any concurrent access to paging descriptors, and allocate
                    // memory without a paging-descriptor lock.
                    result = KernelRange.Allocate(numPages, process, extra, type, null);
                }
            }
            else
            {
                result = FlatPages.Allocate(BytesFromPages(numPages),
                                            UIntPtr.Zero,
                                            MemoryManager.PageSize,
                                            process, extra, type);
            }

            if (result == UIntPtr.Zero)
            {
                DebugStub.WriteLine("******** Kernel OOM on Heap ********");

                //
                // Our kernel runtime can not handle this right now, so rather than
                // return a null which will show up as a cryptic lab failure, always
                // drop to the debugger.
                //
                DebugStub.Break();
            }

            return(result);
        }
コード例 #3
0
ファイル: MemoryManager.cs プロジェクト: Paul1nh0/Singularity
        internal static UIntPtr AllocateIOMemory(UIntPtr limitAddr,
                                                 UIntPtr bytes,
                                                 UIntPtr alignment,
                                                 Process process)
        {
            UIntPtr result = UIntPtr.Zero;

            if (useAddressTranslation)
            {
                result = KernelIOMemoryHeap.Allocate(limitAddr, bytes, alignment, process);
            }
            else
            {
                if (limitAddr > 0)
                {
                    result = FlatPages.AllocateBelow(limitAddr, bytes, alignment, process, 0, PageType.NonGC);
                }
                else
                {
                    result = FlatPages.Allocate(bytes, bytes, alignment, process, 0, PageType.NonGC);
                }
            }

            if (result == UIntPtr.Zero)
            {
                DebugStub.WriteLine("******** Kernel OOM on IoMemory ********");

                //
                // Our kernel runtime can not handle this right now, so rather than
                // return a null which will show up as a cryptic lab failure, always
                // drop to the debugger.
                //
                DebugStub.Break();
            }

            return(result);
        }