summary refs log tree commit diff stats
path: root/hw/puv3.c
diff options
context:
space:
mode:
authorGuan Xuetao <gxt@mprc.pku.edu.cn>2012-08-10 14:42:28 +0800
committerBlue Swirl <blauwirbel@gmail.com>2012-08-11 09:36:59 +0000
commit5c8556a6f64842c78c2e3493f9d7544af5736ddb (patch)
tree209d5cdf80efd9e4b2fdecbe4e25d2c9026e3073 /hw/puv3.c
parentfbbdf9838d30ecdf24b0ff9f6a4e9567d74e39bd (diff)
downloadfocaccia-qemu-5c8556a6f64842c78c2e3493f9d7544af5736ddb.tar.gz
focaccia-qemu-5c8556a6f64842c78c2e3493f9d7544af5736ddb.zip
unicore32-softmmu: Add puv3 interrupt support
This patch adds puv3 interrupt support, include interrupt controler
device simulation and interrupt handler in puv3 machine.

Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'hw/puv3.c')
-rw-r--r--hw/puv3.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/hw/puv3.c b/hw/puv3.c
index 0dc129dd49..287045561d 100644
--- a/hw/puv3.c
+++ b/hw/puv3.c
@@ -22,9 +22,30 @@
 #define KERNEL_LOAD_ADDR        0x03000000
 #define KERNEL_MAX_SIZE         0x00800000 /* Just a guess */
 
+static void puv3_intc_cpu_handler(void *opaque, int irq, int level)
+{
+    CPUUniCore32State *env = opaque;
+
+    assert(irq == 0);
+    if (level) {
+        cpu_interrupt(env, CPU_INTERRUPT_HARD);
+    } else {
+        cpu_reset_interrupt(env, CPU_INTERRUPT_HARD);
+    }
+}
+
 static void puv3_soc_init(CPUUniCore32State *env)
 {
-    /* TODO */
+    qemu_irq *cpu_intc, irqs[PUV3_IRQS_NR];
+    DeviceState *dev;
+    int i;
+
+    /* Initialize interrupt controller */
+    cpu_intc = qemu_allocate_irqs(puv3_intc_cpu_handler, env, 1);
+    dev = sysbus_create_simple("puv3_intc", PUV3_INTC_BASE, *cpu_intc);
+    for (i = 0; i < PUV3_IRQS_NR; i++) {
+        irqs[i] = qdev_get_gpio_in(dev, i);
+    }
 }
 
 static void puv3_board_init(CPUUniCore32State *env, ram_addr_t ram_size)