Pnp resource rebalancing in W2K

Ok you W2K Pnp wizards, I’ve been working on a driver for let’s say a
security related device.

This device is often a PCMCIA card form factor. If I understand things
right, W2K is free to stop my device at any time, and then start it back
up, potentially with different resources. The problem I have is: my device
has internal context that can not just be extracted and saved, and then
restored. Applications pass things like passwords to it, and then it’s
“logged in”. Even if I queue app requests during a resource rebalance, I
can’t get it’s state back to where it was. This is by design, and
considered a security “feature”. I also don’t really know WHEN it’s in a
state that can’t be restored. The apps just passes magic data packets to
it, and those packets influence internal state.

So I guss my questions are:

  1. is there any way to tell W2K to NEVER try and rebalance the resource to
    my device

  2. can I do this and still let the system shut down my device when a user
    requests it (like using the stop button on the PCMCIA tray tool). I think
    what I need is to know the initiator of the stop request

  3. standby mode and hibernation are a whole other can of worms, it seems
    like a system will not conserve power (like on a laptop that really needs
    to) unless I let power IRP’s do their thing, which means pass them down to
    the PCMCIA controller (which I assume shuts off card power, loosing my
    state), hopefully users will have to cope with the fact that their security
    state may go away across suspends (or maybe I should just not let the
    PCMCIA controller power down my card, ever)

  4. is there any test tool that can force a Pnp resource rebalance, I’ve
    seen it happen in the debugger, but don’t know how to make it happen on
    demand for testing

Any ideas or feedback appreciated!

  • Jan
  1. is there any way to tell W2K to NEVER try and rebalance the resource to
    my device

Yes, if you fail IRP_MN_STOP_DEVICE, your device will not be stopped for
resource rebalance.

  1. can I do this and still let the system shut down my device when a user
    requests it (like using the stop button on the PCMCIA tray tool). I think
    what I need is to know the initiator of the stop request

IRP_MN_STOP_DEVICE is a system IRP and it’s only sent by the PnP manager.
I don’t know what you mean by device shutdown. Are you talking about device
ejection? If yes then you can do that. Device ejection is query removal.

  1. standby mode and hibernation are a whole other can of worms, it seems
    like a system will not conserve power (like on a laptop that really needs
    to) unless I let power IRP’s do their thing, which means pass them down to
    the PCMCIA controller (which I assume shuts off card power, loosing my
    state), hopefully users will have to cope with the fact that their security
    state may go away across suspends (or maybe I should just not let the
    PCMCIA controller power down my card, ever)

You could do that. The bus driver can go to a low power mode only if all
the devices on that bus say Okay to go that low power state. If you fail
any set power IRP to go to lower mode, then your device will not be power
down ever, except, for some catastrophic cases such as battery discharge
and so on.

  1. is there any test tool that can force a Pnp resource rebalance, I’ve
    seen it happen in the debugger, but don’t know how to make it happen on
    demand for testing

We have recently come up with a tool that kind of simulates resource
rebalance operation. The tool installs itself as an upper device
filter and sends a stop and start IRP to see how your device is handling
that. It’s on this page http://www.microsoft.com/hwdev/driver/ - called
Plug and Play Driver Test.

-Eliyas

-----Original Message-----
From: Jan Bottorff [mailto:xxxxx@pmatrix.com]
Sent: Tuesday, May 16, 2000 6:04 PM
To: NT Developers Interest List
Subject: [ntdev] Pnp resource rebalancing in W2K

Ok you W2K Pnp wizards, I’ve been working on a driver for let’s say a
security related device.

This device is often a PCMCIA card form factor. If I understand things
right, W2K is free to stop my device at any time, and then start it back
up, potentially with different resources. The problem I have is: my device
has internal context that can not just be extracted and saved, and then
restored. Applications pass things like passwords to it, and then it’s
“logged in”. Even if I queue app requests during a resource rebalance, I
can’t get it’s state back to where it was. This is by design, and
considered a security “feature”. I also don’t really know WHEN it’s in a
state that can’t be restored. The apps just passes magic data packets to
it, and those packets influence internal state.

So I guss my questions are:

  1. is there any way to tell W2K to NEVER try and rebalance the resource to
    my device

  2. can I do this and still let the system shut down my device when a user
    requests it (like using the stop button on the PCMCIA tray tool). I think
    what I need is to know the initiator of the stop request

  3. standby mode and hibernation are a whole other can of worms, it seems
    like a system will not conserve power (like on a laptop that really needs
    to) unless I let power IRP’s do their thing, which means pass them down to
    the PCMCIA controller (which I assume shuts off card power, loosing my
    state), hopefully users will have to cope with the fact that their security
    state may go away across suspends (or maybe I should just not let the
    PCMCIA controller power down my card, ever)

  4. is there any test tool that can force a Pnp resource rebalance, I’ve
    seen it happen in the debugger, but don’t know how to make it happen on
    demand for testing

