Sheesh Phil … there are, after all better programming on Discovery than
MythBusters …
Gary G. Little
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Philip D Barila
Sent: Thursday, June 08, 2006 5:31 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] KMDF Common Buffer DMA
I’ll add that it was “easier” because we needed arbitrarily large input
and output buffers in a single IOCTL, so we used the “unsafe” method of
embedding buffer pointers in a METHOD_BUFFERED control block, and probing
and locking those buffers so we could DMA into and out of them. It’s a
test harness, and it’s never going to be released into the wild, etc…
“Don’t try this at home, we’re what you call professionals.” Bonus points
to the first one who identifies that reference, and why I might think that
their claim to professionalism is as reliable as my own. 
If Microsoft had allowed METHOD_OUT_DIRECT to return a modified input
buffer, we wouldn’t have done all that, we would have defined a
METHOD_IN_DIRECT IOCTL that moved a small amount of data to the hardware,
and brought back a lot of data from it, and a METHOD_OUT_DIRECT IOCTL that
moved a lot of data to the hardware, and moved a small amount of data
back. We were unable to make that particular scenario work, so we gave up
on it and went with the embedded pointer thing.
Even with that, if we weren’t using pre-allocated SGL buffers, I’m not
sure I would dive out of WDF to do WDM-style DMA on the aforementioned
locked buffers. But we are pre-allocating our SGLs, so we have to dive
into WDM so we can use BuildScatterGatherList. Currently that, and
ExFreePoolWithTag, is the only thing keeping us from using this thing on
Windows 2000. I only mention that because if we dropped the pre-allocated
SGLs, we could go with an almost pure KMDF implementation.
If anyone knows how to return more than a status code to the application
sending a METHOD_OUT_DIRECT IOCTL, without resorting to manually
scribbling on the output buffer after the data is transferred to the
hardware, I’d really like to hear about it.
Phil
Philip D. Barila
Seagate Technology LLC
(720) 684-1842
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Gary G Little
Sent: Thursday, June 08, 2006 3:18 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] KMDF Common Buffer DMA
Nothing requires you to use DMA via WDF. Phil and I found it easier to use
WDM DMA in the driver(s) for which we are responsible.
Gary G. Little
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@probo.com
Sent: Thursday, June 08, 2006 3:56 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] KMDF Common Buffer DMA
Let’s say I’m doing a KMDF driver for a non-scatter/gather device for
which the most convenient model is common buffer DMA. (Note how
carefully I worded that to avoid implying that I HAD to use common
buffer DMA…) There are no samples of exactly this scenario, and the
documentation is a bit terse, so I’m guessing a bit on this.
It looks to me like I should create a WDFDMAENABLER, and register
EvtDmaEnablerFill and EvtDmaEnablerFlush handlers. The Fill handler
could then call WdfDmaEnablerWdmGetDmaAdapter, and use that adapter to
call AllocateCommonBuffer, and similarly call FreeCommonBuffer in the
Flush handler. I might also use EvtDmaEnablerDisable to turn off the
device’s DMA pump, if it was still on. But beyond that, I won’t ever
use the DmaEnabler object.
Is that correct?
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer