Author: arty
Date: Wed Nov 11 16:14:32 2009
New Revision: 44106
URL:
http://svn.reactos.org/svn/reactos?rev=44106&view=rev
Log:
Wide page tables.
Added:
branches/arty-newcc/ntoskrnl/mm/section/sptab.c (with props)
Modified:
branches/arty-newcc/ntoskrnl/include/internal/newmm.h
branches/arty-newcc/ntoskrnl/mm/section/data.c
branches/arty-newcc/ntoskrnl/mm/section/image.c
branches/arty-newcc/ntoskrnl/mm/section/pagefile.c
branches/arty-newcc/ntoskrnl/ntoskrnl-generic.rbuild
Modified: branches/arty-newcc/ntoskrnl/include/internal/newmm.h
URL:
http://svn.reactos.org/svn/reactos/branches/arty-newcc/ntoskrnl/include/int…
==============================================================================
--- branches/arty-newcc/ntoskrnl/include/internal/newmm.h [iso-8859-1] (original)
+++ branches/arty-newcc/ntoskrnl/include/internal/newmm.h [iso-8859-1] Wed Nov 11 16:14:32
2009
@@ -256,16 +256,6 @@
#define InterlockedExchangePte(PointerPte, Value) \
InterlockedExchange((PLONG)(PointerPte), Value)
-typedef struct
-{
- ULONG Entry[NR_SECTION_PAGE_ENTRIES];
-} SECTION_PAGE_TABLE, *PSECTION_PAGE_TABLE;
-
-typedef struct
-{
- PSECTION_PAGE_TABLE PageTables[NR_SECTION_PAGE_TABLES];
-} SECTION_PAGE_DIRECTORY, *PSECTION_PAGE_DIRECTORY;
-
typedef struct _MM_SECTION_SEGMENT
{
FAST_MUTEX Lock; /* lock which protects the page directory */
@@ -276,7 +266,6 @@
ULONG Protection;
ULONG Flags;
BOOLEAN WriteCopy;
- SECTION_PAGE_DIRECTORY PageDirectory;
struct
{
@@ -284,6 +273,8 @@
ULONG_PTR VirtualAddress; /* dtart offset into the address range for image sections */
ULONG Characteristics;
} Image;
+
+ RTL_GENERIC_TABLE PageTable;
} MM_SECTION_SEGMENT, *PMM_SECTION_SEGMENT;
typedef struct _MM_IMAGE_SECTION_OBJECT
@@ -517,7 +508,7 @@
{
PROS_SECTION_OBJECT Section;
PMM_SECTION_SEGMENT Segment;
- ULONG Offset;
+ LARGE_INTEGER Offset;
BOOLEAN WasDirty;
BOOLEAN Private;
}
@@ -1054,7 +1045,30 @@
MmDeleteKernelStack(PVOID Stack,
BOOLEAN GuiStack);
-/* balace.c ******************************************************************/
+/* sptab.c *******************************************************************/
+
+VOID
+NTAPI
+MiInitializeSectionPageTable(PMM_SECTION_SEGMENT Segment);
+
+NTSTATUS
+NTAPI
+MiSetPageEntrySectionSegment
+(PMM_SECTION_SEGMENT Segment,
+ PLARGE_INTEGER Offset,
+ ULONG Entry);
+
+ULONG
+NTAPI
+MiGetPageEntrySectionSegment
+(PMM_SECTION_SEGMENT Segment,
+ PLARGE_INTEGER Offset);
+
+VOID
+NTAPI
+MiFreePageTablesSectionSegment(PMM_SECTION_SEGMENT Segment);
+
+/* balance.c ******************************************************************/
VOID
NTAPI
@@ -1699,21 +1713,16 @@
VOID
MmPageOutDeleteMapping(PVOID Context, PEPROCESS Process, PVOID Address);
-ULONG
-NTAPI
-MmGetPageEntrySectionSegment(PMM_SECTION_SEGMENT Segment,
- ULONG Offset);
-
VOID
NTAPI
MmSharePageEntrySectionSegment(PMM_SECTION_SEGMENT Segment,
- ULONG Offset);
+ PLARGE_INTEGER Offset);
BOOLEAN
NTAPI
MmUnsharePageEntrySectionSegment(PROS_SECTION_OBJECT Section,
PMM_SECTION_SEGMENT Segment,
- ULONG Offset,
+ PLARGE_INTEGER Offset,
BOOLEAN Dirty,
BOOLEAN PageOut);
Modified: branches/arty-newcc/ntoskrnl/mm/section/data.c
URL:
http://svn.reactos.org/svn/reactos/branches/arty-newcc/ntoskrnl/mm/section/…
==============================================================================
--- branches/arty-newcc/ntoskrnl/mm/section/data.c [iso-8859-1] (original)
+++ branches/arty-newcc/ntoskrnl/mm/section/data.c [iso-8859-1] Wed Nov 11 16:14:32 2009
@@ -86,21 +86,6 @@
/* Note: Mmsp prefix denotes "Memory Manager Section Private". */
-
-VOID
-NTAPI
-MiFreePageTablesSectionSegment(PMM_SECTION_SEGMENT Segment)
-{
- ULONG i;
- for (i = 0; i < NR_SECTION_PAGE_TABLES; i++)
- {
- if (Segment->PageDirectory.PageTables[i] != NULL)
- {
- ExFreePool(Segment->PageDirectory.PageTables[i]);
- }
- }
-}
-
/*
* FUNCTION: Waits in kernel mode up to ten seconds for an MM_PAGEOP event.
* ARGUMENTS: PMM_PAGEOP which event we should wait for.
@@ -153,69 +138,12 @@
VOID
NTAPI
-MmSetPageEntrySectionSegment(PMM_SECTION_SEGMENT Segment,
- ULONG Offset,
- ULONG Entry)
-{
- PSECTION_PAGE_TABLE Table;
- ULONG DirectoryOffset;
- ULONG TableOffset;
-
- DirectoryOffset = PAGE_TO_SECTION_PAGE_DIRECTORY_OFFSET(Offset);
- Table = Segment->PageDirectory.PageTables[DirectoryOffset];
- if (Table == NULL)
- {
- Table =
- Segment->PageDirectory.PageTables[DirectoryOffset] =
- ExAllocatePoolWithTag(NonPagedPool, sizeof(SECTION_PAGE_TABLE),
- TAG_SECTION_PAGE_TABLE);
- if (Table == NULL)
- {
- ASSERT(FALSE);
- }
- memset(Table, 0, sizeof(SECTION_PAGE_TABLE));
- DPRINT("Table %x\n", Table);
- }
- TableOffset = PAGE_TO_SECTION_PAGE_TABLE_OFFSET(Offset);
- Table->Entry[TableOffset] = Entry;
-}
-
-
-ULONG
-NTAPI
-MmGetPageEntrySectionSegment(PMM_SECTION_SEGMENT Segment,
- ULONG Offset)
-{
- PSECTION_PAGE_TABLE Table;
+MmSharePageEntrySectionSegment(PMM_SECTION_SEGMENT Segment,
+ PLARGE_INTEGER Offset)
+{
ULONG Entry;
- ULONG DirectoryOffset;
- ULONG TableOffset;
-
- //DPRINT("MmGetPageEntrySection(Segment %x, Offset %x)\n", Segment,
Offset);
-
- DirectoryOffset = PAGE_TO_SECTION_PAGE_DIRECTORY_OFFSET(Offset);
- Table = Segment->PageDirectory.PageTables[DirectoryOffset];
- if (Table == NULL)
- {
- return(0);
- }
-
- TableOffset = PAGE_TO_SECTION_PAGE_TABLE_OFFSET(Offset);
- Entry = Table->Entry[TableOffset];
-
- //DPRINT("MmGetPageEntrySection(%p,%x) -> %x\n", Segment, Offset,
Entry);
-
- return(Entry);
-}
-
-VOID
-NTAPI
-MmSharePageEntrySectionSegment(PMM_SECTION_SEGMENT Segment,
- ULONG Offset)
-{
- ULONG Entry;
-
- Entry = MmGetPageEntrySectionSegment(Segment, Offset);
+
+ Entry = MiGetPageEntrySectionSegment(Segment, Offset);
if (Entry == 0)
{
DPRINT1("Entry == 0 for MmSharePageEntrySectionSegment\n");
@@ -231,14 +159,14 @@
ASSERT(FALSE);
}
Entry = MAKE_SSE(PAGE_FROM_SSE(Entry), SHARE_COUNT_FROM_SSE(Entry) + 1);
- MmSetPageEntrySectionSegment(Segment, Offset, Entry);
+ MiSetPageEntrySectionSegment(Segment, Offset, Entry);
}
BOOLEAN
NTAPI
MmUnsharePageEntrySectionSegment(PROS_SECTION_OBJECT Section,
PMM_SECTION_SEGMENT Segment,
- ULONG Offset,
+ PLARGE_INTEGER Offset,
BOOLEAN Dirty,
BOOLEAN PageOut)
{
@@ -246,7 +174,7 @@
DPRINT("MmUnsharePageEntrySectionSegment(%p,%x,Type %x)\n", Segment, Offset,
Segment->Flags);
- Entry = MmGetPageEntrySectionSegment(Segment, Offset);
+ Entry = MiGetPageEntrySectionSegment(Segment, Offset);
if (Entry == 0)
{
DPRINT1("Entry == 0 for MmUnsharePageEntrySectionSegment\n");
@@ -272,16 +200,13 @@
SWAPENTRY SavedSwapEntry;
PFN_TYPE Page;
NTSTATUS Status;
- LARGE_INTEGER FileOffset;
-
- FileOffset.QuadPart = Offset;
Page = PFN_FROM_SSE(Entry);
FileObject = Section->FileObject;
if (MmIsDirtyPageRmap(Page))
{
- Status = MiWriteBackPage(FileObject, &FileOffset, PAGE_SIZE, Page);
+ Status = MiWriteBackPage(FileObject, Offset, PAGE_SIZE, Page);
if (!NT_SUCCESS(Status))
{
DPRINT1("CcRosUnmapCacheSegment failed, status = %x\n", Status);
@@ -293,13 +218,13 @@
SavedSwapEntry = MmGetSavedSwapEntryPage(Page);
if (SavedSwapEntry == 0)
{
- MmSetPageEntrySectionSegment(Segment, Offset, 0);
+ MiSetPageEntrySectionSegment(Segment, Offset, 0);
MmReleasePageMemoryConsumer(MC_USER, Page);
}
}
else
{
- MmSetPageEntrySectionSegment(Segment, Offset, Entry);
+ MiSetPageEntrySectionSegment(Segment, Offset, Entry);
}
DPRINT("MmUnsharePageEntrySectionSegment(%p,%x) -> Done\n", Segment,
Offset);
return(SHARE_COUNT_FROM_SSE(Entry) > 0);
@@ -440,7 +365,7 @@
*/
MmLockSectionSegment(Segment);
- Entry = MmGetPageEntrySectionSegment(Segment, TotalOffset.QuadPart);
+ Entry = MiGetPageEntrySectionSegment(Segment, &TotalOffset);
HasSwapEntry = MmIsPageSwapEntry(Process, (PVOID)PAddress);
DPRINT("Entry %x HasSwapEntry %x Offset %x\n", Entry, HasSwapEntry,
TotalOffset.QuadPart);
@@ -461,7 +386,7 @@
}
MmLockSectionSegment(Segment);
- Entry = MmGetPageEntrySectionSegment(Segment, TotalOffset.QuadPart);
+ Entry = MiGetPageEntrySectionSegment(Segment, &TotalOffset);
if (Entry != 0) // Handled elsewhere
{
@@ -568,7 +493,7 @@
* Check the entry. No one should change the status of a page
* that has a pending page-in.
*/
- Entry1 = MmGetPageEntrySectionSegment(Segment, TotalOffset.QuadPart);
+ Entry1 = MiGetPageEntrySectionSegment(Segment, &TotalOffset);
if (Entry != Entry1)
{
DPRINT1("Someone changed ppte entry while we slept\n");
@@ -580,7 +505,7 @@
* data
*/
Entry = MAKE_SSE(Page << PAGE_SHIFT, 1);
- MmSetPageEntrySectionSegment(Segment, TotalOffset.QuadPart, Entry);
+ MiSetPageEntrySectionSegment(Segment, &TotalOffset, Entry);
MmInsertRmap(Page, Process, (PVOID)PAddress);
MmSetCleanAllRmaps(Page);
@@ -614,7 +539,7 @@
Page = PFN_FROM_SSE(Entry);
- MmSharePageEntrySectionSegment(Segment, TotalOffset.QuadPart);
+ MmSharePageEntrySectionSegment(Segment, &TotalOffset);
Status = MmCreateVirtualMapping(Process,
Address,
@@ -670,7 +595,7 @@
PFN_TYPE NewPage;
NTSTATUS Status;
PVOID PAddress;
- ULONG Offset;
+ LARGE_INTEGER Offset;
PMM_REGION Region;
ULONG Entry;
PEPROCESS Process = MmGetAddressSpaceOwner(AddressSpace);
@@ -691,8 +616,8 @@
* Find the offset of the page
*/
PAddress = MM_ROUND_DOWN(Address, PAGE_SIZE);
- Offset = (ULONG_PTR)PAddress - (ULONG_PTR)MemoryArea->StartingAddress
- + MemoryArea->Data.SectionData.ViewOffset;
+ Offset.QuadPart = (ULONG_PTR)PAddress - (ULONG_PTR)MemoryArea->StartingAddress
+ + MemoryArea->Data.SectionData.ViewOffset;
Segment = MemoryArea->Data.SectionData.Segment;
Section = MemoryArea->Data.SectionData.Section;
@@ -705,7 +630,7 @@
MmLockSectionSegment(Segment);
OldPage = MmGetPfnForProcess(Process, Address);
- Entry = MmGetPageEntrySectionSegment(Segment, Offset);
+ Entry = MiGetPageEntrySectionSegment(Segment, &Offset);
/*
* Check if we are doing COW
@@ -779,7 +704,7 @@
*/
MmDeleteRmap(OldPage, Process, PAddress);
MmInsertRmap(NewPage, Process, PAddress);
- MmUnsharePageEntrySectionSegment(Section, Segment, Offset, FALSE, FALSE);
+ MmUnsharePageEntrySectionSegment(Section, Segment, &Offset, FALSE, FALSE);
MmUnlockSectionSegment(Segment);
DPRINT("Address 0x%.8X\n", Address);
@@ -795,19 +720,19 @@
PVOID Address,
PPFN_TYPE Page)
{
- ULONG Offset;
NTSTATUS Status;
ULONG Entry, Entry1;
SWAPENTRY SwapEntry;
PMM_REGION Region;
+ LARGE_INTEGER Offset;
PEPROCESS Process = MmGetAddressSpaceOwner(AddressSpace);
Address = MM_ROUND_DOWN(Address, PAGE_SIZE);
- Offset = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress;
+ Offset.QuadPart = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress;
Region = MmFindRegion(MemoryArea->StartingAddress,
&MemoryArea->Data.SectionData.RegionListHead,
Address, NULL);
- Entry = MmGetPageEntrySectionSegment(Segment, Offset);
+ Entry = MiGetPageEntrySectionSegment(Segment, &Offset);
SwapEntry = SWAPENTRY_FROM_SSE(Entry);
/*
@@ -839,7 +764,7 @@
* Check the entry. No one should change the status of a page
* that has a pending page-in.
*/
- Entry1 = MmGetPageEntrySectionSegment(Segment, Offset);
+ Entry1 = MiGetPageEntrySectionSegment(Segment, &Offset);
if (Entry != Entry1)
{
DPRINT1("Someone changed ppte entry while we slept\n");
@@ -851,7 +776,7 @@
* data
*/
Entry = MAKE_SSE(*Page << PAGE_SHIFT, 1);
- MmSetPageEntrySectionSegment(Segment, Offset, Entry);
+ MiSetPageEntrySectionSegment(Segment, &Offset, Entry);
MmUnlockSectionSegment(Segment);
/*
@@ -905,7 +830,7 @@
while (FileOffset.QuadPart < End.QuadPart)
{
PVOID Address;
- ULONG Entry = MmGetPageEntrySectionSegment(Segment, FileOffset.QuadPart);
+ ULONG Entry = MiGetPageEntrySectionSegment(Segment, &FileOffset);
if (Entry == 0)
{
if (!NT_SUCCESS(MmRequestPageMemoryConsumer(MC_USER, TRUE, &Page)))
@@ -917,7 +842,7 @@
Address = ((PCHAR)MemoryArea->StartingAddress) + FileOffset.QuadPart -
FirstMapped.QuadPart;
MmCreateVirtualMapping(NULL, Address, PAGE_READWRITE, &Page, 1);
MmInsertRmap(Page, NULL, Address);
- MmSetPageEntrySectionSegment(Segment, FileOffset.QuadPart, MAKE_SSE(Page <<
PAGE_SHIFT, 1));
+ MiSetPageEntrySectionSegment(Segment, &FileOffset, MAKE_SSE(Page <<
PAGE_SHIFT, 1));
}
FileOffset.QuadPart += PAGE_SIZE;
}
@@ -963,7 +888,7 @@
MmLockSectionSegment(PageOutContext->Segment);
MmUnsharePageEntrySectionSegment((PROS_SECTION_OBJECT)PageOutContext->Section,
PageOutContext->Segment,
- PageOutContext->Offset,
+ &PageOutContext->Offset,
PageOutContext->WasDirty,
TRUE);
MmUnlockSectionSegment(PageOutContext->Segment);
@@ -1005,15 +930,15 @@
Context.Segment = MemoryArea->Data.SectionData.Segment;
Context.Section = MemoryArea->Data.SectionData.Section;
- Context.Offset = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress;
- FileOffset.QuadPart = Context.Offset;
+ Context.Offset.QuadPart = (ULONG_PTR)Address -
(ULONG_PTR)MemoryArea->StartingAddress;
+ FileOffset = Context.Offset;
FileObject = Context.Section->FileObject;
/*
* Get the section segment entry and the physical address.
*/
- Entry = MmGetPageEntrySectionSegment(Context.Segment, Context.Offset);
+ Entry = MiGetPageEntrySectionSegment(Context.Segment, &Context.Offset);
if (!MmIsPagePresent(Process, Address))
{
DPRINT1("Trying to page out not-present page at (%d,0x%.8X).\n",
@@ -1132,7 +1057,7 @@
Process,
Address);
Entry = MAKE_SSE(Page << PAGE_SHIFT, 1);
- MmSetPageEntrySectionSegment(Context.Segment, Context.Offset, Entry);
+ MiSetPageEntrySectionSegment(Context.Segment, &Context.Offset, Entry);
}
MmUnlockAddressSpace(AddressSpace);
PageOp->Status = STATUS_UNSUCCESSFUL;
@@ -1178,7 +1103,7 @@
Process,
Address);
Entry = MAKE_SSE(Page << PAGE_SHIFT, 1);
- MmSetPageEntrySectionSegment(Context.Segment, Context.Offset, Entry);
+ MiSetPageEntrySectionSegment(Context.Segment, &Context.Offset, Entry);
}
MmUnlockAddressSpace(AddressSpace);
PageOp->Status = STATUS_UNSUCCESSFUL;
@@ -1208,7 +1133,7 @@
else
{
Entry = MAKE_SWAP_SSE(SwapEntry);
- MmSetPageEntrySectionSegment(Context.Segment, Context.Offset, Entry);
+ MiSetPageEntrySectionSegment(Context.Segment, &Context.Offset, Entry);
}
PageOp->Status = STATUS_SUCCESS;
@@ -1250,7 +1175,7 @@
/*
* Get the section segment entry and the physical address.
*/
- Entry = MmGetPageEntrySectionSegment(Segment, Offset.QuadPart);
+ Entry = MiGetPageEntrySectionSegment(Segment, &Offset);
if (!MmIsPagePresent(Process, Address))
{
DPRINT1("Trying to page out not-present page at (%d,0x%.8X).\n",
@@ -1376,9 +1301,9 @@
ULONG Entry;
FileOffset.QuadPart = PageAddress - BeginningAddress + ViewOffset.QuadPart;
Entry =
- MmGetPageEntrySectionSegment
+ MiGetPageEntrySectionSegment
(MemoryArea->Data.SectionData.Segment,
- FileOffset.QuadPart);
+ &FileOffset);
Page = PFN_FROM_SSE(Entry);
if (Entry != 0 && !IS_SWAP_FROM_SSE(Entry) && MmIsDirtyPageRmap(Page)
&&
FileOffset.QuadPart < FileSize->QuadPart)
@@ -1464,13 +1389,13 @@
Present = MmIsPagePresent(Process, Address);
if (DoCOW && Present)
{
- ULONG Offset;
+ LARGE_INTEGER Offset;
ULONG Entry;
PFN_TYPE Page;
- Offset = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress
+ Offset.QuadPart = (ULONG_PTR)Address -
(ULONG_PTR)MemoryArea->StartingAddress
+ MemoryArea->Data.SectionData.ViewOffset;
- Entry = MmGetPageEntrySectionSegment(Segment, Offset);
+ Entry = MiGetPageEntrySectionSegment(Segment, &Offset);
Page = MmGetPfnForProcess(Process, Address);
Protect = PAGE_READONLY;
@@ -1797,7 +1722,7 @@
Segment->RawLength = MaximumSize;
Segment->Length.QuadPart = PAGE_ROUND_UP(Segment->RawLength.QuadPart);
}
- RtlZeroMemory(&Segment->PageDirectory, sizeof(SECTION_PAGE_DIRECTORY));
+ MiInitializeSectionPageTable(Segment);
}
else
{
@@ -2320,7 +2245,7 @@
PageOp = MmCheckForPageOp(MemoryArea, NULL, NULL, Segment, Offset.QuadPart);
}
- Entry = MmGetPageEntrySectionSegment(Segment, Offset.QuadPart);
+ Entry = MiGetPageEntrySectionSegment(Segment, &Offset);
/*
* For a dirty, datafile, non-private page mark it as dirty in the
@@ -2356,7 +2281,7 @@
else
{
MmDeleteRmap(Page, Process, Address);
- MmUnsharePageEntrySectionSegment(Section, Segment, Offset.QuadPart, Dirty,
FALSE);
+ MmUnsharePageEntrySectionSegment(Section, Segment, &Offset, Dirty, FALSE);
}
}
}
@@ -2703,7 +2628,6 @@
BOOLEAN ExtendFile)
{
PMM_SECTION_SEGMENT Segment = Section->Segment;
- PSECTION_PAGE_TABLE PageTable = NULL;
LARGE_INTEGER OldSize;
DPRINT("Extend Segment %x\n", Segment);
@@ -2719,11 +2643,7 @@
{
NTSTATUS Status;
Status = IoSetInformation(Segment->FileObject, FileEndOfFileInformation,
sizeof(LARGE_INTEGER), NewSize);
- if (!NT_SUCCESS(Status))
- {
- if (PageTable) ExFreePool(PageTable);
- return Status;
- }
+ if (!NT_SUCCESS(Status)) return Status;
}
MmLockSectionSegment(Segment);
Modified: branches/arty-newcc/ntoskrnl/mm/section/image.c
URL:
http://svn.reactos.org/svn/reactos/branches/arty-newcc/ntoskrnl/mm/section/…
==============================================================================
--- branches/arty-newcc/ntoskrnl/mm/section/image.c [iso-8859-1] (original)
+++ branches/arty-newcc/ntoskrnl/mm/section/image.c [iso-8859-1] Wed Nov 11 16:14:32 2009
@@ -86,15 +86,15 @@
MmUnsharePageEntryImageSectionSegment
(PROS_SECTION_OBJECT Section,
PMM_SECTION_SEGMENT Segment,
- ULONG Offset,
+ PLARGE_INTEGER Offset,
BOOLEAN Dirty,
BOOLEAN PageOut)
{
ULONG Entry;
- DPRINT("MmUnsharePageEntrySectionSegment(%p,%x)\n", Segment, Offset);
-
- Entry = MmGetPageEntrySectionSegment(Segment, Offset);
+ DPRINT("MmUnsharePageEntrySectionSegment(%p,%x)\n", Segment,
Offset->u.LowPart);
+
+ Entry = MiGetPageEntrySectionSegment(Segment, Offset);
if (Entry == 0)
{
DPRINT1("Entry == 0 for MmUnsharePageEntrySectionSegment\n");
@@ -120,7 +120,7 @@
PFN_TYPE Page;
LARGE_INTEGER FileOffset;
- FileOffset.QuadPart = Offset + Segment->Image.FileOffset/*.QuadPart*/;
+ FileOffset.QuadPart = Offset->QuadPart +
Segment->Image.FileOffset/*.QuadPart*/;
Page = PFN_FROM_SSE(Entry);
@@ -136,11 +136,11 @@
* for this page. The pager thread can't page out a
* page without a rmap entry.
*/
- MmSetPageEntrySectionSegment(Segment, Offset, Entry);
+ MiSetPageEntrySectionSegment(Segment, Offset, Entry);
}
else
{
- MmSetPageEntrySectionSegment(Segment, Offset, 0);
+ MiSetPageEntrySectionSegment(Segment, Offset, 0);
MmReleasePageMemoryConsumer(MC_USER, Page);
}
}
@@ -165,7 +165,7 @@
ASSERT(FALSE);
}
}
- MmSetPageEntrySectionSegment(Segment, Offset,
MAKE_SWAP_SSE(SavedSwapEntry));
+ MiSetPageEntrySectionSegment(Segment, Offset,
MAKE_SWAP_SSE(SavedSwapEntry));
MmSetSavedSwapEntryPage(Page, 0);
}
MmReleasePageMemoryConsumer(MC_USER, Page);
@@ -179,9 +179,9 @@
}
else
{
- MmSetPageEntrySectionSegment(Segment, Offset, Entry);
- }
- DPRINT("MmUnsharePageEntrySectionSegment(%p,%x) -> Done\n", Segment,
Offset);
+ MiSetPageEntrySectionSegment(Segment, Offset, Entry);
+ }
+ DPRINT("MmUnsharePageEntrySectionSegment(%p,%x) -> Done\n", Segment,
Offset->u.LowPart);
return(SHARE_COUNT_FROM_SSE(Entry) > 0);
}
@@ -193,7 +193,7 @@
PVOID Address,
BOOLEAN Locked)
{
- ULONG Offset;
+ LARGE_INTEGER Offset;
PFN_TYPE Page;
NTSTATUS Status;
PVOID PAddress;
@@ -226,7 +226,7 @@
}
PAddress = MM_ROUND_DOWN(Address, PAGE_SIZE);
- Offset = (ULONG_PTR)PAddress - (ULONG_PTR)MemoryArea->StartingAddress;
+ Offset.QuadPart = (ULONG_PTR)PAddress - (ULONG_PTR)MemoryArea->StartingAddress;
Segment = MemoryArea->Data.SectionData.Segment;
Section = MemoryArea->Data.SectionData.Section;
@@ -239,13 +239,13 @@
*/
MmLockSectionSegment(Segment);
- Entry = MmGetPageEntrySectionSegment(Segment, Offset);
+ Entry = MiGetPageEntrySectionSegment(Segment, &Offset);
HasSwapEntry = MmIsPageSwapEntry(Process, (PVOID)PAddress);
- DPRINT("Entry %x HasSwapEntry %x Offset %x\n", Entry, HasSwapEntry, Offset);
-
- if (Entry == 0 && !HasSwapEntry && Offset <
PAGE_ROUND_UP(Segment->RawLength.QuadPart))
+ DPRINT("Entry %x HasSwapEntry %x Offset %x\n", Entry, HasSwapEntry,
Offset.u.LowPart);
+
+ if (Entry == 0 && !HasSwapEntry && Offset.QuadPart <
PAGE_ROUND_UP(Segment->RawLength.QuadPart))
{
- TotalOffset.QuadPart = Offset + Segment->Image.FileOffset/*.QuadPart*/;
+ TotalOffset.QuadPart = Offset.QuadPart + Segment->Image.FileOffset/*.QuadPart*/;
MmUnlockSectionSegment(Segment);
MmUnlockAddressSpace(AddressSpace);
@@ -258,7 +258,7 @@
}
MmLockSectionSegment(Segment);
- Entry = MmGetPageEntrySectionSegment(Segment, Offset);
+ Entry = MiGetPageEntrySectionSegment(Segment, &Offset);
if (Entry != 0) // Handled elsewhere
{
MmUnlockSectionSegment(Segment);
@@ -385,7 +385,7 @@
* Get the entry corresponding to the offset within the section
*/
DPRINT("MmNotPresentFaultSectionView -> MmGetPageEntrySectionSegment(%p,
%x)\n", Segment, Offset);
- Entry = MmGetPageEntrySectionSegment(Segment, Offset);
+ Entry = MiGetPageEntrySectionSegment(Segment, &Offset);
DPRINT("Got entry %x\n", Entry);
if (Entry == 0)
@@ -400,7 +400,7 @@
*/
MmUnlockAddressSpace(AddressSpace);
- if (Offset >= PAGE_ROUND_UP(Segment->RawLength.QuadPart))
+ if (Offset.QuadPart >= PAGE_ROUND_UP(Segment->RawLength.QuadPart))
{
Status = MmRequestPageMemoryConsumer(MC_USER, TRUE, &Page);
if (!NT_SUCCESS(Status))
@@ -453,7 +453,7 @@
* data
*/
Entry = MAKE_SSE(Page << PAGE_SHIFT, 1);
- MmSetPageEntrySectionSegment(Segment, Offset, Entry);
+ MiSetPageEntrySectionSegment(Segment, &Offset, Entry);
MmInsertRmap(Page, Process, (PVOID)PAddress);
@@ -485,7 +485,7 @@
Page = PFN_FROM_SSE(Entry);
- MmSharePageEntrySectionSegment(Segment, Offset);
+ MmSharePageEntrySectionSegment(Segment, &Offset);
Status = MmCreateVirtualMapping(Process,
Address,
@@ -534,8 +534,8 @@
Context.Segment = MemoryArea->Data.SectionData.Segment;
Context.Section = MemoryArea->Data.SectionData.Section;
- Context.Offset = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress;
- FileOffset.QuadPart = Context.Offset +
Context.Segment->Image.FileOffset/*.QuadPart*/;
+ Context.Offset.QuadPart = (ULONG_PTR)Address -
(ULONG_PTR)MemoryArea->StartingAddress;
+ FileOffset.QuadPart = Context.Offset.QuadPart +
Context.Segment->Image.FileOffset/*.QuadPart*/;
IsImageSection = Context.Section->AllocationAttributes & SEC_IMAGE ? TRUE :
FALSE;
@@ -549,7 +549,7 @@
* then note this is a direct mapped page.
*/
if ((FileOffset.QuadPart % PAGE_SIZE) == 0 &&
- (Context.Offset + PAGE_SIZE <= Context.Segment->RawLength.QuadPart ||
!IsImageSection))
+ (Context.Offset.QuadPart + PAGE_SIZE <=
Context.Segment->RawLength.QuadPart || !IsImageSection))
{
DirectMapped = TRUE;
}
@@ -559,7 +559,7 @@
* Get the section segment entry and the physical address.
*/
DPRINT("MmPageOutSectionView -> MmGetPageEntrySectionSegment(%p, %x)\n",
Context.Segment, Context.Offset);
- Entry = MmGetPageEntrySectionSegment(Context.Segment, Context.Offset);
+ Entry = MiGetPageEntrySectionSegment(Context.Segment, &Context.Offset);
if (!MmIsPagePresent(Process, Address))
{
DPRINT1("Trying to page out not-present page at (%d,0x%.8X).\n",
@@ -608,7 +608,7 @@
MmSetSavedSwapEntryPage(Page, 0);
if (SwapEntry != 0)
{
- MmSetPageEntrySectionSegment(Context.Segment, Context.Offset,
MAKE_SWAP_SSE(SwapEntry));
+ MiSetPageEntrySectionSegment(Context.Segment, &Context.Offset,
MAKE_SWAP_SSE(SwapEntry));
}
MmReleasePageMemoryConsumer(MC_USER, Page);
PageOp->Status = STATUS_SUCCESS;
@@ -715,7 +715,7 @@
Process,
Address);
Entry = MAKE_SSE(Page << PAGE_SHIFT, 1);
- MmSetPageEntrySectionSegment(Context.Segment, Context.Offset, Entry);
+ MiSetPageEntrySectionSegment(Context.Segment, &Context.Offset, Entry);
}
MmUnlockAddressSpace(AddressSpace);
PageOp->Status = STATUS_UNSUCCESSFUL;
@@ -761,7 +761,7 @@
Process,
Address);
Entry = MAKE_SSE(Page << PAGE_SHIFT, 1);
- MmSetPageEntrySectionSegment(Context.Segment, Context.Offset, Entry);
+ MiSetPageEntrySectionSegment(Context.Segment, &Context.Offset, Entry);
}
MmUnlockAddressSpace(AddressSpace);
PageOp->Status = STATUS_UNSUCCESSFUL;
@@ -776,7 +776,7 @@
MmSetSavedSwapEntryPage(Page, 0);
if (Context.Segment->Image.Characteristics & IMAGE_SCN_MEM_SHARED)
{
- MmSetPageEntrySectionSegment(Context.Segment, Context.Offset,
MAKE_SWAP_SSE(SwapEntry));
+ MiSetPageEntrySectionSegment(Context.Segment, &Context.Offset,
MAKE_SWAP_SSE(SwapEntry));
}
else
{
@@ -798,7 +798,7 @@
else
{
Entry = MAKE_SWAP_SSE(SwapEntry);
- MmSetPageEntrySectionSegment(Context.Segment, Context.Offset, Entry);
+ MiSetPageEntrySectionSegment(Context.Segment, &Context.Offset, Entry);
}
PageOp->Status = STATUS_SUCCESS;
@@ -1438,9 +1438,7 @@
ExInitializeFastMutex(&ImageSectionObject->Segments[i].Lock);
ImageSectionObject->Segments[i].Flags = MM_IMAGE_SEGMENT;
ImageSectionObject->Segments[i].ReferenceCount = 1;
-
- RtlZeroMemory(&ImageSectionObject->Segments[i].PageDirectory,
- sizeof(ImageSectionObject->Segments[i].PageDirectory));
+ MiInitializeSectionPageTable(&ImageSectionObject->Segments[i]);
}
ASSERT(NT_SUCCESS(Status));
@@ -1618,18 +1616,18 @@
MmpFreeSharedSegment(PMM_SECTION_SEGMENT Segment)
{
ULONG Length;
- ULONG Offset;
ULONG Entry;
ULONG SavedSwapEntry;
PFN_TYPE Page;
+ LARGE_INTEGER Offset;
Page = 0;
Length = PAGE_ROUND_UP(Segment->Length.QuadPart);
- for (Offset = 0; Offset < Length; Offset += PAGE_SIZE)
- {
- DPRINT("MmAlterViewAttributes -> MmGetPageEntrySectionSegment(%p,
%x)\n", Segment, Offset);
- Entry = MmGetPageEntrySectionSegment(Segment, Offset);
+ for (Offset.QuadPart = 0; Offset.QuadPart < Length; Offset.QuadPart += PAGE_SIZE)
+ {
+ DPRINT("MmAlterViewAttributes -> MmGetPageEntrySectionSegment(%p,
%x)\n", Segment, Offset.u.LowPart);
+ Entry = MiGetPageEntrySectionSegment(Segment, &Offset);
if (Entry)
{
if (IS_SWAP_FROM_SSE(Entry))
@@ -1647,7 +1645,7 @@
}
MmReleasePageMemoryConsumer(MC_USER, Page);
}
- MmSetPageEntrySectionSegment(Segment, Offset, 0);
+ MiSetPageEntrySectionSegment(Segment,& Offset, 0);
}
}
}
@@ -1784,10 +1782,10 @@
{
ULONG Entry;
PFILE_OBJECT FileObject;
- ULONG Offset;
SWAPENTRY SavedSwapEntry;
PMM_PAGEOP PageOp;
NTSTATUS Status;
+ LARGE_INTEGER Offset;
PROS_SECTION_OBJECT Section;
PMM_SECTION_SEGMENT Segment;
PMMSUPPORT AddressSpace;
@@ -1798,13 +1796,13 @@
Address = (PVOID)PAGE_ROUND_DOWN(Address);
- Offset = ((ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress) +
+ Offset.QuadPart = ((ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress) +
MemoryArea->Data.SectionData.ViewOffset;
Section = MemoryArea->Data.SectionData.Section;
Segment = MemoryArea->Data.SectionData.Segment;
- PageOp = MmCheckForPageOp(MemoryArea, NULL, NULL, Segment, Offset);
+ PageOp = MmCheckForPageOp(MemoryArea, NULL, NULL, Segment, Offset.QuadPart);
while (PageOp)
{
@@ -1821,11 +1819,11 @@
MmLockAddressSpace(AddressSpace);
MmLockSectionSegment(Segment);
MmspCompleteAndReleasePageOp(PageOp);
- PageOp = MmCheckForPageOp(MemoryArea, NULL, NULL, Segment, Offset);
- }
-
- DPRINT("MmFreeSectionPage -> MmGetPageEntrySectionSegment(%p, %x)\n",
Segment, Offset);
- Entry = MmGetPageEntrySectionSegment(Segment, Offset);
+ PageOp = MmCheckForPageOp(MemoryArea, NULL, NULL, Segment, Offset.QuadPart);
+ }
+
+ DPRINT("MmFreeSectionPage -> MmGetPageEntrySectionSegment(%p, %x)\n",
Segment, Offset.u.LowPart);
+ Entry = MiGetPageEntrySectionSegment(Segment, &Offset);
/*
* For a dirty, datafile, non-private page mark it as dirty in the
@@ -1872,7 +1870,7 @@
else
{
MmDeleteRmap(Page, Process, Address);
- MmUnsharePageEntryImageSectionSegment(Section, Segment, Offset, Dirty, FALSE);
+ MmUnsharePageEntryImageSectionSegment(Section, Segment, &Offset, Dirty,
FALSE);
}
}
}
Modified: branches/arty-newcc/ntoskrnl/mm/section/pagefile.c
URL:
http://svn.reactos.org/svn/reactos/branches/arty-newcc/ntoskrnl/mm/section/…
==============================================================================
--- branches/arty-newcc/ntoskrnl/mm/section/pagefile.c [iso-8859-1] (original)
+++ branches/arty-newcc/ntoskrnl/mm/section/pagefile.c [iso-8859-1] Wed Nov 11 16:14:32
2009
@@ -62,10 +62,10 @@
PVOID Address,
BOOLEAN Locked)
{
- ULONG Offset;
PFN_TYPE Page;
NTSTATUS Status;
PVOID PAddress;
+ LARGE_INTEGER Offset;
PROS_SECTION_OBJECT Section;
PMM_SECTION_SEGMENT Segment;
ULONG Entry;
@@ -93,7 +93,7 @@
}
PAddress = MM_ROUND_DOWN(Address, PAGE_SIZE);
- Offset = (ULONG_PTR)PAddress - (ULONG_PTR)MemoryArea->StartingAddress;
+ Offset.QuadPart = (ULONG_PTR)PAddress - (ULONG_PTR)MemoryArea->StartingAddress;
Segment = MemoryArea->Data.SectionData.Segment;
Section = MemoryArea->Data.SectionData.Section;
@@ -122,7 +122,7 @@
/*
* Get or create a page operation descriptor
*/
- PageOp = MmGetPageOp(MemoryArea, NULL, 0, Segment, Offset, MM_PAGEOP_PAGEIN, FALSE);
+ PageOp = MmGetPageOp(MemoryArea, NULL, 0, Segment, Offset.QuadPart, MM_PAGEOP_PAGEIN,
FALSE);
if (PageOp == NULL)
{
DPRINT1("MmGetPageOp failed\n");
@@ -181,7 +181,7 @@
{
DPRINT("!MmIsPagePresent(%p, %p)\n", Process, Address);
- Entry = MmGetPageEntrySectionSegment(Segment, Offset);
+ Entry = MiGetPageEntrySectionSegment(Segment, &Offset);
HasSwapEntry = MmIsPageSwapEntry(Process, (PVOID)PAddress);
if (PAGE_FROM_SSE(Entry) == 0 || HasSwapEntry)
@@ -196,7 +196,7 @@
Page = PFN_FROM_SSE(Entry);
- MmSharePageEntrySectionSegment(Segment, Offset);
+ MmSharePageEntrySectionSegment(Segment, &Offset);
/* FIXME: Should we call MmCreateVirtualMappingUnsafe if
* (Section->AllocationAttributes & SEC_PHYSICALMEMORY) is true?
@@ -227,7 +227,7 @@
/*
* Get the entry corresponding to the offset within the section
*/
- Entry = MmGetPageEntrySectionSegment(Segment, Offset);
+ Entry = MiGetPageEntrySectionSegment(Segment, &Offset);
if (Entry == 0)
{
@@ -268,7 +268,7 @@
* Check the entry. No one should change the status of a page
* that has a pending page-in.
*/
- Entry1 = MmGetPageEntrySectionSegment(Segment, Offset);
+ Entry1 = MiGetPageEntrySectionSegment(Segment, &Offset);
if (Entry != Entry1)
{
DPRINT1("Someone changed ppte entry while we slept\n");
@@ -280,7 +280,7 @@
* data
*/
Entry = MAKE_SSE(Page << PAGE_SHIFT, 1);
- MmSetPageEntrySectionSegment(Segment, Offset, Entry);
+ MiSetPageEntrySectionSegment(Segment, &Offset, Entry);
MmUnlockSectionSegment(Segment);
MmInsertRmap(Page, Process, (PVOID)PAddress);
@@ -314,7 +314,7 @@
Page = PFN_FROM_SSE(Entry);
- MmSharePageEntrySectionSegment(Segment, Offset);
+ MmSharePageEntrySectionSegment(Segment, &Offset);
MmUnlockSectionSegment(Segment);
Status = MmCreateVirtualMapping(Process,
@@ -414,7 +414,7 @@
Segment->Length.QuadPart = PAGE_ROUND_UP(MaximumSize.QuadPart);
Segment->Flags = MM_PAGEFILE_SEGMENT;
Segment->WriteCopy = FALSE;
- RtlZeroMemory(&Segment->PageDirectory, sizeof(SECTION_PAGE_DIRECTORY));
+ MiInitializeSectionPageTable(Segment);
*SectionObject = Section;
return(STATUS_SUCCESS);
}
@@ -446,7 +446,7 @@
MmLockSectionSegment(PageOutContext->Segment);
MmUnsharePageEntrySectionSegment((PROS_SECTION_OBJECT)PageOutContext->Section,
PageOutContext->Segment,
- PageOutContext->Offset,
+ &PageOutContext->Offset,
PageOutContext->WasDirty,
TRUE);
MmUnlockSectionSegment(PageOutContext->Segment);
@@ -490,8 +490,8 @@
Context.Segment = MemoryArea->Data.SectionData.Segment;
Context.Section = MemoryArea->Data.SectionData.Section;
- Context.Offset = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress;
- FileOffset.QuadPart = Context.Offset;
+ Context.Offset.QuadPart = (ULONG_PTR)Address -
(ULONG_PTR)MemoryArea->StartingAddress;
+ FileOffset = Context.Offset;
IsImageSection = Context.Section->AllocationAttributes & SEC_IMAGE ? TRUE :
FALSE;
@@ -501,7 +501,7 @@
* Get the section segment entry and the physical address.
*/
DPRINT("MmPageOutSectionView -> MmGetPageEntrySectionSegment(%p, %x)\n",
Context.Segment, Context.Offset);
- Entry = MmGetPageEntrySectionSegment(Context.Segment, Context.Offset);
+ Entry = MiGetPageEntrySectionSegment(Context.Segment, &Context.Offset);
if (!MmIsPagePresent(Process, Address))
{
DPRINT1("Trying to page out not-present page at (%d,0x%.8X).\n",
@@ -608,7 +608,7 @@
Process,
Address);
Entry = MAKE_SSE(Page << PAGE_SHIFT, 1);
- MmSetPageEntrySectionSegment(Context.Segment, Context.Offset, Entry);
+ MiSetPageEntrySectionSegment(Context.Segment, &Context.Offset, Entry);
}
MmUnlockAddressSpace(AddressSpace);
PageOp->Status = STATUS_UNSUCCESSFUL;
@@ -654,7 +654,7 @@
Process,
Address);
Entry = MAKE_SSE(Page << PAGE_SHIFT, 1);
- MmSetPageEntrySectionSegment(Context.Segment, Context.Offset, Entry);
+ MiSetPageEntrySectionSegment(Context.Segment, &Context.Offset, Entry);
}
MmUnlockAddressSpace(AddressSpace);
PageOp->Status = STATUS_UNSUCCESSFUL;
@@ -684,7 +684,7 @@
else
{
Entry = MAKE_SWAP_SSE(SwapEntry);
- MmSetPageEntrySectionSegment(Context.Segment, Context.Offset, Entry);
+ MiSetPageEntrySectionSegment(Context.Segment, &Context.Offset, Entry);
}
PageOp->Status = STATUS_SUCCESS;
@@ -698,9 +698,9 @@
PFN_TYPE Page, SWAPENTRY SwapEntry, BOOLEAN Dirty)
{
ULONG Entry;
- ULONG Offset;
PMM_PAGEOP PageOp;
NTSTATUS Status;
+ LARGE_INTEGER Offset;
PROS_SECTION_OBJECT Section;
PMM_SECTION_SEGMENT Segment;
PMMSUPPORT AddressSpace;
@@ -711,13 +711,13 @@
Address = (PVOID)PAGE_ROUND_DOWN(Address);
- Offset = ((ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress) +
+ Offset.QuadPart = ((ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress) +
MemoryArea->Data.SectionData.ViewOffset;
Section = MemoryArea->Data.SectionData.Section;
Segment = MemoryArea->Data.SectionData.Segment;
- PageOp = MmCheckForPageOp(MemoryArea, NULL, NULL, Segment, Offset);
+ PageOp = MmCheckForPageOp(MemoryArea, NULL, NULL, Segment, Offset.QuadPart);
while (PageOp)
{
@@ -734,16 +734,16 @@
MmLockAddressSpace(AddressSpace);
MmLockSectionSegment(Segment);
MmspCompleteAndReleasePageOp(PageOp);
- PageOp = MmCheckForPageOp(MemoryArea, NULL, NULL, Segment, Offset);
- }
-
- DPRINT("MmFreeSectionPage -> MmGetPageEntrySectionSegment(%p, %x)\n",
Segment, Offset);
- Entry = MmGetPageEntrySectionSegment(Segment, Offset);
+ PageOp = MmCheckForPageOp(MemoryArea, NULL, NULL, Segment, Offset.QuadPart);
+ }
+
+ DPRINT("MmFreeSectionPage -> MmGetPageEntrySectionSegment(%p, %x)\n",
Segment, Offset.u.LowPart);
+ Entry = MiGetPageEntrySectionSegment(Segment, &Offset);
if (Page != 0)
{
MmDeleteRmap(Page, Process, Address);
- MmUnsharePageEntrySectionSegment(Section, Segment, Offset, Dirty, FALSE);
+ MmUnsharePageEntrySectionSegment(Section, Segment, &Offset, Dirty, FALSE);
}
}
Added: branches/arty-newcc/ntoskrnl/mm/section/sptab.c
URL:
http://svn.reactos.org/svn/reactos/branches/arty-newcc/ntoskrnl/mm/section/…
==============================================================================
--- branches/arty-newcc/ntoskrnl/mm/section/sptab.c (added)
+++ branches/arty-newcc/ntoskrnl/mm/section/sptab.c [iso-8859-1] Wed Nov 11 16:14:32 2009
@@ -1,0 +1,202 @@
+/*
+ * Copyright (C) 1998-2005 ReactOS Team (and the authors from the programmers section)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * PROJECT: ReactOS kernel
+ * FILE: ntoskrnl/mm/section.c
+ * PURPOSE: Section object page tables
+ *
+ * PROGRAMMERS: arty
+ */
+
+/* INCLUDES *****************************************************************/
+
+#include <ntoskrnl.h>
+#define NDEBUG
+#include <debug.h>
+
+/* TYPES *********************************************************************/
+
+#define ENTRIES_PER_ELEMENT 244
+
+PVOID NTAPI RtlGetElementGenericTable(PRTL_GENERIC_TABLE Table, PVOID Data);
+ULONG NTAPI RtlNumberGenericTableElements(PRTL_GENERIC_TABLE Table);
+
+typedef struct _SECTION_PAGE_TABLE
+{
+ LARGE_INTEGER FileOffset;
+ ULONG Refcount;
+ ULONG PageEntries[ENTRIES_PER_ELEMENT];
+} SECTION_PAGE_TABLE, *PSECTION_PAGE_TABLE;
+
+SECTION_PAGE_TABLE MiSectionZeroPageTable = { };
+
+static
+PVOID
+NTAPI
+MiSectionPageTableAllocate(PRTL_GENERIC_TABLE Table, CLONG Bytes)
+{
+ PVOID Result;
+ Result = ExAllocatePoolWithTag(NonPagedPool, Bytes, 'MmPt');
+ DPRINT("MiSectionPageTableAllocate(%d) => %p\n", Bytes, Result);
+ return Result;
+}
+
+static
+VOID
+NTAPI
+MiSectionPageTableFree(PRTL_GENERIC_TABLE Table, PVOID Data)
+{
+ DPRINT("MiSectionPageTableFree(%p)\n", Data);
+ ExFreePoolWithTag(Data, 'MmPt');
+}
+
+static
+RTL_GENERIC_COMPARE_RESULTS
+NTAPI
+MiSectionPageTableCompare(PRTL_GENERIC_TABLE Table, PVOID PtrA, PVOID PtrB)
+{
+ PLARGE_INTEGER A = PtrA, B = PtrB;
+ BOOLEAN Result = (A->QuadPart < B->QuadPart) ? GenericLessThan :
+ (A->QuadPart == B->QuadPart) ? GenericEqual : GenericGreaterThan;
+
+ DPRINT
+ ("Compare: %08x%08x vs %08x%08x => %s\n",
+ A->u.HighPart, A->u.LowPart,
+ B->u.HighPart, B->u.LowPart,
+ Result == GenericLessThan ? "GenericLessThan" :
+ Result == GenericGreaterThan ? "GenericGreaterThan" :
+ "GenericEqual");
+
+ return Result;
+}
+
+static
+PSECTION_PAGE_TABLE
+NTAPI
+MiSectionPageTableGet
+(PRTL_GENERIC_TABLE Table,
+ PLARGE_INTEGER FileOffset)
+{
+ LARGE_INTEGER SearchFileOffset;
+ SearchFileOffset.QuadPart = ROUND_DOWN(FileOffset->QuadPart, ENTRIES_PER_ELEMENT *
PAGE_SIZE);
+ return RtlLookupElementGenericTable(Table, &SearchFileOffset);
+}
+
+static
+PSECTION_PAGE_TABLE
+NTAPI
+MiSectionPageTableGetOrAllocate
+(PRTL_GENERIC_TABLE Table,
+ PLARGE_INTEGER FileOffset)
+{
+ LARGE_INTEGER SearchFileOffset;
+ PSECTION_PAGE_TABLE PageTableSlice =
+ MiSectionPageTableGet(Table, FileOffset);
+ if (!PageTableSlice)
+ {
+ SearchFileOffset.QuadPart = ROUND_DOWN(FileOffset->QuadPart,
ENTRIES_PER_ELEMENT * PAGE_SIZE);
+ MiSectionZeroPageTable.FileOffset = SearchFileOffset;
+ MiSectionZeroPageTable.Refcount = 1;
+ PageTableSlice = RtlInsertElementGenericTable
+ (Table, &MiSectionZeroPageTable, sizeof(MiSectionZeroPageTable), NULL);
+ DPRINT
+ ("Allocate page table %x (%08x%08x)\n",
+ PageTableSlice,
+ PageTableSlice->FileOffset.u.HighPart,
+ PageTableSlice->FileOffset.u.LowPart);
+ if (!PageTableSlice) return NULL;
+ }
+ return PageTableSlice;
+}
+
+VOID
+NTAPI
+MiInitializeSectionPageTable(PMM_SECTION_SEGMENT Segment)
+{
+ RtlInitializeGenericTable
+ (&Segment->PageTable,
+ MiSectionPageTableCompare,
+ MiSectionPageTableAllocate,
+ MiSectionPageTableFree,
+ NULL);
+ DPRINT("MiInitializeSectionPageTable(%p)\n", &Segment->PageTable);
+}
+
+NTSTATUS
+NTAPI
+MiSetPageEntrySectionSegment
+(PMM_SECTION_SEGMENT Segment,
+ PLARGE_INTEGER Offset,
+ ULONG Entry)
+{
+ ULONG PageIndex;
+ PSECTION_PAGE_TABLE PageTable;
+ PageTable =
+ MiSectionPageTableGetOrAllocate(&Segment->PageTable, Offset);
+ if (!PageTable) return STATUS_NO_MEMORY;
+ PageIndex =
+ (Offset->QuadPart - PageTable->FileOffset.QuadPart) / PAGE_SIZE;
+ PageTable->PageEntries[PageIndex] = Entry;
+ DPRINT
+ ("MiSetPageEntrySectionSegment(%p,%08x%08x,%x)\n",
+ &Segment->PageTable, Offset->u.HighPart, Offset->u.LowPart,
Entry);
+ return STATUS_SUCCESS;
+}
+
+ULONG
+NTAPI
+MiGetPageEntrySectionSegment
+(PMM_SECTION_SEGMENT Segment,
+ PLARGE_INTEGER Offset)
+{
+ LARGE_INTEGER FileOffset;
+ ULONG PageIndex, Result;
+ PSECTION_PAGE_TABLE PageTable;
+
+ FileOffset.QuadPart =
+ ROUND_DOWN(Offset->QuadPart, ENTRIES_PER_ELEMENT * PAGE_SIZE);
+ PageTable = MiSectionPageTableGet(&Segment->PageTable, &FileOffset);
+ if (!PageTable) return 0;
+ PageIndex =
+ (Offset->QuadPart - PageTable->FileOffset.QuadPart) / PAGE_SIZE;
+ Result = PageTable->PageEntries[PageIndex];
+ DPRINT
+ ("MiGetPageEntrySectionSegment(%p,%08x%08x) => %x\n",
+ &Segment->PageTable,
+ FileOffset.u.HighPart,
+ FileOffset.u.LowPart,
+ Result);
+ return Result;
+}
+
+VOID
+NTAPI
+MiFreePageTablesSectionSegment(PMM_SECTION_SEGMENT Segment)
+{
+ PSECTION_PAGE_TABLE Element;
+ DPRINT("MiFreePageTablesSectionSegment(%p)\n",
&Segment->PageTable);
+ while (RtlNumberGenericTableElements(&Segment->PageTable) &&
+ (Element = RtlGetElementGenericTable(&Segment->PageTable, 0)))
+ {
+ DPRINT
+ ("Delete table for %08x%08x\n",
+ Element->FileOffset.u.HighPart,
+ Element->FileOffset.u.LowPart);
+ RtlDeleteElementGenericTable(&Segment->PageTable, Element);
+ }
+}
Propchange: branches/arty-newcc/ntoskrnl/mm/section/sptab.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: branches/arty-newcc/ntoskrnl/ntoskrnl-generic.rbuild
URL:
http://svn.reactos.org/svn/reactos/branches/arty-newcc/ntoskrnl/ntoskrnl-ge…
==============================================================================
--- branches/arty-newcc/ntoskrnl/ntoskrnl-generic.rbuild [iso-8859-1] (original)
+++ branches/arty-newcc/ntoskrnl/ntoskrnl-generic.rbuild [iso-8859-1] Wed Nov 11 16:14:32
2009
@@ -457,6 +457,7 @@
<file>pagefile.c</file>
<file>pe.c</file>
<file>physical.c</file>
+ <file>sptab.c</file>
</directory>
</if>
</directory>