Windows 10: EvtDevicePrepareHardware/EvtDeviceD0Entry

Hi,

I am currently modifying my driver (PCI/function) to work correctly in
the face of “Fast Boot”.

Up to now I was only using EvtDevicePrepareHardware() to do what’s
needed to initialize the device. Now, on Windows 10, I realized that the
system saves state at shutdown and does not call
EvtDevicePrepareHardware() anymore at all. Rather, I appear to have to
use the EvtDeviceD0Entry() and …exit() callbacks. Done, works.

Except: when the system has been shutdown, I unplug the PCMCIA card. On
boot, the driver for the device (which is is still loaded) receives a
“D0 entry” and the device initialization fails because there is no
device. Still, I get a “D0 exit” afterwards, even though the “D0 entry”
failed.

When I was using the prepare/release hooks, they got called pairwise,
and this is what I built assumptions upon. Now that I moved to the D0
stuff, assumptions don’t hold anymore and I have to fix code. This can
be done, but I am asking myself: is this the way to go?

Thanks,
Joerg

I am not sure how your driver worked previously. Before adding support for fast boot, what did you do in D0Entry? How did you handle system suspend and hibernate? To support both of these states you needed to initialize the device in D0Entry.

As for the failure case where the device is removed, the OS behavior and callbacks you listed are the documented and expected behavior. I am not sure what assumptions are being violated from your POV. Do you expect if you fail D0Entry that you will not have D0Exit called?

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Jörg Faschingbauer
Sent: Wednesday, May 4, 2016 8:08 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Windows 10: EvtDevicePrepareHardware/EvtDeviceD0Entry

Hi,

I am currently modifying my driver (PCI/function) to work correctly in the face of “Fast Boot”.

Up to now I was only using EvtDevicePrepareHardware() to do what’s needed to initialize the device. Now, on Windows 10, I realized that the system saves state at shutdown and does not call
EvtDevicePrepareHardware() anymore at all. Rather, I appear to have to use the EvtDeviceD0Entry() and …exit() callbacks. Done, works.

Except: when the system has been shutdown, I unplug the PCMCIA card. On boot, the driver for the device (which is is still loaded) receives a
“D0 entry” and the device initialization fails because there is no device. Still, I get a “D0 exit” afterwards, even though the “D0 entry”
failed.

When I was using the prepare/release hooks, they got called pairwise, and this is what I built assumptions upon. Now that I moved to the D0 stuff, assumptions don’t hold anymore and I have to fix code. This can be done, but I am asking myself: is this the way to go?

Thanks,
Joerg


NTDEV is sponsored by OSR

Visit the list online at: http:

MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
Details at http:

To unsubscribe, visit the List Server section of OSR Online at http:</http:></http:></http:>

Jörg Faschingbauer wrote:

Except: when the system has been shutdown, I unplug the PCMCIA card. On
boot, the driver for the device (which is is still loaded) receives a
“D0 entry” and the device initialization fails because there is no
device. Still, I get a “D0 exit” afterwards, even though the “D0 entry”
failed.

When I was using the prepare/release hooks, they got called pairwise,
and this is what I built assumptions upon. Now that I moved to the D0
stuff, assumptions don’t hold anymore and I have to fix code. This can
be done, but I am asking myself: is this the way to go?

Hmm. The documentation says “The framework does not call the driver’s
EvtDeviceD0Exit callback function after the EvtDeviceD0Entry callback
function returns a status value for which NT_SUCCESS(status) equals
FALSE.” You’re saying that didn’t happen here?


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