Interrupts: interruptwait waits forever

Hello!
I’m novice in QNX… I installed qnx 6.2 from .iso provided for free in
qnx.com
The problem is the following:
I have a timers PCI card . The card have a external interrupt line,too.

I’m trying to make interrupts working with no success. I’m using
pci_* functions to extract info from the pci configuration space…(ie:
inf.Irq =10)
It yields no problems with ioaddresses and timers configurations. But
when I add interrupt support using interruptwait () the program loops
forever.
Please, let me know what is wrong, or some special qcc options, etc. Or
“link me” to other source of info
thank in advance
Here is the code:

ps: some vars are in globals.h , like inf

#include <stdio.h>
#include <string.h>
#include <sys/neutrino.h>
#include <sys/mman.h>
#include <sys/siginfo.h>
#include <hw/pci.h>
#include <hw/inout.h>
#include <atomic.h>

#include “definic.h”
#include “globales.h”

struct sigevent evento;

//HERE IS THE INT HANDLER
const struct sigevent *isr_func( void *arg, int id )
{
//ENMASCARA INTERRUPCION
InterruptMask( inf.Irq, -1 );

//DO SOMETHING
atomic_add( &ii, 1 );

return (&evento);
}


//MAIN FUNCTION
void main(void)
{
//
int handle = pci_attach(0);
if ( handle == -1 )
{
printf(“Error: pci_attach\n”);
return 0;
}

//INICIALIZA ESTRUCTURA PCI_DEV_INFO
memset( &inf, 0, sizeof( inf ) );
inf.VendorId = VENDOR_ID;
inf.DeviceId = DEVICE_ID;

//BUSCA DEVICE Y LLENA ESTRUCTURA PCI_INFO
void * hdl = pci_attach_device( NULL, PCI_INIT_ALL, 0, &inf );
if ( hdl == NULL )
{
printf( “Error: pci_attach_device\n” );
return 0;
}

//LEE EL ESPACIO DE CONFIGURACION PCI PARA OBTENER LA DIRECCION BASE
int base_addr;
pci_read_config32( inf.BusNumber, inf.DevFunc, 24, 1, &base_addr );

//COPIA VALOR A VARIABLE GLOBAL (Y MATA EL ULTIMO BIT)
Base_Addr = base_addr & 0xFFFE;

//DA ACCESO A LOS PUERTOS I/O
ThreadCtl( _NTO_TCTL_IO, 0 );

//MAP 20 I/O
IOBase = mmap_device_io( 20, Base_Addr );

//CFG TIMER 11 MODE 0
out8( IOBase+15, 0xB0 ); //TIMER CHIP 4, CFG REGISTER

//SETS COUNT
out8( IOBase+14, 0x00 ); //TIMER CHIP 4, TIMER 3
out8( IOBase+14, 0x20 );

//INIC EVENTO
SIGEV_INTR_INIT( &evento );

//ATTACH INTERRUPTION
int idint = InterruptAttach( inf.Irq, isr_func, NULL, 0, 0 ); //I ALSO
FLAG TO PUT ISR AT THE END OF THE ISR CHAIN
if ( idint == -1 )
{
printf( “Error: InterruptAttach\n” );
pci_detach( handle );
return 0;
}

//ENABLE INTERRUPTS IN TIMERS PCI CARD
out8( IOBase+20, 0x01 );

//MAIN LOOP
while ( ii < 100 )
{
//WAIT
InterruptWait( NULL, 0 ); //I ALSO TRIED I_W_(0, NULL)

//DO SOMETHING
printf( “%d\n”, ii );

// SETS A NEW COUNT TIMER
out8( IOBase+14, 0x00 );
out8( IOBase+14, 0xFF );

//UNMASK
// InterruptUnmask( inf.Irq, -1 );
}

//CLOSE APP
InterruptDetach( idint );
pci_detach( handle );
}

Hi,
I’d try two things. First connect to an interrupt on the processor. I
think IRQ 0 is the heartbeat interrupt. QNX uses that interrupt for their
system clock, so you ought to get a steady source there. Once you are sure
that works, you can go on to use other sources. The other thing is to pass
the global data in to your ISR via the area parameter in the
InterruptAttach function.

Good luck,
Dave Kuechenmeister

“Mauricio Manterola” <me@piracy.net> wrote in message
news:3E25FAE9.20BDA062@piracy.net

Hello!
I’m novice in QNX… I installed qnx 6.2 from .iso provided for free in
qnx.com
The problem is the following:
I have a timers PCI card . The card have a external interrupt line,too.

I’m trying to make interrupts working with no success. I’m using
pci_* functions to extract info from the pci configuration space…(ie:
inf.Irq =10)
It yields no problems with ioaddresses and timers configurations. But
when I add interrupt support using interruptwait () the program loops
forever.
Please, let me know what is wrong, or some special qcc options, etc. Or
“link me” to other source of info
thank in advance
Here is the code:

