Author: fireball
Date: Sun Mar 9 16:15:12 2008
New Revision: 32630
URL:
http://svn.reactos.org/svn/reactos?rev=3D32630&view=3Drev
Log:
- Move MiGetPfnEntry into arch-independent mm.h header, along with a few de=
fines, structures, and function prototypes which are going to be used with =
the new pool implementation in future.
- Add two new fields into PHYSICAL_PAGE structure, they will be used (in th=
e future new pool implementation) to find end/start of a non-paged pool all=
ocation without storing the actual pointers (based on NTs own PFN entry opt=
imization for this) - thanks to Alex for providing this great idea!
Modified:
trunk/reactos/ntoskrnl/include/internal/mm.h
trunk/reactos/ntoskrnl/mm/freelist.c
Modified: trunk/reactos/ntoskrnl/include/internal/mm.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/inte=
rnal/mm.h?rev=3D32630&r1=3D32629&r2=3D32630&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/ntoskrnl/include/internal/mm.h (original)
+++ trunk/reactos/ntoskrnl/include/internal/mm.h Sun Mar 9 16:15:12 2008
@@ -55,6 +55,12 @@
#define MM_PAGEOP_PAGEOUT (2)
#define MM_PAGEOP_PAGESYNCH (3)
#define MM_PAGEOP_ACCESSFAULT (4)
+
+/* Number of list heads to use */
+#define MI_FREE_POOL_LISTS 4
+
+/* Signature of free pool blocks */
+#define MM_FREE_POOL_TAG TAG('F', 'r', 'p', 'l')
=
#define PAGE_TO_SECTION_PAGE_DIRECTORY_OFFSET(x) \
((x) / (4*1024*1024))
@@ -275,6 +281,8 @@
ULONG Type: 2;
ULONG Consumer: 3;
ULONG Zero: 1;
+ ULONG StartOfAllocation: 1;
+ ULONG EndOfAllocation: 1;
}
Flags;
ULONG AllFlags;
@@ -337,6 +345,28 @@
LIST_ENTRY RegionListEntry;
} MM_REGION, *PMM_REGION;
=
+/* Entry describing free pool memory */
+typedef struct _MMFREE_POOL_ENTRY
+{
+ LIST_ENTRY List;
+ PFN_NUMBER Size;
+ ULONG Signature;
+ struct _MMFREE_POOL_ENTRY *Owner;
+} MMFREE_POOL_ENTRY, *PMMFREE_POOL_ENTRY;
+
+/* Paged pool information */
+typedef struct _MM_PAGED_POOL_INFO
+{ =
+ PRTL_BITMAP PagedPoolAllocationMap;
+ PRTL_BITMAP EndOfPagedPoolBitmap;
+ PMMPTE FirstPteForPagedPool;
+ PMMPTE LastPteForPagedPool;
+ PMMPTE NextPdeForPagedPoolExpansion;
+ ULONG PagedPoolHint;
+ SIZE_T PagedPoolCommit;
+ SIZE_T AllocatedPagedPool;
+} MM_PAGED_POOL_INFO, *PMM_PAGED_POOL_INFO;
+
extern MM_MEMORY_CONSUMER MiMemoryConsumers[MC_MAXIMUM];
=
typedef VOID
@@ -489,6 +519,25 @@
=
PVOID
NTAPI
+MiAllocatePoolPages(
+ IN POOL_TYPE PoolType,
+ IN SIZE_T SizeInBytes
+);
+
+POOL_TYPE
+NTAPI
+MmDeterminePoolType(
+ IN PVOID VirtualAddress
+);
+
+ULONG
+NTAPI
+MiFreePoolPages(
+ IN PVOID StartingAddress
+);
+
+PVOID
+NTAPI
MmGetMdlPageAddress(
PMDL Mdl,
PVOID Offset
@@ -935,6 +984,29 @@
MmPageOutPhysicalAddress(PFN_TYPE Page);
=
/* freelist.c **********************************************************/
+
+#define ASSERT_PFN(x) ASSERT((x)->Flags.Type !=3D 0)
+
+FORCEINLINE
+PPHYSICAL_PAGE
+MiGetPfnEntry(IN PFN_TYPE Pfn)
+{
+ PPHYSICAL_PAGE Page;
+ extern PPHYSICAL_PAGE MmPageArray;
+ extern ULONG MmPageArraySize;
+
+ /* Make sure the PFN number is valid */
+ ASSERT(Pfn <=3D MmPageArraySize);
+
+ /* Get the entry */
+ Page =3D &MmPageArray[Pfn];
+
+ /* Make sure it's valid */
+ ASSERT_PFN(Page);
+
+ /* Return it */
+ return Page;
+};
=
PFN_TYPE
NTAPI
Modified: trunk/reactos/ntoskrnl/mm/freelist.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/freelist.=
c?rev=3D32630&r1=3D32629&r2=3D32630&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/ntoskrnl/mm/freelist.c (original)
+++ trunk/reactos/ntoskrnl/mm/freelist.c Sun Mar 9 16:15:12 2008
@@ -25,12 +25,9 @@
#define MM_PHYSICAL_PAGE_USED (0x2)
#define MM_PHYSICAL_PAGE_BIOS (0x3)
=
-
-#define ASSERT_PFN(x) ASSERT((x)->Flags.Type !=3D 0)
-
/* GLOBALS ***************************************************************=
*/
=
-static PPHYSICAL_PAGE MmPageArray;
+PPHYSICAL_PAGE MmPageArray;
ULONG MmPageArraySize;
=
static KSPIN_LOCK PageListLock;
@@ -44,25 +41,6 @@
static ULONG UnzeroedPageCount =3D 0;
=
/* FUNCTIONS *************************************************************/
-
-FORCEINLINE
-PPHYSICAL_PAGE
-MiGetPfnEntry(IN PFN_TYPE Pfn)
-{
- PPHYSICAL_PAGE Page;
-
- /* Make sure the PFN number is valid */
- ASSERT(Pfn <=3D MmPageArraySize);
-
- /* Get the entry */
- Page =3D &MmPageArray[Pfn];
-
- /* Make sure it's valid */
- ASSERT_PFN(Page);
-
- /* Return it */
- return Page;
-}
=
PFN_TYPE
NTAPI