Porting DOS interrupt handler under qnx 6

Hi,

I’m trying to port a little Dos code under Qnx

This code call the old isr handler in the new isr handler
using ( _chain_intr(old_isr)

How do i make the same thing under QNX ?

I suppose Qnx Call : InterruptAttach / Detach
save and restore the old isr.

Here is the start of the translation :

// ----------------------------------
// DOS ISR handler
// ----------------------------------

/* Save the old interrupt vector */
old_isr = getvect(int_vector);

/* Install the new interrupt vector */
setvect(int_vector, PCI7200_isr0);

/* Restore old interrupt vector */
setvect(int_vector, old_isr);

void interrupt PCI7200_isr0(void) {

// (…)
/* call the previous handler */
_chain_intr(old_isr);
// (…)
}

==========================================================

// ----------------------------------
// QNX ISR handler
// ----------------------------------

k= InterruptAttach (int_vector, PCI7200_isr0, NULL, 0, 0);

InterruptDetach( k);

const struct sigevent *PCI7200_isr0 (void *arg, int id)
{
}

Thanks for your help

Y.LEROUX <A_ENLEVER_y.leroux@actris.com> wrote:

Hi,

I’m trying to port a little Dos code under Qnx

This code call the old isr handler in the new isr handler
using ( _chain_intr(old_isr)

How do i make the same thing under QNX ?

I suppose Qnx Call : InterruptAttach / Detach
save and restore the old isr.

This is not necessary. In QNX if two different processes both attach
to a certain interrupt then they will both get called, whenever that
interrupt occurs.

NOTE #1: I don’t think there are any guarantees made as to the order that
the ISRs are called.

NOTE #2: If the first ISR is the correct one to process the interrupt,
I don’t think there is any way to prevent the second one from being
called.

NOTE #3: A new process can not remove the ISR vector to an older
process.


Bill Caroselli – Q-TPS Consulting
1-(626) 824-7983
qtps@earthlink.net

In article <b1tq1v$5f7$1@inn.qnx.com>, A_ENLEVER_y.leroux@actris.com says…

Hi,

I’m trying to port a little Dos code under Qnx

This code call the old isr handler in the new isr handler
using ( _chain_intr(old_isr)

How do i make the same thing under QNX ?

As Bill said you don’t need to do it. And some addition to Bill’s Note#1, you can’t control of order in which ISR are
called, but you can put your ISR in end of queue (see the last parameter Flags of InterruptAttach())


I suppose Qnx Call : InterruptAttach / Detach
save and restore the old isr.

No. It was common trick in DOS, but QNX makes a difference. For example, many programs in DOS setted their hot-keys
(keyboard’s shortcuts) in this way: own interrupts reads the scan code from keyboard’s controller, if it’s “hotkey” make
some out to kbd controller to release it and handle it, if not - call old ISR which will do usual things: place
scancode to kbd’s buffer, release kbd controller etc. You can’t do it in QNX. In DOS, old it’s usually BIOS ISR, and
QNX doesn’t use BIOS much (only during sturt-up, but does not if using custom IPL on BIOSless board).

Good place for start is:
http://www.qnx.com/developer/docs/momentics_nc_docs/neutrino/prog/inthandler.html


Here is the start of the translation :

// ----------------------------------
// DOS ISR handler
// ----------------------------------

/* Save the old interrupt vector */
old_isr = getvect(int_vector);

/* Install the new interrupt vector */
setvect(int_vector, PCI7200_isr0);

/* Restore old interrupt vector */
setvect(int_vector, old_isr);

Is it exactly sequence? Restore old ISR should be on exit from program (better in function declared by atexit()), in
DOS, of course :astonished:).

Good luck!
Eduard.

void interrupt PCI7200_isr0(void) {

// (…)
/* call the previous handler */
_chain_intr(old_isr);
// (…)
}

==========================================================

// ----------------------------------
// QNX ISR handler
// ----------------------------------

k= InterruptAttach (int_vector, PCI7200_isr0, NULL, 0, 0);

InterruptDetach( k);

const struct sigevent *PCI7200_isr0 (void *arg, int id)
{
}

Thanks for your help

Bill Caroselli <qtps@earthlink.net> wrote:

This is not necessary. In QNX if two different processes both attach
to a certain interrupt then they will both get called, whenever that
interrupt occurs.

NOTE #1: I don’t think there are any guarantees made as to the order that
the ISRs are called.

QNX4 did not guarantee.

QNX6 will call the new ISR first, unless you pass in
_NTO_INTR_FLAGS_END, in which caset the new ISR will be called last.

NOTE #2: If the first ISR is the correct one to process the interrupt,
I don’t think there is any way to prevent the second one from being
called.

Correct. Both ISRs need to have enough smarts to figure out if it
is their interrupt, or somebody else’s.

-David

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