how to handle the interrupt

Hi all,
As a part of my job i am developing one pci device driver in which
whenever i get the interrupt my system gets restarted.the code that i am
using is simple and as following

first i am regisetering device driver’s InterruptService routine (ISR) by
using

status = IoConnectInterrupt(&devExt->Interrupt,
PciDeviceCInterruptHandler,
devExt, // ISR Context
NULL,
devExt->InterruptVector,
devExt->InterruptLevel,
devExt->InterruptLevel,
devExt->InterruptMode,
TRUE, // shared interrupt
devExt->InterruptAffinity,
FALSE);

and my interrupt handler routine is as following

BOOLEAN
PciDeviceCInterruptHandler(
IN PKINTERRUPT Interupt,
IN PVOID ServiceContext
)
{
BOOLEAN InterruptRecognized = FALSE;
struct DEVICE_EXTENSION *devExt = (struct DEVICE_EXTENSION
*)ServiceContext;
USHORT IntStatus;

DbgPrint(“—> PciDeviceCInterruptHandler\n”);
//IoRequestDpc(devExt->filterDevObj, NULL, devExt);
Pci_Device_Disable_Interrupt(devExt);
KeSetEvent(&devExt->KeInterruptevent, IO_NO_INCREMENT, FALSE);
InterruptRecognized = TRUE;

DbgPrint(“<– NICInterruptHandler\r\n”);

return InterruptRecognized;
}

By using this i am just trying to see weather i am able to get the interrupt
and process it successfully or not i have not added any functionality yet.

but i am suspecting that as i am geting the interrupt my system gets
restarted.

If this is not the right way to handle the iterrupt then please you people
can give me some sample code or any url of the tutorial and any other stuff
that can help me to complete this task successfully.

Thanks
Nayan


Sexy, sultry, sensuous. - see why Bipasha Basu is all that and more. Try MSN
Search http://server1.msn.co.in/Profile/bipashabasu.asp

You cannot call KeSetEvent at DIRQL in your interrupt, you must queue
the DPC so that you can run at the appropriate IRQL (DISPATCH_LEVEL)
where you can set the event. In general, there are very few APIs you
can call at DIRQL.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of nayan kumar
Sent: Friday, September 15, 2006 9:32 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] how to handle the interrupt

Hi all,
As a part of my job i am developing one pci device driver in
which
whenever i get the interrupt my system gets restarted.the code that i am

using is simple and as following

first i am regisetering device driver’s InterruptService routine (ISR)
by
using

status = IoConnectInterrupt(&devExt->Interrupt,
PciDeviceCInterruptHandler,
devExt, // ISR Context
NULL,
devExt->InterruptVector,
devExt->InterruptLevel,
devExt->InterruptLevel,
devExt->InterruptMode,
TRUE, // shared interrupt
devExt->InterruptAffinity,
FALSE);

and my interrupt handler routine is as following

BOOLEAN
PciDeviceCInterruptHandler(
IN PKINTERRUPT Interupt,
IN PVOID ServiceContext
)
{
BOOLEAN InterruptRecognized = FALSE;
struct DEVICE_EXTENSION *devExt = (struct DEVICE_EXTENSION
*)ServiceContext;
USHORT IntStatus;

DbgPrint(“—> PciDeviceCInterruptHandler\n”);
//IoRequestDpc(devExt->filterDevObj, NULL, devExt);
Pci_Device_Disable_Interrupt(devExt);
KeSetEvent(&devExt->KeInterruptevent, IO_NO_INCREMENT, FALSE);
InterruptRecognized = TRUE;

DbgPrint(“<– NICInterruptHandler\r\n”);

return InterruptRecognized;
}

By using this i am just trying to see weather i am able to get the
interrupt
and process it successfully or not i have not added any functionality
yet.

but i am suspecting that as i am geting the interrupt my system gets
restarted.

