John Kiernan <jkiernan@birinc.com> wrote:
I’m a QNX newbie, (recovering VxWorks user). I’m starting to port over
the interrupt code from our VxWorks solution to QNX. In VxWorks, our
interrupt functions just handled everything since everything runs in the
same process space with direct access to the hardware. (MPC8245 based)
Now, I’m not sure what the best way (or normal way) to handle interrupts
in QNX. Should only the most basic stuff (unmasking, masking,etc.) be
handled in the callouts; or should everything interrupt related be
handled in the callouts. Handling everything in the callouts would be
kind of painful since it’d all be in assembly.
There are several layers to this.
The callouts supplied by the startup code to the OS are supposed to
ONLY handle the interrupt controller – so mask, unmask, id, eoi, etc.
For drivers, they generally use either InterruptAttach() to associated
a C function with a particular logical interrupt vector (as defined by
startup), or InterruptAttachEvent() to request notification when a
particular interrupt fires.
For drivers, the choice of using InterruptAttach() or InterruptAttachEvent(),
often comes down to a latency issue – Attach() has the best latency, but
can be more system expensive. Generally, IntteruptAttach() associates an
interrupt handler (or ISR) with a particular hardware interrupt – this
code will talk to the particular card generating the intterupt, reading
status register(s), writing control register(s), and copying information
from hardware memory to RAM. It will generally then notify a thread in
the driver process to do any further data handling.
With AttachEvent(), all the hardware work is done at thread time, with
the interrupt essentially causing a thread to be scheduled.
For example, something like a uart (no FIFO) where if you don’t get a
byte, the next one destroys it, is a place where you’d generally attach
an ISR, while a network card, with largish on-card buffers, is a place
where you might tend to attach an event.
Hope this helps to clarify a bit.
-David
Please follow-up to newsgroup, rather than personal email.
David Gibbs
QNX Training Services
dagibbs@qnx.com