我目前是在一个wince5.0平台上写个小驱动,需要在init里启用一个中断,于是就想到了interruptinitialize()这个函数。现在的问题是如果在原BSP里的某个驱动里使用这个函数调用就没有问题,并且能完成任务;但是我自己写的驱动,编译完成后就总是出现调用错误,出错信息如下:
MyDriver - DLL_PROCESS_ATTACH
MyDriver - DEM_Init
+OALIntrEnableIrqs(1, 0x8c9902c8)
+BSPIntrEnableIrq(-1)
MyDriver - ~ DEM_Init
---------------------------------------------
下面附上我在powerbutton驱动里init函数中的代码,在这里加载就可以。
HANDLE WINAPI PWR_Init(ULONG Identifier)
{
HMODULE hmCore;
// get pointers to APIs for shutting down the system -- this is only necessary if
// we are concerned that somebody might sysgen a version of the OS that doesn't
// contain the appropriate APIs.
gpfnSetSystemPowerState = NULL;
hmCore = (HMODULE) LoadLibrary(_T("coredll.dll"));
if(hmCore == NULL)
return NULL;
gpfnSetSystemPowerState = (PFN_SetSystemPowerState) GetProcAddress(hmCore, _T("SetSystemPowerState"));
FreeLibrary(hmCore);
if (!PwrBtnSocInit(Identifier))
goto InitFailed;
g_hPwrBtnEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
g_hHTimerEvent = CreateEvent(NULL, FALSE, FALSE, NULL);//added by me///////////////////////////////////////////
g_hWaitAppCloseEvent = CreateEvent(NULL,FALSE,FALSE,PM_POWERBTN_WAIT_APP_CLOSE_EVENT);
if(g_hPwrBtnEvent == NULL || g_hWaitAppCloseEvent == NULL)
goto InitFailed;
if (!(InterruptInitialize(g_oalSysInfo.pwrbtnInfo.dwSysIntr, g_hPwrBtnEvent, NULL, 0)))
{
DEBUGMSG(DBG_ATLAS_ZONE_INIT | DBG_ATLAS_ZONE_ERROR, (TEXT("PwrBUTTON INTR INIT Failed\r\n")));
goto InitFailed;
}
if(g_hPwrBtnThread == NULL)
{
g_hPwrBtnThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) PwrButtonIntrThread, NULL, 0, NULL);
if ( g_hPwrBtnThread == NULL)
{
DEBUGMSG(DBG_ATLAS_ZONE_INIT | DBG_ATLAS_ZONE_ERROR, (TEXT("Fatal Error! Failed to create PwrButton threads.\r\n")));
goto InitFailed;
}
}
//////////////////////////////////////....added by me.......................
if (!(InterruptInitialize(SYSINTR_TIMER2, g_hHLTimerEvent, NULL, 0)))
{
RETAILMSG(1, (TEXT("SYSINTR_TIMER2 INTR INIT Failed\r\n")));
}
////////////////////////////////////................end..................
if (g_oalSysInfo.pwrbtnInfo.bCloseWmpOnSleep)
{
if (NULL == g_hCloseWmpEvent)
{
g_hCloseWmpEvent = CreateEvent(NULL,FALSE,FALSE,PM_POWERBTN_CLOSE_WMPLAYER_EVENT);
}
if (NULL == g_hCloseWmpThread)
{
g_hCloseWmpThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) CloseWmpThread, NULL, 0, NULL);
}
if (NULL == g_hCloseWmpEvent || NULL == g_hCloseWmpThread)
{
DEBUGMSG(DBG_ATLAS_ZONE_INIT | DBG_ATLAS_ZONE_ERROR, (TEXT("Fatal Error! Failed to create CloseWmpThread! r\n")));
goto InitFailed;
}
}
//create _T("SHARE_POWER_NOTIFY_EVENT") event, if sleep event come from extern force, will skip this time pwr
ghevNotifyEvent = CreateEvent(NULL, FALSE, FALSE, PM_POWER_NOTIFY_EVENT);
if(ghevNotifyEvent == NULL)
{
RETAILMSG(1,(TEXT("PWR_Init:: create ghevNotifyEvent failure\r\n")));
}
if ( !CeSetThreadPriority(g_hPwrBtnThread, ATLAS_THRDPRI_POWER))
{
DEBUGMSG(DBG_ATLAS_ZONE_INIT | DBG_ATLAS_ZONE_ERROR, (TEXT("Power Button ERROR: CeSetThreadPriority ERROR:%d\n"), GetLastError()));
goto InitFailed;
}
DEBUGMSG(DBG_ATLAS_ZONE_INIT, (TEXT("-PwrButton PWR Init\r\n")));
return g_hPwrBtnThread;
InitFailed:
PWR_Deinit(0);
return NULL;
}
--------------------------------------------
当加上红色的代码时就会出错,当然,我已经将SYSINTR_TIMER2和IRQ_TIMER2在[BSP]\kernel\oal\intr.c文件中的BSPIntrInit里静态连接上了。
这个事情困扰了好几天,还是没找出问题所在。