Common interrupt numbers
authorSebastien Bourdeauducq <sebastien@milkymist.org>
Mon, 21 May 2012 17:52:41 +0000 (19:52 +0200)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Mon, 21 May 2012 17:52:41 +0000 (19:52 +0200)
common/interrupt.h [new file with mode: 0644]
software/bios/isr.c
software/include/hw/interrupts.h [deleted file]
software/libbase/uart.c
top.py

diff --git a/common/interrupt.h b/common/interrupt.h
new file mode 100644 (file)
index 0000000..a5ecd60
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef __INTERRUPT_H
+#define __INTERRUPT_H
+
+#define UART_INTERRUPT         0
+#define TIMER0_INTERRUPT       1
+#define MINIMAC_INTERRUPT      2
+
+#endif /* __INTERRUPT_H */
index 4257d878bc86f838d1546820f3b08fb2a7386ed5..400de2334db04a1062536e3beb681f9f9819e5e6 100644 (file)
@@ -15,8 +15,8 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <hw/interrupts.h>
 #include <hw/uart.h>
+#include <interrupt.h>
 #include <irq.h>
 #include <uart.h>
 
@@ -27,6 +27,6 @@ void isr(void)
        
        irqs = irq_pending() & irq_getmask();
        
-       if(irqs & IRQ_UART)
+       if(irqs & (1 << UART_INTERRUPT))
                uart_isr();
 }
diff --git a/software/include/hw/interrupts.h b/software/include/hw/interrupts.h
deleted file mode 100644 (file)
index 2f48cee..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Milkymist SoC (Software)
- * Copyright (C) 2007, 2008, 2009, 2010 Sebastien Bourdeauducq
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __HW_INTERRUPTS_H
-#define __HW_INTERRUPTS_H
-
-#define IRQ_UART               (0x00000001) /* 0 */
-
-#endif /* __HW_INTERRUPTS_H */
index e4e87ad683ca69d98a3f830eaa40eec2cf199707..760498340bcdf58f670f0de37026fad61cce93d9 100644 (file)
@@ -18,7 +18,7 @@
 #include <uart.h>
 #include <irq.h>
 #include <hw/uart.h>
-#include <hw/interrupts.h>
+#include <interrupt.h>
 
 /*
  * Buffer sizes must be a power of 2 so that modulos can be computed
@@ -121,7 +121,7 @@ void uart_init(void)
        CSR_UART_EV_ENABLE = UART_EV_TX | UART_EV_RX;
 
        mask = irq_getmask();
-       mask |= IRQ_UART;
+       mask |= UART_INTERRUPT;
        irq_setmask(mask);
 }
 
diff --git a/top.py b/top.py
index ae9e5ec77b73385e7092820da90037b9290a9401..53b4c04d85cd1c2587abc6348c23e66e8c4beb3c 100644 (file)
--- a/top.py
+++ b/top.py
@@ -63,6 +63,10 @@ def csr_offset(name):
        assert((base >= 0xe0000000) and (base <= 0xe0010000))
        return (base - 0xe0000000)//0x800
 
+interrupt_macros = get_macros("common/interrupt.h")
+def interrupt_n(name):
+       return int(interrupt_macros[name + "_INTERRUPT"], 0)
+
 version = get_macros("common/version.h")["VERSION"][1:-1]
 
 def get():
@@ -130,9 +134,9 @@ def get():
        # Interrupts
        #
        interrupts = Fragment([
-               cpu0.interrupt[0].eq(uart0.events.irq),
-               cpu0.interrupt[1].eq(timer0.events.irq),
-               cpu0.interrupt[2].eq(minimac0.events.irq)
+               cpu0.interrupt[interrupt_n("UART")].eq(uart0.events.irq),
+               cpu0.interrupt[interrupt_n("TIMER0")].eq(timer0.events.irq),
+               cpu0.interrupt[interrupt_n("MINIMAC")].eq(minimac0.events.irq)
        ])
        
        #