Windows CE Blog        Embedded Product Design Services

Nov/09

28

Customizing Power Manager for SetSystemPowerState()

Changing the system state can be as simple as a cup of tea! by calling SetSystemPowerstate() API. But not all power states can be allowed to set through this API in the default cases. For example setting to “SystemIdle” using this API will be failed.

There are some use cases, we may need to set “systemIdle” through our application/driver or we may need to deny the application/driver to set some power states.  Sometimes, we would like to have our own power state created and it may be allowed to set from the application/driver.  To do this, we have to customize the Windows CE power manager.

Customizing the Power Manager (Windows CE)

  • Since PM driver is the public component, it is not advisable to change the public code directly. We have to copy the PM driver from \WINCE600\PUBLIC\COMMON\OAK\DRIVERS\PM to your BSP driver folder and perform sysgen capture on the PM driver.
  • All power states codes are available on PM\PDD\DEFAULT\pwstates.cpp. PowerStateOn, PowerStateUserIdle, PowerStateSystemIdle, PowerStateSuspended, PowerStateResuming, PowerStateColdReboot and PowerStateReboot are the power states classes derived from PowerState class of PM\PDD\DEFAULT\pwsdef.cpp and pwsdef.hclass PowerStateUserIdle : public PowerState {public:
    PowerStateUserIdle(PowerStateManager *pPwrStateMgr, PowerState * pNextPowerState = NULL )
    :   PowerState(pPwrStateMgr,pNextPowerState)
    {;  };

    .   /*Remaining power states
    .       code */
    .
    .
    .
    virtual BOOL AppsCanRequestState() { return TRUE; }
    };

The above code snippet is the power state class for user idle, derived from PowerState class. Similarly, all power states are having their own classes  as explained above.

Allowing or denying to set the corresponding power state by calling SetSystemPowerState () is evaluated by the “power state manager” through   virtual BOOL AppsCanRequestState () { return TRUE; } function of each power state class. This function is defined as a virtual function in PowerState base class and it can be overridden by the derived power state class based on their needs. Below given figure explains the call flow of SetSystemPowerState () API.

customizing-windows-ce-power-manager-driver31

Fig: Call flow of SetSystemPowerStateAPI

  • If AppsCanRequestState() is return TRUE, Application/driver can set the corresponding power states through SetSystemPowerState() API. AppsCanRequestState() will return FALSE in the PowerState base class and the derived class will override this function to return TRUE, if they need to set through SetSystemPowerstate() API.
  • AppsCanRequestState() function is not overridden by the SystemIdle state. Because of this, calling SetSystemPowerState() with this state as a parameter will not work. If you want to enable, you have to override the AppsCanRequestState() function as explained in the above code snippet.
  • If you have your own power state, you have to override the function as explained above to set from application/driver.

RSS Feed

2 Comments for Customizing Power Manager for SetSystemPowerState()

Gurusamy | January 11, 2010 at 10:30 pm

Thanks Vinoth. You are doing a wonderful Job in Windows CE Domain from Chennai.Congratulations for all your CE Members. Actually I have to customize the PM for my new Project. and this helps me a lot to understand the big picture

Author comment by Vinoth - Microsoft Certified Technology Specialist | February 15, 2010 at 5:46 am

Hi Gurusamy,
Thank you for your appreciation

Leave a comment!

<< Marvell India Technology Day 2009

Creating an effective image viewer in Windows CE >>

Find it!

 

e-con Systems is a leading Product Design services company drives a passion of Productizing ideas, e-con so far have developed Smart phones, PDAs, Industrial data loggers, Loyalty terminals, Point of Sale terminals and Reference platforms among others with OS focus on Windows CE 6.0, Windows Mobile and Linux 2.6.25.

e-con is popularly known for its Computer on Modules, Reference Designs and Camera Solutions among others...

Copyright © 2009 w w w . e - c o n s y s t e m s . c o m . | Download Comp any Profile | Sitemap  Windows Embedded Gold Partner