else
limit = s->limit;
- count = limit - PERIODS_TO_LIMIT(ptimer_get_count(s->timer));
+ if (s->timer)
+ count = limit - PERIODS_TO_LIMIT(ptimer_get_count(s->timer));
+ else
+ count = 0;
+
DPRINTF("get_out: limit %" PRIx64 " count %x%08x\n", s->limit,
s->counthigh, s->count);
s->count = count & TIMER_COUNT_MASK32;
qemu_irq_lower(s->irq);
s->limit = TIMER_MAX_COUNT64;
DPRINTF("processor %d user timer reset\n", s->slave_index);
- ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(s->limit), 1);
+ if (s->timer)
+ ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(s->limit), 1);
} else {
// set limit, reset counter
qemu_irq_lower(s->irq);
s->limit = val & TIMER_MAX_COUNT32;
- if (s->limit == 0) /* free-run */
- ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(TIMER_MAX_COUNT32), 1);
- else
- ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(s->limit), 1);
+ if (s->timer) {
+ if (s->limit == 0) /* free-run */
+ ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(TIMER_MAX_COUNT32), 1);
+ else
+ ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(s->limit), 1);
+ }
}
break;
case TIMER_COUNTER:
qemu_irq_lower(s->irq);
s->limit = TIMER_MAX_COUNT64;
DPRINTF("processor %d user timer reset\n", s->slave_index);
- ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(s->limit), 1);
+ if (s->timer)
+ ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(s->limit), 1);
} else
DPRINTF("not user timer\n");
break;
case TIMER_COUNTER_NORST:
// set limit without resetting counter
s->limit = val & TIMER_MAX_COUNT32;
- if (s->limit == 0) /* free-run */
- ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(TIMER_MAX_COUNT32), 0);
- else
- ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(s->limit), 0);
+ if (s->timer) {
+ if (s->limit == 0) /* free-run */
+ ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(TIMER_MAX_COUNT32), 0);
+ else
+ ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(s->limit), 0);
+ }
break;
case TIMER_STATUS:
if (slavio_timer_is_user(s)) {
// start/stop user counter
if ((val & 1) && !s->running) {
DPRINTF("processor %d user timer started\n", s->slave_index);
- ptimer_run(s->timer, 0);
+ if (s->timer)
+ ptimer_run(s->timer, 0);
s->running = 1;
} else if (!(val & 1) && s->running) {
DPRINTF("processor %d user timer stopped\n", s->slave_index);
- ptimer_stop(s->timer);
+ if (s->timer)
+ ptimer_stop(s->timer);
s->running = 0;
}
}
qemu_put_be64s(f, &s->limit);
qemu_put_be32s(f, &s->count);
qemu_put_be32s(f, &s->counthigh);
- qemu_put_be32(f, 0); // Was irq
qemu_put_be32s(f, &s->reached);
qemu_put_be32s(f, &s->running);
- qemu_put_be32s(f, 0); // Was mode
- qemu_put_ptimer(f, s->timer);
+ if (s->timer)
+ qemu_put_ptimer(f, s->timer);
}
static int slavio_timer_load(QEMUFile *f, void *opaque, int version_id)
{
SLAVIO_TIMERState *s = opaque;
- uint32_t tmp;
- if (version_id != 2)
+ if (version_id != 3)
return -EINVAL;
qemu_get_be64s(f, &s->limit);
qemu_get_be32s(f, &s->count);
qemu_get_be32s(f, &s->counthigh);
- qemu_get_be32s(f, &tmp); // Was irq
qemu_get_be32s(f, &s->reached);
qemu_get_be32s(f, &s->running);
- qemu_get_be32s(f, &tmp); // Was mode
- qemu_get_ptimer(f, s->timer);
+ if (s->timer)
+ qemu_get_ptimer(f, s->timer);
return 0;
}
s->count = 0;
s->reached = 0;
s->slave_mode = 0;
- ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(TIMER_MAX_COUNT32), 1);
- ptimer_run(s->timer, 0);
+ if (!s->master || s->slave_index < s->master->num_slaves) {
+ ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(TIMER_MAX_COUNT32), 1);
+ ptimer_run(s->timer, 0);
+ }
s->running = 1;
qemu_irq_lower(s->irq);
}
s->irq = irq;
s->master = master;
s->slave_index = slave_index;
- bh = qemu_bh_new(slavio_timer_irq, s);
- s->timer = ptimer_init(bh);
- ptimer_set_period(s->timer, TIMER_PERIOD);
+ if (!master || slave_index < master->num_slaves) {
+ bh = qemu_bh_new(slavio_timer_irq, s);
+ s->timer = ptimer_init(bh);
+ ptimer_set_period(s->timer, TIMER_PERIOD);
+ }
slavio_timer_io_memory = cpu_register_io_memory(0, slavio_timer_mem_read,
slavio_timer_mem_write, s);
else
cpu_register_physical_memory(addr, SYS_TIMER_SIZE,
slavio_timer_io_memory);
- register_savevm("slavio_timer", addr, 2, slavio_timer_save,
+ register_savevm("slavio_timer", addr, 3, slavio_timer_save,
slavio_timer_load, s);
qemu_register_reset(slavio_timer_reset, s);
slavio_timer_reset(s);