update for HEAD-2002110701
[reactos.git] / ntoskrnl / mm / iospace.c
index a1b55a9..645a778 100644 (file)
@@ -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());
 }