# What is the best way to reboot the system using system function in an application?

• ### Question

• Dear Developers,

Greetings!!!!

As, i would like to reboot my WinCE 7 based system with an application. I am using one system defined function SetSystemPowerState. Below is the sample code -

DWORD result;
result = SetSystemPowerState(NULL, POWER_STATE_BOOT,0);
if(result){
DEBUGMSG(TRUE,(TEXT("The system is going to boot\r\n")));
}
else{

DEBUGMSG(TRUE,(TEXT("ERROR: While trying to reboot the system :%d\r\n"),GetLastError()));
}

But, when I run my application I got the following debug messages -

 100418 PID:4740016 TID:319004e CePerf.dll is absent - performance data will not be recorded
PB Debugger Loaded 'System_Reboot_DEBUG.exe', no matching symbolic information found.
100535 PID:2cc0652 TID:234063a CePerf.dll is absent - performance data will not be recorded
100537 PID:400002 TID:db0006 PM: DEBUGCHK failed in file d:\bt\2034\public\common\oak\drivers\pm\pdd\default\pwsdef.cpp at line 424
100538 PID:400002 TID:db0006 DefaultPowerStateManager::PlatformMapPowerStateHint: returning 2
100539 PID:2cc0652 TID:234063a The system is going to boot
100539 PID:2cc0652 TID:234063a Dll list:
PB Debugger Unloaded symbols for 'System_Reboot_DEBUG.exe'

But, the system does not boot. Any conclusion with the above observations???

Thursday, April 2, 2015 5:11 AM

### All replies

• Hi,

for x86 platforms - try SetSystemPowerState (NULL, POWER_STATE_RESET, POWER_FORCE) instead.

Default reboot routine is located @ WINCE700\platform\common\src\x86\common\ioctl\reboot.c, but custom BSP may port it to itself.

Good luck.

Thursday, April 2, 2015 8:20 AM
• Dear iShust,

Thanks for reply but I am using Arm arch.

Thursday, April 2, 2015 10:29 AM
• That will require that you, the BSP developer, develop code in the OAL to actually implement rebooting.

But I would try POWER_STATE_RESET first.

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 Tuesday, May 19, 2015 10:41 AM
Thursday, April 2, 2015 12:49 PM
• Dear Developers,

Greetings!!

@Bruce, Thanks for your complement, yes this can be the way to actually implement rebooting but in my query it is mentioned that .....funciton in an application??

Friday, April 3, 2015 3:23 AM
• Using SetSystemPowerState (NULL, POWER_STATE_RESET, POWER_FORCE) will finally call the  KernelLibIoControl((HANDLE)KMOD_OAL, IOCTL_HAL_REBOOT, NULL, 0, NULL, 0, NULL)

you have to implement IOCTL_HAL_REBOOT Kernel IOCTL in OAL part of your BSP.

Vinoth.R

Friday, April 3, 2015 6:26 AM
• Dear Vinoth,

Is reset and reboot both are same. If yes, then okay and if not then please specify the way to reboot the system rather then reset the system????

Friday, April 3, 2015 6:36 AM
• yes. reset can be done though various methods depends on the processor and board . you have to implement the above mentioned IOCTL to perform the reboot through resetting your processor/hardware.