Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Common interrupt numbers

  • Loading branch information...
commit c01594f9fd63dd4c15a6a3dcaf85e32ad8ef3764 1 parent 9424551
Sébastien Bourdeauducq authored May 21, 2012
8  common/interrupt.h
... ...
@@ -0,0 +1,8 @@
  1
+#ifndef __INTERRUPT_H
  2
+#define __INTERRUPT_H
  3
+
  4
+#define UART_INTERRUPT		0
  5
+#define TIMER0_INTERRUPT	1
  6
+#define MINIMAC_INTERRUPT	2
  7
+
  8
+#endif /* __INTERRUPT_H */
4  software/bios/isr.c
@@ -15,8 +15,8 @@
15 15
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16
  */
17 17
 
18  
-#include <hw/interrupts.h>
19 18
 #include <hw/uart.h>
  19
+#include <interrupt.h>
20 20
 #include <irq.h>
21 21
 #include <uart.h>
22 22
 
@@ -27,6 +27,6 @@ void isr(void)
27 27
 	
28 28
 	irqs = irq_pending() & irq_getmask();
29 29
 	
30  
-	if(irqs & IRQ_UART)
  30
+	if(irqs & (1 << UART_INTERRUPT))
31 31
 		uart_isr();
32 32
 }
23  software/include/hw/interrupts.h
... ...
@@ -1,23 +0,0 @@
1  
-/*
2  
- * Milkymist SoC (Software)
3  
- * Copyright (C) 2007, 2008, 2009, 2010 Sebastien Bourdeauducq
4  
- *
5  
- * This program is free software: you can redistribute it and/or modify
6  
- * it under the terms of the GNU General Public License as published by
7  
- * the Free Software Foundation, version 3 of the License.
8  
- *
9  
- * This program is distributed in the hope that it will be useful,
10  
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  
- * GNU General Public License for more details.
13  
- *
14  
- * You should have received a copy of the GNU General Public License
15  
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  
- */
17  
-
18  
-#ifndef __HW_INTERRUPTS_H
19  
-#define __HW_INTERRUPTS_H
20  
-
21  
-#define IRQ_UART		(0x00000001) /* 0 */
22  
-
23  
-#endif /* __HW_INTERRUPTS_H */
4  software/libbase/uart.c
@@ -18,7 +18,7 @@
18 18
 #include <uart.h>
19 19
 #include <irq.h>
20 20
 #include <hw/uart.h>
21  
-#include <hw/interrupts.h>
  21
+#include <interrupt.h>
22 22
 
23 23
 /*
24 24
  * Buffer sizes must be a power of 2 so that modulos can be computed
@@ -121,7 +121,7 @@ void uart_init(void)
121 121
 	CSR_UART_EV_ENABLE = UART_EV_TX | UART_EV_RX;
122 122
 
123 123
 	mask = irq_getmask();
124  
-	mask |= IRQ_UART;
  124
+	mask |= UART_INTERRUPT;
125 125
 	irq_setmask(mask);
126 126
 }
127 127
 
10  top.py
@@ -63,6 +63,10 @@ def csr_offset(name):
63 63
 	assert((base >= 0xe0000000) and (base <= 0xe0010000))
64 64
 	return (base - 0xe0000000)//0x800
65 65
 
  66
+interrupt_macros = get_macros("common/interrupt.h")
  67
+def interrupt_n(name):
  68
+	return int(interrupt_macros[name + "_INTERRUPT"], 0)
  69
+
66 70
 version = get_macros("common/version.h")["VERSION"][1:-1]
67 71
 
68 72
 def get():
@@ -130,9 +134,9 @@ def get():
130 134
 	# Interrupts
131 135
 	#
132 136
 	interrupts = Fragment([
133  
-		cpu0.interrupt[0].eq(uart0.events.irq),
134  
-		cpu0.interrupt[1].eq(timer0.events.irq),
135  
-		cpu0.interrupt[2].eq(minimac0.events.irq)
  137
+		cpu0.interrupt[interrupt_n("UART")].eq(uart0.events.irq),
  138
+		cpu0.interrupt[interrupt_n("TIMER0")].eq(timer0.events.irq),
  139
+		cpu0.interrupt[interrupt_n("MINIMAC")].eq(minimac0.events.irq)
136 140
 	])
137 141
 	
138 142
 	#

0 notes on commit c01594f

Please sign in to comment.
Something went wrong with that request. Please try again.