If this is not the right way to handle the iterrupt then please you
people
can give me some sample code or any url of the tutorial and any other
stuff
that can help me to complete this task successfully.

Thanks
Nayan


Sexy, sultry, sensuous. - see why Bipasha Basu is all that and more. Try
MSN
Search http://server1.msn.co.in/Profile/bipashabasu.asp


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

You should run your driver with a debugger attached. If you had you
probably would have seen the crash in KeSetEvent, which might have
caused you to reread the documentation and see that you can’t call
KeSetEvent at any interrupt level higher than DISPATCH_LEVEL.

Better yet you could run the driver verifier against your driver during
development, in which case the bugcheck would very likely have told you
that you couldn’t call KeSetEvent at > DISPATCH_LEVEL.

Either way it would be better than loading a driver and trying to guess
why the machine rebooted.

-p

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of nayan kumar
Sent: Friday, September 15, 2006 9:32 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] how to handle the interrupt

Hi all,
As a part of my job i am developing one pci device driver in
which
whenever i get the interrupt my system gets restarted.the code that i am

using is simple and as following

first i am regisetering device driver’s InterruptService routine (ISR)
by
using

status = IoConnectInterrupt(&devExt->Interrupt,
PciDeviceCInterruptHandler,
devExt, // ISR Context
NULL,
devExt->InterruptVector,
devExt->InterruptLevel,
devExt->InterruptLevel,
devExt->InterruptMode,
TRUE, // shared interrupt
devExt->InterruptAffinity,
FALSE);

and my interrupt handler routine is as following

BOOLEAN
PciDeviceCInterruptHandler(
IN PKINTERRUPT Interupt,
IN PVOID ServiceContext
)
{
BOOLEAN InterruptRecognized = FALSE;
struct DEVICE_EXTENSION *devExt = (struct DEVICE_EXTENSION
*)ServiceContext;
USHORT IntStatus;

DbgPrint(“—> PciDeviceCInterruptHandler\n”);
//IoRequestDpc(devExt->filterDevObj, NULL, devExt);
Pci_Device_Disable_Interrupt(devExt);
KeSetEvent(&devExt->KeInterruptevent, IO_NO_INCREMENT, FALSE);
InterruptRecognized = TRUE;

DbgPrint(“<– NICInterruptHandler\r\n”);

return InterruptRecognized;
}

By using this i am just trying to see weather i am able to get the
interrupt
and process it successfully or not i have not added any functionality
yet.

but i am suspecting that as i am geting the interrupt my system gets
restarted.

If this is not the right way to handle the iterrupt then please you
people
can give me some sample code or any url of the tutorial and any other
stuff
that can help me to complete this task successfully.

Thanks
Nayan


Sexy, sultry, sensuous. - see why Bipasha Basu is all that and more. Try
MSN
Search http://server1.msn.co.in/Profile/bipashabasu.asp


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

You cannot call KeSetEvent from the ISR, call it from the DPC.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: “nayan kumar”
To: “Windows System Software Devs Interest List”
Sent: Friday, September 15, 2006 8:31 PM
Subject: [ntdev] how to handle the interrupt

