InterruptAttach()-problems

Hello.
Since my card is working properly, I’m trying to write an ISR.

After starting this my system hangs up and i don’t know why. I’m working on
x86 and I’ve read this:
http://www.qnx.com/developers/docs/qnx_6.1_docs/neutrino/prog/inthandler.html
It seems, that I don’t handle the InterruptAttach()-function right, but
don’t find my fault.

Tobias

// this thread is dedicated to handling and managing interrupts
void * int_thread (void *arg){
int interruptID = 0;
// _uint32 intevent;
struct sigevent *event;

ThreadCtl (_NTO_TCTL_IO, NULL); // enable I/O privilege
printf(“test\n”);

// attach the ISR to IRQ 11
interruptID = InterruptAttach (11, isr_handler, &event, sizeof(event), 0);
printf(“InterruptID = %d\n”, interruptID);
if (interruptID == -1){
printf(“InterruptAttach() failed!\n”);
exit(-1);
}

while (1){
InterruptWait (NULL, NULL);

// do the work
printf("\nInterrupt angekommen!!!\n");

}
}

// this is the ISR
const struct sigevent * isr_handler (void *area, int id){
// get and set registers
intevent = *IEEE1394_HW_OHCI_GetReg(OHCI1394_IntEventClear);
IEEE1394_HW_OHCI_SetReg(OHCI1394_IntEventClear, intevent &
~OHCI1394_busReset);

if (!intevent) return NULL;
else SIGEV_INTR_INIT( (struct sigevent *) area );

return (area);
}

int main(){
IEEE1394_HW_PCI_Init(); /* initialising my card */

// start up a thread that is dedicated to interrupt processing
pthread_create (NULL, NULL, &int_thread, NULL);

/* Allow threads to run for 2 seconds. */
sleep( 2 );
}

Try IRQ#0 first, it don’t require any acks or other operations. This way you eliminate any PCI or card issues.


Evan

In article <d436jn$2ni$1@inn.qnx.com>, t.nothdurft@tu-bs.de says…

Tobias,

Hello.
Since my card is working properly, I’m trying to write an ISR.

After starting this my system hangs up and i don’t know why. I’m working on
x86 and I’ve read this:
http://www.qnx.com/developers/docs/qnx_6.1_docs/neutrino/prog/inthandler.html
It seems, that I don’t handle the InterruptAttach()-function right, but
don’t find my fault.

Tobias

// this thread is dedicated to handling and managing interrupts
void * int_thread (void *arg){
int interruptID = 0;
// _uint32 intevent;
struct sigevent *event;
//You need event here (or better in main()), not a pointer.

struct sigevent event;

ThreadCtl (_NTO_TCTL_IO, NULL); // enable I/O privilege
printf(“test\n”);

// You want init the event right here
SIGEV_INTR_INIT(&event);


// attach the ISR to IRQ 11
interruptID = InterruptAttach (11, isr_handler, &event, sizeof(event), 0);
//To my great surprise the line above is absolutly correct



printf(“InterruptID = %d\n”, interruptID);
if (interruptID == -1){
printf(“InterruptAttach() failed!\n”);
exit(-1);
}

while (1){
InterruptWait (NULL, NULL);

// do the work
printf("\nInterrupt angekommen!!!\n");

}

//Should be InterruptDetach(interruptID) somewhere, think you kill this
//thread: there is no thread, there is no stack, there
//is no event structure, hang again.

}

// this is the ISR
const struct sigevent * isr_handler (void *area, int id){
// get and set registers
intevent = *IEEE1394_HW_OHCI_GetReg(OHCI1394_IntEventClear);
IEEE1394_HW_OHCI_SetReg(OHCI1394_IntEventClear, intevent &
~OHCI1394_busReset);

if (!intevent) return NULL;
else SIGEV_INTR_INIT( (struct sigevent *) area );

return (area);
//It is much simple:

if(!intevent) return NULL;
else return(area);

}

int main(){
IEEE1394_HW_PCI_Init(); /* initialising my card */

// start up a thread that is dedicated to interrupt processing
pthread_create (NULL, NULL, &int_thread, NULL);

/* Allow threads to run for 2 seconds. */
sleep( 2 );
}



Cheers,

Eduard.

In article <MPG.1ccf7290457dd0339896b0@inn.qnx.com>, ed1k@fake.address
says…

In article <d436jn$2ni$> 1@inn.qnx.com> >, > t.nothdurft@tu-bs.de > says…

// this is the ISR
const struct sigevent * isr_handler (void *area, int id){
// get and set registers
intevent = *IEEE1394_HW_OHCI_GetReg(OHCI1394_IntEventClear);
IEEE1394_HW_OHCI_SetReg(OHCI1394_IntEventClear, intevent &
~OHCI1394_busReset);

Just forgot to mention, if those lines above clear interrupt request on

the IRQ line, that’s OK. If not, you have to mask interrupt here and
unmask in interrupt thread after you calm the h/w down to clean IRQ
line.
Eduard.

Thanks! It’s working now! :slight_smile:

“ed1k” <ed1k@fake.address> schrieb im Newsbeitrag
news:MPG.1ccf7710fb167df99896b1@inn.qnx.com

In article <> MPG.1ccf7290457dd0339896b0@inn.qnx.com> >, > ed1k@fake.address
says…
In article <d436jn$2ni$> 1@inn.qnx.com> >, > t.nothdurft@tu-bs.de > says…

// this is the ISR
const struct sigevent * isr_handler (void *area, int id){
// get and set registers
intevent = *IEEE1394_HW_OHCI_GetReg(OHCI1394_IntEventClear);
IEEE1394_HW_OHCI_SetReg(OHCI1394_IntEventClear, intevent &
~OHCI1394_busReset);

Just forgot to mention, if those lines above clear interrupt request on
the IRQ line, that’s OK. If not, you have to mask interrupt here and
unmask in interrupt thread after you calm the h/w down to clean IRQ
line.
Eduard.

In article <d45uki$5iv$1@inn.qnx.com>, t.nothdurft@tu-bs.de says…

Thanks! It’s working now! > :slight_smile:
You’re welcome > :slight_smile: