Hi All,
I want to allocate a DMA buffer which is to be physically contiguous with 64-byte aligned. So I did something like
- Used WdfDmaEnablerCreate() to create DMA enabler object.
- Created common buffer using WdfCommonBufferCreate().
- Used WdfCommonBufferGetAlignedVirtualAddress() and WdfCommonBufferGetAlignedLogicalAddress() to get the virtual and physical addressed.
- Programmed DMA register by writing the physical address.
I would like to know if this is the correct procedure to create a DMA buffer which is physically contiguous.
Also, I have one more question.
I want to create a pool of consistent memory blocks for dma. How can I do this. I thought of using the following, but I’m not sure of it.
- Use WdfDmaEnablerCreate() to create DMA enabler object.
- Call WdfDmaTransactionCreate() to create DMA transaction.
- Call WdfDmaTransactionInitialize().
The problem here is I do not have MDL where I can use. Can any one let me know if I can use the first method to create a memory blocks for dma?
My PCI hardware specification states these two statements
- The physical memory pointer is assumed to be physically contiguous and 64-byte aligned (for first requirement)
- Creates a pool of consistent memory blocks for dma (for second requirement)
I never had chance to work with DMA earlier. So, any help is much appreciated.
Thanks and Regards,
bubu
Sounds right to me… this is the programming pattern that’s used for “continuous mode” DMA. DMA operations repeatedly take place between the device and a buffer you establish in host memory.
Well, no. This is the model for PACKET-based DMA, in which the DMA operations take place between a buffer (typically, a user data buffer that changes on a per-request basis) and your device.
The problem I’m having in answering your overall question is that I’m not sure what you mean by “consistent memory blocks.” Given what I’ve described above, can you elaborate a bit more?
Peter
OSR
Thank you for the reply.
By “consistent memory blocks” I mean that the blocks of memory which are logically ordered in a dma buffer.
OK, that doesn’t work either. “logically ordered” doesn’t have any sort of definition in Windows (or CS) that I’m aware of.
Do you mean “contiguous” (the range of physical addresses of the memory pages comprising the buffer are adjacent, throughout the entire range of the buffer, from beginning to end) as opposed to “consistent”?
I’m not trying to be a jerk and beat you over some word definition… I’m trying to understand what you’re asking.
If you mean contiguous then WdfCommonBufferCreate does just that.
Peter
OSR
By the definition in the specification it looks like a contiguous memory buffer is required. So I think WdfCommonBufferCreate would do the trick. But I wasn’t sure of it so I had to post my question.
Thanks for answering.
> I would like to know if this is the correct procedure to create a DMA buffer which is physically
contiguous.
Yes.
I want to create a pool of consistent memory blocks for dma.
For what?
–
Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com