Re: Do I need a WdfDmaTransaction before accessing a Common Buffer?
- From: Charles Gardiner <invalid@xxxxxxxxxxxxxxx>
- Date: Tue, 05 May 2009 09:11:04 +0200
Tim Roberts schrieb:
Charles Gardiner <invalid@xxxxxxxxxxxxxxx> wrote:
Just for clarification: I see I mixed the terms common-buffer/circular
buffer at least twice below.
Correct is, the data set is written to a _circular_ buffer (in user
space).
How did you lock that buffer into memory, and how did you get the physical
address?
I locked the user-space circular buffer into memory by pending the
request indefinitely. Then, obtained the physical addresses by
-1- setting up a WdfDmaTransaction
(WdfDmaTransactionInitializeUsingRequest)
-2- Executing the Dma Transaction (WdfDmaTransactionExecute)
-3- Taking the S/G list(s) passed to the EvtProgramDma callback and
storing these in a buffer. They are then cyclically passed to my DMA
hardware.
My real issue is the _common-buffer_ (WDFCOMMONBUFFER object) which is
made up of 'n' structures each describing 'n' circular buffers as
desribed above. One of the structure elements (a single ULONG) is
written by the DMA hardware everytime it writes a block to a circular
buffer and contains the last location written (circular buffer offset).
Initially, I obtained the logical addresses to the common-buffer by
calling WdfCommonBufferGetAlignedLogicalAddress, computed the offsets to
the structure elements and just set this address up in the hardware as
target address of the offset recorder. This solution blue-screened on
me. Next, I tried getting the Mdl to the common-buffer using
IoAllocateMdl and based on the result of
WdfCommonBufferGetAlignedVirtualAddress. Strangely, this approach worked
as long as the Mdl was below 4Gbytes. If it ended up to be above
4Gbytes, this solution blue screened on me too. (My hardware can
generate 48 bit addresses)
What I now do is:
-1- set up an additional DMA transaction to the common buffer using
WdfDmaTransactionInitialize
-2- Get the Mdl to the WDFCOMMONBUFFER by calling
WdfCommonBufferGetAlignedVirtualAddress and IoAllocateMdl.
I now never use these values but WdfDmaTransactionInitialize requires an
Mdl in one of it's parameters and this is the most 'related' Mdl, IMHO.
-3- In the EvtProgramDma callback to this (common buffer) DMA
transaction, compute the offset to the required common buffer structure
element based on the result from
WdfCommonBufferGetAlignedLogicalAddress, and pass this to the hardware.
(i.e. just ignore the S/G list passed to EvtProgramDma)
This solution has now been running for several hours so I assume it's
ok. My resumee: KMDF is missing a
'WdfDmaTransactionInitializeUsingCommonBuffer' call or something similar.
.
- Follow-Ups:
- Re: Do I need a WdfDmaTransaction before accessing a Common Buffer?
- From: Brandon Wilson [MSFT]
- Re: Do I need a WdfDmaTransaction before accessing a Common Buffer?
- References:
- Do I need a WdfDmaTransaction before accessing a Common Buffer?
- From: Charles Gardiner
- Re: Do I need a WdfDmaTransaction before accessing a Common Buffer?
- From: Charles Gardiner
- Re: Do I need a WdfDmaTransaction before accessing a Common Buffer?
- From: Tim Roberts
- Do I need a WdfDmaTransaction before accessing a Common Buffer?
- Prev by Date: Re: sdio-uart windowsXP driver development
- Next by Date: Re: Signature Pad(HID) and RDP
- Previous by thread: Re: Do I need a WdfDmaTransaction before accessing a Common Buffer?
- Next by thread: Re: Do I need a WdfDmaTransaction before accessing a Common Buffer?
- Index(es):
Relevant Pages
|