> Hi all,
> As a part of my job i am developing one pci device driver in which
> whenever i get the interrupt my system gets restarted.the code that i am
> using is simple and as following
>
> first i am regisetering device driver’s InterruptService routine (ISR) by
> using
>
> status = IoConnectInterrupt(&devExt->Interrupt,
> PciDeviceCInterruptHandler,
> devExt, // ISR Context
> NULL,
> devExt->InterruptVector,
> devExt->InterruptLevel,
> devExt->InterruptLevel,
> devExt->InterruptMode,
> TRUE, // shared interrupt
> devExt->InterruptAffinity,
> FALSE);
>
> and my interrupt handler routine is as following
>
> BOOLEAN
> PciDeviceCInterruptHandler(
> IN PKINTERRUPT Interupt,
> IN PVOID ServiceContext
> )
> {
> BOOLEAN InterruptRecognized = FALSE;
> struct DEVICE_EXTENSION *devExt = (struct DEVICE_EXTENSION
> *)ServiceContext;
> USHORT IntStatus;
>
> DbgPrint(“—> PciDeviceCInterruptHandler\n”);
> //IoRequestDpc(devExt->filterDevObj, NULL, devExt);
> Pci_Device_Disable_Interrupt(devExt);
> KeSetEvent(&devExt->KeInterruptevent, IO_NO_INCREMENT, FALSE);
> InterruptRecognized = TRUE;
>
> DbgPrint(“<– NICInterruptHandler\r\n”);
>
> return InterruptRecognized;
> }
>
> By using this i am just trying to see weather i am able to get the interrupt
> and process it successfully or not i have not added any functionality yet.
>
> but i am suspecting that as i am geting the interrupt my system gets
> restarted.
>
> If this is not the right way to handle the iterrupt then please you people
> can give me some sample code or any url of the tutorial and any other stuff
> that can help me to complete this task successfully.
>
> Thanks
> Nayan
>
> _________________________________________________________________
> Sexy, sultry, sensuous. - see why Bipasha Basu is all that and more. Try MSN
> Search http://server1.msn.co.in/Profile/bipashabasu.asp
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Aside from all the other (correct) responses that you got, it’s critical
that you only return TRUE from your ISR if and only if your device was
actually generating an interrupt and if you have already cleared that
condition in your ISR (by touching your hardware) so that it is no longer
generating an interrupt when you return.

  • Jake Oshins
    Windows Kernel Team
    (Former Interrupt Guy)

“nayan kumar” wrote in message news:xxxxx@ntdev…
> Hi all,
> As a part of my job i am developing one pci device driver in which
> whenever i get the interrupt my system gets restarted.the code that i am
> using is simple and as following
>
> first i am regisetering device driver’s InterruptService routine (ISR) by
> using
>
> status = IoConnectInterrupt(&devExt->Interrupt,
> PciDeviceCInterruptHandler,
> devExt, // ISR Context
> NULL,
> devExt->InterruptVector,
> devExt->InterruptLevel,
> devExt->InterruptLevel,
> devExt->InterruptMode,
> TRUE, // shared interrupt
> devExt->InterruptAffinity,
> FALSE);
>
> and my interrupt handler routine is as following
>
> BOOLEAN
> PciDeviceCInterruptHandler(
> IN PKINTERRUPT Interupt,
> IN PVOID ServiceContext
> )
> {
> BOOLEAN InterruptRecognized = FALSE;
> struct DEVICE_EXTENSION *devExt = (struct DEVICE_EXTENSION
> *)ServiceContext;
> USHORT IntStatus;
>
> DbgPrint(“—> PciDeviceCInterruptHandler\n”);
> //IoRequestDpc(devExt->filterDevObj, NULL, devExt);
> Pci_Device_Disable_Interrupt(devExt);
> KeSetEvent(&devExt->KeInterruptevent, IO_NO_INCREMENT, FALSE);
> InterruptRecognized = TRUE;
>
> DbgPrint(“<– NICInterruptHandler\r\n”);
>
> return InterruptRecognized;
> }
>
> By using this i am just trying to see weather i am able to get the
> interrupt and process it successfully or not i have not added any
> functionality yet.
>
> but i am suspecting that as i am geting the interrupt my system gets
> restarted.
>
> If this is not the right way to handle the iterrupt then please you people
> can give me some sample code or any url of the tutorial and any other
> stuff that can help me to complete this task successfully.
>
> Thanks
> Nayan
>
> _________________________________________________________________
> Sexy, sultry, sensuous. - see why Bipasha Basu is all that and more. Try
> MSN Search http://server1.msn.co.in/Profile/bipashabasu.asp
>
>

