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);
{
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 */
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)
{
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;
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);