aboutsummaryrefslogtreecommitdiff
path: root/hw/slavio_timer.c
diff options
context:
space:
mode:
authorblueswir1 <blueswir1@c046a42c-6fe2-441c-8c8c-71466251a162>2007-12-27 20:23:20 +0000
committerblueswir1 <blueswir1@c046a42c-6fe2-441c-8c8c-71466251a162>2007-12-27 20:23:20 +0000
commit85e3023e2f081b9302ca5ea0705212d7e49e00dd (patch)
tree41da408b5d9d865e2a0996c67c80c3b210bc050c /hw/slavio_timer.c
parent14e51cc7a42870f9e64084ee4f1a579ffea5788b (diff)
Remove unused timers
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3862 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'hw/slavio_timer.c')
-rw-r--r--hw/slavio_timer.c67
1 files changed, 40 insertions, 27 deletions
diff --git a/hw/slavio_timer.c b/hw/slavio_timer.c
index 9987d38aea..7cbd1ea62a 100644
--- a/hw/slavio_timer.c
+++ b/hw/slavio_timer.c
@@ -104,7 +104,11 @@ static void slavio_timer_get_out(SLAVIO_TIMERState *s)
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;
@@ -190,15 +194,18 @@ static void slavio_timer_mem_writel(void *opaque, target_phys_addr_t addr,
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:
@@ -207,28 +214,33 @@ static void slavio_timer_mem_writel(void *opaque, target_phys_addr_t addr,
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;
}
}
@@ -280,29 +292,26 @@ static void slavio_timer_save(QEMUFile *f, void *opaque)
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;
}
@@ -315,8 +324,10 @@ static void slavio_timer_reset(void *opaque)
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);
}
@@ -336,9 +347,11 @@ static SLAVIO_TIMERState *slavio_timer_init(target_phys_addr_t addr,
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);
@@ -348,7 +361,7 @@ static SLAVIO_TIMERState *slavio_timer_init(target_phys_addr_t addr,
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);