Supporting different devices in WDM driver.

Hi all,
I have a WDM driver that is working fine. I just got a requirement
for supporting more than one instance of device on the same system. That
is instead of one controller we will have two controllers. The only
change I can think of is :

  1. Add device will be called multiple times.
  2. Each time the Add Device is called we will have to create a new
    device [using IoCreateDevice].

Apart from this do you guys think that there could be possible changes
that I might need to make or could point me to something that might need
another look??

Thanks…
– Ajitabh

> Apart from this do you guys think that there could be possible changes

that I might
need to make or could point me to something that might need another look??

Depends on how well you followed the rules in data layout originally. If
you did everything exactly right, AddDevice shoudl take care of it for you.

From past experience with single-device drivers, I would be willing to
suspect that you have at least some per-device data, buffers, pointers,
counters, etc. that probably lives at the driver level rather than the
device level. Or you have some sort of single buffer pool, and no locking,
since it was never needed before. As soon as you add a second device, you
are going to start tripping on yourself when two devices start using the
same data and/or pointers and counters.

Look for allocations in the driver structure rather than the device
extension. Check if you have separate counters and pointers for both
devices. Check how the interrupt routine interfaces to the DPC routine.
Make sure the DPC routine is really going to run for the right device.
Those are the sort of problems I’ve seen in the past with this sort of
thing. If allof those are good, you should be fine.

Loren

If the driver is properly written there should be no changes. One thing to
watch out for are names, if you use a name for IoCreateDevice or
IoCreateSymbolicLink you need to have a differentiator (a number instance).


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
http://www.windrvr.com
Remove StopSpam from the email to reply

“Ajitabh Saxena” wrote in message
news:xxxxx@ntdev…
Hi all,
I have a WDM driver that is working fine. I just got a requirement
for supporting more than one instance of device on the same system. That
is instead of one controller we will have two controllers. The only
change I can think of is :

1. Add device will be called multiple times.
2. Each time the Add Device is called we will have to create a new
device [using IoCreateDevice].

Apart from this do you guys think that there could be possible changes
that I might need to make or could point me to something that might need
another look??

Thanks…
– Ajitabh

Ajitabh Saxena wrote:

Hi all,
I have a WDM driver that is working fine. I just got a requirement
for supporting more than one instance of device on the same system.
That is instead of one controller we will have two controllers. The
only change I can think of is :

  1. Add device will be called multiple times.
  2. Each time the Add Device is called we will have to create a new
    device [using IoCreateDevice].

Apart from this do you guys think that there could be possible changes
that I might need to make or could point me to something that might
need another look??

Unless you’ve done something wrong, like abusing global variables, there
shouldn’t be any changes at all to your code to support multiple
instances. The architecture of WDM is designed to support this from the
ground up. The instances are unrelated to each other.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Thanks guys.I think my driver will rock ‘n’ Roll then. :slight_smile:

– Ajitabh

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Thursday, February 15, 2007 12:25 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Supporting different devices in WDM driver.

Ajitabh Saxena wrote:

Hi all,
I have a WDM driver that is working fine. I just got a requirement

for supporting more than one instance of device on the same system.
That is instead of one controller we will have two controllers. The
only change I can think of is :

  1. Add device will be called multiple times.
  2. Each time the Add Device is called we will have to create a new
    device [using IoCreateDevice].

Apart from this do you guys think that there could be possible changes

that I might need to make or could point me to something that might
need another look??

Unless you’ve done something wrong, like abusing global variables, there
shouldn’t be any changes at all to your code to support multiple
instances. The architecture of WDM is designed to support this from the
ground up. The instances are unrelated to each other.


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

Be sure you don’t maintain device state in global or static variables,
or if you must share state across the devices that you understand how to
synchronize access to it properly.

As the simplest example, I’ve seen drivers which define a global
PMY_DEVICE_EXTENSION variable which they use in all of their dispatch
routines. That fails miserably once AddDevice is called a second time.

-p

From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ajitabh Saxena
Sent: Thursday, February 15, 2007 12:00 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Supporting different devices in WDM driver.

Hi all,

I have a WDM driver that is working fine. I just got a requirement
for supporting more than one instance of device on the same system. That
is instead of one controller we will have two controllers. The only
change I can think of is :

  1. Add device will be called multiple times.

  2. Each time the Add Device is called we will have to create a new
    device [using IoCreateDevice].

Apart from this do you guys think that there could be possible changes
that I might need to make or could point me to something that might need
another look??

Thanks…

– Ajitabh


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

>Apart from this do you guys think that there could be possible changes

Be accurate with any globals, better to have no globals at all (only device
extensions).

If you have globals - be sure to synchronize access to them.


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