diff options
author | Julien Grall <julien.grall@linaro.org> | 2013-05-09 18:11:02 +0100 |
---|---|---|
committer | Ian Campbell <ian.campbell@citrix.com> | 2013-05-13 11:59:59 +0100 |
commit | 95edff23232dbc94761d7e956669723ffb5c69bc (patch) | |
tree | 2fb352c4f68c0a590dc7bd7a8feb88c629d34312 | |
parent | 699f48cd134f6cf92375f0b00fcb67cffc8f40b4 (diff) | |
download | xen-95edff23232dbc94761d7e956669723ffb5c69bc.tar.gz xen-95edff23232dbc94761d7e956669723ffb5c69bc.tar.bz2 xen-95edff23232dbc94761d7e956669723ffb5c69bc.zip |
xen/arm: Don't hardcode virtual timer IRQs
Define virtual timer IRQs per VCPU
Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
-rw-r--r-- | xen/arch/arm/time.c | 9 | ||||
-rw-r--r-- | xen/arch/arm/vtimer.c | 13 | ||||
-rw-r--r-- | xen/include/asm-arm/time.h | 3 |
3 files changed, 19 insertions, 6 deletions
diff --git a/xen/arch/arm/time.c b/xen/arch/arm/time.c index ecb76263eb..2e928bc8d2 100644 --- a/xen/arch/arm/time.c +++ b/xen/arch/arm/time.c @@ -49,6 +49,13 @@ unsigned long __read_mostly cpu_khz; /* CPU clock frequency in kHz. */ static struct dt_irq timer_irq[MAX_TIMER_PPI]; +const struct dt_irq *timer_dt_irq(enum timer_ppi ppi) +{ + ASSERT(ppi >= TIMER_PHYS_SECURE_PPI && ppi < MAX_TIMER_PPI); + + return &timer_irq[ppi]; +} + /*static inline*/ s_time_t ticks_to_ns(uint64_t ticks) { return muldiv64(ticks, SECONDS(1), 1000 * cpu_khz); @@ -192,7 +199,7 @@ static void vtimer_interrupt(int irq, void *dev_id, struct cpu_user_regs *regs) { current->arch.virt_timer.ctl = READ_SYSREG32(CNTV_CTL_EL0); WRITE_SYSREG32(current->arch.virt_timer.ctl | CNTx_CTL_MASK, CNTV_CTL_EL0); - vgic_vcpu_inject_irq(current, irq, 1); + vgic_vcpu_inject_irq(current, current->arch.virt_timer.irq, 1); } /* Route timer's IRQ on this CPU */ diff --git a/xen/arch/arm/vtimer.c b/xen/arch/arm/vtimer.c index 6993425aa5..aee762a07d 100644 --- a/xen/arch/arm/vtimer.c +++ b/xen/arch/arm/vtimer.c @@ -34,14 +34,14 @@ static void phys_timer_expired(void *data) struct vtimer *t = data; t->ctl |= CNTx_CTL_PENDING; if ( !(t->ctl & CNTx_CTL_MASK) ) - vgic_vcpu_inject_irq(t->v, 30, 1); + vgic_vcpu_inject_irq(t->v, t->irq, 1); } static void virt_timer_expired(void *data) { struct vtimer *t = data; t->ctl |= CNTx_CTL_MASK; - vgic_vcpu_inject_irq(t->v, 27, 1); + vgic_vcpu_inject_irq(t->v, t->irq, 1); } int vcpu_domain_init(struct domain *d) @@ -55,17 +55,20 @@ int vcpu_vtimer_init(struct vcpu *v) { struct vtimer *t = &v->arch.phys_timer; + /* TODO: Retrieve physical and virtual timer IRQ from the guest + * DT. For the moment we use dom0 DT + */ + init_timer(&t->timer, phys_timer_expired, t, v->processor); t->ctl = 0; t->cval = NOW(); - t->irq = 30; + t->irq = timer_dt_irq(TIMER_PHYS_NONSECURE_PPI)->irq; t->v = v; t = &v->arch.virt_timer; init_timer(&t->timer, virt_timer_expired, t, v->processor); t->ctl = 0; - t->cval = 0; - t->irq = 27; + t->irq = timer_dt_irq(TIMER_VIRT_PPI)->irq; t->v = v; return 0; diff --git a/xen/include/asm-arm/time.h b/xen/include/asm-arm/time.h index 05833ce60f..f7aa86864f 100644 --- a/xen/include/asm-arm/time.h +++ b/xen/include/asm-arm/time.h @@ -21,6 +21,9 @@ enum timer_ppi MAX_TIMER_PPI = 4, }; +/* Get one of the timer IRQ description */ +const struct dt_irq* timer_dt_irq(enum timer_ppi ppi); + /* Route timer's IRQ on this CPU */ extern void __cpuinit route_timer_interrupt(void); |