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 (4)

  1. Matt says:

    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.

  2. cenet says:

    If the driver is involved in the paging system, then leave it unpageable; otherwise, yes, make it pageable.

    There is a PBT_TRANSITION. Typically, a component only needs to know about one edge (UP or DOWN). Historically on CE, the power down execution happened in critical system thread, so components tended to do the least amount of processing in this context (like a device driver will simply power down associated hardware).

    I haven’t used the IOCTL_POWER_* codes, but it sounds like another way to go. Most of the networking components that I changed have minimal stream device driver code (enough to plumb a path from application space) so I didn’t have to use IOCTL_POWER_* codes.