aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorths <ths@c046a42c-6fe2-441c-8c8c-71466251a162>2007-01-24 01:47:51 +0000
committerths <ths@c046a42c-6fe2-441c-8c8c-71466251a162>2007-01-24 01:47:51 +0000
commit4de9b249d37c1b382cc3e5a21fad1b4a11cec2fa (patch)
tree3991d58b09108b5c18a4388b2c2a8b6cb8f57142 /hw
parent30c4bbace19e802979009cc5c16fb4e14dc6bda6 (diff)
Reworking MIPS interrupt handling, by Aurelien Jarno.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2350 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'hw')
-rw-r--r--hw/gt64xxx.c5
-rw-r--r--hw/i8259.c7
-rw-r--r--hw/mips_int.c39
-rw-r--r--hw/mips_malta.c10
-rw-r--r--hw/mips_r4k.c9
-rw-r--r--hw/mips_timer.c6
6 files changed, 54 insertions, 22 deletions
diff --git a/hw/gt64xxx.c b/hw/gt64xxx.c
index f3ff613811..84e041fcfc 100644
--- a/hw/gt64xxx.c
+++ b/hw/gt64xxx.c
@@ -1,7 +1,7 @@
/*
* QEMU GT64120 PCI host
*
- * Copyright (c) 2006 Aurelien Jarno
+ * Copyright (c) 2006,2007 Aurelien Jarno
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -433,7 +433,8 @@ static uint32_t gt64120_readl (void *opaque,
val = s->regs[saddr];
break;
case GT_PCI0_IACK:
- val = pic_intack_read(isa_pic);
+ /* Read the IRQ number */
+ val = pic_read_irq(isa_pic);
break;
/* SDRAM Parameters */
diff --git a/hw/i8259.c b/hw/i8259.c
index c747f106e9..f8b5a984b5 100644
--- a/hw/i8259.c
+++ b/hw/i8259.c
@@ -161,6 +161,13 @@ void pic_update_irq(PicState2 *s)
#endif
s->irq_request(s->irq_request_opaque, 1);
}
+
+/* all targets should do this rather than acking the IRQ in the cpu */
+#if defined(TARGET_MIPS)
+ else {
+ s->irq_request(s->irq_request_opaque, 0);
+ }
+#endif
}
#ifdef DEBUG_IRQ_LATENCY
diff --git a/hw/mips_int.c b/hw/mips_int.c
new file mode 100644
index 0000000000..93d599fc60
--- /dev/null
+++ b/hw/mips_int.c
@@ -0,0 +1,39 @@
+#include "vl.h"
+#include "cpu.h"
+
+/* Raise IRQ to CPU if necessary. It must be called every time the active
+ IRQ may change */
+void cpu_mips_update_irq(CPUState *env)
+{
+ if ((env->CP0_Status & env->CP0_Cause & CP0Ca_IP_mask) &&
+ (env->CP0_Status & (1 << CP0St_IE)) &&
+ !(env->hflags & MIPS_HFLAG_EXL) &&
+ !(env->hflags & MIPS_HFLAG_ERL) &&
+ !(env->hflags & MIPS_HFLAG_DM)) {
+ if (! (env->interrupt_request & CPU_INTERRUPT_HARD)) {
+ cpu_interrupt(env, CPU_INTERRUPT_HARD);
+ }
+ } else {
+ cpu_reset_interrupt(env, CPU_INTERRUPT_HARD);
+ }
+}
+
+void cpu_mips_irq_request(void *opaque, int irq, int level)
+{
+ CPUState *env = first_cpu;
+
+ uint32_t mask;
+
+ if (irq >= 16)
+ return;
+
+ mask = 1 << (irq + CP0Ca_IP);
+
+ if (level) {
+ env->CP0_Cause |= mask;
+ } else {
+ env->CP0_Cause &= ~mask;
+ }
+ cpu_mips_update_irq(env);
+}
+
diff --git a/hw/mips_malta.c b/hw/mips_malta.c
index 12343e0ade..7ddf2fd175 100644
--- a/hw/mips_malta.c
+++ b/hw/mips_malta.c
@@ -54,16 +54,10 @@ typedef struct {
static PITState *pit;
+/* The 8259 is attached to the MIPS CPU INT0 pin, ie interrupt 2 */
static void pic_irq_request(void *opaque, int level)
{
- CPUState *env = first_cpu;
- if (level) {
- env->CP0_Cause |= 0x00000400;
- cpu_interrupt(env, CPU_INTERRUPT_HARD);
- } else {
- env->CP0_Cause &= ~0x00000400;
- cpu_reset_interrupt(env, CPU_INTERRUPT_HARD);
- }
+ cpu_mips_irq_request(opaque, 2, level);
}
/* Malta FPGA */
diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c
index ffed67c2a5..5fa5b76a68 100644
--- a/hw/mips_r4k.c
+++ b/hw/mips_r4k.c
@@ -38,14 +38,7 @@ static PITState *pit; /* PIT i8254 */
/*The PIC is attached to the MIPS CPU INT0 pin */
static void pic_irq_request(void *opaque, int level)
{
- CPUState *env = first_cpu;
- if (level) {
- env->CP0_Cause |= 0x00000400;
- cpu_interrupt(env, CPU_INTERRUPT_HARD);
- } else {
- env->CP0_Cause &= ~0x00000400;
- cpu_reset_interrupt(env, CPU_INTERRUPT_HARD);
- }
+ cpu_mips_irq_request(opaque, 2, level);
}
static void mips_qemu_writel (void *opaque, target_phys_addr_t addr,
diff --git a/hw/mips_timer.c b/hw/mips_timer.c
index 251324d7b8..bc83036b34 100644
--- a/hw/mips_timer.c
+++ b/hw/mips_timer.c
@@ -57,8 +57,7 @@ void cpu_mips_store_count (CPUState *env, uint32_t value)
void cpu_mips_store_compare (CPUState *env, uint32_t value)
{
cpu_mips_update_count(env, cpu_mips_get_count(env), value);
- env->CP0_Cause &= ~0x00008000;
- cpu_reset_interrupt(env, CPU_INTERRUPT_HARD);
+ cpu_mips_irq_request(env, 7, 0);
}
static void mips_timer_cb (void *opaque)
@@ -72,8 +71,7 @@ static void mips_timer_cb (void *opaque)
}
#endif
cpu_mips_update_count(env, cpu_mips_get_count(env), env->CP0_Compare);
- env->CP0_Cause |= 0x00008000;
- cpu_interrupt(env, CPU_INTERRUPT_HARD);
+ cpu_mips_irq_request(env, 7, 1);
}
void cpu_mips_clock_init (CPUState *env)