提交 85e3023e 编写于 作者: B blueswir1

Remove unused timers


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3862 c046a42c-6fe2-441c-8c8c-71466251a162
上级 14e51cc7
...@@ -104,7 +104,11 @@ static void slavio_timer_get_out(SLAVIO_TIMERState *s) ...@@ -104,7 +104,11 @@ static void slavio_timer_get_out(SLAVIO_TIMERState *s)
else else
limit = s->limit; limit = s->limit;
if (s->timer)
count = limit - PERIODS_TO_LIMIT(ptimer_get_count(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, DPRINTF("get_out: limit %" PRIx64 " count %x%08x\n", s->limit,
s->counthigh, s->count); s->counthigh, s->count);
s->count = count & TIMER_COUNT_MASK32; s->count = count & TIMER_COUNT_MASK32;
...@@ -190,16 +194,19 @@ static void slavio_timer_mem_writel(void *opaque, target_phys_addr_t addr, ...@@ -190,16 +194,19 @@ static void slavio_timer_mem_writel(void *opaque, target_phys_addr_t addr,
qemu_irq_lower(s->irq); qemu_irq_lower(s->irq);
s->limit = TIMER_MAX_COUNT64; s->limit = TIMER_MAX_COUNT64;
DPRINTF("processor %d user timer reset\n", s->slave_index); DPRINTF("processor %d user timer reset\n", s->slave_index);
if (s->timer)
ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(s->limit), 1); ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(s->limit), 1);
} else { } else {
// set limit, reset counter // set limit, reset counter
qemu_irq_lower(s->irq); qemu_irq_lower(s->irq);
s->limit = val & TIMER_MAX_COUNT32; s->limit = val & TIMER_MAX_COUNT32;
if (s->timer) {
if (s->limit == 0) /* free-run */ if (s->limit == 0) /* free-run */
ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(TIMER_MAX_COUNT32), 1); ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(TIMER_MAX_COUNT32), 1);
else else
ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(s->limit), 1); ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(s->limit), 1);
} }
}
break; break;
case TIMER_COUNTER: case TIMER_COUNTER:
if (slavio_timer_is_user(s)) { if (slavio_timer_is_user(s)) {
...@@ -207,6 +214,7 @@ static void slavio_timer_mem_writel(void *opaque, target_phys_addr_t addr, ...@@ -207,6 +214,7 @@ static void slavio_timer_mem_writel(void *opaque, target_phys_addr_t addr,
qemu_irq_lower(s->irq); qemu_irq_lower(s->irq);
s->limit = TIMER_MAX_COUNT64; s->limit = TIMER_MAX_COUNT64;
DPRINTF("processor %d user timer reset\n", s->slave_index); DPRINTF("processor %d user timer reset\n", s->slave_index);
if (s->timer)
ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(s->limit), 1); ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(s->limit), 1);
} else } else
DPRINTF("not user timer\n"); DPRINTF("not user timer\n");
...@@ -214,20 +222,24 @@ static void slavio_timer_mem_writel(void *opaque, target_phys_addr_t addr, ...@@ -214,20 +222,24 @@ static void slavio_timer_mem_writel(void *opaque, target_phys_addr_t addr,
case TIMER_COUNTER_NORST: case TIMER_COUNTER_NORST:
// set limit without resetting counter // set limit without resetting counter
s->limit = val & TIMER_MAX_COUNT32; s->limit = val & TIMER_MAX_COUNT32;
if (s->timer) {
if (s->limit == 0) /* free-run */ if (s->limit == 0) /* free-run */
ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(TIMER_MAX_COUNT32), 0); ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(TIMER_MAX_COUNT32), 0);
else else
ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(s->limit), 0); ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(s->limit), 0);
}
break; break;
case TIMER_STATUS: case TIMER_STATUS:
if (slavio_timer_is_user(s)) { if (slavio_timer_is_user(s)) {
// start/stop user counter // start/stop user counter
if ((val & 1) && !s->running) { if ((val & 1) && !s->running) {
DPRINTF("processor %d user timer started\n", s->slave_index); DPRINTF("processor %d user timer started\n", s->slave_index);
if (s->timer)
ptimer_run(s->timer, 0); ptimer_run(s->timer, 0);
s->running = 1; s->running = 1;
} else if (!(val & 1) && s->running) { } else if (!(val & 1) && s->running) {
DPRINTF("processor %d user timer stopped\n", s->slave_index); DPRINTF("processor %d user timer stopped\n", s->slave_index);
if (s->timer)
ptimer_stop(s->timer); ptimer_stop(s->timer);
s->running = 0; s->running = 0;
} }
...@@ -280,28 +292,25 @@ static void slavio_timer_save(QEMUFile *f, void *opaque) ...@@ -280,28 +292,25 @@ static void slavio_timer_save(QEMUFile *f, void *opaque)
qemu_put_be64s(f, &s->limit); qemu_put_be64s(f, &s->limit);
qemu_put_be32s(f, &s->count); qemu_put_be32s(f, &s->count);
qemu_put_be32s(f, &s->counthigh); qemu_put_be32s(f, &s->counthigh);
qemu_put_be32(f, 0); // Was irq
qemu_put_be32s(f, &s->reached); qemu_put_be32s(f, &s->reached);
qemu_put_be32s(f, &s->running); qemu_put_be32s(f, &s->running);
qemu_put_be32s(f, 0); // Was mode if (s->timer)
qemu_put_ptimer(f, s->timer); qemu_put_ptimer(f, s->timer);
} }
static int slavio_timer_load(QEMUFile *f, void *opaque, int version_id) static int slavio_timer_load(QEMUFile *f, void *opaque, int version_id)
{ {
SLAVIO_TIMERState *s = opaque; SLAVIO_TIMERState *s = opaque;
uint32_t tmp;
if (version_id != 2) if (version_id != 3)
return -EINVAL; return -EINVAL;
qemu_get_be64s(f, &s->limit); qemu_get_be64s(f, &s->limit);
qemu_get_be32s(f, &s->count); qemu_get_be32s(f, &s->count);
qemu_get_be32s(f, &s->counthigh); qemu_get_be32s(f, &s->counthigh);
qemu_get_be32s(f, &tmp); // Was irq
qemu_get_be32s(f, &s->reached); qemu_get_be32s(f, &s->reached);
qemu_get_be32s(f, &s->running); qemu_get_be32s(f, &s->running);
qemu_get_be32s(f, &tmp); // Was mode if (s->timer)
qemu_get_ptimer(f, s->timer); qemu_get_ptimer(f, s->timer);
return 0; return 0;
...@@ -315,8 +324,10 @@ static void slavio_timer_reset(void *opaque) ...@@ -315,8 +324,10 @@ static void slavio_timer_reset(void *opaque)
s->count = 0; s->count = 0;
s->reached = 0; s->reached = 0;
s->slave_mode = 0; s->slave_mode = 0;
if (!s->master || s->slave_index < s->master->num_slaves) {
ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(TIMER_MAX_COUNT32), 1); ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(TIMER_MAX_COUNT32), 1);
ptimer_run(s->timer, 0); ptimer_run(s->timer, 0);
}
s->running = 1; s->running = 1;
qemu_irq_lower(s->irq); qemu_irq_lower(s->irq);
} }
...@@ -336,9 +347,11 @@ static SLAVIO_TIMERState *slavio_timer_init(target_phys_addr_t addr, ...@@ -336,9 +347,11 @@ static SLAVIO_TIMERState *slavio_timer_init(target_phys_addr_t addr,
s->irq = irq; s->irq = irq;
s->master = master; s->master = master;
s->slave_index = slave_index; s->slave_index = slave_index;
if (!master || slave_index < master->num_slaves) {
bh = qemu_bh_new(slavio_timer_irq, s); bh = qemu_bh_new(slavio_timer_irq, s);
s->timer = ptimer_init(bh); s->timer = ptimer_init(bh);
ptimer_set_period(s->timer, TIMER_PERIOD); ptimer_set_period(s->timer, TIMER_PERIOD);
}
slavio_timer_io_memory = cpu_register_io_memory(0, slavio_timer_mem_read, slavio_timer_io_memory = cpu_register_io_memory(0, slavio_timer_mem_read,
slavio_timer_mem_write, s); slavio_timer_mem_write, s);
...@@ -348,7 +361,7 @@ static SLAVIO_TIMERState *slavio_timer_init(target_phys_addr_t addr, ...@@ -348,7 +361,7 @@ static SLAVIO_TIMERState *slavio_timer_init(target_phys_addr_t addr,
else else
cpu_register_physical_memory(addr, SYS_TIMER_SIZE, cpu_register_physical_memory(addr, SYS_TIMER_SIZE,
slavio_timer_io_memory); 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); slavio_timer_load, s);
qemu_register_reset(slavio_timer_reset, s); qemu_register_reset(slavio_timer_reset, s);
slavio_timer_reset(s); slavio_timer_reset(s);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册