_Oliver
驱动牛犊
驱动牛犊
  • 注册日期2001-09-10
  • 最后登录2002-11-22
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:1074回复:0

请教高手一个中断问题

楼主#
更多 发布于:2002-03-19 15:08
我参考Chris Cant的例子PHDIo,做了个ISA的驱动程序,但发现在2K下运行正常,但在98与NT下中断程序总不响应中断信号。怎么也看不出问题出在哪,总觉得好象是连接时没边上。但程序好象是没错呀,运行时也打印说连上了,要不2K也不通运行呀?我在PHDIO的例子上,去掉了中断要命令才能连接的部分,直接在创建时就连上。请大侠帮我看看这程序错在哪儿,不胜感激。
NTSTATUS PHDIoCreate( IN PDEVICE_OBJECT phddo,
IN PIRP Irp)
{
PGTSV_DEVICE_EXTENSION dx = (PGTSV_DEVICE_EXTENSION)phddo->DeviceExtension;
PIO_STACK_LOCATION IrpStack = IoGetCurrentIrpStackLocation(Irp);

dx->GotPortOrMemory = false;
dx->GotInterrupt = false;
dx->PortNeedsMapping = false;
dx->ConnectedToInterrupt = false;
dx->ResourceOverride = FALSE;

// Get resources from filename string
PUNICODE_STRING usfilename = &(IrpStack->FileObject->FileName);
NTSTATUS status = GetResourcesFromFilename(usfilename,dx);
if( !NT_SUCCESS(status)) goto fail;

// We must have IO port resource
if( !dx->GotPortOrMemory)
{
status = STATUS_INVALID_PARAMETER;
goto fail;
}

// Claim resources
status = ClaimResources(phddo);
if( !NT_SUCCESS(status))
{
goto fail;
}

// Translate and map resources
status = TranslateAndMapResources(phddo);
if( !NT_SUCCESS(status))
{
UnclaimResources(phddo);
goto fail;
}

if (dx->GotInterrupt) {
KdPrint((\"Got Interrupt Source!\"));
// Try to connect to interrupt
status = IoConnectInterrupt( &dx->InterruptObject, (PKSERVICE_ROUTINE)InterruptHandler,
dx, NULL, dx->Vector, dx->Irql, dx->Irql, dx->Mode, FALSE, dx->Affinity, FALSE);
if( NT_SUCCESS(status)) {
//initialize interrupt event handle
if(dx->intevent!=NULL)
{
ObDereferenceObject(dx->intevent);
dx->intevent=NULL;
}

dx->pGenCmd=NULL;
dx->pDataInoutReq=NULL;

//release and clear background commandset
if(dx->pCmdset != NULL)
{
ExFreePool(dx->pCmdset);
dx->pCmdset=NULL;
}
KdPrint((\"Interrupt Connected!\"));
dx->ConnectedToInterrupt = true;
}
else {KdPrint((\"Interrupt Can\'t Connected!\"));}
}
else {KdPrint((\"Can\'t Got Interrupt Resource!\")); }
/// Complete
return CompleteIrp(Irp,status);

// On error, make sure everything\'s off
fail:
dx->GotPortOrMemory = false;
dx->GotInterrupt = false;
dx->PortNeedsMapping = false;
dx->ConnectedToInterrupt = false;
return CompleteIrp(Irp,status);
}
游客

返回顶部