DriverEntry中注册了接口函数:
Characteristics.DisableInterruptHandler = xxxx_MiniportDisableInterrupt;
Characteristics.EnableInterruptHandler = NULL;
Characteristics.HandleInterruptHandler = xxxx_MiniPortHandleInterrupt;
Characteristics.InitializeHandler = xxxx_MiniportInitialize;
Characteristics.ISRHandler = xxxx_MiniportISR;
...
xxxx_MiniportInitialize()中申请了逻辑中断号:
status = NdisMRegisterInterrupt(
&Adapter->Interrupt,
Adapter->MiniportAdapterHandle,
Adapter->InterruptNumber, // 20
0,
TRUE,
FALSE,
NdisInterruptLatched
);
网卡会产生独立的中断,物理中断号为20 。
发送包时,产生了发送中断,进入OEMInterruptHandler(),检查确实是网卡中断(20),但返回的逻辑中断号sysIntr却是-1(0xFFFFFFFF),这是为什么呢??
后来在NdisMRegisterInterrupt()后加入了下面的语句:
KernelIoControl(IOCTL_HAL_REQUEST_SYSINTR, &dwIrq, sizeof(dwIrq), &dwSysintr, sizeof(dwSysintr), 0);
其中将dwIrq设置为网卡中断对应的OAL中断号,得到了一个逻辑中断号dwSysintr.
网卡发送包,进入OEMInterruptHandler(),返回的逻辑中断号确实等于dwSysintr, 但之后却并没有调用xxxx_MiniportISR()函数,为什么啊??
谢谢指点。
上面有个写错了,不是
Characteristics.EnableInterruptHandler = NULL;
应该是
Characteristics.EnableInterruptHandler = xxxx_EnableInterruptHandler ;
NdisMRegisterInterrupt函数是用来通过Adapter->Interrupt即IRQ来注册一个sysintr,返回的逻辑中断号sysIntr却是-1是因为调用NdisMRegisterInterrupt之前可能你使能了中断,此时IRQ未绑定一个sysintr。所以应该在NdisMRegisterInterrupt之后使能中断,并且网卡的中断不执行isr处理程序不清中断是不会再产生中断的。注册表中可以把sysintr项屏蔽掉,只留下Interrupt就行了。