KMDF software-only bus driver communication with FDOs

Hello, all -

I’m in the process of writing my very first device driver, something I’ve wanted to do for years but with kmdf I believe it’s finally down to my level. :wink:

I started 2 weeks ago with no previous driver knowledge or experience, but I now have a bus driver question that I can’t seem to find the answer to…

First off, this is all software drivers; there’s no hardware.

I have a working bus driver (dynamic enumeration), based on Toaster bus. It only allows a certain child driver to be plugged in - for testing, I’ve based the child driver on the RAMDisk example. Each child on the bus has an indentification description of ULONG; address descriptions are not used. The child driver is also kmdf.

My question #1: Is it possible for the bus to pass parameters to the child driver at the time of creation? At the very least, I would like the child driver to be aware of its identification number, but there are other parameters that would be useful as well. Is there a standard way of doing this for tightly coupled drivers?

My question #2: Currently, the child driver specifies its own nt device name. I’d like to do this in the PDO in the bus driver instead (which is more correct according to MSDN), but if I assign a name for the PDO, it seems to get overwritten when the PDO device is created. How do I do this?

Thanks,
-Steve

Look at WdfDeviceQueryProperty. For simple stuff like a ulong bus address this is the way to go. Make sure the bus driver is setting the property you are querying for. For more complex interactions you can implement a device interface that is essentially a function call interface between your FDO and the bus driver.

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-288817-
xxxxx@lists.osr.com] On Behalf Of xxxxx@hotmail.com
Sent: Saturday, June 02, 2007 1:59 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] KMDF software-only bus driver communication with FDOs

Hello, all -

I’m in the process of writing my very first device driver, something
I’ve wanted to do for years but with kmdf I believe it’s finally down
to my level. :wink:

I started 2 weeks ago with no previous driver knowledge or experience,
but I now have a bus driver question that I can’t seem to find the
answer to…

First off, this is all software drivers; there’s no hardware.

I have a working bus driver (dynamic enumeration), based on Toaster
bus. It only allows a certain child driver to be plugged in - for
testing, I’ve based the child driver on the RAMDisk example. Each child
on the bus has an indentification description of ULONG; address
descriptions are not used. The child driver is also kmdf.

My question #1: Is it possible for the bus to pass parameters to the
child driver at the time of creation? At the very least, I would like
the child driver to be aware of its identification number, but there
are other parameters that would be useful as well. Is there a standard
way of doing this for tightly coupled drivers?

My question #2: Currently, the child driver specifies its own nt device
name. I’d like to do this in the PDO in the bus driver instead (which
is more correct according to MSDN), but if I assign a name for the PDO,
it seems to get overwritten when the PDO device is created. How do I do
this?

Thanks,
-Steve


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

Mark -

Thanks for the tip! A Q-interface is exactly what I was looking for!

-Steve

> My question #1: Is it possible for the bus to pass parameters to the child at
the

time of creation? At the very least, I would like the child driver to be aware
of its
identification number, but there are other parameters that would be useful as
well. Is there a standard way of doing this for tightly coupled drivers?

IRP_MN_QUERY_INTERFACE. The child will ask the function pointer table from the
bus using this call.

My question #2: Currently, the child driver specifies its own nt device name.
I’d
like to do this in the PDO in the bus driver instead (which is more correct
according to MSDN),

No, this is not correct according to MSDN. According to MSDN, the best way is
to use autogenerated device names for PDOs.


Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

I just have to say this driver defined interface idea is a lifesaver! Or a timesaver, at least… :slight_smile: Also, Doron’s posts I’ve found helpful as well. Has this idea been around long? I’m asking because it doesn’t seem that Microsoft’s WDF book covers driver-defined interfaces at all.

Many thanks to you all for being patient with this newbie. I was a bit confused until I realized that a “driver interface” is completely different than a “driver defined interface”. Terminology… :slight_smile:

-Steve

P.S. Maxim - thanks for the correction on PDO naming. You are correct.

QueryInterface may be more than you are looking for. If you just need a unique address for your device, the device properties are the way to go. DeviceInterfaces violate the layering between FDO and PDO and introduce complexity that you can probably get along without. It really depends on what your requirements are. As I said, for your stated requirement of a simple ULONG address, go with the device properties.

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-288899-
xxxxx@lists.osr.com] On Behalf Of xxxxx@hotmail.com
Sent: Sunday, June 03, 2007 1:47 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] KMDF software-only bus driver communication with
FDOs

I just have to say this driver defined interface idea is a lifesaver!
Or a timesaver, at least… :slight_smile: Also, Doron’s posts I’ve found helpful
as well. Has this idea been around long? I’m asking because it doesn’t
seem that Microsoft’s WDF book covers driver-defined interfaces at all.

Many thanks to you all for being patient with this newbie. I was a bit
confused until I realized that a “driver interface” is completely
different than a “driver defined interface”. Terminology… :slight_smile:

-Steve

P.S. Maxim - thanks for the correction on PDO naming. You are correct.


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

I respectfully disagree. Outside of a root enumerated device, you are
typically tightly bound between the FDO and the PDO b/c the PDO provides
services for the FDO. Mark, the properties you can specify with
DEVICE_REGISTRY_PROPERTY (via WdfDeviceQueryProperty or
IoGetDeviceProperty) are not extensible and usually do not fit into a
driver’s property schema cleanly (although in this case,
DevicePropertyAddress might be appropriate). Furthermore, I would think
that this is just as tightly binding the FDO to the PDO, just in a more
/implicit/ manner since it is not declarative or i/o based.

Steve, why didn’t we cover driver defined interfaces? Well, the book is
huge already and there are ton of topics we could not cover ;). Is it
something to write about? Probably. Is it something most people would
implement as a bus driver and use? Not as likely, but still a popular
programming pattern. Glad you found the blog entries useful, that is
what I strive for.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Mark Roddy
Sent: Sunday, June 03, 2007 3:02 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] KMDF software-only bus driver communication with
FDOs

QueryInterface may be more than you are looking for. If you just need a
unique address for your device, the device properties are the way to go.
DeviceInterfaces violate the layering between FDO and PDO and introduce
complexity that you can probably get along without. It really depends on
what your requirements are. As I said, for your stated requirement of a
simple ULONG address, go with the device properties.

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-288899-
xxxxx@lists.osr.com] On Behalf Of xxxxx@hotmail.com
Sent: Sunday, June 03, 2007 1:47 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] KMDF software-only bus driver communication with
FDOs

I just have to say this driver defined interface idea is a lifesaver!
Or a timesaver, at least… :slight_smile: Also, Doron’s posts I’ve found helpful
as well. Has this idea been around long? I’m asking because it doesn’t
seem that Microsoft’s WDF book covers driver-defined interfaces at
all.

Many thanks to you all for being patient with this newbie. I was a bit
confused until I realized that a “driver interface” is completely
different than a “driver defined interface”. Terminology… :slight_smile:

-Steve

P.S. Maxim - thanks for the correction on PDO naming. You are correct.


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