[NTOS]: Enable usage of ARM3 paged pool, up until Mm Phase 2.
[reactos.git] / reactos / ntoskrnl / include / internal / mm.h
index 55c90fd..d8c6178 100644 (file)
@@ -1,5 +1,4 @@
-#ifndef __INCLUDE_INTERNAL_MM_H
-#define __INCLUDE_INTERNAL_MM_H
+#pragma once
 
 #include <internal/arch/mm.h>
 
@@ -19,7 +18,6 @@ extern ULONG MmLowestPhysicalPage;
 extern ULONG MmHighestPhysicalPage;
 extern ULONG MmAvailablePages;
 extern ULONG MmResidentAvailablePages;
-extern ULONG MmNumberOfSystemPtes;
 
 extern PVOID MmPagedPoolBase;
 extern ULONG MmPagedPoolSize;
@@ -48,14 +46,14 @@ extern SIZE_T MmPagedPoolCommit;
 extern SIZE_T MmPeakCommitment;
 extern SIZE_T MmtotalCommitLimitMaximum;
 
-extern PVOID MiDebugMapping;
-extern PMMPTE MmDebugPte;
+extern BOOLEAN MiDbgReadyForPhysical;
 
 struct _KTRAP_FRAME;
 struct _EPROCESS;
 struct _MM_RMAP_ENTRY;
 struct _MM_PAGEOP;
 typedef ULONG SWAPENTRY;
+typedef ULONG PFN_TYPE, *PPFN_TYPE;
 
 //
 // MmDbgCopyMemory Flags
@@ -109,28 +107,10 @@ typedef ULONG SWAPENTRY;
 /* Number of list heads to use */
 #define MI_FREE_POOL_LISTS 4
 
-#define MI_HYPERSPACE_PTES                  (256 - 1)
-#define MI_ZERO_PTES                        (32)
-#define MI_MAPPING_RANGE_START              (ULONG_PTR)HYPER_SPACE
-#define MI_MAPPING_RANGE_END                (MI_MAPPING_RANGE_START + \
-                                             MI_HYPERSPACE_PTES * PAGE_SIZE)
-#define MI_ZERO_PTE                         (PMMPTE)(MI_MAPPING_RANGE_END + \
-                                             PAGE_SIZE)
 
 /* Signature of free pool blocks */
 #define MM_FREE_POOL_TAG    'lprF'
 
-#define PAGE_TO_SECTION_PAGE_DIRECTORY_OFFSET(x) \
-    ((x) / (4*1024*1024))
-
-#define PAGE_TO_SECTION_PAGE_TABLE_OFFSET(x) \
-    ((((x)) % (4*1024*1024)) / (4*1024))
-
-#define NR_SECTION_PAGE_TABLES              1024
-#define NR_SECTION_PAGE_ENTRIES             1024
-
-#define TEB_BASE                            0x7FFDE000
-
 /* 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)
@@ -170,17 +150,6 @@ typedef ULONG SWAPENTRY;
  */
 #define MM_POOL_ALIGNMENT                   8
 
-/*
- * Maximum size of the kmalloc area (this is totally arbitary)
- */
-#define MM_KERNEL_MAP_SIZE                  (16*1024*1024)
-#define MM_KERNEL_MAP_BASE                  (0xf0c00000)
-
-/*
- * FIXME - different architectures have different cache line sizes...
- */
-#define MM_CACHE_LINE_SIZE                  32
-
 #define MM_ROUND_UP(x,s)                    \
     ((PVOID)(((ULONG_PTR)(x)+(s)-1) & ~((ULONG_PTR)(s)-1)))
 
@@ -233,7 +202,6 @@ typedef ULONG SWAPENTRY;
     (PAGE_WRITECOPY | \
     PAGE_EXECUTE_WRITECOPY)
 
-#define MI_PFN_ELEMENT(Pfn) (&MmPfnDatabase[Pfn])
 
 #define InterlockedCompareExchangePte(PointerPte, Exchange, Comperand) \
     InterlockedCompareExchange((PLONG)(PointerPte), Exchange, Comperand)
@@ -376,9 +344,6 @@ typedef struct _MMPFN
             USHORT ShortFlags;
         } e2;
     } u3;
