ENTERPRISE

Windows 7 : Programming Plug and Play and Power Management - Callbacks for Power-Up and Power-Down , Callback for Wake Signal Support

12/7/2013 2:24:58 AM

1. Callbacks for Power-Up and Power-Down

Drivers implement the EvtDeviceDOEntry and EvtDeviceDOExit callbacks to be notified when the device enters and exits the working state, respectively.

In a function driver (FDO), KMDF calls the EvtDeviceDOEntry callback after the device has entered the DO power state. The function driver’s EvtDeviceDOEntry callback should initialize the device and perform any other tasks that are required each time the device enters the working state.

In a bus driver (PDO), KMDF calls the EvtDeviceDOEntry callback to put the device into the DO power state. (If you are familiar with WDM drivers, you probably remember that a request to power up a device must be handled by the bus driver first and then other drivers higher in the device stack. For a request to lower the power state, the opposite is true.) A bus driver’s EvtDeviceDOEntry callback should put the device hardware in the DO state and perform any additional initialization that the device requires at this time.

The EvtDeviceDOEntry callback is called with a pointer to the WDFDEVICE object and a pointer to an enumerator that identifies the most recent power state of the device, before the transition to DO began.

KMDF calls the EvtDeviceDOExit callback any time the device must leave the DO state. The callback is passed a pointer to the WDFDEVICE object and a pointer to an enumerator that identifies the new power state. In a function driver (FDO), the callback should perform any final tasks that are required before the device changes power state. In a bus driver, the callback should change the power state of the physical hardware.

In the Featured Toaster sample, both of these functions are stubs.

2. Callback for Wake Signal Support

Drivers for devices that can generate wake signals implement the following callbacks to support wake-up:

  • EvtDeviceArmWakeFromSO and EvtDeviceDisarmWakeFromSO

  • EvtDeviceWakeFromSOTriggered

  • EvtDeviceArmWakeFromSx and EvtDeviceDisarmWakeFromSx

  • EvtDeviceWakeFromSxTriggered

To enable the wake signal, KMDF calls EvtDeviceArmWakeFromSO and EvtDeviceArmWakeFromSx while the device is in DO, but while power-managed I/O is stopped. Therefore, the driver does not receive I/O requests from power-managed queues while arming its device and so is not required to synchronize its I/O operations with these callbacks.

In the wake-arming callbacks, a function driver should handle any device-specific tasks that are required to enable the device to generate a wake signal. KMDF transitions the device out of the DO state soon after the wake signal is successfully enabled. The driver should not yet perform any tasks related to power state change; KMDF calls the driver’s EvtDeviceDOExit function to do that.

The EvtDeviceDisarmWakeFromSO and EvtDeviceDisarmWakeFromSx callbacks should undo any device-specific tasks that the driver performed to enable the wake signal for its device. KMDF calls the disarm callbacks after EvtDeviceDOEntry has returned the device to the DO state.

The Featured Toaster sample registers the ToasterEvtDeviceWakeArm function for both the EvtDeviceArmWakeFromSO and EvtDeviceArmWakeFromSx events. Likewise, it registers ToasterEvtDeviceWakeDisarm for both the EvtDeviceDisarmWakeFromSO and EvtDeviceDisarmWakeFromSx events.

In the Featured Toasted sample, these callbacks are stubs.

If the device triggers a wake signal when the system is in SO or Sx, the EvtDeviceWakeFromSOTriggered and EvtDeviceWakeFromSxTriggered events occur, respectively. KMDF calls these functions after the driver’s EvtDeviceDOEntry callback and before the EvtDeviceDisarmWakeFromSO or EvtDeviceDisarmWakeFromSx callback. The wake-triggered callback should perform any tasks that are required after the wake signal is triggered, but should not disarm the wake signal.

The Featured Toaster sample registers the ToasterEvtDeviceWakeTriggered callback for both the EvtDeviceWakeFromSOTriggered and EvtDeviceWakeFromSxTriggered events. In the sample, this callback is a stub.

Other  
  •  Windows 7 : Programming Plug and Play and Power Management - Managing Power Policy
  •  Windows 7 : Programming Plug and Play and Power Management - Registering Callbacks
  •  Parallel Programming with Microsoft Visual Studio 2010 : Using the MapReduce Pattern (part 2)
  •  Parallel Programming with Microsoft Visual Studio 2010 : Using the MapReduce Pattern (part 1)
  •  Parallel Programming with Microsoft Visual Studio 2010 : Data Parallelism - Reduction
  •  NET Debugging : Visual Studio (part 3) - Visual Studio 2010
  •  NET Debugging : Visual Studio (part 2) - .NET Framework Source-Level Debugging
  •  NET Debugging : Visual Studio (part 1) - SOS Integration
  •  System Center Configuration Manager 2007 : Creating Packages (part 3) - About Packages, Programs, Collections, Distribution Points, and Advertisements
  •  System Center Configuration Manager 2007 : Creating Packages (part 2) - Comparing GPO-based Software Distribution to ConfigMgr Software Distribution
  •  
    Video
    Video tutorials
    - How To Install Windows 8

    - How To Install Windows Server 2012

    - How To Install Windows Server 2012 On VirtualBox

    - How To Disable Windows 8 Metro UI

    - How To Install Windows Store Apps From Windows 8 Classic Desktop

    - How To Disable Windows Update in Windows 8

    - How To Disable Windows 8 Metro UI

    - How To Add Widgets To Windows 8 Lock Screen

    - How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010
    programming4us programming4us
    Top 10
    Free Mobile And Desktop Apps For Accessing Restricted Websites
    MASERATI QUATTROPORTE; DIESEL : Lure of Italian limos
    TOYOTA CAMRY 2; 2.5 : Camry now more comely
    KIA SORENTO 2.2CRDi : Fuel-sipping slugger
    How To Setup, Password Protect & Encrypt Wireless Internet Connection
    Emulate And Run iPad Apps On Windows, Mac OS X & Linux With iPadian
    Backup & Restore Game Progress From Any Game With SaveGameProgress
    Generate A Facebook Timeline Cover Using A Free App
    New App for Women ‘Remix’ Offers Fashion Advice & Style Tips
    SG50 Ferrari F12berlinetta : Prancing Horse for Lion City's 50th
    Popular Tags
    Video Tutorail Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Exchange Server Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 Adobe Flash Professional Dreamweaver Adobe Illustrator Adobe Photoshop CorelDRAW X5 CorelDraw 10 windows Phone 7 windows Phone 8 Iphone