Interrupts#
It is often necessary to handle hardware interrupts when creating a device driver. To enable the userspace server to do so, Phoenix-RTOS provides a special callback mechanism. Driver registers interrupt handler via syscall:
int interrupt(unsigned int n, int (*f)(unsigned int, void *), void *arg, unsigned int cond, unsigned int *handle);
where:
n
- is platform dependent interrupt number,f
- is an interrupt handler,arg
- is passed to the handler during call,cond
- is handle to conditional,handle
- points to variable which will hold new interrupt handle.
Interrupt syscall registers callback function to be executed when the interrupt number n
occurs and enables (if not
enabled already) this interrupt in the controller.
The callback function is invoked directly from the kernel space with interrupts globally disabled. It allows the handler to be able to prevent the same interrupt to be executed again (e.g. when an interrupt is caused by the signal level, not edge).
If handler returns value >= 0 then kernel performs condSignal()
on a conditional passed when registering interrupt. If
this feature is not needed, one can pass 0 as cond
.