BeRTOS
irq.c
Go to the documentation of this file.
00001 
00040 #include "irq.h"
00041 
00042 #include <cfg/module.h>
00043 #include <kern/proc_p.h>
00044 #include <kern/proc.h>
00045 
00046 #include "cfg/cfg_proc.h"
00047 
00048 #include <unistd.h> // FIXME: move POSIX stuff to irq_posix.h
00049 
00050 MOD_DEFINE(irq)
00051 
00052 // FIXME
00053 static void (*irq_handlers[100])(void);
00054 
00055 /* signal handler */
00056 void irq_entry(int signum)
00057 {
00058     irq_handlers[signum]();
00059 }
00060 
00061 void irq_register(int irq, void (*callback)(void))
00062 {
00063     irq_handlers[irq] = callback;
00064 }
00065 
00066 void irq_init(void)
00067 {
00068     struct sigaction act;
00069 
00070     act.sa_handler = irq_entry;
00071     sigemptyset(&act.sa_mask);
00072     //sigaddset(&act.sa_mask, irq);
00073     act.sa_flags = SA_RESTART; // | SA_SIGINFO;
00074 
00075     sigaction(SIGUSR1, &act, NULL);
00076     sigaction(SIGALRM, &act, NULL);
00077 
00078     MOD_INIT(irq);
00079 }