https://git.reactos.org/?p=reactos.git;a=commitdiff;h=462d9a097483f6fdabeca…
commit 462d9a097483f6fdabeca18b7aa93b6b4bc9c993
Author: Jérôme Gardou <jerome.gardou(a)reactos.org>
AuthorDate: Fri Oct 23 16:16:51 2020 +0200
Commit: Jérôme Gardou <jerome.gardou(a)reactos.org>
CommitDate: Wed Feb 3 09:41:21 2021 +0100
[NTOSKRNL] Unload the cargo: We only use tiny bits of "NEWCC"
---
ntoskrnl/cache/section/data.c | 13 ++++++++-----
ntoskrnl/cache/section/fault.c | 6 ++++++
ntoskrnl/cache/section/io.c | 2 ++
ntoskrnl/include/internal/mm.h | 2 ++
ntoskrnl/mm/ARM3/section.c | 9 +++++++++
ntoskrnl/mm/marea.c | 10 ++++++++++
ntoskrnl/mm/mmfault.c | 8 ++++----
ntoskrnl/mm/mminit.c | 5 +++++
ntoskrnl/mm/rmap.c | 2 ++
ntoskrnl/mm/section.c | 31 +++++++++++++++++++++++++++++--
ntoskrnl/ntos.cmake | 10 +++++-----
11 files changed, 82 insertions(+), 16 deletions(-)
diff --git a/ntoskrnl/cache/section/data.c b/ntoskrnl/cache/section/data.c
index cd92979ac1c..1ec6a3326d9 100644
--- a/ntoskrnl/cache/section/data.c
+++ b/ntoskrnl/cache/section/data.c
@@ -112,6 +112,7 @@ _MmUnlockSectionSegment(PMM_SECTION_SEGMENT Segment, const char *file,
int line)
//DPRINT("MmUnlockSectionSegment(%p,%s:%d)\n", Segment, file, line);
}
+#ifdef NEWCC
/*
MiFlushMappedSection
@@ -265,7 +266,6 @@ This deletes a segment entirely including its page map.
It must have been unmapped in every address space.
*/
-
VOID
NTAPI
MmFinalizeSegment(PMM_SECTION_SEGMENT Segment)
@@ -274,6 +274,8 @@ MmFinalizeSegment(PMM_SECTION_SEGMENT Segment)
DPRINT("Finalize segment %p\n", Segment);
+ __debugbreak();
+
MmLockSectionSegment(Segment);
RemoveEntryList(&Segment->ListOfSegments);
if (Segment->Flags & MM_DATAFILE_SEGMENT) {
@@ -303,7 +305,6 @@ MmFinalizeSegment(PMM_SECTION_SEGMENT Segment)
ExFreePoolWithTag(Segment, TAG_MM_SECTION_SEGMENT);
}
-#ifdef NEWCC
NTSTATUS
NTAPI
MmCreateCacheSection(PROS_SECTION_OBJECT *SectionObject,
@@ -534,7 +535,6 @@ MmCreateCacheSection(PROS_SECTION_OBJECT *SectionObject,
*SectionObject = Section;
return STATUS_SUCCESS;
}
-#endif
NTSTATUS
NTAPI
@@ -605,6 +605,7 @@ _MiMapViewOfSegment(PMMSUPPORT AddressSpace,
return STATUS_SUCCESS;
}
+#endif
/*
@@ -621,6 +622,8 @@ MiFreeSegmentPage(PMM_SECTION_SEGMENT Segment,
ULONG_PTR Entry;
PFILE_OBJECT FileObject = Segment->FileObject;
+ __debugbreak();
+
Entry = MmGetPageEntrySectionSegment(Segment, FileOffset);
DPRINTC("MiFreeSegmentPage(%p:%I64x -> Entry %Ix\n",
Segment,
@@ -710,6 +713,7 @@ MmFreeCacheSectionPage(PVOID Context,
}
}
+#ifdef NEWCC
NTSTATUS
NTAPI
MmUnmapViewOfCacheSegment(PMMSUPPORT AddressSpace,
@@ -755,7 +759,6 @@ MmUnmapViewOfCacheSegment(PMMSUPPORT AddressSpace,
return STATUS_SUCCESS;
}
-#ifdef NEWCC
NTSTATUS
NTAPI
MmExtendCacheSection(PROS_SECTION_OBJECT Section,
@@ -793,7 +796,6 @@ MmExtendCacheSection(PROS_SECTION_OBJECT Section,
MmUnlockSectionSegment(Segment);
return STATUS_SUCCESS;
}
-#endif
NTSTATUS
NTAPI
@@ -844,5 +846,6 @@ MmUnmapCacheViewInSystemSpace (IN PVOID MappedBase)
return Status;
}
+#endif /* NEWCC */
/* EOF */
diff --git a/ntoskrnl/cache/section/fault.c b/ntoskrnl/cache/section/fault.c
index c70805a71ae..e869dac88fb 100644
--- a/ntoskrnl/cache/section/fault.c
+++ b/ntoskrnl/cache/section/fault.c
@@ -82,6 +82,8 @@ rmaps, so each mapping should be immediately followed by an rmap
addition.
#define DPRINTC DPRINT
extern KEVENT MmWaitPageEvent;
+
+#ifdef NEWCC
extern PMMWSL MmWorkingSetList;
/*
@@ -150,6 +152,7 @@ MmNotPresentFaultCachePage (
if (Segment->FileObject)
{
+ __debugbreak();
DPRINT("FileName %wZ\n", &Segment->FileObject->FileName);
}
@@ -453,9 +456,11 @@ MiCowCacheSectionPage (
DPRINT("Address 0x%p\n", Address);
return STATUS_SUCCESS;
}
+#endif
KEVENT MmWaitPageEvent;
+#ifdef NEWCC
typedef struct _WORK_QUEUE_WITH_CONTEXT
{
WORK_QUEUE_ITEM WorkItem;
@@ -960,3 +965,4 @@ MmNotPresentFaultCacheSection(KPROCESSOR_MODE Mode,
return Status;
}
+#endif
diff --git a/ntoskrnl/cache/section/io.c b/ntoskrnl/cache/section/io.c
index 20454abb905..8ac93b06134 100644
--- a/ntoskrnl/cache/section/io.c
+++ b/ntoskrnl/cache/section/io.c
@@ -188,6 +188,7 @@ MiSimpleRead(PFILE_OBJECT FileObject,
return Status;
}
+#ifdef NEWCC
/*
Convenience function for writing from kernel space. This issues a paging
@@ -334,3 +335,4 @@ _MiWriteBackPage(PFILE_OBJECT FileObject,
return Status;
}
+#endif
diff --git a/ntoskrnl/include/internal/mm.h b/ntoskrnl/include/internal/mm.h
index c118866d5b5..1fbe513524f 100644
--- a/ntoskrnl/include/internal/mm.h
+++ b/ntoskrnl/include/internal/mm.h
@@ -69,7 +69,9 @@ typedef ULONG_PTR SWAPENTRY;
#endif
#define MEMORY_AREA_SECTION_VIEW (1)
+#ifdef NEWCC
#define MEMORY_AREA_CACHE (2)
+#endif
#define MEMORY_AREA_OWNED_BY_ARM3 (15)
#define MEMORY_AREA_STATIC (0x80000000)
diff --git a/ntoskrnl/mm/ARM3/section.c b/ntoskrnl/mm/ARM3/section.c
index d1f1e5bbaf2..bff71dfe81c 100644
--- a/ntoskrnl/mm/ARM3/section.c
+++ b/ntoskrnl/mm/ARM3/section.c
@@ -1666,9 +1666,14 @@ MiGetFileObjectForSectionAddress(
}
else
{
+#ifdef NEWCC
ASSERT(MemoryArea->Type == MEMORY_AREA_CACHE);
DPRINT1("Address is a cache section!\n");
return STATUS_SECTION_NOT_IMAGE;
+#else
+ ASSERT(FALSE);
+ return STATUS_SECTION_NOT_IMAGE;
+#endif
}
}
else
@@ -1739,8 +1744,12 @@ MiGetFileObjectForVad(
}
else
{
+#ifdef NEWCC
ASSERT(MemoryArea->Type == MEMORY_AREA_CACHE);
DPRINT1("VAD is a cache section!\n");
+#else
+ ASSERT(FALSE);
+#endif
return NULL;
}
}
diff --git a/ntoskrnl/mm/marea.c b/ntoskrnl/mm/marea.c
index d953f422f96..3736a5a36c8 100644
--- a/ntoskrnl/mm/marea.c
+++ b/ntoskrnl/mm/marea.c
@@ -178,7 +178,11 @@ MmInsertMemoryArea(
ASSERT(Process != NULL);
if (marea->Type != MEMORY_AREA_OWNED_BY_ARM3)
{
+#ifdef NEWCC
ASSERT(marea->Type == MEMORY_AREA_SECTION_VIEW || marea->Type ==
MEMORY_AREA_CACHE);
+#else
+ ASSERT(marea->Type == MEMORY_AREA_SECTION_VIEW);
+#endif
/* Insert the VAD */
MiLockProcessWorkingSetUnsafe(PsGetCurrentProcess(), PsGetCurrentThread());
@@ -353,7 +357,11 @@ MmFreeMemoryArea(
if (MemoryArea->Vad)
{
ASSERT(MemoryArea->VadNode.EndingVpn + 1 <
(ULONG_PTR)MmSystemRangeStart >> PAGE_SHIFT);
+#ifdef NEWCC
ASSERT(MemoryArea->Type == MEMORY_AREA_SECTION_VIEW || MemoryArea->Type
== MEMORY_AREA_CACHE);
+#else
+ ASSERT(MemoryArea->Type == MEMORY_AREA_SECTION_VIEW);
+#endif
/* MmCleanProcessAddressSpace might have removed it (and this would be
MmDeleteProcessAdressSpace) */
ASSERT(MemoryArea->VadNode.u.VadFlags.Spare != 0);
@@ -545,10 +553,12 @@ MiRosCleanupMemoryArea(
{
Status = MiRosUnmapViewOfSection(Process, BaseAddress,
Process->ProcessExiting);
}
+#ifdef NEWCC
else if (MemoryArea->Type == MEMORY_AREA_CACHE)
{
Status = MmUnmapViewOfCacheSegment(&Process->Vm, BaseAddress);
}
+#endif
else
{
/* There shouldn't be anything else! */
diff --git a/ntoskrnl/mm/mmfault.c b/ntoskrnl/mm/mmfault.c
index 68910e7a2d9..75f7b584a22 100644
--- a/ntoskrnl/mm/mmfault.c
+++ b/ntoskrnl/mm/mmfault.c
@@ -79,7 +79,7 @@ MmpAccessFault(KPROCESSOR_MODE Mode,
MemoryArea,
(PVOID)Address);
break;
-
+#ifdef NEWCC
case MEMORY_AREA_CACHE:
// This code locks for itself to keep from having to break a lock
// passed in.
@@ -89,7 +89,7 @@ MmpAccessFault(KPROCESSOR_MODE Mode,
if (!FromMdl)
MmLockAddressSpace(AddressSpace);
break;
-
+#endif
default:
Status = STATUS_ACCESS_VIOLATION;
break;
@@ -171,7 +171,7 @@ MmNotPresentFault(KPROCESSOR_MODE Mode,
(PVOID)Address,
FromMdl);
break;
-
+#ifdef NEWCC
case MEMORY_AREA_CACHE:
// This code locks for itself to keep from having to break a lock
// passed in.
@@ -181,7 +181,7 @@ MmNotPresentFault(KPROCESSOR_MODE Mode,
if (!FromMdl)
MmLockAddressSpace(AddressSpace);
break;
-
+#endif
default:
Status = STATUS_ACCESS_VIOLATION;
break;
diff --git a/ntoskrnl/mm/mminit.c b/ntoskrnl/mm/mminit.c
index 422ba568bb9..6c1a5f274d6 100644
--- a/ntoskrnl/mm/mminit.c
+++ b/ntoskrnl/mm/mminit.c
@@ -214,12 +214,17 @@ MmInitSystem(IN ULONG Phase,
/* Initialize the kernel address space */
ASSERT(Phase == 1);
+#ifdef NEWCC
InitializeListHead(&MiSegmentList);
ExInitializeFastMutex(&MiGlobalPageOperation);
KeInitializeEvent(&MmWaitPageEvent, SynchronizationEvent, FALSE);
// Until we're fully demand paged, we can do things the old way through
// the balance manager
+ // CcInitView will override this...
MmInitializeMemoryConsumer(MC_CACHE, MiRosTrimCache);
+#else
+ KeInitializeEvent(&MmWaitPageEvent, SynchronizationEvent, FALSE);
+#endif
MmKernelAddressSpace = &PsIdleProcess->Vm;
diff --git a/ntoskrnl/mm/rmap.c b/ntoskrnl/mm/rmap.c
index aa6a7b0d6f2..9fea631dd09 100644
--- a/ntoskrnl/mm/rmap.c
+++ b/ntoskrnl/mm/rmap.c
@@ -167,12 +167,14 @@ MmPageOutPhysicalAddress(PFN_NUMBER Page)
*/
Status = MmPageOutSectionView(AddressSpace, MemoryArea, Address, Entry);
}
+#ifdef NEWCC
else if (Type == MEMORY_AREA_CACHE)
{
/* NEWCC does locking itself */
MmUnlockAddressSpace(AddressSpace);
Status = MmpPageOutPhysicalAddress(Page);
}
+#endif
else
{
KeBugCheck(MEMORY_MANAGEMENT);
diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c
index fbf44868d90..32ee1f48786 100644
--- a/ntoskrnl/mm/section.c
+++ b/ntoskrnl/mm/section.c
@@ -60,6 +60,29 @@
extern MMSESSION MmSession;
+#ifndef NEWCC
+KEVENT MmWaitPageEvent;
+
+VOID
+NTAPI
+_MmLockSectionSegment(PMM_SECTION_SEGMENT Segment, const char *file, int line)
+{
+ //DPRINT("MmLockSectionSegment(%p,%s:%d)\n", Segment, file, line);
+ ExAcquireFastMutex(&Segment->Lock);
+ Segment->Locked = TRUE;
+}
+
+VOID
+NTAPI
+_MmUnlockSectionSegment(PMM_SECTION_SEGMENT Segment, const char *file, int line)
+{
+ ASSERT(Segment->Locked);
+ Segment->Locked = FALSE;
+ ExReleaseFastMutex(&Segment->Lock);
+ //DPRINT("MmUnlockSectionSegment(%p,%s:%d)\n", Segment, file, line);
+}
+#endif
+
NTSTATUS
NTAPI
MiMapViewInSystemSpace(IN PVOID Section,
@@ -4067,9 +4090,13 @@ MiRosUnmapViewOfSection(IN PEPROCESS Process,
MemoryArea = MmLocateMemoryAreaByAddress(AddressSpace,
BaseAddress);
if (MemoryArea == NULL ||
- ((MemoryArea->Type != MEMORY_AREA_SECTION_VIEW) &&
- (MemoryArea->Type != MEMORY_AREA_CACHE)) ||
+#ifdef NEWCC
+ ((MemoryArea->Type != MEMORY_AREA_SECTION_VIEW) &&
(MemoryArea->Type != MEMORY_AREA_CACHE)) ||
+#else
+ (MemoryArea->Type != MEMORY_AREA_SECTION_VIEW) ||
+#endif
MemoryArea->DeleteInProgress)
+
{
if (MemoryArea) ASSERT(MemoryArea->Type != MEMORY_AREA_OWNED_BY_ARM3);
MmUnlockAddressSpace(AddressSpace);
diff --git a/ntoskrnl/ntos.cmake b/ntoskrnl/ntos.cmake
index 79317e880db..2a098336288 100644
--- a/ntoskrnl/ntos.cmake
+++ b/ntoskrnl/ntos.cmake
@@ -28,7 +28,11 @@ if(NEWCC)
${REACTOS_SOURCE_DIR}/ntoskrnl/cache/lazyrite.c
${REACTOS_SOURCE_DIR}/ntoskrnl/cache/logsup.c
${REACTOS_SOURCE_DIR}/ntoskrnl/cache/mdlsup.c
- ${REACTOS_SOURCE_DIR}/ntoskrnl/cache/pinsup.c)
+ ${REACTOS_SOURCE_DIR}/ntoskrnl/cache/pinsup.c
+ ${REACTOS_SOURCE_DIR}/ntoskrnl/cache/section/fault.c
+ ${REACTOS_SOURCE_DIR}/ntoskrnl/cache/section/swapout.c
+ ${REACTOS_SOURCE_DIR}/ntoskrnl/cache/section/data.c
+ ${REACTOS_SOURCE_DIR}/ntoskrnl/cache/section/reqtools.c)
else()
list(APPEND SOURCE
${REACTOS_SOURCE_DIR}/ntoskrnl/cc/cacheman.c
@@ -42,11 +46,7 @@ endif()
list(APPEND SOURCE
${REACTOS_SOURCE_DIR}/ntoskrnl/cache/section/io.c
- ${REACTOS_SOURCE_DIR}/ntoskrnl/cache/section/data.c
- ${REACTOS_SOURCE_DIR}/ntoskrnl/cache/section/fault.c
- ${REACTOS_SOURCE_DIR}/ntoskrnl/cache/section/reqtools.c
${REACTOS_SOURCE_DIR}/ntoskrnl/cache/section/sptab.c
- ${REACTOS_SOURCE_DIR}/ntoskrnl/cache/section/swapout.c
${REACTOS_SOURCE_DIR}/ntoskrnl/config/cmalloc.c
${REACTOS_SOURCE_DIR}/ntoskrnl/config/cmapi.c
${REACTOS_SOURCE_DIR}/ntoskrnl/config/cmboot.c