- Changed MmGetContinuousPages from using an alignment to using a boundary.
[reactos.git] / reactos / ntoskrnl / mm / cont.c
index eb9c93e..4c6df84 100644 (file)
@@ -28,16 +28,44 @@ MmFreeContinuousPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address,
    }
 }
 
-/*
+/**********************************************************************
+ * NAME       EXPORTED
+ * MmAllocateContiguousMemorySpecifyCache@32
+ *
+ * DESCRIPTION
+  *  Allocates a range of physically contiguous memory
+ * with a cache parameter.
+ *
+ * ARGUMENTS
+ * NumberOfBytes
+ *  Size of the memory block to allocate;
+ *
+ * LowestAcceptableAddress
+ *  Lowest address valid for the caller.
+ *
+ * HighestAcceptableAddress
+ *  Highest address valid for the caller.
+ *
+ * BoundaryAddressMultiple
+ *  Address multiple not to be crossed by allocated buffer (optional).
+ *
+ * CacheType
+ *  Type of caching to use.
+ *
+ * RETURN VALUE
+ *  The virtual address of the memory block on success;
+ * NULL on error.
+ *
+ * REVISIONS
+ *
  * @implemented
  */
 PVOID STDCALL
-MmAllocateContiguousAlignedMemory(IN ULONG NumberOfBytes,
-                                  IN PHYSICAL_ADDRESS LowestAcceptableAddress OPTIONAL,
-                                  IN PHYSICAL_ADDRESS HighestAcceptableAddress,
-                                  IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL,
-                                  IN MEMORY_CACHING_TYPE CacheType OPTIONAL,
-                                  IN ULONG Alignment)
+MmAllocateContiguousMemorySpecifyCache(IN SIZE_T NumberOfBytes,
+                                       IN PHYSICAL_ADDRESS LowestAcceptableAddress OPTIONAL,
+                                       IN PHYSICAL_ADDRESS HighestAcceptableAddress,
+                                       IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL,
+                                       IN MEMORY_CACHING_TYPE CacheType OPTIONAL)
 {
    PMEMORY_AREA MArea;
    NTSTATUS Status;
@@ -66,7 +94,7 @@ MmAllocateContiguousAlignedMemory(IN ULONG NumberOfBytes,
                                &MArea,
                                FALSE,
                                FALSE,
-                               BoundaryAddressMultiple);
+                               (PHYSICAL_ADDRESS)0LL);
    MmUnlockAddressSpace(MmGetKernelAddressSpace());
 
    if (!NT_SUCCESS(Status))
@@ -77,7 +105,7 @@ MmAllocateContiguousAlignedMemory(IN ULONG NumberOfBytes,
    PBase = MmGetContinuousPages(NumberOfBytes,
                                 LowestAcceptableAddress,
                                 HighestAcceptableAddress,
-                                Alignment);
+                                BoundaryAddressMultiple);
    if (PBase == 0)
    {
       MmLockAddressSpace(MmGetKernelAddressSpace());
@@ -91,7 +119,7 @@ MmAllocateContiguousAlignedMemory(IN ULONG NumberOfBytes,
    for (i = 0; i < (PAGE_ROUND_UP(NumberOfBytes) / PAGE_SIZE); i++, PBase++)
    {
       MmCreateVirtualMapping(NULL,
-                             (char*)BaseAddress + (i * 4096),
+                             (char*)BaseAddress + (i * PAGE_SIZE),
                              Attributes,
                              &PBase,
                             1);
@@ -130,18 +158,11 @@ PVOID STDCALL
 MmAllocateContiguousMemory (IN ULONG NumberOfBytes,
                             IN PHYSICAL_ADDRESS HighestAcceptableAddress)
 {
-   PHYSICAL_ADDRESS LowestAcceptableAddress;
-   PHYSICAL_ADDRESS BoundaryAddressMultiple;
-
-   LowestAcceptableAddress.QuadPart = 0;
-   BoundaryAddressMultiple.QuadPart = 0;
-
-   return(MmAllocateContiguousAlignedMemory(NumberOfBytes,
-          LowestAcceptableAddress,
-          HighestAcceptableAddress,
-          BoundaryAddressMultiple,
-          MmCached,
-          PAGE_SIZE));
+   return MmAllocateContiguousMemorySpecifyCache(NumberOfBytes,
+                                                 (PHYSICAL_ADDRESS)0LL,
+                                                 HighestAcceptableAddress,
+                                                 (PHYSICAL_ADDRESS)0LL,
+                                                 MmCached);
 }
 
 
@@ -179,53 +200,6 @@ MmFreeContiguousMemory(IN PVOID BaseAddress)
    MmUnlockAddressSpace(MmGetKernelAddressSpace());
 }
 
-/**********************************************************************
- * NAME       EXPORTED
- * MmAllocateContiguousMemorySpecifyCache@32
- *
- * DESCRIPTION
-  *  Allocates a range of physically contiguous memory
- * with a cache parameter.
- *
- * ARGUMENTS
- * NumberOfBytes
- *  Size of the memory block to allocate;
- *
- * LowestAcceptableAddress
- *  Lowest address valid for the caller.
- *
- * HighestAcceptableAddress
- *  Highest address valid for the caller.
- *
- * BoundaryAddressMultiple
- *  Address multiple not to be crossed by allocated buffer (optional).
- *
- * CacheType
- *  Type of caching to use.
- *
- * RETURN VALUE
- *  The virtual address of the memory block on success;
- * NULL on error.
- *
- * REVISIONS
- *
- * @implemented
- */
-PVOID STDCALL
-MmAllocateContiguousMemorySpecifyCache (IN ULONG NumberOfBytes,
-                                        IN PHYSICAL_ADDRESS LowestAcceptableAddress,
-                                        IN PHYSICAL_ADDRESS HighestAcceptableAddress,
-                                        IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL,
-                                        IN MEMORY_CACHING_TYPE CacheType)
-{
-   return(MmAllocateContiguousAlignedMemory(NumberOfBytes,
-          LowestAcceptableAddress,
-          HighestAcceptableAddress,
-          BoundaryAddressMultiple,
-          CacheType,
-          PAGE_SIZE));
-}
-
 /**********************************************************************
  * NAME       EXPORTED
  * MmFreeContiguousMemorySpecifyCache@12