Commit bd7e2875fe99ca9621c02666e11389602b512f4b
1 parent
6fa13c17
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
Showing
1 changed file
with
7 additions
and
2 deletions
hw/slavio_timer.c
| ... | ... | @@ -97,9 +97,14 @@ static int slavio_timer_is_user(SLAVIO_TIMERState *s) |
| 97 | 97 | // Convert from ptimer countdown units |
| 98 | 98 | static void slavio_timer_get_out(SLAVIO_TIMERState *s) |
| 99 | 99 | { |
| 100 | - uint64_t count; | |
| 100 | + uint64_t count, limit; | |
| 101 | 101 | |
| 102 | - count = s->limit - PERIODS_TO_LIMIT(ptimer_get_count(s->timer)); | |
| 102 | + if (s->limit == 0) /* free-run processor or system counter */ | |
| 103 | + limit = TIMER_MAX_COUNT32; | |
| 104 | + else | |
| 105 | + limit = s->limit; | |
| 106 | + | |
| 107 | + count = limit - PERIODS_TO_LIMIT(ptimer_get_count(s->timer)); | |
| 103 | 108 | DPRINTF("get_out: limit %" PRIx64 " count %x%08x\n", s->limit, |
| 104 | 109 | s->counthigh, s->count); |
| 105 | 110 | s->count = count & TIMER_COUNT_MASK32; | ... | ... |