阅读:2809回复:4
POWERBUTTON的问题?
我把PWR_IST这个线程中的SetSystemPowerState( NULL, POWER_STATE_ON, POWER_FORCE );这一句注释掉了,怎么系统还是一样可以唤醒呢?哪位大侠作过这方面的,来指点指点,是否按了键之后,还有其他地方调用了这个函数?
|
|
沙发#
发布于:2007-04-13 18:55
把必要的条件说清楚
不是每个人都有你一样的BSP的 |
|
板凳#
发布于:2007-04-14 00:57
看起来像是2410/2440里的
在powerbutton驱动里,在电源键按下后,会判断系统当前的电源状态,如果是运行状态,就会通过调用SetSystemPowerState()使系统进入休眠状态 而唤醒其实是和powerbutton驱动没有任何关系的,所以注释掉与否没什么关系,唤醒主要是由bootloader和WinCE启动部分代码来实现的 |
|
地板#
发布于:2007-04-14 09:15
但是我跟踪了一下,按键后首先会调HW_PowerUp,然后会进入PWR_IST执行SetSystemPowerState( NULL, POWER_STATE_ON, POWER_FORCE );
下面是这部分代码,大家看看有问题吗? BOOL HW_PowerUp(PPWR_CONTEXT pPWR) { RETAILMSG(1, (TEXT("PCF: HW_PowerUp \r\n"))); pPWR->State = RESUME; SetInterruptEvent(SYSINTR_POWER); return TRUE; } static DWORD PWR_IST(PPWR_CONTEXT pPWR) { int CurrStatus = RUN; DWORD we; WCHAR state[1024] = {0}; LPWSTR pState = &state[0]; DWORD dwBufChars = (sizeof(state) / sizeof(state[0])); DWORD dwStateFlags = 0; DWORD dwErr; if (!pPWR) return ERROR_INVALID_PARAMETER; while (1) { __try { we = WaitForSingleObject(pPWR->ISTEvent, INFINITE); RETAILMSG(1,(TEXT("\r\nPWR_IST: pPWR->State = 0x%x \r\n"), pPWR->State)); dwErr = GetSystemPowerState(pState, dwBufChars, &dwStateFlags); if (ERROR_SUCCESS != dwErr) { RETAILMSG(1, (TEXT("PMGET!GetSystemPowerState:ERROR:%d\n"), dwErr)); } else { RETAILMSG(1, (TEXT("PMGET! System Power state is '%s', flags 0x%08x\n"), state, dwStateFlags)); switch (POWER_STATE(dwStateFlags)) { case POWER_STATE_ON: RETAILMSG(1, (TEXT("PMGET!\tPOWER_STATE_ON\n"))); break; case POWER_STATE_OFF: RETAILMSG(1, (TEXT("PMGET!\tPOWER_STATE_OFF\n"))); break; case POWER_STATE_CRITICAL: RETAILMSG(1, (TEXT("PMGET!\tPOWER_STATE_CRITICAL\n"))); break; case POWER_STATE_BOOT: RETAILMSG(1, (TEXT("PMGET!\tPOWER_STATE_BOOT\n"))); break; case POWER_STATE_IDLE: RETAILMSG(1, (TEXT("PMGET!\tPOWER_STATE_IDLE\n"))); break; case POWER_STATE_SUSPEND: RETAILMSG(1, (TEXT("PMGET!\tPOWER_STATE_SUSPEND\n"))); break; case POWER_STATE_RESET: RETAILMSG(1, (TEXT("PMGET!\tPOWER_STATE_RESET\n"))); break; case 0: break; default: RETAILMSG(1,(TEXT("PMGET!\tUnknown Power State Flags:0x%x\n"),dwStateFlags)); ASSERT(0); break; } } switch (pPWR->State) { case RUN: RETAILMSG(1, (TEXT("PWR_IST: RUN\r\n"))); if (CurrStatus == SUSPEND) { RETAILMSG(1, (TEXT("CurrStatus == SUSPEND\r\n"))); pPWR->State = RUN; CurrStatus = RUN; // clear any potential pending ADC interrupt InterruptDone(SYSINTR_POWER); SetSystemPowerState( NULL, POWER_STATE_ON, POWER_FORCE ); continue; } else if (CurrStatus == RESUME) { RETAILMSG(1, (TEXT("CurrStatus == RESUME\r\n"))); if ( wcscmp(state,TEXT("unattended")) == 0 ) { RETAILMSG(1, (TEXT("Unattended Power Off Mode\r\n"))); pPWR->State = RUN; CurrStatus = SUSPEND; continue; } // else if ( wcscmp(state,TEXT("resuming")) == 0 ) // { // RETAILMSG(1, (TEXT("Still resuming...\r\n"))); // Sleep(1000); // SetEvent(pPWR->ISTEvent); // continue; // } else { RETAILMSG(1, (TEXT("Power On\r\n"))); pPWR->State = RUN; CurrStatus = RUN; // clear any potential pending ADC interrupt InterruptDone(SYSINTR_POWER); SetSystemPowerState( NULL, POWER_STATE_ON,POWER_FORCE ); continue; } } break; case INITIALIZE: // Keep from reading our clear on read INTx registers // during init. RETAILMSG(1, (TEXT("PWR_IST: INITIALIZE\r\n"))); Sleep(10); continue; break; case SUSPEND: RETAILMSG(1, (TEXT("PWR_IST: SUSPEND\r\n"))); // continue; break; case RESUME: case ADC_ERROR: RETAILMSG(1,(TEXT("PWR_IST: %s \r\n"), pPWR->State == RESUME ? L"RESUME" : L"ADC_ERROR" )); pPWR->State = RUN; CurrStatus = RESUME; // clear any potential pending ADC interrupt InterruptDone(SYSINTR_POWER); Sleep(200); SetEvent(pPWR->ISTEvent); // SetSystemPowerState( NULL, POWER_STATE_ON, POWER_FORCE ); continue; break; case UNINITIALIZED: RETAILMSG(1,(TEXT("PWR_IST: ExitThread \r\n"))); ExitThread(ERROR_SUCCESS); return ERROR_SUCCESS; default: RETAILMSG(1,(TEXT("PWR_IST: unknown state: %u\r\n"), pPWR->State)); TEST_TRAP; continue; break; } // // get status // // EnterCriticalSection(&pPWR->RegCS); // // if ( !pPWR->ResetRegReady ) { // } else { // // get & restore the cleared registers // pPWR->ResetRegReady = FALSE; // } LeaveCriticalSection(&pPWR->RegCS); // clear the interrupt before power off InterruptDone(SYSINTR_POWER); CurrStatus = SUSPEND; SetSystemPowerState( NULL, POWER_STATE_SUSPEND, POWER_FORCE ); } _except(EXCEPTION_EXECUTE_HANDLER) { RETAILMSG(1,(TEXT("!!! PWR_IST EXCEPTION: 0x%X !!!\r\n"), GetExceptionCode() )); } } } |
|
地下室#
发布于:2007-04-25 10:40
引用第2楼lostinfog于2007-04-14 00:57发表的“”: 高手能否说一下唤醒的代码在bootloader和WinCE启动部分的什么地方?能否讲讲这部分的流程 |
|