-/* signal handler */
-void irq_entry(int signum)
-{
- Process * const old_process = CurrentProcess;
-
- irq_handlers[signum]();
-
- if (!CurrentProcess)
- {
- TRACEMSG("no runnable processes!");
- IRQ_ENABLE;
- pause();
- }
- else
- {
- if (old_process != CurrentProcess)
- {
- TRACEMSG("switching from %p:%s to %p:%s",
- old_process, old_process ? old_process->monitor.name : "-",
- CurrentProcess, CurrentProcess->monitor.name);
-
- if (old_process)
- swapcontext(&old_process->context, &CurrentProcess->context);
- else
- setcontext(&CurrentProcess->context);
-
- /* not reached */
- }
- TRACEMSG("keeping %p:%s", CurrentProcess, CurrentProcess->monitor.name);
- }
-}
-
-void irq_register(int irq, void (*callback)(void))
-{
- irq_handlers[irq] = callback;
-}
-
-void irq_init(void)
-{
- struct sigaction act;
- act.sa_handler = irq_entry;
- sigemptyset(&act.sa_mask);
- //sigaddset(&act.sa_mask, irq);
- act.sa_flags = SA_RESTART; /* | SA_SIGINFO; */
-
- sigaction(SIGUSR1, &act, NULL);
- #if !(ARCH & ARCH_QT)
- sigaction(SIGALRM, &act, NULL);
- #endif
-}
-