PCI device IRQ question! Help!

Dear all
Now I write a PCI device . If I want to use the interrupt function . How can I to write? Befor I use interruptattachevent() to write a parallel printer port interrupt . The parallel printer 's IRQ is “0x7” . now I have some question:
1ã€

You have to use the pci_() functions to search for your device. Identical devices (i.e. devices with the same Vendor and Device ID) are enumerated with the pci index. Once you found it, you walk through the list of resources until you find the interrupt line. This value gets passed to InterruptAttach() functions.

Regards,
Albrecht

My program can run the interrupt loop. but I have a question. If I want to run "Nointerrupt_loop() " in the disable interrupt time. How to write ?
because I can disable interrupt from HW. The program is run to stop “printf(“wait\n”);” Help me!
Thanks!

main()
{

pthread(–);

}

void *int_thread(void *arg)
{

struct sigevent event;
int intr_id,timeout;

ThreadCtl(_NTO_TCTL_IO, 0);
event.sigev_notify=SIGEV_INTR;
intr_id = InterruptAttachEvent(info.Irq , &event, 0 );
if ( intr_id == -1 ) {
printf( “Couldn’t attach event to IRQ %d\n”, info.Irq );
return EXIT_FAILURE;
}

printf(“wait\n”);
while(1 )
{
timeout=InterruptWait( 0, NULL )
timeout=InterruptWait( 0, NULL );
if (timeout == -1 ) {
printf( “Time Out\n” );
return EXIT_FAILURE;
}
/* Reenable this interrupt */
InterruptUnmask( info.Irq , intr_id );

Nointerrupt_loop();

}
}

Why do you call InterruptWait twice?? The first one will unblock, and the second one will sleep forever, because the interrupt was masked automatically before the first one unblocked. I’m also not sure on what you want to do with the timeout. You need to call TimerTimeout before the blocking function to use this. I never used it for InterruptWait, though…

sorry! I push it error! The corrent program is one InterruprWait(). The timeout is InterruprWait() return value if API has a error. so you can use the TimerTimeOut to set this timeout 's time. anyway , how can I write which to do the Interrupt thing and nointerrupt thing in the same program?
Can you give a example or idea? Help! Help!

main()
{

pthread(–);

}

void *int_thread(void *arg)
{

struct sigevent event;
int intr_id,timeout;

ThreadCtl(_NTO_TCTL_IO, 0);
event.sigev_notify=SIGEV_INTR;
intr_id = InterruptAttachEvent(info.Irq , &event, 0 );
if ( intr_id == -1 ) {
printf( “Couldn’t attach event to IRQ %d\n”, info.Irq );
return EXIT_FAILURE;
}

printf(“wait\n”);
while(1 )
{
timeout=InterruptWait( 0, NULL )
if (timeout == -1 ) {
printf( “Time Out\n” );
return EXIT_FAILURE;
}
/* Reenable this interrupt */
InterruptUnmask( info.Irq , intr_id );

Nointerrupt_loop();

}
}

You mean no interrupts at all? Then just but InteruptDisable() InterruptEnable() around Nointerrupt_loop.

Why do you need to disable the interrupts?

Because the interrupt isn’t cycle occur. If the HW call the function , the interrupt can occur. I don’t need to disable interrupt . but I must wait the interrupt occur , I can go to read the status. then switch(status) to do the function. so I have two interface. one is polling interface.the other is interrupt . The nornal time is pollig the memory , if the interrupt occur I can R/W the memory. now I don’t any idea. do you give me? Help! thanks!

Not sure if I understand, but maybe you want to do Interrupt Handling, and at the same time something else in your program? That’s easy - you just create an extra thread (pthread_create) for your interrupt handling. In the new thread, you would do the InterruptAttachEvent and then loop in InterruptWait. In your main thread meanwhile, you can do other things in some kind of loop.

yeah i got it
thx a lot

Dear sir,
please help me how to calculate the number interrupt of device which This value gets passed to InterruptAttach*() functions.

thanks ,
tuyndie