Split test suite in new file.
[bertos.git] / cpu / arm / drv / sysirq_at91.c
index 7b12af2d8f4993d2b918467a0f3280adbdf74443..281c7963f8afdbee1fb0fc472ca961a3171cd921 100644 (file)
@@ -94,20 +94,18 @@ STATIC_ASSERT(countof(sysirq_tab) == SYSIRQ_CNT);
  * various sources (system timer, etc..) and calls
  * the corresponding handler.
  */
-static void sysirq_dispatcher(void) __attribute__ ((naked));
+static void sysirq_dispatcher(void) __attribute__ ((interrupt));
 static void sysirq_dispatcher(void)
 {
-       IRQ_ENTRY();
-
-       /* PIT */
-       if ((PIT_MR & BV(PITIEN))
-           && (PIT_SR & BV(PITS))
-           && sysirq_tab[SYSIRQ_PIT].handler)
-               sysirq_tab[SYSIRQ_PIT].handler();
-
-       /* TODO: add other system sources here */
+       for (unsigned i = 0; i < countof(sysirq_tab); i++)
+       {
+               if (sysirq_tab[i].enabled
+                && sysirq_tab[i].handler)
+                       sysirq_tab[i].handler();
+       }
 
-       IRQ_EXIT();
+       /* Inform hw that we have served the IRQ */
+       AIC_EOICR = 0;
 }
 
 #define SYSIRQ_PRIORITY 0 ///< default priority for system irqs.
@@ -125,8 +123,8 @@ void sysirq_init(void)
        IRQ_SAVE_DISABLE(flags);
 
        /* Disable all system interrupts */
-       PIT_MR &= BV(PITIEN);
-       /* TODO: add other system sources here */
+       for (unsigned i = 0; i < countof(sysirq_tab); i++)
+               sysirq_tab[i].setEnable(false);
 
        /* Set the vector. */
        AIC_SVR(SYSC_ID) = sysirq_dispatcher;