]> xenbits.xensource.com Git - people/iwj/xen.git/commitdiff
xen/arm: Don't hardcode virtual timer IRQs
authorJulien Grall <julien.grall@linaro.org>
Thu, 9 May 2013 17:11:02 +0000 (18:11 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Mon, 13 May 2013 10:59:59 +0000 (11:59 +0100)
Define virtual timer IRQs per VCPU

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
xen/arch/arm/time.c
xen/arch/arm/vtimer.c
xen/include/asm-arm/time.h

index ecb76263eb7ad23a876cacc53a793f270f3f32e8..2e928bc8d2018f7b699f17fde173356f1e0b1426 100644 (file)
@@ -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 */
index 6993425aa51178f512b92974c24cf6ca7037b32f..aee762a07de629eb646d14eed4bce16df6168b53 100644 (file)
@@ -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;
index 05833ce60fab343728f6141aa22561b4a71f5715..f7aa86864f98cf6f74adadd620b2086c2c146086 100644 (file)
@@ -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);