IMPLEMENTING POWER MANAGEMENT

This section implements a rudimentary Power Management (PM) system for a device driver. The system is implemented as the four Power Management IOCTLs and registers the device for system requests to change its power state, and responds to queries about its power state. This PM system does not implement a message queue to handle power requests and does not attempt to send any requests to change its power state because of any inactivity, and so on by itself. The code in this section is in the code snippets file. The driver subproject is also included in the folder MorePower.

1. Create a new stream driver with the CEDriverWiz Wizard with the following configuration:

  • Stream Name: MorePower
  • Suffix: MPW
  • Driver in kernel mode
  • Enable Driver I/O
  • Disable the PowerUp/PowerDown functions
  • Seek is not needed
  • Disable Driver Context
  • Enable Advanced IOCTls
  • Enable Retail Mode macros
  • Enable Power IOCTLs

The last option adds the four power IOCTLs:

  • IOCTL_POWER_CAPABILITIES
    • Checks device-specific capabilities
  • IOCTL_POWER_GET
    • Gets the current device power state
  • IOCTL_POWER_SET
    • Requests a change from one device power state to another
  • IOCTL_REGISTER_POWER_RELATIONSHIP
    • Notifies the parent device so that the parent device can register all the devices that it controls

These IOCTLs as added by the wizard need implementation and return false to indicate to the operating system that PM has not been implemented.

2. Add the following declarations, the #include entries ...

Get Professional Windows® Embedded Compact 7 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.