大家好,最近在我一个ce下的usb key的驱动开发,出现这样的问题,麻烦大家给个意见。问题描述如下:
驱动中我采用xxx_read 和xxx_write来响应读写操作,也就是采用流设备的方式。读写操作中,写操作不会有问题,而读操作中一次最多读取到64 byte的数据(设备一次只能发送64byte),所以在少于64byte的字节读操作时不会有问题,但是因为ukey涉及到rsa密钥对产生,它的数据大于64byte,也就是说一次传输无法完成。问题就出现在这里,在生成rsa密钥对的时候,由于数据量大,会出现设备死等的现象。
跟踪到ohci层发现,在每次设备传输完成的时候调用的CheckForDoneTransfers中,发现64个byte的数据已经到了td缓冲区,并且已经缓存起来。这个时候程序不再往下执行。跟正常操作的进行比较过后发现,在64 byte的数据写进td缓冲区后,就不再有后续的操作。问题也是在下面这个CheckForDoneTransfersThread函数中产生的
ULONG CHCCAera::CheckForDoneTransfersThread( )
{
SetKMode(TRUE);
DEBUGMSG( ZONE_TRANSFER && ZONE_VERBOSE, (TEXT("+CHCCAera::CheckForDoneTransfersThread\n")) );
DEBUGCHK( m_hCheckForDoneTransfersEvent != NULL );
while ( !m_fCheckTransferThreadClosing ) {
WaitForSingleObject( m_hCheckForDoneTransfersEvent, INFINITE );
if ( m_fCheckTransferThreadClosing ) {
break;
}
// Must be set when this thread is signalled but under stress conditions
// it could get temporarily unset by the time we get here. If that
// happens then we just wait for the event to get signalled again.
TDLINK pTD;
pTD.td = (P_TD) InterlockedExchange((LPLONG)&m_pDoneHead, 0L);
while (pTD.td) {
CPipe * pTDPipe;
if (pTD.td->bfIsIsoch) {
pTDPipe = pTD.itd->pPipe;
ASSERT(pTD.itd->pTransfer->GetPipe() == pTDPipe);
}
else {
pTDPipe = pTD.td->pPipe ;
ASSERT( pTD.td->pTransfer->GetPipe() == pTDPipe);
}
// these fields all have the same offsets for TDs and ITDs
if (pTD.td->bfDiscard) {
// the transfer has been aborted already and completed elsewhere
DEBUGMSG(ZONE_WARNING, (TEXT("CPipe::CFDT DISCARDING td %08x nxt %08x xfr %08x\n"), pTD.td, pTD.td->paNextTd.td,pTDPipe));
pTD = pTD.td->paNextTd;
continue;
}
DEBUGMSG(ZONE_TRANSFER && ZONE_VERBOSE, (TEXT("CPipe::CFDT td %08x nxt %08x xfr %08x\n"), pTD.td, pTD.td->paNextTd,pTDPipe));
// advance pTD first because it will get freed if it's the last TD of the transfer
// see notes above for why we can and want to advance multiple
TDLINK pNextTD = pTD.td->paNextTd; // same offset as for itd
RETAILMSG(N,(TEXT("TO CheckForDoneTransfers\r\n")));
pTDPipe->CheckForDoneTransfers(pTD);
pTD = pNextTD;
}
}
DEBUGMSG( ZONE_TRANSFER && ZONE_VERBOSE, (TEXT("-CHCCAera::CheckForDoneTransfersThread\n")) );
return 0;
}
无法再进入这个while (pTD.td)循环,而且也等不到hCheckForDoneTransfersEvent这个事件。不知道出现这样的问题,该有什么好的方法解决,多谢大家指教!!
是不是我没有表达清楚我的意思,大家不理解呢?
尝试了很多方法去试图自己发中断信号,可是会出现device.exe报错。
希望遇到过的朋友能给个意见,mm我多谢大家了。
ps:该设备采用的是控制传输,就是IssueVendorTransfer
请问您是哪个USBKey厂家的?我现在正需要这样支持WinCE的产品,你开发出来后我第一个购买。QQ:476833461