阅读:2994回复:3
PCI中断 一开启就重启,怎么回事?附代码
用windriver生成的驱动,调试PCI插卡,代码如下:
hPCI = (MBIPCI_HANDLE) malloc(1024*16); hPCI->hWD = INVALID_HANDLE_VALUE; strcpy(lic.cLicense,"6C3CC2FF5629291736D037215760FFA056B8CBDE.111"); WD_License(hPCI->hWD,&lic); hPCI->hWD = WD_Open(); if (hPCI->hWD==INVALID_HANDLE_VALUE) { AfxMessageBox("无效license"); return 0; } WD_VERSION ver; BZERO(ver); dwStatus = WD_Version(hPCI->hWD,&ver); /*Check WD Version*/ if(ver.dwVer < WD_VER) { /*Old than what is using*/ AfxMessageBox("驱动版本不匹配"); WD_Close(hPCI->hWD); return(0); } BZERO(pciScan); pciScan.searchId.dwVendorId = 0x104c; /*Chip ID*/ pciScan.searchId.dwDeviceId = 0x8025; dwStatus = WD_PciScanCards(hPCI->hWD, &pciScan); /*Search Device */ if (dwStatus == 0) /*search OK*/ { BZERO(pciCardInfo); pciCardInfo.pciSlot = pciScan.cardSlot[0]; /*------------------------ 2。4 获取PCI设备信息------------------------------------------------*/ dwStatus = WD_PciGetCardInfo(hPCI->hWD, &pciCardInfo); if (dwStatus == 0) { for(loop = 0;loop < pciCardInfo.Card.dwItems;loop++) { if(pciCardInfo.Card.Item[loop].item == ITEM_INTERRUPT) { hPCI->cardReg.Card.Item[0].item = ITEM_INTERRUPT; hPCI->cardReg.Card.Item[0].fNotSharable = TRUE; hPCI->cardReg.Card.Item[0].I.Int.dwInterrupt = pciCardInfo.Card.Item[loop].I.Int.dwInterrupt; hPCI->cardReg.Card.Item[0].I.Int.dwOptions = pciCardInfo.Card.Item [loop].I.Int.dwOptions;//或者 = 1; } if((pciCardInfo.Card.Item[loop].item == ITEM_MEMORY)&& (pciCardInfo.Card.Item[loop].I.Mem.dwBar == 0)) { hPCI->cardReg.Card.Item[1].item = ITEM_MEMORY; hPCI->cardReg.Card.Item[1].fNotSharable = pciCardInfo.Card.Item [loop].fNotSharable; hPCI->cardReg.Card.Item[1].I.Mem = pciCardInfo.Card.Item [loop].I.Mem; } } hPCI->pciSlot = pciCardInfo.pciSlot; hPCI->cardReg.fCheckLockOnly = FALSE; hPCI->cardReg.Card.dwItems = 2; /*-------------------------- 2。5 注册PCI设备---------------------------------------------------*/ dwStatus = WD_CardRegister(hPCI->hWD, &hPCI->cardReg); if(dwStatus != 0) { WD_Close(hPCI->hWD); delete[] hPCI; AfxMessageBox("打开设备失败"); return(0); } } else { WD_Close(hPCI->hWD); delete[] hPCI; AfxMessageBox("打开设备失败"); return(0); } } else { WD_Close(hPCI->hWD); delete[] hPCI; AfxMessageBox("打开设备失败"); return(0); } BZERO(Intrp); Intrp.hInterrupt = hPCI->cardReg.Card.Item[0].I.Int.hInterrupt; Intrp.dwOptions = 0; Intrp.Cmd = NULL; Intrp.dwCmds = 0; if(!InterruptEnable(&thread_handle,hPCI->hWD,&Intrp,(INT_HANDLER)isr_V,pdata)) /*程序执行到这句就重启了,请大侠们给症断症断怎么回事,传入的参数已经由注册时获取,看了好像都没问题,中断号什么的都对了,*/ { nStatus = WD_DMAUnlock(hPCI->hWD,&dma); nStatus = WD_CardUnregister(hPCI->hWD,&hPCI->cardReg); WD_Close(hPCI->hWD); delete[] hPCI; return(0); } 中断服务例程: INT_HANDLER isr_V() { driver->link->ClrAllInt(driver->link); printf("ddddddd"); return(0); } |
|
沙发#
发布于:2010-10-19 00:12
是不是中断服务例程中不能用printf()之类的函数?
|
|
板凳#
发布于:2010-12-10 09:30
中断中尽量不要有打印信息,那样不太好~~~
|
|
地板#
发布于:2010-12-10 10:53
尽量使用驱动中专用的打印函数,比如:KdPrint(("123"))
|
|