diff --git a/reactos/ntoskrnl/mm/cont.c b/reactos/ntoskrnl/mm/cont.c index ee7c49eb350..339556d643f 100644 --- a/reactos/ntoskrnl/mm/cont.c +++ b/reactos/ntoskrnl/mm/cont.c @@ -1,4 +1,4 @@ -/* $Id: cont.c,v 1.24 2002/10/01 19:27:22 chorns Exp $ +/* $Id: cont.c,v 1.25 2002/11/05 20:35:33 hbirr Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -63,11 +63,13 @@ MmAllocateContiguousAlignedMemory(IN ULONG NumberOfBytes, Alignment); if (PBase.QuadPart == 0LL) { + MmLockAddressSpace(MmGetKernelAddressSpace()); MmFreeMemoryArea(MmGetKernelAddressSpace(), BaseAddress, 0, NULL, NULL); + MmUnlockAddressSpace(MmGetKernelAddressSpace()); return(NULL); } for (i = 0; i < (PAGE_ROUND_UP(NumberOfBytes) / 4096); i++) @@ -142,11 +144,13 @@ MmAllocateContiguousMemory (IN ULONG NumberOfBytes, VOID STDCALL MmFreeContiguousMemory(IN PVOID BaseAddress) { + MmLockAddressSpace(MmGetKernelAddressSpace()); MmFreeMemoryArea(MmGetKernelAddressSpace(), BaseAddress, 0, MmFreeContinuousPage, NULL); + MmUnlockAddressSpace(MmGetKernelAddressSpace()); } diff --git a/reactos/ntoskrnl/mm/iospace.c b/reactos/ntoskrnl/mm/iospace.c index 3fd6c22d228..0ce9fba44a5 100644 --- a/reactos/ntoskrnl/mm/iospace.c +++ b/reactos/ntoskrnl/mm/iospace.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: iospace.c,v 1.16 2002/10/01 19:27:22 chorns Exp $ +/* $Id: iospace.c,v 1.17 2002/11/05 20:35:33 hbirr Exp $ * * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/iospace.c @@ -96,7 +96,7 @@ MmMapIoSpace (IN PHYSICAL_ADDRESS PhysicalAddress, { Attributes |= (PAGE_NOCACHE | PAGE_WRITETHROUGH); } - for (i = 0; (i < ((NumberOfBytes + PAGE_SIZE - 1) / PAGE_SIZE)); i++) + for (i = 0; (i < (PAGE_ROUND_UP(NumberOfBytes) / PAGE_SIZE)); i++) { Status = MmCreateVirtualMappingForKernel(Result + (i * PAGE_SIZE), @@ -141,11 +141,13 @@ VOID STDCALL MmUnmapIoSpace (IN PVOID BaseAddress, IN ULONG NumberOfBytes) { - (VOID)MmFreeMemoryArea(&PsGetCurrentProcess()->AddressSpace, - (PVOID)(((ULONG)BaseAddress / PAGE_SIZE) * PAGE_SIZE), - NumberOfBytes, - NULL, - NULL); + MmLockAddressSpace(MmGetKernelAddressSpace()); + MmFreeMemoryArea(MmGetKernelAddressSpace(), + (PVOID)(((ULONG)BaseAddress / PAGE_SIZE) * PAGE_SIZE), + NumberOfBytes, + NULL, + NULL); + MmUnlockAddressSpace(MmGetKernelAddressSpace()); } diff --git a/reactos/ntoskrnl/mm/ncache.c b/reactos/ntoskrnl/mm/ncache.c index 788ed24786d..d6ceb34db8f 100644 --- a/reactos/ntoskrnl/mm/ncache.c +++ b/reactos/ntoskrnl/mm/ncache.c @@ -1,4 +1,4 @@ -/* $Id: ncache.c,v 1.22 2002/10/01 19:27:23 chorns Exp $ +/* $Id: ncache.c,v 1.23 2002/11/05 20:35:33 hbirr Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -71,7 +71,7 @@ MmAllocateNonCachedMemory(IN ULONG NumberOfBytes) } Attributes = PAGE_READWRITE | PAGE_SYSTEM | PAGE_NOCACHE | PAGE_WRITETHROUGH; - for (i = 0; i <= (NumberOfBytes / PAGE_SIZE); i++) + for (i = 0; i < (PAGE_ROUND_UP(NumberOfBytes) / PAGE_SIZE); i++) { PHYSICAL_ADDRESS NPage; @@ -125,11 +125,13 @@ MmFreeNonCachedPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address, VOID STDCALL MmFreeNonCachedMemory (IN PVOID BaseAddress, IN ULONG NumberOfBytes) { + MmLockAddressSpace(MmGetKernelAddressSpace()); MmFreeMemoryArea (MmGetKernelAddressSpace(), BaseAddress, NumberOfBytes, MmFreeNonCachedPage, NULL); + MmUnlockAddressSpace(MmGetKernelAddressSpace()); }