Moving a Battery Driver from GWES to Device Manager (Windows Embedded CE 6.0)
1/6/2010
In Windows CE .NET 4.2, hardware platform-specific battery support code has been moved from GWES into an installable driver loaded by the Device Manager.
With this design, configurations that do not include GWES can receive access to the battery application programming interfaces (APIs). This design also enables battery information to become available earlier in the boot process and enables you to support batteries that report more, or different, data than the standard APIs permit.
Applications can continue to use the battery functions without modification. However, you should be aware of the following:
- If you are using a custom Cesysgen.bat file, rather than an Hlbase- or Iabase-based file, set the %COREDLL_COMPONENTS% environment variable to contain the Battery component and set the %CE_MODULES% environment variable to contain the Battdrvr Sysgen target.
- The battery functions are ready to use when the SYSTEM/BatteryAPIsReady event is signaled. This event is defined as BATTERY_API_EVENT_NAME in Battery.h.
- The battery driver must advertise the {DD176277-CD34-4980-91EE-67DBEF3D8913} GUID, preferably in the driver's IClass subkey. This GUID is defined as BATTERY_DRIVER_CLASS in Battery.h. Drivers that advertise this interface must support the IOCTLs listed in Battery.h.
- A sample null battery driver is provided in the %_WINCEROOT%\Public\Common\Oak\Drivers\Battdrvr directory. The Battdrvr Sysgen target automatically links this driver to the run-time image.
- The battery driver is divided into a model device driver (MDD) and a platform dependent driver (PDD). The Battdrvr_lib library implements the MDD and includes a sample PDD. To implement an actual PDD, implement all of the PDD entry points in Sbattif.c in your OS design and link with the MDD.
- For a sample battery driver, see %_WINCEROOT\Platform\Xsc1bd\Drivers\Battdrvr.
To move an existing battery driver out of the \GWES directory
Add battdrvr to %_WINCEROOT%\Public\Common\OAK\Drivers\Dirs.
Copy source and header information from \GWES\Battery into %_WINCEROOT%\Public\Common\OAK\Drivers\Battdrvr.
Copy %_WINCEROOT%\Platform\Xsc1bd\Drivers\Battdrvr\Sources along with Makefile and Battdrvr.def to %_WINCEROOT%\Public\Common\OAK\Drivers\Battdrvr.
Edit the Sources file as appropriate for your sources. For example, you should change the file name and include the path.
Edit the battery sources to supply the new APIs required by the MDDs. When the OS design's battery driver contains object files that list all of the entry points currently provided by Sbattif.c in the MDD, the linker includes the OS design code rather than Sbattif.obj in the final executable. This way, OEMs can link their own PDD with the battery driver library created in public. The battery driver in public serves as both a sample driver and as an MDD.
Add .bib and .reg entries for the new drivers, using any of the sample OS designs as a guide. Search for BATTDRVR in Platform.bib and Platform.reg for examples.
If your battery driver shares resources with any other drivers and previously relied on the fact that GWES was loaded later than installable drivers, adjust the driver load order in the registry appropriately.