Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to map from one MDL to another with extra data

4 views
Skip to first unread message

mudehuai

unread,
Nov 8, 2009, 12:03:01 PM11/8/09
to

Hi:

I am new to driver and want to modify the bulkusb example to talk to our
device.

The problem is that when the driver receives the raw data from the user
space, I need to add a header to it before sending the data to the device.

In BulkUsb_DispatchReadWrite(), it calls the IoBuildPartialMdl to map the
user mdl directly to the URB mdl allocated by the driver. In my case, i want
the new URB mdl to include a header and then the data described by the user
mdl.

I cannot figure out how to do this with MDL manipulation.

I thought about allocate a buffer in the driver and fill it with the header
and the data described by the user mdl. Then create the new URB mdl from this
buffer.

However, it would be great if I can avoid this extra copy with MDL
manipulation.

Thanks in advance.

cheers,

Doron Holan [MSFT]

unread,
Nov 9, 2009, 7:41:53 PM11/9/09
to
bulkusb is a very old sample, you should start your driver work with
usbsamp. actually, you should investigate winusb where you do not have to
write a driver all, but this assumes the app can use winusb.dll and not
expect a CreateFile/DeviceIoControl interface.

now with that said, the underlying usb host controller stack does not
support chained MDLs, so you cannot prepend your header without a full
memory copy. the simplest solution is to allocate a buffer large enough for
your app's buffer + the header, copy the user's buffer, initialize the
header and send the buffer down in an URB as is (let the underlying bus
allocate the PMDL for you, the PMDL in this case does not buy you anything).

d

"mudehuai" <mude...@discussions.microsoft.com> wrote in message
news:446AE0D1-31D6-4B9D...@microsoft.com...

0 new messages