我用的wince 5 2410平台,在PwrButton驱动不能触发 WaitForSingleObject(gPwrButtonIntrEvent, INFINITE)
下面是PwrButton驱动的代码:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
/*
* This driver uses EINT0 button as POWER ON/OFF Button.
*
*/
// Request a SYSINTR value from the OAL.
//
if (!KernelIoControl(IOCTL_HAL_REQUEST_SYSINTR, &g_PwrButtonIrq, sizeof(UINT32), &g_PwrButtonSysIntr, sizeof(UINT32), NULL))
{
RETAILMSG(1, (TEXT("ERROR: PwrButton: Failed to request sysintr value for power button interrupt.\r\n")));
// g_PwrButtonSysIntr=SYSINTR_UNDEFINED;
return(0);
}
RETAILMSG(1,(TEXT("INFO: PwrButton: Mapped Irq 0x%x to SysIntr 0x%x.\r\n"), g_PwrButtonIrq, g_PwrButtonSysIntr));
if (!(InterruptInitialize(g_PwrButtonSysIntr, gPwrButtonIntrEvent, NULL, 0)))
{
// CloseHandle(gPwrButtonIntrEvent);
if (gOffFlag == FALSE)
{
if (PBT_IsPushed()) /* To Filter Noise */
{
Sleep(200);
if (PBT_IsPushed())
{
RETAILMSG(1, (TEXT("::: Back Light On/Off \r\n")));
}
else
{
// Soft reset and standard suspend-resume both start with suspend for now.
#if (WINCEOSVER >= 400)
// call whichever shutdown API is available
if(gpfnSetSystemPowerState != NULL)
{
gpfnSetSystemPowerState(NULL, POWER_STATE_SUSPEND, POWER_FORCE);
}
else
{
PowerOffSystem();
}
#else
PowerOffSystem();
#endif
// Give control back to system if it wants it for anything. Not in
// power handling mode yet. All suspend and resume operations
// will be performed in the PowerOffSystem() function.
Sleep(0);
}
}
InterruptDone(g_PwrButtonSysIntr);
}
}
RETAILMSG(1, (TEXT(":::end while 1 \r\n")));
return 0;
//
// Device deinit - devices are expected to close down.
// The device manager does not check the return code.
//
BOOL
DSK_Deinit(
DWORD dwContext // future: pointer to the per disk structure
)
{
return TRUE;
} // DSK_Deinit
//
// Returns handle value for the open instance.
//
DWORD
DSK_Open(
DWORD dwData,
DWORD dwAccess,
DWORD dwShareMode
)
{
return 0;
} // DSK_Open
//
// I/O Control function - responds to info, read and write control codes.
// The read and write take a scatter/gather list in pInBuf
//
BOOL
DSK_IOControl(
DWORD Handle,
DWORD dwIoControlCode,
PBYTE pInBuf,
DWORD nInBufSize,
PBYTE pOutBuf,
DWORD nOutBufSize,
PDWORD pBytesReturned
)
{
return FALSE;
} // DSK_IOControl