PVOID
MmAllocateContiguousMemory(
IN ULONG NumberOfBytes,
IN PHYSICAL_ADDRESS HighestAcceptableAddress
);
MmAllocateContiguousMemory allocates a range of physically contiguous, cache-aligned memory from nonpaged pool.
Parameters
NumberOfBytes
Specifies the size in bytes of the block of contiguous memory to be allocated.
HighestAcceptableAddress
Specifies the highest valid physical address the driver can use. For example, if a device can only reference physical memory in the lower 16MB, this value would be set to 0x00000000FFFFFF.
Return Value
MmAllocateContiguousMemory returns the base virtual address for the allocated memory. If the request cannot be satisfied, NULL is returned.
Comments
MmAllocateContiguousMemory can be called to allocate a contiguous block of physical memory for a long-term internal buffer, usually from the DriverEntry routine.
A device driver that must use contiguous memory should allocate only what it needs during driver initialization because nonpaged pool is likely to become fragmented as the system runs. Such a driver must deallocate the memory if it is unloaded. Contiguous allocations are aligned on an integral multiple of the processor’s data-cache-line size to prevent cache and coherency problems.
Callers of MmAllocateContiguousMemory must be running at IRQL = PASSIVE_LEVEL.
See Also
HalAllocateCommonBuffer, KeGetDcacheFillSize, MmAllocateNonCachedMemory, MmFreeContiguousMemory