Sparc32: timer field is never NULL

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
Blue Swirl 2009-08-31 19:30:17 +00:00
parent 55a6e51f2a
commit 9ebec28b6c
1 changed files with 12 additions and 30 deletions

View File

@ -110,11 +110,8 @@ static void slavio_timer_get_out(CPUTimerState *t)
} else {
limit = t->limit;
}
if (t->timer) {
count = limit - PERIODS_TO_LIMIT(ptimer_get_count(t->timer));
} else {
count = 0;
}
DPRINTF("get_out: limit %" PRIx64 " count %x%08x\n", t->limit, t->counthigh,
t->count);
t->count = count & TIMER_COUNT_MASK32;
@ -219,9 +216,7 @@ static void slavio_timer_mem_writel(void *opaque, target_phys_addr_t addr,
count = ((uint64_t)t->counthigh << 32) | t->count;
DPRINTF("processor %d user timer set to %016" PRIx64 "\n",
timer_index, count);
if (t->timer) {
ptimer_set_count(t->timer, LIMIT_TO_PERIODS(t->limit - count));
}
} else {
// set limit, reset counter
qemu_irq_lower(t->irq);
@ -247,23 +242,18 @@ static void slavio_timer_mem_writel(void *opaque, target_phys_addr_t addr,
count = ((uint64_t)t->counthigh) << 32 | t->count;
DPRINTF("processor %d user timer set to %016" PRIx64 "\n",
timer_index, count);
if (t->timer) {
ptimer_set_count(t->timer, LIMIT_TO_PERIODS(t->limit - count));
}
} else
DPRINTF("not user timer\n");
break;
case TIMER_COUNTER_NORST:
// set limit without resetting counter
t->limit = val & TIMER_MAX_COUNT32;
if (t->timer) {
if (t->limit == 0) { /* free-run */
ptimer_set_limit(t->timer,
LIMIT_TO_PERIODS(TIMER_MAX_COUNT32), 0);
ptimer_set_limit(t->timer, LIMIT_TO_PERIODS(TIMER_MAX_COUNT32), 0);
} else {
ptimer_set_limit(t->timer, LIMIT_TO_PERIODS(t->limit), 0);
}
}
break;
case TIMER_STATUS:
if (slavio_timer_is_user(tc)) {
@ -271,16 +261,12 @@ static void slavio_timer_mem_writel(void *opaque, target_phys_addr_t addr,
if ((val & 1) && !t->running) {
DPRINTF("processor %d user timer started\n",
timer_index);
if (t->timer) {
ptimer_run(t->timer, 0);
}
t->running = 1;
} else if (!(val & 1) && t->running) {
DPRINTF("processor %d user timer stopped\n",
timer_index);
if (t->timer) {
ptimer_stop(t->timer);
}
t->running = 0;
}
}
@ -361,11 +347,9 @@ static void slavio_timer_save(QEMUFile *f, void *opaque)
qemu_put_be32s(f, &curr_timer->counthigh);
qemu_put_be32s(f, &curr_timer->reached);
qemu_put_be32s(f, &curr_timer->running);
if (curr_timer->timer) {
qemu_put_ptimer(f, curr_timer->timer);
}
}
}
static int slavio_timer_load(QEMUFile *f, void *opaque, int version_id)
{
@ -383,10 +367,8 @@ static int slavio_timer_load(QEMUFile *f, void *opaque, int version_id)
qemu_get_be32s(f, &curr_timer->counthigh);
qemu_get_be32s(f, &curr_timer->reached);
qemu_get_be32s(f, &curr_timer->running);
if (curr_timer->timer) {
qemu_get_ptimer(f, curr_timer->timer);
}
}
return 0;
}