-#ifdef _WIN64
-    ULONG UsedPageTableEntries;
-#endif
     union
     {
         MMPTE OriginalPte;
@@ -389,7 +354,7 @@ typedef struct _MMPFN
         ULONG_PTR EntireFrame;               // SavedSwapEntry
         struct
         {
-            ULONG_PTR PteFrame: 8*sizeof(PVOID)-7;
+            ULONG_PTR PteFrame:25;
             ULONG_PTR InPageError:1;
             ULONG_PTR VerifierAllocation:1;
             ULONG_PTR AweAllocation:1;
@@ -501,7 +466,7 @@ typedef VOID
     PVOID Context,
     PMEMORY_AREA MemoryArea,
     PVOID Address,
-    PFN_NUMBER Page,
+    PFN_TYPE Page,
     SWAPENTRY SwapEntry,
     BOOLEAN Dirty
 );
@@ -723,7 +688,7 @@ VOID
 NTAPI
 MmBuildMdlFromPages(
     PMDL Mdl,
-    PPFN_NUMBER Pages
+    PULONG Pages
 );
 
 /* mminit.c ******************************************************************/
@@ -773,7 +738,7 @@ NTSTATUS
 NTAPI
 MmReadFromSwapPage(
     SWAPENTRY SwapEntry,
-    PFN_NUMBER Page
+    PFN_TYPE Page
 );
 
 BOOLEAN
@@ -784,7 +749,7 @@ NTSTATUS
 NTAPI
 MmWriteToSwapPage(
     SWAPENTRY SwapEntry,
-    PFN_NUMBER Page
+    PFN_TYPE Page
 );
 
 NTSTATUS
@@ -910,7 +875,7 @@ MmQueryAnonMem(
     PMEMORY_AREA MemoryArea,
     PVOID Address,
     PMEMORY_BASIC_INFORMATION Info,
-    PSIZE_T ResultLength
+    PULONG ResultLength
 );
 
 VOID
@@ -952,18 +917,18 @@ ExUnmapPage(PVOID Addr);
 
 PVOID
 NTAPI
-ExAllocatePageWithPhysPage(PFN_NUMBER Page);
+ExAllocatePageWithPhysPage(PFN_TYPE Page);
 
 NTSTATUS
 NTAPI
 MiCopyFromUserPage(
-    PFN_NUMBER Page,
+    PFN_TYPE Page,
     PVOID SourceAddress
 );
 
 NTSTATUS
 NTAPI
-MiZeroPage(PFN_NUMBER Page);
+MiZeroPage(PFN_TYPE Page);
 
 /* memsafe.s *****************************************************************/
 
@@ -1034,7 +999,7 @@ NTSTATUS
 NTAPI
 MmReleasePageMemoryConsumer(
     ULONG Consumer,
-    PFN_NUMBER Page
+    PFN_TYPE Page
 );
 
 NTSTATUS
@@ -1042,7 +1007,7 @@ NTAPI
 MmRequestPageMemoryConsumer(
     ULONG Consumer,
     BOOLEAN MyWait,
-    PPFN_NUMBER AllocatedPage
+    PPFN_TYPE AllocatedPage
 );
 
 VOID
@@ -1058,18 +1023,18 @@ MmRebalanceMemoryConsumers(VOID);
 VOID
 NTAPI
 MmSetRmapListHeadPage(
-    PFN_NUMBER Page,
+    PFN_TYPE Page,
     struct _MM_RMAP_ENTRY* ListHead
 );
 
 struct _MM_RMAP_ENTRY*
 NTAPI
-MmGetRmapListHeadPage(PFN_NUMBER Page);
+MmGetRmapListHeadPage(PFN_TYPE Page);
 
 VOID
 NTAPI
 MmInsertRmap(
-    PFN_NUMBER Page,
+    PFN_TYPE Page,
     struct _EPROCESS *Process,
     PVOID Address
 );
@@ -1077,7 +1042,7 @@ MmInsertRmap(
 VOID
 NTAPI
 MmDeleteAllRmaps(
-    PFN_NUMBER Page,
+    PFN_TYPE Page,
     PVOID Context,
     VOID (*DeleteMapping)(PVOID Context, struct _EPROCESS *Process, PVOID Address)
 );
@@ -1085,7 +1050,7 @@ MmDeleteAllRmaps(
 VOID
 NTAPI
 MmDeleteRmap(
-    PFN_NUMBER Page,
+    PFN_TYPE Page,
     struct _EPROCESS *Process,
     PVOID Address
 );
@@ -1096,31 +1061,29 @@ MmInitializeRmapList(VOID);
 
 VOID
 NTAPI
-MmSetCleanAllRmaps(PFN_NUMBER Page);
+MmSetCleanAllRmaps(PFN_TYPE Page);
 
 VOID
 NTAPI
-MmSetDirtyAllRmaps(PFN_NUMBER Page);
+MmSetDirtyAllRmaps(PFN_TYPE Page);
 
 BOOLEAN
 NTAPI
-MmIsDirtyPageRmap(PFN_NUMBER Page);
+MmIsDirtyPageRmap(PFN_TYPE Page);
 
 NTSTATUS
 NTAPI
-MmWritePagePhysicalAddress(PFN_NUMBER Page);
+MmWritePagePhysicalAddress(PFN_TYPE Page);
 
 NTSTATUS
 NTAPI
-MmPageOutPhysicalAddress(PFN_NUMBER Page);
+MmPageOutPhysicalAddress(PFN_TYPE Page);
 
 /* freelist.c **********************************************************/
 
-#define ASSERT_PFN(x) ASSERT((x)->u3.e1.CacheAttribute != 0)
-
 FORCEINLINE
 PMMPFN
-MiGetPfnEntry(IN PFN_NUMBER Pfn)
+MiGetPfnEntry(IN PFN_TYPE Pfn)
 {
     PMMPFN Page;
     extern RTL_BITMAP MiPfnBitMap;
@@ -1134,9 +1097,6 @@ MiGetPfnEntry(IN PFN_NUMBER Pfn)
     /* Get the entry */
     Page = &MmPfnDatabase[Pfn];
 
-    /* Make sure it's valid */
-    ASSERT_PFN(Page);
-
     /* Return it */
     return Page;
 };
@@ -1151,33 +1111,33 @@ MiGetPfnEntryIndex(IN PMMPFN Pfn1)
     return Pfn1 - MmPfnDatabase;
 }
 
-PFN_NUMBER
+PFN_TYPE
 NTAPI
-MmGetLRUNextUserPage(PFN_NUMBER PreviousPage);
+MmGetLRUNextUserPage(PFN_TYPE PreviousPage);
 
-PFN_NUMBER
+PFN_TYPE
 NTAPI
 MmGetLRUFirstUserPage(VOID);
 
 VOID
 NTAPI
-MmInsertLRULastUserPage(PFN_NUMBER Page);
+MmInsertLRULastUserPage(PFN_TYPE Page);
 
 VOID
 NTAPI
-MmRemoveLRUUserPage(PFN_NUMBER Page);
+MmRemoveLRUUserPage(PFN_TYPE Page);
 
 VOID
 NTAPI
-MmLockPage(PFN_NUMBER Page);
+MmLockPage(PFN_TYPE Page);
 
 VOID
 NTAPI
-MmUnlockPage(PFN_NUMBER Page);
+MmUnlockPage(PFN_TYPE Page);
 
 ULONG
 NTAPI
-MmGetLockCountPage(PFN_NUMBER Page);
+MmGetLockCountPage(PFN_TYPE Page);
 
 VOID
 NTAPI
@@ -1191,7 +1151,7 @@ MmDumpPfnDatabase(
    VOID
 );
 
-PFN_NUMBER
+PFN_TYPE
 NTAPI
 MmGetContinuousPages(
     ULONG NumberOfBytes,
@@ -1226,7 +1186,7 @@ MiUnmapPageInHyperSpace(IN PEPROCESS Process,
 
 PVOID
 NTAPI
-MiMapPagesToZeroInHyperSpace(IN PFN_NUMBER *Pages,
+MiMapPagesToZeroInHyperSpace(IN PMMPFN *Pages,
                              IN PFN_NUMBER NumberOfPages);
 
 VOID
@@ -1249,7 +1209,8 @@ FORCEINLINE
 PVOID
 MiMapPageToZeroInHyperSpace(IN PFN_NUMBER Page)
 {
-    return MiMapPagesToZeroInHyperSpace(&Page, 1);
+    PMMPFN Pfn1 = MiGetPfnEntry(Page);
+    return MiMapPagesToZeroInHyperSpace(&Pfn1, 1);
 }
 
 #define MmDeleteHyperspaceMapping(x) MiUnmapPageInHyperSpace(HyperProcess, x, HyperIrql);
@@ -1261,7 +1222,7 @@ NTAPI
 MmCreateVirtualMappingForKernel(
     PVOID Address,
     ULONG flProtect,
-    PPFN_NUMBER Pages,
+    PPFN_TYPE Pages,
     ULONG PageCount
 );
 
@@ -1278,7 +1239,7 @@ MmCreateVirtualMapping(
     struct _EPROCESS* Process,
     PVOID Address,
     ULONG flProtect,
-    PPFN_NUMBER Pages,
+    PPFN_TYPE Pages,
     ULONG PageCount
 );
 
@@ -1288,7 +1249,7 @@ MmCreateVirtualMappingUnsafe(
     struct _EPROCESS* Process,
     PVOID Address,
     ULONG flProtect,
-    PPFN_NUMBER Pages,
+    PPFN_TYPE Pages,
     ULONG PageCount
 );
 
@@ -1323,7 +1284,7 @@ MmDisableVirtualMapping(
     struct _EPROCESS *Process,
     PVOID Address,
     BOOLEAN* WasDirty,
-    PPFN_NUMBER Page
+    PPFN_TYPE Page
 );
 
 VOID
@@ -1363,7 +1324,7 @@ MmIsPageSwapEntry(
 VOID
 NTAPI
 MmTransferOwnershipPage(
-    PFN_NUMBER Page,
+    PFN_TYPE Page,
     ULONG NewConsumer
 );
 
@@ -1374,11 +1335,10 @@ MmSetDirtyPage(
     PVOID Address
 );
 
-PFN_NUMBER
+PFN_TYPE
 NTAPI
 MmAllocPage(
-    ULONG Consumer,
-    SWAPENTRY SavedSwapEntry
+    ULONG Consumer
 );
 
 LONG
@@ -1388,34 +1348,34 @@ MmAllocPagesSpecifyRange(
     PHYSICAL_ADDRESS LowestAddress,
     PHYSICAL_ADDRESS HighestAddress,
     ULONG NumberOfPages,
-    PPFN_NUMBER Pages
+    PPFN_TYPE Pages
 );
 
 VOID
 NTAPI
-MmDereferencePage(PFN_NUMBER Page);
+MmDereferencePage(PFN_TYPE Page);
 
 VOID
 NTAPI
-MmReferencePage(PFN_NUMBER Page);
+MmReferencePage(PFN_TYPE Page);
 
 ULONG
 NTAPI
-MmGetReferenceCountPage(PFN_NUMBER Page);
+MmGetReferenceCountPage(PFN_TYPE Page);
 
 BOOLEAN
 NTAPI
-MmIsPageInUse(PFN_NUMBER Page);
+MmIsPageInUse(PFN_TYPE Page);
 
 VOID
 NTAPI
 MmSetSavedSwapEntryPage(
-    PFN_NUMBER Page,
+    PFN_TYPE Page,
     SWAPENTRY SavedSwapEntry);
 
 SWAPENTRY
 NTAPI
-MmGetSavedSwapEntryPage(PFN_NUMBER Page);
+MmGetSavedSwapEntryPage(PFN_TYPE Page);
 
 VOID
 NTAPI
@@ -1435,7 +1395,7 @@ MmDeletePageTable(
     PVOID Address
 );
 
-PFN_NUMBER
+PFN_TYPE
 NTAPI
 MmGetPfnForProcess(
     struct _EPROCESS *Process,
@@ -1447,14 +1407,14 @@ NTAPI
 MmCreateProcessAddressSpace(
     IN ULONG MinWs,
     IN PEPROCESS Dest,
-    IN PULONG_PTR DirectoryTableBase
+    IN PULONG DirectoryTableBase
 );
 
 NTSTATUS
 NTAPI
 MmInitializeHandBuiltProcess(
     IN PEPROCESS Process,
-    IN PULONG_PTR DirectoryTableBase
+    IN PULONG DirectoryTableBase
 );
 
 
@@ -1479,7 +1439,7 @@ MmDeleteVirtualMapping(
     PVOID Address,
     BOOLEAN FreePage,
     BOOLEAN* WasDirty,
-    PPFN_NUMBER Page
+    PPFN_TYPE Page
 );
 
 BOOLEAN
@@ -1491,11 +1451,11 @@ MmIsDirtyPage(
 
 VOID
 NTAPI
-MmMarkPageMapped(PFN_NUMBER Page);
+MmMarkPageMapped(PFN_TYPE Page);
 
 VOID
 NTAPI
-MmMarkPageUnmapped(PFN_NUMBER Page);
+MmMarkPageUnmapped(PFN_TYPE Page);
 
 VOID
 NTAPI
@@ -1583,19 +1543,13 @@ MmAllocateSection(
     PVOID BaseAddress
 );
 
-VOID
-NTAPI
-MmFreeSection(
-    PVOID BaseAddress
-);
-
 NTSTATUS
 NTAPI
 MmQuerySectionView(
     PMEMORY_AREA MemoryArea,
     PVOID Address,
     PMEMORY_BASIC_INFORMATION Info,
-    PSIZE_T ResultLength
+    PULONG ResultLength
 );
 
 NTSTATUS
@@ -1688,8 +1642,8 @@ MiQueryVirtualMemory(
     IN PVOID Address,
     IN MEMORY_INFORMATION_CLASS VirtualMemoryInformationClass,
     OUT PVOID VirtualMemoryInformation,
-    IN SIZE_T Length,
-    OUT PSIZE_T ResultLength
+    IN ULONG Length,
+    OUT PULONG ResultLength
 );
 
 /* sysldr.c ******************************************************************/
@@ -1788,5 +1742,3 @@ MmGetKernelAddressSpace(VOID)
 {
     return MmKernelAddressSpace;
 }
-
-#endif