aboutsummaryrefslogtreecommitdiff
path: root/hw/xtensa/pic_cpu.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/xtensa/pic_cpu.c')
-rw-r--r--hw/xtensa/pic_cpu.c47
1 files changed, 26 insertions, 21 deletions
diff --git a/hw/xtensa/pic_cpu.c b/hw/xtensa/pic_cpu.c
index 0e812d7f06..a8939f5e58 100644
--- a/hw/xtensa/pic_cpu.c
+++ b/hw/xtensa/pic_cpu.c
@@ -68,36 +68,37 @@ static void xtensa_set_irq(void *opaque, int irq, int active)
uint32_t irq_bit = 1 << irq;
if (active) {
- env->sregs[INTSET] |= irq_bit;
+ atomic_or(&env->sregs[INTSET], irq_bit);
} else if (env->config->interrupt[irq].inttype == INTTYPE_LEVEL) {
- env->sregs[INTSET] &= ~irq_bit;
+ atomic_and(&env->sregs[INTSET], ~irq_bit);
}
check_interrupts(env);
}
}
-void xtensa_timer_irq(CPUXtensaState *env, uint32_t id, uint32_t active)
-{
- qemu_set_irq(env->irq_inputs[env->config->timerint[id]], active);
-}
-
static void xtensa_ccompare_cb(void *opaque)
{
XtensaCcompareTimer *ccompare = opaque;
CPUXtensaState *env = ccompare->env;
unsigned i = ccompare - env->ccompare;
- xtensa_timer_irq(env, i, 1);
+ qemu_set_irq(env->irq_inputs[env->config->timerint[i]], 1);
+}
+
+static void xtensa_set_runstall(void *opaque, int irq, int active)
+{
+ CPUXtensaState *env = opaque;
+ xtensa_runstall(env, active);
}
void xtensa_irq_init(CPUXtensaState *env)
{
- env->irq_inputs = (void **)qemu_allocate_irqs(
- xtensa_set_irq, env, env->config->ninterrupt);
- if (xtensa_option_enabled(env->config, XTENSA_OPTION_TIMER_INTERRUPT)) {
- unsigned i;
+ unsigned i;
+ env->irq_inputs = qemu_allocate_irqs(xtensa_set_irq, env,
+ env->config->ninterrupt);
+ if (xtensa_option_enabled(env->config, XTENSA_OPTION_TIMER_INTERRUPT)) {
env->time_base = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
env->ccount_base = env->sregs[CCOUNT];
for (i = 0; i < env->config->nccompare; ++i) {
@@ -106,16 +107,20 @@ void xtensa_irq_init(CPUXtensaState *env)
xtensa_ccompare_cb, env->ccompare + i);
}
}
+ for (i = 0; i < env->config->nextint; ++i) {
+ unsigned irq = env->config->extint[i];
+
+ env->ext_irq_inputs[i] = env->irq_inputs[irq];
+ }
+ env->runstall_irq = qemu_allocate_irq(xtensa_set_runstall, env, 0);
}
-void *xtensa_get_extint(CPUXtensaState *env, unsigned extint)
+qemu_irq *xtensa_get_extints(CPUXtensaState *env)
{
- if (extint < env->config->nextint) {
- unsigned irq = env->config->extint[extint];
- return env->irq_inputs[irq];
- } else {
- qemu_log("%s: trying to acquire invalid external interrupt %d\n",
- __func__, extint);
- return NULL;
- }
+ return env->ext_irq_inputs;
+}
+
+qemu_irq xtensa_get_runstall(CPUXtensaState *env)
+{
+ return env->runstall_irq;
}