ps: some vars are in globals.h , like inf

#include <stdio.h
#include <string.h
#include <sys/neutrino.h
#include <sys/mman.h
#include <sys/siginfo.h
#include <hw/pci.h
#include <hw/inout.h
#include <atomic.h

#include “definic.h”
#include “globales.h”

struct sigevent evento;

//HERE IS THE INT HANDLER
const struct sigevent *isr_func( void *arg, int id )
{
//ENMASCARA INTERRUPCION
InterruptMask( inf.Irq, -1 );

//DO SOMETHING
atomic_add( &ii, 1 );

return (&evento);
}

thanks… I get it works using irq=0. Is it possible a bad configured pci
cnfiguration area in the PLX pci chip’s card?
Maybe 10 isn’t the real irq number for that card.

thanks again… I’ll keep trying different irq numbers.

Mauricio

David Kuechenmeister wrote:

Hi,
I’d try two things. First connect to an interrupt on the processor. I
think IRQ 0 is the heartbeat interrupt. QNX uses that interrupt for their
system clock, so you ought to get a steady source there. Once you are sure
that works, you can go on to use other sources. The other thing is to pass
the global data in to your ISR via the area parameter in the
InterruptAttach function.

Good luck,
Dave Kuechenmeister

“Mauricio Manterola” <> me@piracy.net> > wrote in message
news:> 3E25FAE9.20BDA062@piracy.net> …
Hello!
I’m novice in QNX… I installed qnx 6.2 from .iso provided for free in
qnx.com
The problem is the following:
I have a timers PCI card . The card have a external interrupt line,too.

I’m trying to make interrupts working with no success. I’m using
pci_* functions to extract info from the pci configuration space…(ie:
inf.Irq =10)
It yields no problems with ioaddresses and timers configurations. But
when I add interrupt support using interruptwait () the program loops
forever.
Please, let me know what is wrong, or some special qcc options, etc. Or
“link me” to other source of info
thank in advance
Here is the code:

ps: some vars are in globals.h , like inf

#include <stdio.h
#include <string.h
#include <sys/neutrino.h
#include <sys/mman.h
#include <sys/siginfo.h
#include <hw/pci.h
#include <hw/inout.h
#include <atomic.h

#include “definic.h”
#include “globales.h”

struct sigevent evento;

//HERE IS THE INT HANDLER
const struct sigevent *isr_func( void *arg, int id )
{
//ENMASCARA INTERRUPCION
InterruptMask( inf.Irq, -1 );

//DO SOMETHING
atomic_add( &ii, 1 );

return (&evento);
}

Try the pci command. I think you might find the information that you need.

David

“Mauricio Manterola” <me@piracy.net> wrote in message
news:3E273DDD.ECC2919B@piracy.net

thanks… I get it works using irq=0. Is it possible a bad configured
pci
cnfiguration area in the PLX pci chip’s card?
Maybe 10 isn’t the real irq number for that card.

thanks again… I’ll keep trying different irq numbers.

Mauricio

David Kuechenmeister wrote:

Hi,
I’d try two things. First connect to an interrupt on the processor. I
think IRQ 0 is the heartbeat interrupt. QNX uses that interrupt for
their
system clock, so you ought to get a steady source there. Once you are
sure
that works, you can go on to use other sources. The other thing is to
pass
the global data in to your ISR via the area parameter in the
InterruptAttach function.

Good luck,
Dave Kuechenmeister

“Mauricio Manterola” <> me@piracy.net> > wrote in message
news:> 3E25FAE9.20BDA062@piracy.net> …
Hello!
I’m novice in QNX… I installed qnx 6.2 from .iso provided for free
in
qnx.com
The problem is the following:
I have a timers PCI card . The card have a external interrupt
line,too.

I’m trying to make interrupts working with no success. I’m using
pci_* functions to extract info from the pci configuration
space…(ie:
inf.Irq =10)
It yields no problems with ioaddresses and timers configurations. But
when I add interrupt support using interruptwait () the program loops
forever.
Please, let me know what is wrong, or some special qcc options, etc.
Or
“link me” to other source of info
thank in advance
Here is the code:

ps: some vars are in globals.h , like inf

#include <stdio.h
#include <string.h
#include <sys/neutrino.h
#include <sys/mman.h
#include <sys/siginfo.h
#include <hw/pci.h
#include <hw/inout.h
#include <atomic.h

#include “definic.h”
#include “globales.h”

struct sigevent evento;

//HERE IS THE INT HANDLER
const struct sigevent *isr_func( void *arg, int id )
{
//ENMASCARA INTERRUPCION
InterruptMask( inf.Irq, -1 );

//DO SOMETHING
atomic_add( &ii, 1 );

return (&evento);
}