Need a hint on PNP USB

I’m a bit lost. On a PNP USB driver how do you know which
device you were loaded for? I’m positive the driver shouldn’t
just assume as their could be more than one of a perticular
device hooked up.

>I’m a bit lost. On a PNP USB driver how do you know which

device you were loaded for? I’m positive the driver shouldn’t
just assume as their could be more than one of a perticular
device hooked up.

If we’re talking about a PNP function driver, your driver get’s called at
it’s AddDevice entry point, and passed the physical device object for the
correct device. Your driver will get called at AddDevice for each instance
of the device. The mapping between actual device and your driver is
controlled by the PNP info in the INF file.

Correctly associating a specific device with a generic driver that can
handle many different flavors of a device is a problem. For example, I
worked on a PNP PCMCIA function driver last spring that was supposed to
work with a bunch of different similar devices. The driver potentially
could determine if the inserted PCMCIA card was compatible by querying the
device attribute memory. We ended up with a bunch of PNP id’s in the INF
file, to try and get all compatible devices connected to the driver. This
wasn’t perfect, as multiple vendors made the device, and didn’t exactly
publish a complete list of every possible PNP id for every version of the
device. Future versions, with new PNP id’s will also not be on the list.

  • Jan

> I’m a bit lost. On a PNP USB driver how do you know which

device you were loaded for? I’m positive the driver shouldn’t
just assume as their could be more than one of a perticular
device hooked up.

The USB bus driver reads config ROMs (or how they are called in USB?) from
each bus node, forms a PnP device ID from the config ROM contents and
reports them to PnP.
PnP finds a driver for each PnP ID by INF file scan.
So, your driver will be loaded (attached to the devnodes) only of the
devices with the config ROM contents matching the hardware IDs in your
driver’s INF.

Max

> > I’m a bit lost. On a PNP USB driver how do you know which

> device you were loaded for? I’m positive the driver shouldn’t
> just assume as their could be more than one of a perticular
> device hooked up.

The USB bus driver reads config ROMs (or how they are
called in USB?) from
each bus node, forms a PnP device ID from the config ROM
contents and
reports them to PnP.
PnP finds a driver for each PnP ID by INF file scan.
So, your driver will be loaded (attached to the devnodes)
only of the
devices with the config ROM contents matching the hardware
IDs in your
driver’s INF.

Thanks for your reply. I have learned that IRP’s are sent
down the stack to the USB drivers. And when the IRP’s
get to them they know which device you want to talk to
automaticly getting that info from the device stack.
You don’t open a handle to the device. You just pass URB
requsts down. And also many URB requests automaticly
transfer data on the control pipe without you having to
do anything but fill in the URB info.