joyjit mullick wrote:
please help me in clarifying some doubts regarding the following call
MmAllocateContiguousMemorySpecifyCache : which is used to allocate io
memory for drivers.
That description is a bit terse. It is used to allocate common buffers
for devices that do non-scatter/gather DMA.
1)how the allocated memory in host will beccessed by the DMA
controller (considering the case of a bus master device).
i would like to know whether a logical address will be used or direct
phy addresses?
The correct approach is to let the kernel DMA abstraction
(IoGetDmaAdapter) worry about this. The device eventually needs to be
told the bus physical address.
2)why calling MmAllocateContiguousMemorySpecifyCache followed by
MmGetPhysicalAddress is not a good practice
for all platforms.
I’ll give you an example. Let’s say you have a bus-mastering PCI device
that only handles 32-bit physical addresses, as many do. Let’s say
you’re running on a Server 2003 system with 16GB of RAM. Statistically,
it’s quite likely that MmAllocateContiguousMemorySpecifyCache is going
to return you memory with a physical address beyond the 4GB mark. Your
hardware can’t handle that. You’re stuck.
IoGetDmaAdapter, on the other hand, will do whatever needs to be done,
by allocating “bounce buffers” within the first 4GB of physical RAM, and
making sure that the physical addresses you get are all within the range
for your device.
3)which call is better suited for aloocating 2k size chunk of packets
MmAllocateContiguousMemorySpecifyCache or NdisMAllocateSharedMemory
Pavel already addressed this. However, I’d like to add one additional
note. There is no need to use MmAllocateContiguousMemorySpecifyCache
for a buffer this small. If you allocate 4k bytes, you will get one
complete page of memory, and memory within a single page is always
contiguous.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.