From b4f774ec1ec97d5bfde84faf7c0036272b6b2d19 Mon Sep 17 00:00:00 2001 From: Hartmut Birr Date: Tue, 7 Jun 2005 17:07:34 +0000 Subject: [PATCH] - Removed the process member from the memory area structure. - Add the copyright notice and all programmers. svn path=/trunk/; revision=15832 --- reactos/ntoskrnl/include/internal/mm.h | 40 ++++++++++- reactos/ntoskrnl/mm/anonmem.c | 65 +++++++++++++----- reactos/ntoskrnl/mm/marea.c | 38 ++++++++++- reactos/ntoskrnl/mm/section.c | 94 ++++++++++++++++++-------- 4 files changed, 185 insertions(+), 52 deletions(-) diff --git a/reactos/ntoskrnl/include/internal/mm.h b/reactos/ntoskrnl/include/internal/mm.h index 65d0d9d2725..a7e6ec8db8e 100644 --- a/reactos/ntoskrnl/include/internal/mm.h +++ b/reactos/ntoskrnl/include/internal/mm.h @@ -1,5 +1,40 @@ -/* - * Higher level memory managment definitions +/* $Id$ + * + * Copyright (C) 1998-2005 ReactOS Team (and the authors from the programmers section) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + * PROJECT: ReactOS kernel + * FILE: ntoskrnl/include/internal/mm.h + * PURPOSE: level memory managment definitions + * + * PROGRAMMERS: David Welch + * Casper Hornstrup + * Hartmut Birr + * Ge van Geldorp + * Eric Kohl + * silverblade + * James Tabor + * Alex Ionescu + * tamlin + * Thomas Weidenmueller + * Filip Navara + * KJK::Hyperion + * Gregor Anich + * Steven Edwards */ #ifndef __INCLUDE_INTERNAL_MM_H @@ -218,7 +253,6 @@ typedef struct _MEMORY_AREA ULONG Type; ULONG Attributes; ULONG LockCount; - struct _EPROCESS* Process; /* FIXME: We don't need this! */ BOOLEAN DeleteInProgress; ULONG PageOpCount; union diff --git a/reactos/ntoskrnl/mm/anonmem.c b/reactos/ntoskrnl/mm/anonmem.c index 71dc55af95e..3005270bc96 100644 --- a/reactos/ntoskrnl/mm/anonmem.c +++ b/reactos/ntoskrnl/mm/anonmem.c @@ -1,11 +1,42 @@ /* $Id$ * - * COPYRIGHT: See COPYING in the top level directory + * Copyright (C) 2002-2005 ReactOS Team (and the authors from the programmers section) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/anonmem.c * PURPOSE: Implementing anonymous memory. * * PROGRAMMERS: David Welch + * Hartmut Birr + * Casper Hornstrup + * KJK::Hyperion + * Ge van Geldorp + * Eric Kohl + * Royce Mitchell III + * Aleksey Bragin + * Jason Filby + * Art Yerkes + * Gunnar Andre' Dalsnes + * Filip Navara + * Thomas Weidenmueller + * Alex Ionescu + * Trevor McCort + * Steven Edwards */ /* INCLUDE *****************************************************************/ @@ -42,7 +73,7 @@ MmWritePageVirtualMemory(PMADDRESS_SPACE AddressSpace, /* * Get that the page actually is dirty. */ - if (!MmIsDirtyPage(MemoryArea->Process, Address)) + if (!MmIsDirtyPage(AddressSpace->Process, Address)) { PageOp->Status = STATUS_SUCCESS; KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE); @@ -53,7 +84,7 @@ MmWritePageVirtualMemory(PMADDRESS_SPACE AddressSpace, /* * Speculatively set the mapping to clean. */ - MmSetCleanPage(MemoryArea->Process, Address); + MmSetCleanPage(AddressSpace->Process, Address); /* * If necessary, allocate an entry in the paging file for this page @@ -64,7 +95,7 @@ MmWritePageVirtualMemory(PMADDRESS_SPACE AddressSpace, SwapEntry = MmAllocSwapPage(); if (SwapEntry == 0) { - MmSetDirtyPage(MemoryArea->Process, Address); + MmSetDirtyPage(AddressSpace->Process, Address); PageOp->Status = STATUS_PAGEFILE_QUOTA_EXCEEDED; KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE); MmReleasePageOp(PageOp); @@ -80,7 +111,7 @@ MmWritePageVirtualMemory(PMADDRESS_SPACE AddressSpace, { DPRINT1("MM: Failed to write to swap page (Status was 0x%.8X)\n", Status); - MmSetDirtyPage(MemoryArea->Process, Address); + MmSetDirtyPage(AddressSpace->Process, Address); PageOp->Status = STATUS_UNSUCCESSFUL; KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE); MmReleasePageOp(PageOp); @@ -125,7 +156,7 @@ MmPageOutVirtualMemory(PMADDRESS_SPACE AddressSpace, /* * Disable the virtual mapping. */ - MmDisableVirtualMapping(MemoryArea->Process, Address, + MmDisableVirtualMapping(AddressSpace->Process, Address, &WasDirty, &Page); if (Page == 0) @@ -138,11 +169,11 @@ MmPageOutVirtualMemory(PMADDRESS_SPACE AddressSpace, */ if (!WasDirty) { - MmDeleteVirtualMapping(MemoryArea->Process, Address, FALSE, NULL, NULL); + MmDeleteVirtualMapping(AddressSpace->Process, Address, FALSE, NULL, NULL); MmDeleteAllRmaps(Page, NULL, NULL); if ((SwapEntry = MmGetSavedSwapEntryPage(Page)) != 0) { - MmCreatePageFileMapping(MemoryArea->Process, Address, SwapEntry); + MmCreatePageFileMapping(AddressSpace->Process, Address, SwapEntry); MmSetSavedSwapEntryPage(Page, 0); } MmReleasePageMemoryConsumer(MC_USER, Page); @@ -162,7 +193,7 @@ MmPageOutVirtualMemory(PMADDRESS_SPACE AddressSpace, if (SwapEntry == 0) { MmShowOutOfSpaceMessagePagingFile(); - MmEnableVirtualMapping(MemoryArea->Process, Address); + MmEnableVirtualMapping(AddressSpace->Process, Address); PageOp->Status = STATUS_UNSUCCESSFUL; KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE); MmReleasePageOp(PageOp); @@ -178,7 +209,7 @@ MmPageOutVirtualMemory(PMADDRESS_SPACE AddressSpace, { DPRINT1("MM: Failed to write to swap page (Status was 0x%.8X)\n", Status); - MmEnableVirtualMapping(MemoryArea->Process, Address); + MmEnableVirtualMapping(AddressSpace->Process, Address); PageOp->Status = STATUS_UNSUCCESSFUL; KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE); MmReleasePageOp(PageOp); @@ -189,8 +220,8 @@ MmPageOutVirtualMemory(PMADDRESS_SPACE AddressSpace, * Otherwise we have succeeded, free the page */ DPRINT("MM: Swapped out virtual memory page 0x%.8X!\n", Page << PAGE_SHIFT); - MmDeleteVirtualMapping(MemoryArea->Process, Address, FALSE, NULL, NULL); - MmCreatePageFileMapping(MemoryArea->Process, Address, SwapEntry); + MmDeleteVirtualMapping(AddressSpace->Process, Address, FALSE, NULL, NULL); + MmCreatePageFileMapping(AddressSpace->Process, Address, SwapEntry); MmDeleteAllRmaps(Page, NULL, NULL); MmSetSavedSwapEntryPage(Page, 0); MmReleasePageMemoryConsumer(MC_USER, Page); @@ -256,7 +287,7 @@ MmNotPresentFaultVirtualMemory(PMADDRESS_SPACE AddressSpace, /* * Get or create a page operation */ - PageOp = MmGetPageOp(MemoryArea, MemoryArea->Process->UniqueProcessId, + PageOp = MmGetPageOp(MemoryArea, AddressSpace->Process->UniqueProcessId, (PVOID)PAGE_ROUND_DOWN(Address), NULL, 0, MM_PAGEOP_PAGEIN, FALSE); if (PageOp == NULL) @@ -344,7 +375,7 @@ MmNotPresentFaultVirtualMemory(PMADDRESS_SPACE AddressSpace, { SWAPENTRY SwapEntry; - MmDeletePageFileMapping(MemoryArea->Process, Address, &SwapEntry); + MmDeletePageFileMapping(AddressSpace->Process, Address, &SwapEntry); Status = MmReadFromSwapPage(SwapEntry, Page); if (!NT_SUCCESS(Status)) { @@ -357,7 +388,7 @@ MmNotPresentFaultVirtualMemory(PMADDRESS_SPACE AddressSpace, * Set the page. If we fail because we are out of memory then * try again */ - Status = MmCreateVirtualMapping(MemoryArea->Process, + Status = MmCreateVirtualMapping(AddressSpace->Process, (PVOID)PAGE_ROUND_DOWN(Address), Region->Protect, &Page, @@ -365,7 +396,7 @@ MmNotPresentFaultVirtualMemory(PMADDRESS_SPACE AddressSpace, while (Status == STATUS_NO_MEMORY) { MmUnlockAddressSpace(AddressSpace); - Status = MmCreateVirtualMapping(MemoryArea->Process, + Status = MmCreateVirtualMapping(AddressSpace->Process, Address, Region->Protect, &Page, @@ -382,7 +413,7 @@ MmNotPresentFaultVirtualMemory(PMADDRESS_SPACE AddressSpace, /* * Add the page to the process's working set */ - MmInsertRmap(Page, MemoryArea->Process, (PVOID)PAGE_ROUND_DOWN(Address)); + MmInsertRmap(Page, AddressSpace->Process, (PVOID)PAGE_ROUND_DOWN(Address)); /* * Finish the operation diff --git a/reactos/ntoskrnl/mm/marea.c b/reactos/ntoskrnl/mm/marea.c index 9291de2816f..f60d1d67218 100644 --- a/reactos/ntoskrnl/mm/marea.c +++ b/reactos/ntoskrnl/mm/marea.c @@ -1,11 +1,44 @@ /* $Id$ * - * COPYRIGHT: See COPYING in the top level directory + * Copyright (C) 1998-2005 ReactOS Team (and the authors from the programmers section) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/marea.c * PURPOSE: Implements memory areas * - * PROGRAMMERS: David Welch (welch@mcmail.com) + * PROGRAMMERS: Rex Jolliff + * David Welch + * Eric Kohl + * Philip Susi + * Casper Hornstrup + * Hartmut Birr + * Eric Kohl + * Ge van Geldorp + * Royce Mitchell III + * Aleksey Bragin + * Jason Filby + * Thomas Weidenmueller + * Gunnar Andre' Dalsnes + * tamlin + * Alex Ionescu + * Filip Navara + * Herve Poussineau + * Steven Edwards */ /* INCLUDES *****************************************************************/ @@ -974,7 +1007,6 @@ MmCreateMemoryArea(PEPROCESS Process, MemoryArea->EndingAddress = (PVOID)((ULONG_PTR)*BaseAddress + tmpLength); MemoryArea->Attributes = Attributes; MemoryArea->LockCount = 0; - MemoryArea->Process = Process; MemoryArea->PageOpCount = 0; MemoryArea->DeleteInProgress = FALSE; diff --git a/reactos/ntoskrnl/mm/section.c b/reactos/ntoskrnl/mm/section.c index 094c85c8931..3522f059b38 100644 --- a/reactos/ntoskrnl/mm/section.c +++ b/reactos/ntoskrnl/mm/section.c @@ -1,11 +1,47 @@ /* $Id$ * - * COPYRIGHT: See COPYING in the top level directory + * Copyright (C) 1998-2005 ReactOS Team (and the authors from the programmers section) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/section.c * PURPOSE: Implements section objects * - * PROGRAMMERS: David Welch (welch@mcmail.com) + * PROGRAMMERS: Rex Jolliff + * David Welch + * Eric Kohl + * Emanuele Aliberti + * Eugene Ingerman + * Hartmut Birr + * Casper Hornstrup + * KJK::Hyperion + * Guido de Jong + * Ge van Geldorp + * Royce Mitchell III + * Filip Navara + * Aleksey Bragin + * Jason Filby + * Thomas Weidenmueller + * Gunnar Andre' Dalsnes + * tamlin + * Alex Ionescu + * Gregor Anich + * Steven Edwards + * Herve Poussineau */ /* INCLUDES *****************************************************************/ @@ -727,7 +763,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace, /* FIXME: Should we call MmCreateVirtualMappingUnsafe if * (Section->AllocationAttributes & SEC_PHYSICALMEMORY) is true? */ - Status = MmCreateVirtualMapping(MemoryArea->Process, + Status = MmCreateVirtualMapping(AddressSpace->Process, Address, Attributes, &Page, @@ -737,7 +773,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace, DbgPrint("Unable to create virtual mapping\n"); KEBUGCHECK(0); } - MmInsertRmap(Page, MemoryArea->Process, (PVOID)PAddress); + MmInsertRmap(Page, AddressSpace->Process, (PVOID)PAddress); } if (Locked) { @@ -1540,14 +1576,14 @@ MmPageOutSectionView(PMADDRESS_SPACE AddressSpace, */ if (Context.Private) { - Status = MmCreateVirtualMapping(MemoryArea->Process, + Status = MmCreateVirtualMapping(AddressSpace->Process, Address, MemoryArea->Attributes, &Page, 1); - MmSetDirtyPage(MemoryArea->Process, Address); + MmSetDirtyPage(AddressSpace->Process, Address); MmInsertRmap(Page, - MemoryArea->Process, + AddressSpace->Process, Address); } else @@ -1557,14 +1593,14 @@ MmPageOutSectionView(PMADDRESS_SPACE AddressSpace, * set it back into the section segment entry so we don't loose * our copy. Otherwise it will be handled by the cache manager. */ - Status = MmCreateVirtualMapping(MemoryArea->Process, + Status = MmCreateVirtualMapping(AddressSpace->Process, Address, MemoryArea->Attributes, &Page, 1); - MmSetDirtyPage(MemoryArea->Process, Address); + MmSetDirtyPage(AddressSpace->Process, Address); MmInsertRmap(Page, - MemoryArea->Process, + AddressSpace->Process, Address); Entry = MAKE_SSE(Page << PAGE_SHIFT, 1); MmSetPageEntrySectionSegment(Context.Segment, Context.Offset, Entry); @@ -1589,26 +1625,26 @@ MmPageOutSectionView(PMADDRESS_SPACE AddressSpace, */ if (Context.Private) { - Status = MmCreateVirtualMapping(MemoryArea->Process, + Status = MmCreateVirtualMapping(AddressSpace->Process, Address, MemoryArea->Attributes, &Page, 1); - MmSetDirtyPage(MemoryArea->Process, Address); + MmSetDirtyPage(AddressSpace->Process, Address); MmInsertRmap(Page, - MemoryArea->Process, + AddressSpace->Process, Address); } else { - Status = MmCreateVirtualMapping(MemoryArea->Process, + Status = MmCreateVirtualMapping(AddressSpace->Process, Address, MemoryArea->Attributes, &Page, 1); - MmSetDirtyPage(MemoryArea->Process, Address); + MmSetDirtyPage(AddressSpace->Process, Address); MmInsertRmap(Page, - MemoryArea->Process, + AddressSpace->Process, Address); Entry = MAKE_SSE(Page << PAGE_SHIFT, 1); MmSetPageEntrySectionSegment(Context.Segment, Context.Offset, Entry); @@ -1635,7 +1671,7 @@ MmPageOutSectionView(PMADDRESS_SPACE AddressSpace, if (Context.Private) { - Status = MmCreatePageFileMapping(MemoryArea->Process, + Status = MmCreatePageFileMapping(AddressSpace->Process, Address, SwapEntry); if (!NT_SUCCESS(Status)) @@ -3641,7 +3677,6 @@ VOID STATIC MmFreeSectionPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address, PFN_TYPE Page, SWAPENTRY SwapEntry, BOOLEAN Dirty) { - PMEMORY_AREA MArea; ULONG Entry; PFILE_OBJECT FileObject; PBCB Bcb; @@ -3651,23 +3686,24 @@ MmFreeSectionPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address, NTSTATUS Status; PSECTION_OBJECT Section; PMM_SECTION_SEGMENT Segment; + PMADDRESS_SPACE AddressSpace; - MArea = (PMEMORY_AREA)Context; + AddressSpace = (PMADDRESS_SPACE)Context; Address = (PVOID)PAGE_ROUND_DOWN(Address); - Offset = ((ULONG_PTR)Address - (ULONG_PTR)MArea->StartingAddress) + + Offset = ((ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress) + MemoryArea->Data.SectionData.ViewOffset; - Section = MArea->Data.SectionData.Section; - Segment = MArea->Data.SectionData.Segment; + Section = MemoryArea->Data.SectionData.Section; + Segment = MemoryArea->Data.SectionData.Segment; - PageOp = MmCheckForPageOp(MArea, NULL, NULL, Segment, Offset); + PageOp = MmCheckForPageOp(MemoryArea, NULL, NULL, Segment, Offset); while (PageOp) { MmUnlockSectionSegment(Segment); - MmUnlockAddressSpace(&MArea->Process->AddressSpace); + MmUnlockAddressSpace(AddressSpace); Status = MmspWaitForPageOpCompletionEvent(PageOp); if (Status != STATUS_SUCCESS) @@ -3676,10 +3712,10 @@ MmFreeSectionPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address, KEBUGCHECK(0); } - MmLockAddressSpace(&MArea->Process->AddressSpace); + MmLockAddressSpace(AddressSpace); MmLockSectionSegment(Segment); MmspCompleteAndReleasePageOp(PageOp); - PageOp = MmCheckForPageOp(MArea, NULL, NULL, Segment, Offset); + PageOp = MmCheckForPageOp(MemoryArea, NULL, NULL, Segment, Offset); } Entry = MmGetPageEntrySectionSegment(Segment, Offset); @@ -3733,12 +3769,12 @@ MmFreeSectionPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address, MmFreeSwapPage(SavedSwapEntry); MmSetSavedSwapEntryPage(Page, 0); } - MmDeleteRmap(Page, MArea->Process, Address); + MmDeleteRmap(Page, AddressSpace->Process, Address); MmReleasePageMemoryConsumer(MC_USER, Page); } else { - MmDeleteRmap(Page, MArea->Process, Address); + MmDeleteRmap(Page, AddressSpace->Process, Address); MmUnsharePageEntrySectionSegment(Section, Segment, Offset, Dirty, FALSE); } } @@ -3789,7 +3825,7 @@ MmUnmapViewOfSegment(PMADDRESS_SPACE AddressSpace, Status = MmFreeMemoryArea(AddressSpace, MemoryArea, MmFreeSectionPage, - MemoryArea); + AddressSpace); } MmUnlockSectionSegment(Segment); ObDereferenceObject(Section);