Commit 6240d6467077a12c24878bab645d8e2983e4975a
1 parent
19f8e5dd
Fix setting counter limit to 0 (Robert Reif)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3834 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
8 additions
and
7 deletions
hw/slavio_timer.c
... | ... | @@ -175,7 +175,6 @@ static void slavio_timer_mem_writel(void *opaque, target_phys_addr_t addr, |
175 | 175 | { |
176 | 176 | SLAVIO_TIMERState *s = opaque; |
177 | 177 | uint32_t saddr; |
178 | - int reload = 0; | |
179 | 178 | |
180 | 179 | DPRINTF("write " TARGET_FMT_plx " %08x\n", addr, val); |
181 | 180 | saddr = (addr & TIMER_MAXADDR) >> 2; |
... | ... | @@ -191,9 +190,10 @@ static void slavio_timer_mem_writel(void *opaque, target_phys_addr_t addr, |
191 | 190 | // set limit, reset counter |
192 | 191 | qemu_irq_lower(s->irq); |
193 | 192 | s->limit = val & TIMER_MAX_COUNT32; |
194 | - if (!s->limit) | |
195 | - s->limit = TIMER_MAX_COUNT32; | |
196 | - ptimer_set_limit(s->timer, s->limit >> 9, 1); | |
193 | + if (s->limit == 0) /* free-run */ | |
194 | + ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(TIMER_MAX_COUNT32), 1); | |
195 | + else | |
196 | + ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(s->limit), 1); | |
197 | 197 | } |
198 | 198 | break; |
199 | 199 | case TIMER_COUNTER: |
... | ... | @@ -209,9 +209,10 @@ static void slavio_timer_mem_writel(void *opaque, target_phys_addr_t addr, |
209 | 209 | case TIMER_COUNTER_NORST: |
210 | 210 | // set limit without resetting counter |
211 | 211 | s->limit = val & TIMER_MAX_COUNT32; |
212 | - if (!s->limit) | |
213 | - s->limit = TIMER_MAX_COUNT32; | |
214 | - ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(s->limit), reload); | |
212 | + if (s->limit == 0) /* free-run */ | |
213 | + ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(TIMER_MAX_COUNT32), 0); | |
214 | + else | |
215 | + ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(s->limit), 0); | |
215 | 216 | break; |
216 | 217 | case TIMER_STATUS: |
217 | 218 | if (slavio_timer_is_user(s)) { | ... | ... |