none
Implementing SetSystemPowerState to reset RRS feed

  • Question

  • I'm kind of new with windows ce, but I have to get a software reset to work, right now if i called SetSystemPowerState(NULL,POWER_STATE_RESET,0) it will shut the system down. I need to change this to allow a restart instead, and I'm just trying to figure out whate this call will do and how the system handles it so I can change it.
    Tuesday, March 29, 2011 4:07 PM

Answers

  • Yes, that does look like a bug, or at least an undocumented feature.  If using PMSTUBS, then you must pass in POWER_STATE_RESET as the options.   If you are using full power managment, then you don't need to do that - it correctly looks at the state instead of the options.


    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.
    www.Eurotech.com
    • Marked as answer by Kevin Chaves Tuesday, March 29, 2011 10:22 PM
    Tuesday, March 29, 2011 8:07 PM
    Moderator

All replies

  • If you search PUBLIC\COMMON\OAK\DRIVERS\PM for POWER_STATE_RESET you will find that it handles this by calling KernelIoControl(IOCTL_HAL_REBOOT, NULL, 0, NULL, 0, NULL)

    So you can either, change the handling of IOCTL_HAL_REBOOT, or change the PM code to do something different.


    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.
    www.Eurotech.com
    • Proposed as answer by Vinoth[MCTS] Tuesday, March 29, 2011 5:49 PM
    Tuesday, March 29, 2011 4:55 PM
    Moderator
  • I actually think we just found a bug in windows CE, it works if we call it like this

    SetSystemPowerState(NULL,POWER_STATE_RESET,POWER_STATE_RESET)

    our board support package already has a implementation to get the reset, which is what i was looking for, in our case it uses watchdog to get the system to reboot. but to get to the KernelLibIoControl() call never works because it &'s the options with the state

        } else if((dwOptions & POWER_STATE_RESET) != 0) {  // reset only works if its the the options are the same
            // is this to be a cold boot?
            BOOL fCleanReboot = FALSE;
            __try {
                fCleanReboot = (_tcscmp(pwsState, _T("coldreboot")) == 0);
            }__except (EXCEPTION_EXECUTE_HANDLER ) {
                fCleanReboot = FALSE;
            }
            if(fCleanReboot) {
                SetCleanRebootFlag();
            }
            // should not return from this call, but if we do just suspend the system
            KernelLibIoControl((HANDLE)KMOD_OAL, IOCTL_HAL_REBOOT, NULL, 0, NULL, 0, NULL);
            RETAILMSG(TRUE, (_T("PM: PmSetSystemPowerState(Stubs): KernelIoControl(IOCTL_HAL_REBOOT) returned!\r\n")));
            DEBUGCHK(FALSE);        // break into the debugger

    Tuesday, March 29, 2011 6:00 PM
  • What version of Windows CE are you targeting?
    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.
    www.Eurotech.com
    Tuesday, March 29, 2011 6:55 PM
    Moderator
  • this is windows ce 6.0 r3 with updates up to December 2010
    Tuesday, March 29, 2011 7:12 PM
  • Yes, that does look like a bug, or at least an undocumented feature.  If using PMSTUBS, then you must pass in POWER_STATE_RESET as the options.   If you are using full power managment, then you don't need to do that - it correctly looks at the state instead of the options.


    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.
    www.Eurotech.com
    • Marked as answer by Kevin Chaves Tuesday, March 29, 2011 10:22 PM
    Tuesday, March 29, 2011 8:07 PM
    Moderator
  • How would we not use pmstubs, it just happens to be the one we fall into when calling SetSystemPowerState?

     

    Tuesday, March 29, 2011 8:27 PM
  • By including Power Management (full) instead of Power Managment (minimal) from the catalog.
    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.
    www.Eurotech.com
    Tuesday, March 29, 2011 9:50 PM
    Moderator