Any ideas or feedback appreciated!

  • Jan

You are currently subscribed to ntdev as: xxxxx@microsoft.com
To unsubscribe send a blank email to $subst(‘Email.Unsub’)

Hi,

  1. is there any way to tell W2K to NEVER try and rebalance the resource to
    my device

Yes, if you fail IRP_MN_STOP_DEVICE, your device will not be stopped for
resource rebalance.

  1. can I do this and still let the system shut down my device when a user
    requests it (like using the stop button on the PCMCIA tray tool). I think
    what I need is to know the initiator of the stop request

IRP_MN_STOP_DEVICE is a system IRP and it’s only sent by the PnP manager.
I don’t know what you mean by device shutdown. Are you talking about device
ejection? If yes then you can do that. Device ejection is query removal.

Let me look again at the exact sequence of IRP I see under different
conditions. That may be correct that I can tell the difference between a
resource rebalance (which I don’t want) and a user request to stop the
device (which I do want).

  1. standby mode and hibernation are a whole other can of worms, it seems
    like a system will not conserve power (like on a laptop that really needs
    to) unless I let power IRP’s do their thing, which means pass them down to
    the PCMCIA controller (which I assume shuts off card power, loosing my
    state), hopefully users will have to cope with the fact that their security
    state may go away across suspends (or maybe I should just not let the
    PCMCIA controller power down my card, ever)

You could do that. The bus driver can go to a low power mode only if all
the devices on that bus say Okay to go that low power state. If you fail
any set power IRP to go to lower mode, then your device will not be power
down ever, except, for some catastrophic cases such as battery discharge
and so on.

Will other parts of the system still go to low power? I though if all
devices didn’t agree then suspend mode was not entered. A valid tradoff
might be battery power consumption will be somewhat greater during suspend
if my device is inserted.

  1. is there any test tool that can force a Pnp resource rebalance, I’ve
    seen it happen in the debugger, but don’t know how to make it happen on
    demand for testing

We have recently come up with a tool that kind of simulates resource
rebalance operation. The tool installs itself as an upper device
filter and sends a stop and start IRP to see how your device is handling
that. It’s on this page http://www.microsoft.com/hwdev/driver/ - called
Plug and Play Driver Test.

Thanks for the ideas!

Any chance the error where the PCMCIA bus driver doesn’t return correct
slot info on the IRP_MN_QUERY_CAPABILITIES call will get fixed anytime soon
(it’s always zero). Or other ideas on how to ask the PDO what PCMCIA slot
it’s physically attached to? Even the Microsoft PCMCIA UI displays the
wrong thing. I insert a card in slot 1, and the UI says slot zero. I assume
the IRP_MN_QUERY_CAPABILITIES bug is the root cause?

  • Jan

http://support.microsoft.com/support/kb/articles/q256/1/61.asp

Is this what you need?

-Eliyas

Any chance the error where the PCMCIA bus driver doesn’t return correct
slot info on the IRP_MN_QUERY_CAPABILITIES call will get fixed anytime soon
(it’s always zero). Or other ideas on how to ask the PDO what PCMCIA slot
it’s physically attached to? Even the Microsoft PCMCIA UI displays the
wrong thing. I insert a card in slot 1, and the UI says slot zero. I assume
the IRP_MN_QUERY_CAPABILITIES bug is the root cause?

At 08:09 AM 5/17/00 -0700, Eliyas Yakub wrote:
>http://support.microsoft.com/support/kb/articles/q256/1/61.asp
>
>Is this what you need?

Yes, I tried to make that code work before, without any success. I don’t
remember the error I got back, but didn’t seem to get a structure full of
card data. If you look at that code it seems to set the socket number
BEFORE the IOCTL call, so assume it get’s passed down the stack to the bus
driver. Assuming I could figure out how to make it work, I’m still not sure
it tells me what physical socket is associated with a specific PDO, since
all the PDO’s on a bus would pass it down to their owning bus driver. I
also have to assume this is NOT how the PCMCIA UI tries to report the slot
number. I think you can insert ANY PCMCIA can in slot 1, and the UI says
it’s slot 0. This bug is documented (W2K release notes I believe) where it
says if you insert two identical PCMCIA cards, you can’t get the PCMCIA UI
tray applet to stop the correct one.

- Jan