diff --git a/reactos/ntoskrnl/include/internal/mm.h b/reactos/ntoskrnl/include/internal/mm.h index 1af6e97647b..af0d03d464d 100644 --- a/reactos/ntoskrnl/include/internal/mm.h +++ b/reactos/ntoskrnl/include/internal/mm.h @@ -9,9 +9,6 @@ struct _EPROCESS; extern PMMSUPPORT MmKernelAddressSpace; extern PFN_COUNT MiFreeSwapPages; extern PFN_COUNT MiUsedSwapPages; -extern SIZE_T MmTotalPagedPoolQuota; -extern SIZE_T MmTotalNonPagedPoolQuota; -extern PHYSICAL_ADDRESS MmSharedDataPagePhysicalAddress; extern PFN_COUNT MmNumberOfPhysicalPages; extern UCHAR MmDisablePagingExecutive; extern PFN_NUMBER MmLowestPhysicalPage; @@ -19,9 +16,6 @@ extern PFN_NUMBER MmHighestPhysicalPage; extern PFN_NUMBER MmAvailablePages; extern PFN_NUMBER MmResidentAvailablePages; -extern PMEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptor; -extern MEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptorOrg; - extern LIST_ENTRY MmLoadedUserImageList; extern KMUTANT MmSystemLoadLock; @@ -43,8 +37,8 @@ extern SIZE_T MmPagedPoolCommit; extern SIZE_T MmPeakCommitment; extern SIZE_T MmtotalCommitLimitMaximum; -extern PVOID MiDebugMapping; -extern PMMPTE MmDebugPte; +extern PVOID MiDebugMapping; // internal +extern PMMPTE MmDebugPte; // internal struct _KTRAP_FRAME; struct _EPROCESS; @@ -66,7 +60,7 @@ typedef ULONG_PTR SWAPENTRY; // #define MMDBG_COPY_MAX_SIZE 0x8 -#if defined(_X86_) +#if defined(_X86_) // intenal for marea.c #define MI_STATIC_MEMORY_AREAS (14) #else #define MI_STATIC_MEMORY_AREAS (13) @@ -77,19 +71,6 @@ typedef ULONG_PTR SWAPENTRY; #define MEMORY_AREA_OWNED_BY_ARM3 (15) #define MEMORY_AREA_STATIC (0x80000000) -#define MM_PHYSICAL_PAGE_MPW_PENDING (0x8) - -#define MM_CORE_DUMP_TYPE_NONE (0x0) -#define MM_CORE_DUMP_TYPE_MINIMAL (0x1) -#define MM_CORE_DUMP_TYPE_FULL (0x2) - -/* Number of list heads to use */ -#define MI_FREE_POOL_LISTS 4 - - -/* Signature of free pool blocks */ -#define MM_FREE_POOL_TAG 'lprF' - /* Although Microsoft says this isn't hardcoded anymore, they won't be able to change it. Stuff depends on it */ #define MM_VIRTMEM_GRANULARITY (64 * 1024) @@ -119,32 +100,13 @@ typedef ULONG_PTR SWAPENTRY; #define SESSION_POOL_MASK 32 #define VERIFIER_POOL_MASK 64 -#define MM_PAGED_POOL_SIZE (100*1024*1024) -#define MM_NONPAGED_POOL_SIZE (100*1024*1024) - -/* - * Paged and non-paged pools are 8-byte aligned - */ -#define MM_POOL_ALIGNMENT 8 - +// FIXME: use ALIGN_UP_BY #define MM_ROUND_UP(x,s) \ ((PVOID)(((ULONG_PTR)(x)+(s)-1) & ~((ULONG_PTR)(s)-1))) #define MM_ROUND_DOWN(x,s) \ ((PVOID)(((ULONG_PTR)(x)) & ~((ULONG_PTR)(s)-1))) -#define PAGE_FLAGS_VALID_FROM_USER_MODE \ - (PAGE_READONLY | \ - PAGE_READWRITE | \ - PAGE_WRITECOPY | \ - PAGE_EXECUTE | \ - PAGE_EXECUTE_READ | \ - PAGE_EXECUTE_READWRITE | \ - PAGE_EXECUTE_WRITECOPY | \ - PAGE_GUARD | \ - PAGE_NOACCESS | \ - PAGE_NOCACHE) - #define PAGE_FLAGS_VALID_FOR_SECTION \ (PAGE_READONLY | \ PAGE_READWRITE | \ @@ -331,9 +293,10 @@ typedef struct _MMPFNENTRY USHORT RemovalRequested:1; USHORT CacheAttribute:2; USHORT Rom:1; - USHORT ParityError:1; // HasRmap + USHORT ParityError:1; } MMPFNENTRY; +// Mm internal typedef struct _MMPFN { union @@ -427,6 +390,7 @@ typedef struct _MM_REGION LIST_ENTRY RegionListEntry; } MM_REGION, *PMM_REGION; +// Mm internal /* Entry describing free pool memory */ typedef struct _MMFREE_POOL_ENTRY { @@ -531,9 +495,10 @@ MmLocateMemoryAreaByAddress( PVOID Address ); +// fixme: unused? ULONG_PTR NTAPI -MmFindGapAtAddress( +MmFindGapAtAddress_( PMMSUPPORT AddressSpace, PVOID Address ); @@ -556,10 +521,6 @@ MmFreeMemoryAreaByPtr( PVOID FreePageContext ); -VOID -NTAPI -MmDumpMemoryAreas(PMMSUPPORT AddressSpace); - PMEMORY_AREA NTAPI MmLocateMemoryAreaByRegion( @@ -577,14 +538,6 @@ MmFindGap( BOOLEAN TopDown ); -VOID -NTAPI -MmReleaseMemoryAreaIfDecommitted( - struct _EPROCESS *Process, - PMMSUPPORT AddressSpace, - PVOID BaseAddress -); - VOID NTAPI MmMapMemoryArea(PVOID BaseAddress, @@ -603,14 +556,6 @@ MiCheckAllProcessMemoryAreas(VOID); /* npool.c *******************************************************************/ -VOID -NTAPI -MiDebugDumpNonPagedPool(BOOLEAN NewOnly); - -VOID -NTAPI -MiDebugDumpNonPagedPoolStats(BOOLEAN NewOnly); - VOID NTAPI MiInitializeNonPagedPool(VOID); @@ -634,71 +579,8 @@ MiFreePoolPages( IN PVOID StartingAddress ); -PVOID -NTAPI -MmGetMdlPageAddress( - PMDL Mdl, - PVOID Offset -); - /* pool.c *******************************************************************/ -PVOID -NTAPI -ExAllocateNonPagedPoolWithTag( - POOL_TYPE type, - ULONG size, - ULONG Tag, - PVOID Caller -); - -PVOID -NTAPI -ExAllocatePagedPoolWithTag( - POOL_TYPE Type, - ULONG size, - ULONG Tag -); - -VOID -NTAPI -ExFreeNonPagedPool(PVOID block); - -VOID -NTAPI -ExFreePagedPool(IN PVOID Block); - -BOOLEAN -NTAPI -ExpIsPoolTagDebuggable(ULONG Tag); - -PVOID -NTAPI -ExpAllocateDebugPool( - POOL_TYPE Type, - ULONG Size, - ULONG Tag, - PVOID Caller, - BOOLEAN EndOfPage -); - -VOID -NTAPI -ExpFreeDebugPool(PVOID Block, BOOLEAN PagedPool); - -VOID -NTAPI -MmInitializePagedPool(VOID); - -PVOID -NTAPI -MiAllocateSpecialPool( - IN POOL_TYPE PoolType, - IN SIZE_T NumberOfBytes, - IN ULONG Tag, - IN ULONG Underrun -); - BOOLEAN NTAPI MiRaisePoolQuota( @@ -718,10 +600,6 @@ MmBuildMdlFromPages( /* mminit.c ******************************************************************/ -VOID -NTAPI -MiShutdownMemoryManager(VOID); - VOID NTAPI MmInit1( @@ -733,13 +611,6 @@ NTAPI MmInitSystem(IN ULONG Phase, IN PLOADER_PARAMETER_BLOCK LoaderBlock); -VOID -NTAPI -MiFreeInitMemory(VOID); - -VOID -NTAPI -MmInitializeMdlImplementation(VOID); /* pagefile.c ****************************************************************/ @@ -747,10 +618,6 @@ SWAPENTRY NTAPI MmAllocSwapPage(VOID); -VOID -NTAPI -MmDereserveSwapPages(ULONG Nr); - VOID NTAPI MmFreeSwapPage(SWAPENTRY Entry); @@ -770,10 +637,6 @@ MmReadFromSwapPage( PFN_NUMBER Page ); -BOOLEAN -NTAPI -MmReserveSwapPages(ULONG Nr); - NTSTATUS NTAPI MmWriteToSwapPage( @@ -781,21 +644,6 @@ MmWriteToSwapPage( PFN_NUMBER Page ); -NTSTATUS -NTAPI -MmDumpToPagingFile( - ULONG BugCode, - ULONG BugCodeParameter1, - ULONG BugCodeParameter2, - ULONG BugCodeParameter3, - ULONG BugCodeParameter4, - struct _KTRAP_FRAME* TrapFrame -); - -BOOLEAN -NTAPI -MmIsAvailableSwapPage(VOID); - VOID NTAPI MmShowOutOfSpaceMessagePagingFile(VOID); @@ -908,75 +756,8 @@ MmAccessFault( IN PVOID TrapInformation ); -/* anonmem.c *****************************************************************/ - -NTSTATUS -NTAPI -MmNotPresentFaultVirtualMemory( - PMMSUPPORT AddressSpace, - MEMORY_AREA* MemoryArea, - PVOID Address -); - -NTSTATUS -NTAPI -MmPageOutVirtualMemory( - PMMSUPPORT AddressSpace, - PMEMORY_AREA MemoryArea, - PVOID Address, - PFN_NUMBER Page -); - -NTSTATUS -NTAPI -MmQueryAnonMem( - PMEMORY_AREA MemoryArea, - PVOID Address, - PMEMORY_BASIC_INFORMATION Info, - PSIZE_T ResultLength -); - -VOID -NTAPI -MmFreeVirtualMemory( - struct _EPROCESS* Process, - PMEMORY_AREA MemoryArea -); - -NTSTATUS -NTAPI -MmProtectAnonMem( - PMMSUPPORT AddressSpace, - PMEMORY_AREA MemoryArea, - PVOID BaseAddress, - SIZE_T Length, - ULONG Protect, - PULONG OldProtect -); - -NTSTATUS -NTAPI -MmWritePageVirtualMemory( - PMMSUPPORT AddressSpace, - PMEMORY_AREA MArea, - PVOID Address, - PFN_NUMBER Page -); - /* kmap.c ********************************************************************/ -PVOID -NTAPI -ExAllocatePage(VOID); - -VOID -NTAPI -ExUnmapPage(PVOID Addr); - -PVOID -NTAPI -ExAllocatePageWithPhysPage(PFN_NUMBER Page); - NTSTATUS NTAPI MiCopyFromUserPage( @@ -984,16 +765,6 @@ MiCopyFromUserPage( PFN_NUMBER OldPage ); -NTSTATUS -NTAPI -MiZeroPage(PFN_NUMBER Page); - -/* memsafe.s *****************************************************************/ - -PVOID -FASTCALL -MmSafeReadPtr(PVOID Source); - /* process.c *****************************************************************/ PVOID @@ -1149,40 +920,12 @@ VOID NTAPI MmRemoveLRUUserPage(PFN_NUMBER Page); -VOID -NTAPI -MmLockPage(PFN_NUMBER Page); - -VOID -NTAPI -MmUnlockPage(PFN_NUMBER Page); - -ULONG -NTAPI -MmGetLockCountPage(PFN_NUMBER Page); - -VOID -NTAPI -MmInitializePageList( - VOID -); - VOID NTAPI MmDumpArmPfnDatabase( IN BOOLEAN StatusOnly ); -PFN_NUMBER -NTAPI -MmGetContinuousPages( - ULONG NumberOfBytes, - PHYSICAL_ADDRESS LowestAcceptableAddress, - PHYSICAL_ADDRESS HighestAcceptableAddress, - PHYSICAL_ADDRESS BoundaryAddressMultiple, - BOOLEAN ZeroPages -); - VOID NTAPI MmZeroPageThread( @@ -1231,22 +974,6 @@ MmCreateHyperspaceMapping(IN PFN_NUMBER Page) /* i386/page.c *********************************************************/ -NTSTATUS -NTAPI -MmCreateVirtualMappingForKernel( - PVOID Address, - ULONG flProtect, - PPFN_NUMBER Pages, - ULONG PageCount -); - -NTSTATUS -NTAPI -MmCommitPagedPoolAddress( - PVOID Address, - BOOLEAN Locked -); - NTSTATUS NTAPI MmCreateVirtualMapping( @@ -1299,13 +1026,6 @@ VOID NTAPI MmInitGlobalKernelPageDirectory(VOID); -VOID -NTAPI -MmEnableVirtualMapping( - struct _EPROCESS *Process, - PVOID Address -); - VOID NTAPI MmGetPageFileMapping( @@ -1336,13 +1056,6 @@ MmIsPageSwapEntry( PVOID Address ); -VOID -NTAPI -MmTransferOwnershipPage( - PFN_NUMBER Page, - ULONG NewConsumer -); - VOID NTAPI MmSetDirtyPage( @@ -1356,16 +1069,6 @@ MmAllocPage( ULONG Consumer ); -LONG -NTAPI -MmAllocPagesSpecifyRange( - ULONG Consumer, - PHYSICAL_ADDRESS LowestAddress, - PHYSICAL_ADDRESS HighestAddress, - ULONG NumberOfPages, - PPFN_NUMBER Pages -); - VOID NTAPI MmDereferencePage(PFN_NUMBER Page); @@ -1399,10 +1102,6 @@ MmSetCleanPage( PVOID Address ); -NTSTATUS -NTAPI -MmCreatePageTable(PVOID PAddress); - VOID NTAPI MmDeletePageTable( @@ -1439,10 +1138,6 @@ MmInitializeHandBuiltProcess2( IN PEPROCESS Process ); -NTSTATUS -NTAPI -MmReleaseMmInfo(struct _EPROCESS *Process); - NTSTATUS NTAPI MmSetExecuteOptions(IN ULONG ExecuteOptions); @@ -1451,10 +1146,6 @@ NTSTATUS NTAPI MmGetExecuteOptions(IN PULONG ExecuteOptions); -VOID -NTAPI -MmDeleteProcessPageDirectory(struct _EPROCESS *Process); - VOID NTAPI MmDeleteVirtualMapping( @@ -1472,30 +1163,6 @@ MmIsDirtyPage( PVOID Address ); -VOID -NTAPI -MmMarkPageMapped(PFN_NUMBER Page); - -VOID -NTAPI -MmMarkPageUnmapped(PFN_NUMBER Page); - -VOID -NTAPI -MmUpdatePageDir( - struct _EPROCESS *Process, - PVOID Address, - ULONG Size -); - -VOID -NTAPI -MiInitPageDirectoryMap(VOID); - -ULONG -NTAPI -MiGetUserPageDirectoryCount(VOID); - /* wset.c ********************************************************************/ NTSTATUS @@ -1565,13 +1232,6 @@ MmGetFileNameForSection( OUT POBJECT_NAME_INFORMATION *ModuleName ); -PVOID -NTAPI -MmAllocateSection( - IN SIZE_T Length, - PVOID BaseAddress -); - NTSTATUS NTAPI MmQuerySectionView( @@ -1630,41 +1290,6 @@ VOID NTAPI MmFreeSectionSegments(PFILE_OBJECT FileObject); -/* mpw.c *********************************************************************/ - -NTSTATUS -NTAPI -MmInitMpwThread(VOID); - -NTSTATUS -NTAPI -MmInitBsmThread(VOID); - -/* pager.c *******************************************************************/ - -BOOLEAN -NTAPI -MiIsPagerThread(VOID); - -VOID -NTAPI -MiStartPagerThread(VOID); - -VOID -NTAPI -MiStopPagerThread(VOID); - -NTSTATUS -FASTCALL -MiQueryVirtualMemory( - IN HANDLE ProcessHandle, - IN PVOID Address, - IN MEMORY_INFORMATION_CLASS VirtualMemoryInformationClass, - OUT PVOID VirtualMemoryInformation, - IN SIZE_T Length, - OUT PSIZE_T ResultLength -); - /* sysldr.c ******************************************************************/ VOID diff --git a/reactos/ntoskrnl/ke/powerpc/kiinit.c b/reactos/ntoskrnl/ke/powerpc/kiinit.c index 1d9c68b7f3c..94ed31e51ac 100644 --- a/reactos/ntoskrnl/ke/powerpc/kiinit.c +++ b/reactos/ntoskrnl/ke/powerpc/kiinit.c @@ -189,7 +189,7 @@ KiInitializeKernel(IN PKPROCESS InitProcess, InitThread->Affinity = 1 << Number; InitThread->WaitIrql = DISPATCH_LEVEL; InitProcess->ActiveProcessors = 1 << Number; - + /* HACK for MmUpdatePageDir */ ((PETHREAD)InitThread)->ThreadsProcess = (PEPROCESS)InitProcess; @@ -228,11 +228,8 @@ KiInitializeKernel(IN PKPROCESS InitProcess, Prcb->DpcStack = DpcStack; } - /* Free Initial Memory */ - // MiFreeInitMemory(); - KfRaiseIrql(DISPATCH_LEVEL); - + KeSetPriorityThread(InitThread, 0); /* Setup decrementer exception */ KiSetupDecrementerTrap(); @@ -297,7 +294,7 @@ KiSystemStartupReal(IN PLOADER_PARAMETER_BLOCK LoaderBlock) /* Skip initial setup if this isn't the Boot CPU */ if (Cpu) goto AppCpuInit; - + /* Initialize the PCR */ RtlZeroMemory(Pcr, PAGE_SIZE); KiInitializePcr(Cpu, diff --git a/reactos/ntoskrnl/ke/powerpc/stubs.c b/reactos/ntoskrnl/ke/powerpc/stubs.c index 3f4e8983331..99744da4c6f 100644 --- a/reactos/ntoskrnl/ke/powerpc/stubs.c +++ b/reactos/ntoskrnl/ke/powerpc/stubs.c @@ -151,13 +151,6 @@ KiSwapContext(PKTHREAD CurrentThread, PKTHREAD NewThread) return TRUE; } -NTSTATUS -NTAPI -Mmi386ReleaseMmInfo(PEPROCESS Process) -{ - return STATUS_UNSUCCESSFUL; -} - VOID NTAPI KeI386VdmInitialize(VOID) diff --git a/reactos/ntoskrnl/mm/amd64/page.c b/reactos/ntoskrnl/mm/amd64/page.c index 573c9834583..315feb01e04 100644 --- a/reactos/ntoskrnl/mm/amd64/page.c +++ b/reactos/ntoskrnl/mm/amd64/page.c @@ -137,57 +137,6 @@ MiFlushTlb(PMMPTE Pte, PVOID Address) } } -static -VOID -MmDeletePageTablePfn(PFN_NUMBER PageFrameNumber, ULONG Level) -{ - PMMPTE PageTable; - KIRQL OldIrql; - PMMPFN PfnEntry; - ULONG i, NumberEntries; - - /* Check if this is a page table */ - if (Level > 0) - { - NumberEntries = (Level == 4) ? MiAddressToPxi(MmHighestUserAddress)+1 : 512; - - /* Map the page table in hyperspace */ - PageTable = (PMMPTE)MmCreateHyperspaceMapping(PageFrameNumber); - - /* Loop all page table entries */ - for (i = 0; i < NumberEntries; i++) - { - /* Check if the entry is valid */ - if (PageTable[i].u.Hard.Valid) - { - /* Recursively free the page that backs it */ - MmDeletePageTablePfn(PageTable[i].u.Hard.PageFrameNumber, Level - 1); - } - } - - /* Delete the hyperspace mapping */ - MmDeleteHyperspaceMapping(PageTable); - } - - /* Check if this is a legacy allocation */ - PfnEntry = MiGetPfnEntry(PageFrameNumber); - if (MI_IS_ROS_PFN(PfnEntry)) - { - /* Free it using the legacy API */ - MmReleasePageMemoryConsumer(MC_SYSTEM, PageFrameNumber); - } - else - { - OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); - - /* Free it using the ARM3 API */ - MI_SET_PFN_DELETED(PfnEntry); - MiDecrementShareCount(PfnEntry, PageFrameNumber); - - KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql); - } -} - static PMMPTE MiGetPteForProcess( @@ -497,15 +446,6 @@ MmSetDirtyPage(PEPROCESS Process, PVOID Address) MiFlushTlb(Pte, Address); } - -NTSTATUS -NTAPI -Mmi386ReleaseMmInfo(PEPROCESS Process) -{ - UNIMPLEMENTED; - return STATUS_UNSUCCESSFUL; -} - VOID NTAPI MmDeleteVirtualMapping( @@ -560,15 +500,6 @@ MmDeletePageFileMapping(PEPROCESS Process, PVOID Address, UNIMPLEMENTED; } - -VOID -NTAPI -MmEnableVirtualMapping(PEPROCESS Process, PVOID Address) -{ - UNIMPLEMENTED; -} - - NTSTATUS NTAPI MmCreatePageFileMapping(PEPROCESS Process, diff --git a/reactos/ntoskrnl/mm/arm/page.c b/reactos/ntoskrnl/mm/arm/page.c index 3ae1430f89e..de76e662340 100644 --- a/reactos/ntoskrnl/mm/arm/page.c +++ b/reactos/ntoskrnl/mm/arm/page.c @@ -137,16 +137,6 @@ MmCreateProcessAddressSpace(IN ULONG MinWs, return FALSE; } -VOID -NTAPI -MmUpdatePageDir(IN PEPROCESS Process, - IN PVOID Address, - IN ULONG Size) -{ - /* Nothing to do */ - return; -} - PULONG NTAPI MmGetPageDirectory(VOID) @@ -309,19 +299,3 @@ MmInitGlobalKernelPageDirectory(VOID) } } -/* PUBLIC FUNCTIONS ***********************************************************/ - -/* - * @implemented - */ -PHYSICAL_ADDRESS -NTAPI -MmGetPhysicalAddress(IN PVOID Address) -{ - PHYSICAL_ADDRESS PhysicalAddress; - PhysicalAddress.QuadPart = 0; - - UNIMPLEMENTED_DBGBREAK(); - - return PhysicalAddress; -} diff --git a/reactos/ntoskrnl/mm/arm/stubs.c b/reactos/ntoskrnl/mm/arm/stubs.c index 2d43dfc27db..bed724de73e 100644 --- a/reactos/ntoskrnl/mm/arm/stubs.c +++ b/reactos/ntoskrnl/mm/arm/stubs.c @@ -237,58 +237,6 @@ MiGetPageEntryForProcess(IN PEPROCESS Process, return Pte; } -VOID -NTAPI -MmDeletePageTable(IN PEPROCESS Process, - IN PVOID Address) -{ - PMMPDE_HARDWARE PointerPde; - - // - // Not valid for kernel addresses - // - DPRINT("MmDeletePageTable(%p, %p)\n", Process, Address); - ASSERT(Address < MmSystemRangeStart); - - // - // Check if this is for a different process - // - if ((Process) && (Process != PsGetCurrentProcess())) - { - // - // FIXME-USER: Need to attach to the process - // - ASSERT(FALSE); - } - - // - // Get the PDE - // - PointerPde = MiGetPdeAddress(Address); - - // - // On ARM, we use a section mapping for the original low-memory mapping - // - if ((Address) || (PointerPde->u.Hard.Section.Valid == 0)) - { - // - // Make sure it's valid - // - ASSERT(PointerPde->u.Hard.Coarse.Valid == 1); - } - - // - // Clear the PDE - // - PointerPde->u.Hard.AsUlong = 0; - ASSERT(PointerPde->u.Hard.Coarse.Valid == 0); - - // - // Invalidate the TLB entry - // - MiFlushTlb((PMMPTE)PointerPde, MiGetPteAddress(Address)); -} - BOOLEAN NTAPI MmCreateProcessAddressSpace(IN ULONG MinWs, @@ -367,17 +315,6 @@ MmCreateProcessAddressSpace(IN ULONG MinWs, return TRUE; } -NTSTATUS -NTAPI -Mmi386ReleaseMmInfo(IN PEPROCESS Process) -{ - // - // FIXME-USER: Need to delete address space - // - UNIMPLEMENTED_DBGBREAK(); - return STATUS_NOT_IMPLEMENTED; -} - PULONG NTAPI MmGetPageDirectory(VOID) @@ -388,17 +325,6 @@ MmGetPageDirectory(VOID) return (PULONG)KeArmTranslationTableRegisterGet().AsUlong; } -VOID -NTAPI -MmEnableVirtualMapping(IN PEPROCESS Process, - IN PVOID Address) -{ - // - // TODO - // - UNIMPLEMENTED_DBGBREAK(); -} - NTSTATUS NTAPI MmCreateVirtualMappingInternal(IN PEPROCESS Process, @@ -482,24 +408,6 @@ MmCreateVirtualMappingInternal(IN PEPROCESS Process, return STATUS_SUCCESS; } -NTSTATUS -NTAPI -MmCreateVirtualMappingForKernel(IN PVOID Address, - IN ULONG Protection, - IN PPFN_NUMBER Pages, - IN ULONG PageCount) -{ - // - // Call the internal version - // - return MmCreateVirtualMappingInternal(NULL, - Address, - Protection, - Pages, - PageCount, - FALSE); -} - NTSTATUS NTAPI MmCreateVirtualMappingUnsafe(IN PEPROCESS Process, @@ -774,59 +682,6 @@ MmInitGlobalKernelPageDirectory(VOID) } } -VOID -NTAPI -MiInitPageDirectoryMap(VOID) -{ - MEMORY_AREA* MemoryArea = NULL; - PVOID BaseAddress; - NTSTATUS Status; - - // - // Create memory area for the PTE area - // - BaseAddress = (PVOID)PTE_BASE; - Status = MmCreateMemoryArea(MmGetKernelAddressSpace(), - MEMORY_AREA_OWNED_BY_ARM3, - &BaseAddress, - 0x1000000, - PAGE_READWRITE, - &MemoryArea, - TRUE, - 0, - PAGE_SIZE); - ASSERT(NT_SUCCESS(Status)); - - // - // Create memory area for the PDE area - // - BaseAddress = (PVOID)PDE_BASE; - Status = MmCreateMemoryArea(MmGetKernelAddressSpace(), - MEMORY_AREA_OWNED_BY_ARM3, - &BaseAddress, - 0x100000, - PAGE_READWRITE, - &MemoryArea, - TRUE, - 0, - PAGE_SIZE); - ASSERT(NT_SUCCESS(Status)); - - // - // And finally, hyperspace - // - BaseAddress = (PVOID)HYPER_SPACE; - Status = MmCreateMemoryArea(MmGetKernelAddressSpace(), - MEMORY_AREA_OWNED_BY_ARM3, - &BaseAddress, - PAGE_SIZE, - PAGE_READWRITE, - &MemoryArea, - TRUE, - 0, - PAGE_SIZE); - ASSERT(NT_SUCCESS(Status)); -} /* PUBLIC FUNCTIONS ***********************************************************/ diff --git a/reactos/ntoskrnl/mm/freelist.c b/reactos/ntoskrnl/mm/freelist.c index 62a5e6205f5..e65ba48ffbb 100644 --- a/reactos/ntoskrnl/mm/freelist.c +++ b/reactos/ntoskrnl/mm/freelist.c @@ -14,10 +14,6 @@ #define NDEBUG #include -#if defined (ALLOC_PRAGMA) -#pragma alloc_text(INIT, MmInitializePageList) -#endif - #define MODULE_INVOLVED_IN_ARM3 #include "ARM3/miarm.h" diff --git a/reactos/ntoskrnl/mm/i386/page.c b/reactos/ntoskrnl/mm/i386/page.c index c18a0d1c5f8..3ccebac2c38 100644 --- a/reactos/ntoskrnl/mm/i386/page.c +++ b/reactos/ntoskrnl/mm/i386/page.c @@ -16,7 +16,6 @@ #if defined (ALLOC_PRAGMA) #pragma alloc_text(INIT, MmInitGlobalKernelPageDirectory) -#pragma alloc_text(INIT, MiInitPageDirectoryMap) #endif @@ -592,35 +591,6 @@ MmSetDirtyPage(PEPROCESS Process, PVOID Address) } } -VOID -NTAPI -MmEnableVirtualMapping(PEPROCESS Process, PVOID Address) -{ - PULONG Pt; - ULONG Pte; - - Pt = MmGetPageTableForProcess(Process, Address, FALSE); - if (Pt == NULL) - { - //HACK to get DPH working, waiting for MM rewrite :-/ - //KeBugCheck(MEMORY_MANAGEMENT); - return; - } - - /* Do not mark a 0 page as present */ - if(0 == InterlockedCompareExchangePte(Pt, 0, 0)) - return; - - do - { - Pte = *Pt; - } while (Pte != InterlockedCompareExchangePte(Pt, Pte | PA_PRESENT, Pte)); - - /* We don't need to flush the TLB here because it - * won't cache translations for non-present pages */ - MmUnmapPageTable(Pt); -} - BOOLEAN NTAPI MmIsPagePresent(PEPROCESS Process, PVOID Address) diff --git a/reactos/ntoskrnl/mm/i386/pagepae.c b/reactos/ntoskrnl/mm/i386/pagepae.c index f7a4c428e7f..f217e972884 100644 --- a/reactos/ntoskrnl/mm/i386/pagepae.c +++ b/reactos/ntoskrnl/mm/i386/pagepae.c @@ -15,7 +15,6 @@ #if defined (ALLOC_PRAGMA) #pragma alloc_text(INIT, MmInitGlobalKernelPageDirectory) -#pragma alloc_text(INIT, MiInitPageDirectoryMap) #endif @@ -56,17 +55,6 @@ ULONGLONG MmGlobalKernelPageDirectoryForPAE[2048]; #define PAE_PTE_TO_PFN(X) (PAE_PAGE_MASK(X) >> PAGE_SHIFT) #define PAE_PFN_TO_PTE(X) ((X) << PAGE_SHIFT) -#if defined(__GNUC__) -#define PTE_TO_PAGE(X) ((LARGE_INTEGER)(LONGLONG)(PAGE_MASK(X))) -#else -__inline LARGE_INTEGER PTE_TO_PAGE(ULONG npage) -{ - LARGE_INTEGER dummy; - dummy.QuadPart = (LONGLONG)(PAGE_MASK(npage)); - return dummy; -} -#endif - extern BOOLEAN Ke386Pae; extern BOOLEAN Ke386NoExecute; @@ -197,149 +185,6 @@ ProtectToPTE(ULONG flProtect) #define PAE_ADDR_TO_PTE_OFFSET(v) ((((ULONG_PTR)(v)) % (512 * PAGE_SIZE)) / PAGE_SIZE) - -NTSTATUS -NTAPI -Mmi386ReleaseMmInfo(PEPROCESS Process) -{ - PUSHORT LdtDescriptor; - ULONG LdtBase; - ULONG i, j; - - DPRINT("Mmi386ReleaseMmInfo(Process %x)\n",Process); - - LdtDescriptor = (PUSHORT) &Process->Pcb.LdtDescriptor; - LdtBase = LdtDescriptor[1] | - ((LdtDescriptor[2] & 0xff) << 16) | - ((LdtDescriptor[3] & ~0xff) << 16); - - DPRINT("LdtBase: %x\n", LdtBase); - - if (LdtBase) - { - ExFreePool((PVOID) LdtBase); - } - - if (Ke386Pae) - { - PULONGLONG PageDirTable; - PULONGLONG PageDir; - PULONGLONG Pde; - ULONG k; - - PageDirTable = (PULONGLONG)MmCreateHyperspaceMapping(PAE_PTE_TO_PFN(Process->Pcb.DirectoryTableBase.QuadPart)); - for (i = 0; i < 4; i++) - { - PageDir = (PULONGLONG)MmCreateHyperspaceMapping(PAE_PTE_TO_PFN(PageDirTable[i])); - if (i < PAE_ADDR_TO_PDTE_OFFSET(MmSystemRangeStart)) - { - for (j = 0; j < 512; j++) - { - if (PageDir[j] != 0LL) - { - DPRINT1("ProcessId %d, Pde for %08x - %08x is not freed, RefCount %d\n", - Process->UniqueProcessId, - (i * 512 + j) * 512 * PAGE_SIZE, (i * 512 + j + 1) * 512 * PAGE_SIZE - 1, - ((PMADDRESS_SPACE)&Process->VadRoot)->PageTableRefCountTable[i*512 + j]); - Pde = MmCreateHyperspaceMapping(PAE_PTE_TO_PFN(PageDir[j])); - for (k = 0; k < 512; k++) - { - if(Pde[k] != 0) - { - if (Pde[k] & PA_PRESENT) - { - DPRINT1("Page at %08x is not freed\n", - (i * 512 + j) * 512 * PAGE_SIZE + k * PAGE_SIZE); - } - else - { - DPRINT1("Swapentry %x at %x is not freed\n", - (i * 512 + j) * 512 * PAGE_SIZE + k * PAGE_SIZE); - } - } - } - MmDeleteHyperspaceMapping(Pde); - MmReleasePageMemoryConsumer(MC_NPPOOL, PAE_PTE_TO_PFN(PageDir[j])); - } - } - } - if (i == PAE_ADDR_TO_PDTE_OFFSET(HYPERSPACE)) - { - MmReleasePageMemoryConsumer(MC_NPPOOL, PAE_PTE_TO_PFN(PageDir[PAE_ADDR_TO_PDE_PAGE_OFFSET(HYPERSPACE)])); - MmReleasePageMemoryConsumer(MC_NPPOOL, PAE_PTE_TO_PFN(PageDir[PAE_ADDR_TO_PDE_PAGE_OFFSET(HYPERSPACE)+1])); - } - MmDeleteHyperspaceMapping(PageDir); - MmReleasePageMemoryConsumer(MC_NPPOOL, PAE_PTE_TO_PFN(PageDirTable[i])); - } - MmDeleteHyperspaceMapping((PVOID)PageDirTable); - MmReleasePageMemoryConsumer(MC_NPPOOL, PAE_PTE_TO_PFN(Process->Pcb.DirectoryTableBase.QuadPart)); - } - else - { - PULONG Pde; - PULONG PageDir; - PageDir = MmCreateHyperspaceMapping(PTE_TO_PFN(Process->Pcb.DirectoryTableBase.u.LowPart)); - for (i = 0; i < ADDR_TO_PDE_OFFSET(MmSystemRangeStart); i++) - { - if (PageDir[i] != 0) - { - DPRINT1("Pde for %08x - %08x is not freed, RefCount %d\n", - i * 4 * 1024 * 1024, (i + 1) * 4 * 1024 * 1024 - 1, - ((PMADDRESS_SPACE)&Process->VadRoot)->PageTableRefCountTable[i]); - Pde = MmCreateHyperspaceMapping(PTE_TO_PFN(PageDir[i])); - for (j = 0; j < 1024; j++) - { - if(Pde[j] != 0) - { - if (Pde[j] & PA_PRESENT) - { - DPRINT1("Page at %08x is not freed\n", - i * 4 * 1024 * 1024 + j * PAGE_SIZE); - } - else - { - DPRINT1("Swapentry %x at %x is not freed\n", - Pde[j], i * 4 * 1024 * 1024 + j * PAGE_SIZE); - } - } - } - MmDeleteHyperspaceMapping(Pde); - MmReleasePageMemoryConsumer(MC_NPPOOL, PTE_TO_PFN(PageDir[i])); - } - } - MmReleasePageMemoryConsumer(MC_NPPOOL, PTE_TO_PFN(PageDir[ADDR_TO_PDE_OFFSET(HYPERSPACE)])); - MmDeleteHyperspaceMapping(PageDir); - MmReleasePageMemoryConsumer(MC_NPPOOL, PTE_TO_PFN(Process->Pcb.DirectoryTableBase.u.LowPart)); - } - -#if defined(__GNUC__) - - Process->Pcb.DirectoryTableBase.QuadPart = 0LL; -#else - - Process->Pcb.DirectoryTableBase.QuadPart = 0; -#endif - - DPRINT("Finished Mmi386ReleaseMmInfo()\n"); - return(STATUS_SUCCESS); -} - -NTSTATUS -NTAPI -MmInitializeHandBuiltProcess(IN PEPROCESS Process, - IN PLARGE_INTEGER DirectoryTableBase) -{ - /* Share the directory base with the idle process */ - *DirectoryTableBase = PsGetCurrentProcess()->Pcb.DirectoryTableBase; - - /* Initialize the Addresss Space */ - MmInitializeAddressSpace(Process, (PMADDRESS_SPACE)&Process->VadRoot); - - /* The process now has an address space */ - Process->HasAddressSpace = TRUE; - return STATUS_SUCCESS; -} - BOOLEAN NTAPI MmCreateProcessAddressSpace(IN ULONG MinWs, @@ -420,39 +265,6 @@ MmCreateProcessAddressSpace(IN ULONG MinWs, return TRUE; } -VOID -NTAPI -MmDeletePageTable(PEPROCESS Process, PVOID Address) -{ - PEPROCESS CurrentProcess = PsGetCurrentProcess(); - - if (Process != NULL && Process != CurrentProcess) - { - KeAttachProcess(&Process->Pcb); - } - - if (Ke386Pae) - { - ULONGLONG ZeroPde = 0LL; - (void)ExfpInterlockedExchange64UL(PAE_ADDR_TO_PDE(Address), &ZeroPde); - MiFlushTlb((PULONG)PAE_ADDR_TO_PDE(Address), PAE_ADDR_TO_PTE(Address)); - } - else - { - *(ADDR_TO_PDE(Address)) = 0; - MiFlushTlb(ADDR_TO_PDE(Address), ADDR_TO_PTE(Address)); - } - if (Address >= MmSystemRangeStart) - { - ASSERT(FALSE); - // MmGlobalKernelPageDirectory[ADDR_TO_PDE_OFFSET(Address)] = 0; - } - if (Process != NULL && Process != CurrentProcess) - { - KeDetachProcess(); - } -} - VOID NTAPI MmFreePageTable(PEPROCESS Process, PVOID Address) @@ -1105,73 +917,6 @@ MmIsDirtyPage(PEPROCESS Process, PVOID Address) } } -BOOLEAN -NTAPI -MmIsAccessedAndResetAccessPage(PEPROCESS Process, PVOID Address) -{ - if (Address < MmSystemRangeStart && Process == NULL) - { - DPRINT1("MmIsAccessedAndResetAccessPage is called for user space without a process.\n"); - ASSERT(FALSE); - } - if (Ke386Pae) - { - PULONGLONG Pt; - ULONGLONG Pte; - ULONGLONG tmpPte; - - Pt = MmGetPageTableForProcessForPAE(Process, Address, FALSE); - if (Pt == NULL) - { - ASSERT(FALSE); - } - - do - { - Pte = *Pt; - tmpPte = Pte & ~PA_ACCESSED; - } while (Pte != ExfInterlockedCompareExchange64UL(Pt, &tmpPte, &Pte)); - - if (Pte & PA_ACCESSED) - { - MiFlushTlb((PULONG)Pt, Address); - return TRUE; - } - else - { - MmUnmapPageTable((PULONG)Pt); - return FALSE; - } - } - else - { - PULONG Pt; - ULONG Pte; - - Pt = MmGetPageTableForProcess(Process, Address, FALSE); - if (Pt == NULL) - { - ASSERT(FALSE); - } - - do - { - Pte = *Pt; - } while (Pte != InterlockedCompareExchangeUL(Pt, Pte & ~PA_ACCESSED, Pte)); - - if (Pte & PA_ACCESSED) - { - MiFlushTlb(Pt, Address); - return TRUE; - } - else - { - MmUnmapPageTable(Pt); - return FALSE; - } - } -} - VOID NTAPI MmSetCleanPage(PEPROCESS Process, PVOID Address) @@ -1298,62 +1043,6 @@ MmSetDirtyPage(PEPROCESS Process, PVOID Address) } } -VOID -NTAPI -MmEnableVirtualMapping(PEPROCESS Process, PVOID Address) -{ - if (Ke386Pae) - { - PULONGLONG Pt; - ULONGLONG Pte; - ULONGLONG tmpPte; - - Pt = MmGetPageTableForProcessForPAE(Process, Address, FALSE); - if (Pt == NULL) - { - ASSERT(FALSE); - } - - do - { - Pte = *Pt; - tmpPte = Pte | PA_PRESENT; - } while (Pte != ExfInterlockedCompareExchange64UL(Pt, &tmpPte, &Pte)); - if (!(Pte & PA_PRESENT)) - { - MiFlushTlb((PULONG)Pt, Address); - } - else - { - MmUnmapPageTable((PULONG)Pt); - } - } - else - { - PULONG Pt; - ULONG Pte; - - Pt = MmGetPageTableForProcess(Process, Address, FALSE); - if (Pt == NULL) - { - ASSERT(FALSE); - } - - do - { - Pte = *Pt; - } while (Pte != InterlockedCompareExchangeUL(Pt, Pte | PA_PRESENT, Pte)); - if (!(Pte & PA_PRESENT)) - { - MiFlushTlb(Pt, Address); - } - else - { - MmUnmapPageTable(Pt); - } - } -} - BOOLEAN NTAPI MmIsPagePresent(PEPROCESS Process, PVOID Address) @@ -1386,134 +1075,6 @@ MmIsPageSwapEntry(PEPROCESS Process, PVOID Address) } } -NTSTATUS -NTAPI -MmCreateVirtualMappingForKernel(PVOID Address, - ULONG flProtect, - PPFN_NUMBER Pages, - ULONG PageCount) -{ - ULONG Attributes; - ULONG i; - PVOID Addr; - ULONG PdeOffset, oldPdeOffset; - BOOLEAN NoExecute = FALSE; - - DPRINT("MmCreateVirtualMappingForKernel(%x, %x, %x, %d)\n", - Address, flProtect, Pages, PageCount); - - if (Address < MmSystemRangeStart) - { - DPRINT1("MmCreateVirtualMappingForKernel is called for user space\n"); - ASSERT(FALSE); - } - - Attributes = ProtectToPTE(flProtect); - if (Attributes & 0x80000000) - { - NoExecute = TRUE; - } - Attributes &= 0xfff; - if (Ke386GlobalPagesEnabled) - { - Attributes |= PA_GLOBAL; - } - - Addr = Address; - - if (Ke386Pae) - { - PULONGLONG Pt = NULL; - ULONGLONG Pte; - - oldPdeOffset = PAE_ADDR_TO_PDE_OFFSET(Addr) + 1; - for (i = 0; i < PageCount; i++, Addr = (PVOID)((ULONG_PTR)Addr + PAGE_SIZE)) - { - if (!(Attributes & PA_PRESENT) && Pages[i] != 0) - { - DPRINT1("Setting physical address but not allowing access at address " - "0x%.8X with attributes %x/%x.\n", - Addr, Attributes, flProtect); - ASSERT(FALSE); - } - - PdeOffset = PAE_ADDR_TO_PDE_OFFSET(Addr); - if (oldPdeOffset != PdeOffset) - { - Pt = MmGetPageTableForProcessForPAE(NULL, Addr, TRUE); - if (Pt == NULL) - { - ASSERT(FALSE); - } - } - else - { - Pt++; - } - oldPdeOffset = PdeOffset; - - Pte = PFN_TO_PTE(Pages[i]) | Attributes; - if (NoExecute) - { - Pte |= 0x8000000000000000LL; - } - Pte = ExfpInterlockedExchange64UL(Pt, &Pte); - if (Pte != 0LL) - { - ASSERT(FALSE); - } - } - } - else - { - PULONG Pt; - ULONG Pte; - - oldPdeOffset = ADDR_TO_PDE_OFFSET(Addr); - Pt = MmGetPageTableForProcess(NULL, Addr, TRUE); - if (Pt == NULL) - { - ASSERT(FALSE); - } - Pt--; - - for (i = 0; i < PageCount; i++, Addr = (PVOID)((ULONG_PTR)Addr + PAGE_SIZE)) - { - if (!(Attributes & PA_PRESENT) && Pages[i] != 0) - { - DPRINT1("Setting physical address but not allowing access at address " - "0x%.8X with attributes %x/%x.\n", - Addr, Attributes, flProtect); - ASSERT(FALSE); - } - - PdeOffset = ADDR_TO_PDE_OFFSET(Addr); - if (oldPdeOffset != PdeOffset) - { - Pt = MmGetPageTableForProcess(NULL, Addr, TRUE); - if (Pt == NULL) - { - ASSERT(FALSE); - } - } - else - { - Pt++; - } - oldPdeOffset = PdeOffset; - - Pte = *Pt; - if (Pte != 0) - { - ASSERT(FALSE); - } - (void)InterlockedExchangeUL(Pt, PFN_TO_PTE(Pages[i]) | Attributes); - } - } - - return(STATUS_SUCCESS); -} - NTSTATUS NTAPI MmCreatePageFileMapping(PEPROCESS Process, @@ -1949,49 +1510,6 @@ MmSetPageProtect(PEPROCESS Process, PVOID Address, ULONG flProtect) } } -/* - * @implemented - */ -PHYSICAL_ADDRESS NTAPI -MmGetPhysicalAddress(PVOID vaddr) -/* - * FUNCTION: Returns the physical address corresponding to a virtual address - */ -{ - PHYSICAL_ADDRESS p; - - DPRINT("MmGetPhysicalAddress(vaddr %x)\n", vaddr); - if (Ke386Pae) - { - ULONGLONG Pte; - Pte = MmGetPageEntryForProcessForPAE(NULL, vaddr); - if (Pte != 0 && Pte & PA_PRESENT) - { - p.QuadPart = PAE_PAGE_MASK(Pte); - p.u.LowPart |= (ULONG_PTR)vaddr & (PAGE_SIZE - 1); - } - else - { - p.QuadPart = 0; - } - } - else - { - ULONG Pte; - Pte = MmGetPageEntryForProcess(NULL, vaddr); - if (Pte != 0 && Pte & PA_PRESENT) - { - p.QuadPart = PAGE_MASK(Pte); - p.u.LowPart |= (ULONG_PTR)vaddr & (PAGE_SIZE - 1); - } - else - { - p.QuadPart = 0; - } - } - return p; -} - PVOID NTAPI MmCreateHyperspaceMapping(PFN_NUMBER Page) @@ -2121,28 +1639,6 @@ MmCreateHyperspaceMapping(PFN_NUMBER Page) return Address; } -PFN_NUMBER -NTAPI -MmChangeHyperspaceMapping(PVOID Address, PFN_NUMBER NewPage) -{ - PFN_NUMBER Pfn; - ASSERT (IS_HYPERSPACE(Address)); - if (Ke386Pae) - { - ULONGLONG Entry = PAE_PFN_TO_PTE(NewPage) | PA_PRESENT | PA_READWRITE; - Entry = (ULONG)ExfpInterlockedExchange64UL(PAE_ADDR_TO_PTE(Address), &Entry); - Pfn = PAE_PTE_TO_PFN(Entry); - } - else - { - ULONG Entry; - Entry = InterlockedExchange((PLONG)ADDR_TO_PTE(Address), PFN_TO_PTE(NewPage) | PA_PRESENT | PA_READWRITE); - Pfn = PTE_TO_PFN(Entry); - } - __invlpg(Address); - return Pfn; -} - PFN_NUMBER NTAPI MmDeleteHyperspaceMapping(PVOID Address) @@ -2165,91 +1661,6 @@ MmDeleteHyperspaceMapping(PVOID Address) return Pfn; } -VOID -NTAPI -MmUpdatePageDir(PEPROCESS Process, PVOID Address, ULONG Size) -{ - ULONG StartOffset, EndOffset, Offset; - - if (Address < MmSystemRangeStart) - { - ASSERT(FALSE); - } - if (Ke386Pae) - { - PULONGLONG PageDirTable; - PULONGLONG Pde; - ULONGLONG ZeroPde = 0LL; - ULONG i; - - for (i = PAE_ADDR_TO_PDTE_OFFSET(Address); i <= PAE_ADDR_TO_PDTE_OFFSET((PVOID)((ULONG_PTR)Address + Size)); i++) - { - if (i == PAE_ADDR_TO_PDTE_OFFSET(Address)) - { - StartOffset = PAE_ADDR_TO_PDE_PAGE_OFFSET(Address); - } - else - { - StartOffset = 0; - } - if (i == PAE_ADDR_TO_PDTE_OFFSET((PVOID)((ULONG_PTR)Address + Size))) - { - EndOffset = PAE_ADDR_TO_PDE_PAGE_OFFSET((PVOID)((ULONG_PTR)Address + Size)); - } - else - { - EndOffset = 511; - } - - if (Process != NULL && Process != PsGetCurrentProcess()) - { - PageDirTable = MmCreateHyperspaceMapping(PAE_PTE_TO_PFN(Process->Pcb.DirectoryTableBase.QuadPart)); - Pde = (PULONGLONG)MmCreateHyperspaceMapping(PTE_TO_PFN(PageDirTable[i])); - MmDeleteHyperspaceMapping(PageDirTable); - } - else - { - Pde = (PULONGLONG)PAE_PAGEDIRECTORY_MAP + i*512; - } - - for (Offset = StartOffset; Offset <= EndOffset; Offset++) - { - if (i * 512 + Offset < PAE_ADDR_TO_PDE_OFFSET(PAGETABLE_MAP) || i * 512 + Offset >= PAE_ADDR_TO_PDE_OFFSET(PAGETABLE_MAP)+4) - { - (void)ExfInterlockedCompareExchange64UL(&Pde[Offset], &MmGlobalKernelPageDirectoryForPAE[i*512 + Offset], &ZeroPde); - } - } - MmUnmapPageTable((PULONG)Pde); - } - } - else - { - PULONG Pde; - StartOffset = ADDR_TO_PDE_OFFSET(Address); - EndOffset = ADDR_TO_PDE_OFFSET((PVOID)((ULONG_PTR)Address + Size)); - - if (Process != NULL && Process != PsGetCurrentProcess()) - { - Pde = MmCreateHyperspaceMapping(PTE_TO_PFN(Process->Pcb.DirectoryTableBase.u.LowPart)); - } - else - { - Pde = (PULONG)PAGEDIRECTORY_MAP; - } - for (Offset = StartOffset; Offset <= EndOffset; Offset++) - { - if (Offset != ADDR_TO_PDE_OFFSET(PAGETABLE_MAP)) - { - (void)InterlockedCompareExchangeUL(&Pde[Offset], MmGlobalKernelPageDirectory[Offset], 0); - } - } - if (Pde != (PULONG)PAGEDIRECTORY_MAP) - { - MmDeleteHyperspaceMapping(Pde); - } - } -} - VOID INIT_FUNCTION NTAPI @@ -2297,53 +1708,4 @@ MmInitGlobalKernelPageDirectory(VOID) } } -ULONG -NTAPI -MiGetUserPageDirectoryCount(VOID) -{ - return Ke386Pae ? PAE_ADDR_TO_PDE_OFFSET(MmSystemRangeStart) : ADDR_TO_PDE_OFFSET(MmSystemRangeStart); -} - -VOID -INIT_FUNCTION -NTAPI -MiInitPageDirectoryMap(VOID) -{ - MEMORY_AREA* kernel_map_desc = NULL; - MEMORY_AREA* hyperspace_desc = NULL; - PVOID BaseAddress; - NTSTATUS Status; - - DPRINT("MiInitPageDirectoryMap()\n"); - - BaseAddress = (PVOID)PAGETABLE_MAP; - Status = MmCreateMemoryArea(MmGetKernelAddressSpace(), - MEMORY_AREA_SYSTEM, - &BaseAddress, - Ke386Pae ? 0x800000 : 0x400000, - PAGE_READWRITE, - &kernel_map_desc, - TRUE, - 0, - PAGE_SIZE); - if (!NT_SUCCESS(Status)) - { - ASSERT(FALSE); - } - BaseAddress = (PVOID)HYPERSPACE; - Status = MmCreateMemoryArea(MmGetKernelAddressSpace(), - MEMORY_AREA_SYSTEM, - &BaseAddress, - 0x400000, - PAGE_READWRITE, - &hyperspace_desc, - TRUE, - 0, - PAGE_SIZE); - if (!NT_SUCCESS(Status)) - { - ASSERT(FALSE); - } -} - /* EOF */ diff --git a/reactos/ntoskrnl/mm/marea.c b/reactos/ntoskrnl/mm/marea.c index 759be7aef28..5deec1abb9b 100644 --- a/reactos/ntoskrnl/mm/marea.c +++ b/reactos/ntoskrnl/mm/marea.c @@ -1205,7 +1205,7 @@ MmDeleteProcessAddressSpace(PEPROCESS Process) MmUnlockAddressSpace(&Process->Vm); - DPRINT("Finished MmReleaseMmInfo()\n"); + DPRINT("Finished MmDeleteProcessAddressSpace()\n"); MmDeleteProcessAddressSpace2(Process); return(STATUS_SUCCESS); } diff --git a/reactos/ntoskrnl/mm/pagefile.c b/reactos/ntoskrnl/mm/pagefile.c index 06563d97e32..f534a66e1df 100644 --- a/reactos/ntoskrnl/mm/pagefile.c +++ b/reactos/ntoskrnl/mm/pagefile.c @@ -351,37 +351,6 @@ MmInitPagingFile(VOID) MiPagingFileCount = 0; } -BOOLEAN -NTAPI -MmReserveSwapPages(ULONG Nr) -{ - KIRQL oldIrql; - ULONG MiAvailSwapPages; - - KeAcquireSpinLock(&PagingFileListLock, &oldIrql); - MiAvailSwapPages = - (MiFreeSwapPages * MM_PAGEFILE_COMMIT_RATIO) + MM_PAGEFILE_COMMIT_GRACE; - MiReservedSwapPages = MiReservedSwapPages + Nr; - if ((MM_PAGEFILE_COMMIT_RATIO != 0) && (MiAvailSwapPages < MiReservedSwapPages)) - { - KeReleaseSpinLock(&PagingFileListLock, oldIrql); - return(FALSE); - } - KeReleaseSpinLock(&PagingFileListLock, oldIrql); - return(TRUE); -} - -VOID -NTAPI -MmDereserveSwapPages(ULONG Nr) -{ - KIRQL oldIrql; - - KeAcquireSpinLock(&PagingFileListLock, &oldIrql); - MiReservedSwapPages = MiReservedSwapPages - Nr; - KeReleaseSpinLock(&PagingFileListLock, oldIrql); -} - static ULONG MiAllocPageFromPagingFile(PPAGINGFILE PagingFile) { @@ -439,13 +408,6 @@ MmFreeSwapPage(SWAPENTRY Entry) KeReleaseSpinLock(&PagingFileListLock, oldIrql); } -BOOLEAN -NTAPI -MmIsAvailableSwapPage(VOID) -{ - return(MiFreeSwapPages > 0); -} - SWAPENTRY NTAPI MmAllocSwapPage(VOID) diff --git a/reactos/ntoskrnl/mm/powerpc/page.c b/reactos/ntoskrnl/mm/powerpc/page.c index 33f051dc1f5..c0acc4825b2 100644 --- a/reactos/ntoskrnl/mm/powerpc/page.c +++ b/reactos/ntoskrnl/mm/powerpc/page.c @@ -17,7 +17,6 @@ #if defined (ALLOC_PRAGMA) #pragma alloc_text(INIT, MmInitGlobalKernelPageDirectory) -#pragma alloc_text(INIT, MiInitPageDirectoryMap) #endif /* GLOBALS *****************************************************************/ @@ -103,22 +102,6 @@ MmCopyMmInfo(PEPROCESS Src, return(STATUS_SUCCESS); } -NTSTATUS -NTAPI -MmInitializeHandBuiltProcess(IN PEPROCESS Process, - IN PLARGE_INTEGER DirectoryTableBase) -{ - /* Share the directory base with the idle process */ - *DirectoryTableBase = PsGetCurrentProcess()->Pcb.DirectoryTableBase; - - /* Initialize the Addresss Space */ - MmInitializeAddressSpace(Process, (PMADDRESS_SPACE)&Process->VadRoot); - - /* The process now has an address space */ - Process->HasAddressSpace = TRUE; - return STATUS_SUCCESS; -} - BOOLEAN NTAPI MmCreateProcessAddressSpace(IN ULONG MinWs, @@ -177,20 +160,6 @@ MmGetPhysicalAddressProcess(PEPROCESS Process, PVOID Addr) return (PVOID)info.phys; } -/* - * @implemented - */ -PHYSICAL_ADDRESS NTAPI -MmGetPhysicalAddress(PVOID vaddr) -/* - * FUNCTION: Returns the physical address corresponding to a virtual address - */ -{ - PHYSICAL_ADDRESS Addr; - Addr.QuadPart = (ULONG)MmGetPhysicalAddressProcess(PsGetCurrentProcess()->UniqueProcessId, vaddr); - return Addr; -} - PFN_NUMBER NTAPI MmGetPfnForProcess(PEPROCESS Process, @@ -274,24 +243,6 @@ MmIsDirtyPage(PEPROCESS Process, PVOID Address) return !!(info.flags & MMU_PAGE_DIRTY); } -BOOLEAN -NTAPI -MmIsAccessedAndResetAccessPage(PEPROCESS Process, PVOID Address) -{ - ppc_map_info_t info = { 0 }; - - if (Address < MmSystemRangeStart && Process == NULL) - { - DPRINT1("MmIsAccessedAndResetAccessPage is called for user space without a process.\n"); - ASSERT(FALSE); - } - - info.proc = Process ? (int)Process->UniqueProcessId : 0; - info.addr = (vaddr_t)Address; - MmuInqPage(&info, 1); - return !!(info.flags /*& MMU_PAGE_ACCESS*/); -} - VOID NTAPI MmSetCleanPage(PEPROCESS Process, PVOID Address) @@ -304,12 +255,6 @@ MmSetDirtyPage(PEPROCESS Process, PVOID Address) { } -VOID -NTAPI -MmEnableVirtualMapping(PEPROCESS Process, PVOID Address) -{ -} - BOOLEAN NTAPI MmIsPagePresent(PEPROCESS Process, PVOID Address) @@ -335,44 +280,6 @@ MmIsPageSwapEntry(PEPROCESS Process, PVOID Address) return !(Entry & PA_PRESENT) && Entry != 0 ? TRUE : FALSE; } -NTSTATUS -NTAPI -MmCreateVirtualMappingForKernel(PVOID Address, - ULONG flProtect, - PPFN_NUMBER Pages, - ULONG PageCount) -{ - ULONG i; - PVOID Addr; - - DPRINT("MmCreateVirtualMappingForKernel(%x, %x, %x, %d)\n", - Address, flProtect, Pages, PageCount); - - if (Address < MmSystemRangeStart) - { - DPRINT1("MmCreateVirtualMappingForKernel is called for user space\n"); - ASSERT(FALSE); - } - - Addr = Address; - - for (i = 0; i < PageCount; i++, Addr = (PVOID)((ULONG_PTR)Addr + PAGE_SIZE)) - { -#if 0 - if (!(Attributes & PA_PRESENT) && Pages[i] != 0) - { - DPRINT1("Setting physical address but not allowing access at address " - "0x%.8X with attributes %x/%x.\n", - Addr, Attributes, flProtect); - ASSERT(FALSE); - } - (void)InterlockedExchangeUL(Pt, PFN_TO_PTE(Pages[i]) | Attributes); -#endif - } - - return(STATUS_SUCCESS); -} - NTSTATUS NTAPI MmCreatePageFileMapping(PEPROCESS Process, @@ -568,23 +475,6 @@ MmCreateHyperspaceMapping(PFN_NUMBER Page) return Address; } -PFN_NUMBER -NTAPI -MmChangeHyperspaceMapping(PVOID Address, PFN_NUMBER NewPage) -{ - PFN_NUMBER OldPage; - ppc_map_info_t info = { 0 }; - - info.proc = 0; - info.addr = (vaddr_t)Address; - MmuUnmapPage(&info, 1); - OldPage = info.phys; - info.phys = (paddr_t)NewPage; - MmuMapPage(&info, 1); - - return NewPage; -} - PFN_NUMBER NTAPI MmDeleteHyperspaceMapping(PVOID Address) @@ -607,26 +497,6 @@ MmInitGlobalKernelPageDirectory(VOID) { } -VOID -INIT_FUNCTION -NTAPI -MiInitPageDirectoryMap(VOID) -{ -} - -ULONG -NTAPI -MiGetUserPageDirectoryCount(VOID) -{ - return 0; -} - -VOID -NTAPI -MmUpdatePageDir(PEPROCESS Process, PVOID Address, ULONG Size) -{ -} - /* Create a simple, primitive mapping at the specified address on a new page */ NTSTATUS MmPPCCreatePrimitiveMapping(ULONG_PTR PageAddr) {