aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorblueswir1 <blueswir1@c046a42c-6fe2-441c-8c8c-71466251a162>2007-12-19 17:58:24 +0000
committerblueswir1 <blueswir1@c046a42c-6fe2-441c-8c8c-71466251a162>2007-12-19 17:58:24 +0000
commitbd7e2875fe99ca9621c02666e11389602b512f4b (patch)
treecac8b56a4b9305f56fcbb5e84d5196023a26bafa
parent6fa13c170c6f85bf76b23d689df2cc576f12bffd (diff)
Fix count calculation when counter limit set to 0 (Robert Reif)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3840 c046a42c-6fe2-441c-8c8c-71466251a162
-rw-r--r--hw/slavio_timer.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/hw/slavio_timer.c b/hw/slavio_timer.c
index f98647f98f..e854358175 100644
--- a/hw/slavio_timer.c
+++ b/hw/slavio_timer.c
@@ -97,9 +97,14 @@ static int slavio_timer_is_user(SLAVIO_TIMERState *s)
// Convert from ptimer countdown units
static void slavio_timer_get_out(SLAVIO_TIMERState *s)
{
- uint64_t count;
+ uint64_t count, limit;
- count = s->limit - PERIODS_TO_LIMIT(ptimer_get_count(s->timer));
+ if (s->limit == 0) /* free-run processor or system counter */
+ limit = TIMER_MAX_COUNT32;
+ else
+ limit = s->limit;
+
+ count = limit - PERIODS_TO_LIMIT(ptimer_get_count(s->timer));
DPRINTF("get_out: limit %" PRIx64 " count %x%08x\n", s->limit,
s->counthigh, s->count);
s->count = count & TIMER_COUNT_MASK32;