Hi Doron and Jake ,
Thanks for your support.I made changes according to your
instruction as wel as other that i got from other great people.But i am
still failing to handle the interrupt success fully.i am new to this driver
development and this is my first assignment.although i am able to read and
write the register successfully but i dangerouly stuck with this interrupt
handling problem.if i can get any wdm pci device diver sample for handling
interrupt only it would be very helpfull to overcome from this problem.

Thanks and Regards
Nayan

From: Doron Holan
>Reply-To: “Windows System Software Devs Interest List”
>
>To: “Windows System Software Devs Interest List”
>Subject: RE: [ntdev] how to handle the interrupt
>Date: Fri, 15 Sep 2006 10:00:18 -0700
>
>You cannot call KeSetEvent at DIRQL in your interrupt, you must queue
>the DPC so that you can run at the appropriate IRQL (DISPATCH_LEVEL)
>where you can set the event. In general, there are very few APIs you
>can call at DIRQL.
>
>d
>
>-----Original Message-----
>From: xxxxx@lists.osr.com
>[mailto:xxxxx@lists.osr.com] On Behalf Of nayan kumar
>Sent: Friday, September 15, 2006 9:32 AM
>To: Windows System Software Devs Interest List
>Subject: [ntdev] how to handle the interrupt
>
>Hi all,
> As a part of my job i am developing one pci device driver in
>which
>whenever i get the interrupt my system gets restarted.the code that i am
>
>using is simple and as following
>
>first i am regisetering device driver’s InterruptService routine (ISR)
>by
>using
>
>status = IoConnectInterrupt(&devExt->Interrupt,
> PciDeviceCInterruptHandler,
> devExt, // ISR Context
> NULL,
> devExt->InterruptVector,
> devExt->InterruptLevel,
> devExt->InterruptLevel,
> devExt->InterruptMode,
> TRUE, // shared interrupt
> devExt->InterruptAffinity,
> FALSE);
>
>and my interrupt handler routine is as following
>
>BOOLEAN
>PciDeviceCInterruptHandler(
> IN PKINTERRUPT Interupt,
> IN PVOID ServiceContext
> )
>{
> BOOLEAN InterruptRecognized = FALSE;
> struct DEVICE_EXTENSION devExt = (struct DEVICE_EXTENSION
>
)ServiceContext;
> USHORT IntStatus;
>
> DbgPrint(“—> PciDeviceCInterruptHandler\n”);
> //IoRequestDpc(devExt->filterDevObj, NULL, devExt);
> Pci_Device_Disable_Interrupt(devExt);
> KeSetEvent(&devExt->KeInterruptevent, IO_NO_INCREMENT, FALSE);
> InterruptRecognized = TRUE;
>
> DbgPrint(“<– NICInterruptHandler\r\n”);
>
> return InterruptRecognized;
>}
>
>By using this i am just trying to see weather i am able to get the
>interrupt
>and process it successfully or not i have not added any functionality
>yet.
>
>but i am suspecting that as i am geting the interrupt my system gets
>restarted.
>
>If this is not the right way to handle the iterrupt then please you
>people
>can give me some sample code or any url of the tutorial and any other
>stuff
>that can help me to complete this task successfully.
>
>Thanks
>Nayan
>
>
>Sexy, sultry, sensuous. - see why Bipasha Basu is all that and more. Try
>MSN
>Search http://server1.msn.co.in/Profile/bipashabasu.asp
>
>
>—
>Questions? First check the Kernel Driver FAQ at
>http://www.osronline.com/article.cfm?id=256
>
>To unsubscribe, visit the List Server section of OSR Online at
>http://www.osronline.com/page.cfm?name=ListServer
>
>—
>Questions? First check the Kernel Driver FAQ at
>http://www.osronline.com/article.cfm?id=256
>
>To unsubscribe, visit the List Server section of OSR Online at
>http://www.osronline.com/page.cfm?name=ListServer


Connect with your friends who use Yahoo! Messenger with Voice. Click!
http://www.msnspecials.in/wlmyahoo/index.asp