Query regarding REMOVE_DEVICE handling by a Bus Driver

Hi,
How should a PnP Function driver acting as a bus driver for an
underlying bus handle IRP_MN_REMOVE_DEVICE IRP? I have a case where the
function driver is removed through the device manager. This function driver
is acting as a bus driver for an underlying bus (like 1394) and has
enumerated some devices and loaded drivers for them. Should the function
driver unload all the device drivers loaded by it (for its child devices)
and then complete its REMOVE_DEVICE IRP? I want some details in this regard.

Thanks & Regards,
S.Balaji

***********************************************************************
Disclaimer:
This document is intended for transmission to the named recipient only. If
you are not that person, you should note that legal rights reside in this
document and you are not authorized to access, read, disclose, copy, use or
otherwise deal with it and any such actions are prohibited and may be
unlawful. The views expressed in this document are not necessarily those of
HCL Technologies Ltd. Notice is hereby given that no representation,
contract or other binding obligation shall be created by this e-mail, which
must be interpreted accordingly. Any representations, contractual rights or
obligations shall be separately communicated in writing and signed in the
original by a duly authorized officer of the relevant company.
***********************************************************************


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

> enumerated some devices and loaded drivers for them. Should the function

driver unload all the device drivers loaded by it (for its child devices)

IIRC you can call IoDeleteDevice for all your remaning child PDOs in REMOVE
handler of the parent FDO. Assume that the child stacks are already
disassembled.

See also the Toaster sample, this comment for instance:

//
// Typically the system removes all the children before
// removing the parent FDO. If for any reason child Pdos are
// still present we will destroy them explicitly, with one
exception -
// we will not delete the PDOs that are in SurpriseRemovePending
state.
//

Max


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

If the child device was surprise removed, it’s stack will still get an
IRP_MN_REMOVE_DEVICE IRP at some point, so you can’t call IoDeleteDevice on
the child PDO from the bus driver in the bus driver’s remove handler in
that case. The child stack has to stick around to handle the eventual
remove. Have the child PDO’s remove handler delete the PDO in that case
and everything should unload fine. The toaster sample in the latest DDK,
as Max mentioned, is the place to see how this is done correctly.

Another thing to watch out for, is the child stack can get multiple
IRP_MN_REMOVE_DEVICE IRPs. So, the child stack has to be able to handle a
remove even after IoDeleteDevice is called on the child PDO for that
stack.

These are probably the two trickiest elements to getting a bus driver
correct. Well, these and handling power according to the On Now Power
Management white paper from Microsoft. But, I have only seen one bus
driver implement this white paper’s power strategy, mine.

If you are looking for cross-platform compatibility with Win98/ME be aware
that there are some significant differences in bus driver operation
especially as relates to power management. Win98/ME track child and parent
power states and won’t let certain events occur in the wrong order, like a
child powering up before the bus driver. These platforms will actually
power up the bus first automatically. This is not the case in 2000/XP.
Power management is completely up to the bus driver on these platforms.
There may well be cases where it doesn’t matter, but if it does for your
bus, then on 2000/XP your bus driver must track the child PDO power states
and power the bus driver accordingly. Compound this with the fact that you
shouldn’t block in a power handler and you have a really fun situation.

Good luck.

Bill McKenzie
Software Engineer
bSquare Corporation

On 09/25/01, ““Maxim S. Shatskih” ” wrote:
> > enumerated some devices and loaded drivers for them. Should the function
> > driver unload all the device drivers loaded by it (for its child devices)
>
> IIRC you can call IoDeleteDevice for all your remaning child PDOs in REMOVE
> handler of the parent FDO. Assume that the child stacks are already
> disassembled.
>
> See also the Toaster sample, this comment for instance:
>
> //
> // Typically the system removes all the children before
> // removing the parent FDO. If for any reason child Pdos are
> // still present we will destroy them explicitly, with one
> exception -
> // we will not delete the PDOs that are in SurpriseRemovePending
> state.
> //
>
> Max
>
>
>
> —
> You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com