From 8528e582c4124634376de162bd7b949de39c1603 Mon Sep 17 00:00:00 2001 From: Michel Pollet Date: Thu, 15 Mar 2012 14:16:34 +0000 Subject: [PATCH] irq: Added an INIT flag 'filtered' interrupts didn't work if the initial value was the same as the one used to raise the irq. Now it works properly, can could also be used to track IRQs in the pool by usage. Signed-off-by: Michel Pollet --- simavr/sim/sim_irq.c | 6 +++++- simavr/sim/sim_irq.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/simavr/sim/sim_irq.c b/simavr/sim/sim_irq.c index 0e4c56e..68d218b 100644 --- a/simavr/sim/sim_irq.c +++ b/simavr/sim/sim_irq.c @@ -71,6 +71,7 @@ avr_init_irq( for (int i = 0; i < count; i++) { irq[i].irq = base + i; + irq[i].flags = IRQ_FLAG_INIT; if (pool) _avr_irq_pool_add(pool, &irq[i]); if (names && names[i]) @@ -185,8 +186,11 @@ avr_raise_irq( if (!irq) return ; uint32_t output = (irq->flags & IRQ_FLAG_NOT) ? !value : value; - if (irq->value == output && (irq->flags & IRQ_FLAG_FILTERED)) + // if value is the same but it's the first time, raise it anyway + if (irq->value == output && + (irq->flags & IRQ_FLAG_FILTERED) && !(irq->flags & IRQ_FLAG_INIT)) return; + irq->flags &= ~IRQ_FLAG_INIT; avr_irq_hook_t *hook = irq->hook; while (hook) { avr_irq_hook_t * next = hook->next; diff --git a/simavr/sim/sim_irq.h b/simavr/sim/sim_irq.h index d75c8e7..ed2d5e5 100644 --- a/simavr/sim/sim_irq.h +++ b/simavr/sim/sim_irq.h @@ -55,6 +55,7 @@ enum { IRQ_FLAG_NOT = (1 << 0), //!< change polarity of the IRQ IRQ_FLAG_FILTERED = (1 << 1), //!< do not "notify" if "value" is the same as previous raise IRQ_FLAG_ALLOC = (1 << 2), //!< this irq structure was malloced via avr_alloc_irq + IRQ_FLAG_INIT = (1 << 3), //!< this irq hasn't been used yet }; /* -- 2.39.5