Share via


Pageable Device Drivers

During the Windows Mobile 5.0 timeframe, we changed most of the networking components to be pageable device drivers. This caused boot times to decrease by a significant amount since there was now more than 2MB extra free RAM.

 

A device driver can safely be made pageable if:

   1. it does not need to do any processing during the critical power down and power up phase (xxx_PowerDown and xxx_PowerUp)

   2. it is not involved in the paging process

 

All that needs to be done to make a device driver pageable is:

  1. remove the xxx_PowerDown and xxx_PowerUp entries from the driver’s .def file
  2. add the value, “Flags”=dword:2, to the device driver’s device key (2 == DEVFLAGS_LOADLIBRARY). By default, a device driver’s DLL is loaded with LoadDriver() which loads it as non-pageable.

 

In some device drivers the only processing during xxx_PowerDown/Up is to note that the system power mode has changed. Such processing can be replaced with a thread that uses a Message Queue (CreateMsgQueue) which it has passed to the RequestPowerNotifications function, specifying PBT_RESUME. Then it can loop calling ReadMsgQueue.

The PBT_RESUME messages get posted in a timely enough manner that this method is in most cases an adequate replacement for xxx_PowerDown/Up.

 

Author: David Kanz

Comments

  • Anonymous
    June 13, 2006
    Interesting article, I wasn't aware of this. So you're saying that whenever a driver has empty PowerUp/PowerDown (ie those functions are just empty stubs?), you should specify DEVFLAGS_LOADLIBRARY for that driver?


    And also, wherever possible, use PBT_RESUME instead of PowerUp/PowerDown? But doesn't PBT_RESUME only tell you when the system has been resumed, so it's only working to replace PowerUp? Isn't there some corresponding "PBT_SUSPEND"?

    Would an alternative be to use IOCTL_POWER_SET, and make sure to associate the platform's suspended state so the driver for sure gets such an ioctl to change its state for suspend/resume?

    There's no overflow of MSDN documentation around DEVFLAGS_LOADLIBRARY, some more details would be helpful.
  • Anonymous
    November 30, 2006
    The comment has been removed
  • Anonymous
    January 23, 2008
    PingBack from http://softwareinformation.247blogging.info/windows-ce-networking-team-weblog-pageable-device-drivers/
  • Anonymous
    June 15, 2009
    PingBack from http://mydebtconsolidator.info/story.php?id=12166