pci interrupt handling and MAKEFILE procedures

hello every one,

this is a posting regarding interrupt handling and makefile,

we r naive users of ***qnx4 and would be happy if any one can help in
the following matters,we r using pci card with plx 9052 chip.
we are able to access the card memory.and we are also getting the irq
line no,but …

the problem seems to be whenevr we get interrupt frm the board our
interrupt handler is not getting invoked we are using qnx_hint_attach
and also using the compilation options… -T1 -Wc,-s prg.c and
one more main point ****this program includes the code for all the
handling ,mem accessing and also our application lib functions,this we
are doing as we are not sure of the make file procedure…is it fine
or is it mandatory to compile the interrupt code …etc separately
using a make file…if so we would like to get some help on the
****makefile.
any help will be highly appreciated
thanking u in advance.

regards
kalyug

“Apollo Computing Laboratories (P) Ltd.” <apollo@hd1.vsnl.net.in> wrote:

hello every one,

this is a posting regarding interrupt handling and makefile,

we r naive users of ***qnx4 and would be happy if any one can help in
the following matters,we r using pci card with plx 9052 chip.
we are able to access the card memory.and we are also getting the irq
line no,but …

the problem seems to be whenevr we get interrupt frm the board our
interrupt handler is not getting invoked we are using qnx_hint_attach
and also using the compilation options… -T1 -Wc,-s prg.c and
one more main point ****this program includes the code for all the
handling ,mem accessing and also our application lib functions,this we
are doing as we are not sure of the make file procedure…is it fine
or is it mandatory to compile the interrupt code …etc separately
using a make file…if so we would like to get some help on the
****makefile.
any help will be highly appreciated
thanking u in advance.

I would strongly suggest putting the irq handler code, and just the
irq handler code, in a seperate C source file.

Then compile:

cc -c -Wc,-s -zu interrupt.c
cc -c prg.c
cc -T1 prg.o interrupt.o -o prg

This may not be the cause/source of your problem with not getting
the interrupts, but is the proper way to build your program.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

“David Gibbs” <dagibbs@qnx.com> schrieb im Newsbeitrag
news:aion9o$4t$1@nntp.qnx.com

“Apollo Computing Laboratories (P) Ltd.” <> apollo@hd1.vsnl.net.in> > wrote:
hello every one,

this is a posting regarding interrupt handling and makefile,

we r naive users of ***qnx4 and would be happy if any one can help in
the following matters,we r using pci card with plx 9052 chip.
we are able to access the card memory.and we are also getting the irq
line no,but …

the problem seems to be whenevr we get interrupt frm the board our
interrupt handler is not getting invoked we are using qnx_hint_attach
and also using the compilation options… -T1 -Wc,-s prg.c and
one more main point ****this program includes the code for all the
handling ,mem accessing and also our application lib functions,this we
are doing as we are not sure of the make file procedure…is it fine
or is it mandatory to compile the interrupt code …etc separately
using a make file…if so we would like to get some help on the
****makefile.
any help will be highly appreciated
thanking u in advance.

I would strongly suggest putting the irq handler code, and just the
irq handler code, in a seperate C source file.

Then compile:

cc -c -Wc,-s -zu interrupt.c
cc -c prg.c
cc -T1 prg.o interrupt.o -o prg

And also note that -T1 does nothing unless you run the process SUID=root

This may not be the cause/source of your problem with not getting
the interrupts, but is the proper way to build your program.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

Werner Schweizer <Werner.Schweizer@ch.mullermartini.com> wrote:

I would strongly suggest putting the irq handler code, and just the
irq handler code, in a seperate C source file.

Then compile:

cc -c -Wc,-s -zu interrupt.c
cc -c prg.c
cc -T1 prg.o interrupt.o -o prg

And also note that -T1 does nothing unless you run the process SUID=root

Actually, if you link -T1, then the program can only be run as root.

I think it is -T0 that gives you hardware privs (-T1) if run as root
and normal privs (-T3, the default) if run as non-root.

But, it is important to note that this is an option for the linker,
it doesn’t matter for the .c to .o stage, just for the .o to executable
stage.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

“David Gibbs” <dagibbs@qnx.com> wrote in message
news:air8ef$rsc$1@nntp.qnx.com

Werner Schweizer <> Werner.Schweizer@ch.mullermartini.com> > wrote:

I would strongly suggest putting the irq handler code, and just the
irq handler code, in a seperate C source file.

Then compile:

cc -c -Wc,-s -zu interrupt.c
cc -c prg.c
cc -T1 prg.o interrupt.o -o prg

And also note that -T1 does nothing unless you run the process SUID=root

Actually, if you link -T1, then the program can only be run as root.

I think it is -T0 that gives you hardware privs (-T1) if run as root
and normal privs (-T3, the default) if run as non-root.

afair -Tx directly moved into code segment RPL except -T0

But, it is important to note that this is an option for the linker,
it doesn’t matter for the .c to .o stage, just for the .o to executable
stage.

// wbr

hello,

thanks for that compiling options,i need a small clarification, regarding
that in case i proceed as u said and compile these using the options
specified what do i get,do i get a exe file sort of thing that can be run.

