Skip to content

Commit

Permalink
Common interrupt numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastien Bourdeauducq committed May 21, 2012
1 parent 9424551 commit c01594f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 30 deletions.
8 changes: 8 additions & 0 deletions common/interrupt.h
@@ -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 */
4 changes: 2 additions & 2 deletions software/bios/isr.c
Expand Up @@ -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>

Expand All @@ -27,6 +27,6 @@ void isr(void)

irqs = irq_pending() & irq_getmask();

if(irqs & IRQ_UART)
if(irqs & (1 << UART_INTERRUPT))
uart_isr();
}
23 changes: 0 additions & 23 deletions software/include/hw/interrupts.h

This file was deleted.

4 changes: 2 additions & 2 deletions software/libbase/uart.c
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}

Expand Down
10 changes: 7 additions & 3 deletions top.py
Expand Up @@ -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():
Expand Down Expand Up @@ -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)
])

#
Expand Down

0 comments on commit c01594f

Please sign in to comment.