regards,
kalyan

hello all,

i gues it will be a bit better if i describe it a bit more,

it is like we are coding a driver for our pci addon card wiith plx 9052
chip.we are proceeding in the following way…


we are using the MAKEFILE and on making it we expect a file to be generted
inthe specified directory and this we want to run at the back end and later
we want to test it by attaching some application programs. what is
currently happening is…


when we make file running the following command

make all interruptprg.c prg.c prg.o interruptprg.c

we get the file we expect in the expected location and on running it we
sucessfully find it in the sin.but when we try sin ir,we dont find it there
and i guess it means it is not attaching to the interrupt routines,actually
my doubt is ****what part of the code do i need to include in this interrupt
program …do i need to have all the interrupt related code in that
porogram…like the isr interrupt handling etc…

regards,
kalyan.

kalyano <kalyano@rediffmail.com> wrote:

hello all,

i gues it will be a bit better if i describe it a bit more,

it is like we are coding a driver for our pci addon card wiith plx 9052
chip.we are proceeding in the following way…



we are using the MAKEFILE and on making it we expect a file to be generted
inthe specified directory and this we want to run at the back end and later
we want to test it by attaching some application programs. what is
currently happening is…



when we make file running the following command

make all interruptprg.c prg.c prg.o interruptprg.c

we get the file we expect in the expected location and on running it we
sucessfully find it in the sin.but when we try sin ir,we dont find it there
and i guess it means it is not attaching to the interrupt routines,actually
my doubt is ****what part of the code do i need to include in this interrupt
program …do i need to have all the interrupt related code in that
porogram…like the isr interrupt handling etc…

If it appears in the “sin” output, but not the “sin irq” output,
then it has run but not hooked into the interrupt chain.

– did you check the return value from qnx_hint_attach()?
– did it succeed?
– if not, did you check errno to see why it failed?

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

…hi all,

yeah of course i checked and didnt find any error …the checking was like
i gave an if condition where if the qnx_hint_attach failed then it will
return -1 but it didnt happen.so how do i proceed from here…need a solution
soon.
thanks,

kalyan.

kalyano <kalyano@rediffmail.com> wrote:

.hi all,

yeah of course i checked and didnt find any error …the checking was like
i gave an if condition where if the qnx_hint_attach failed then it will
return -1 but it didnt happen.so how do i proceed from here…need a solution
soon.
thanks,

What interrupt number are you passing? Can you post the snippet of
code that you’re using to do that attach?

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

Here we are getting the Interruppt line 9 .

Whenever interrupt is fired from our board,the handler should get invoked
and the p value should get incremented
But it never happens .Here is the snippet .




p=0; —global declaration
InitInterrupts(Intr)
{

*(BAR2+0x4c)=0x58; // BAR2 is memory mapped
*(BAR2+0x4d)=0x02; // 0x4c ,0x4d are the PLX 9052’s
ISR


outp(BAR3+0x100,Intr);

if( (irq_proxy=qnx_proxy_attach(0,0,0,-1)==-1))
{
printf(“unable to attach to proxy\n”);
return;
}

if ((irq_id=qnx_hint_attach(IntrLine,&Handler,FP_SG(&irq_proxy))==-1)
{
printf(“Unable to attach to interrupt\n”);
return;
}

}

pidt_t far Handler()
{

p++;




return(0);
}



David Gibbs <dagibbs@qnx.com> wrote in message
news:aj8eke$oe1$1@nntp.qnx.com

kalyano <> kalyano@rediffmail.com> > wrote:
.hi all,

yeah of course i checked and didnt find any error …the checking was
like
i gave an if condition where if the qnx_hint_attach failed then it will
return -1 but it didnt happen.so how do i proceed from here…need a
solution
soon.
thanks,

What interrupt number are you passing? Can you post the snippet of
code that you’re using to do that attach?

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

kalyano <kalyano@rediffmail.com> wrote:

Here we are getting the Interruppt line 9 .

Whenever interrupt is fired from our board,the handler should get invoked
and the p value should get incremented
But it never happens .Here is the snippet .



p=0; —global declaration
InitInterrupts(Intr)
{

*(BAR2+0x4c)=0x58; // BAR2 is memory mapped
*(BAR2+0x4d)=0x02; // 0x4c ,0x4d are the PLX 9052’s
ISR



outp(BAR3+0x100,Intr);

if( (irq_proxy=qnx_proxy_attach(0,0,0,-1)==-1))
{
printf(“unable to attach to proxy\n”);
return;
}

if ((irq_id=qnx_hint_attach(IntrLine,&Handler,FP_SG(&irq_proxy))==-1)
{

IntrLine is assigned elsewhere?

Otherwise this looks pretty normal. As I said, I can’t see why
this would fail to work, or you would fail to see the interrupt
line attached in “sin irq”. You don’t even need hardware at a
particular irq point for an interrupt attach call to work – you
just need to make the call, and have your process still running.

I was wondering about IntrLine’s value, because if it was > 15, it
might still attach, but “sin irq” might only check the standar
0-15 interrupt range.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.