From 6240d6467077a12c24878bab645d8e2983e4975a Mon Sep 17 00:00:00 2001 From: blueswir1 Date: Mon, 17 Dec 2007 18:21:57 +0000 Subject: Fix setting counter limit to 0 (Robert Reif) git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3834 c046a42c-6fe2-441c-8c8c-71466251a162 --- hw/slavio_timer.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/hw/slavio_timer.c b/hw/slavio_timer.c index 1018f70a9f..f98647f98f 100644 --- a/hw/slavio_timer.c +++ b/hw/slavio_timer.c @@ -175,7 +175,6 @@ static void slavio_timer_mem_writel(void *opaque, target_phys_addr_t addr, { SLAVIO_TIMERState *s = opaque; uint32_t saddr; - int reload = 0; DPRINTF("write " TARGET_FMT_plx " %08x\n", addr, val); saddr = (addr & TIMER_MAXADDR) >> 2; @@ -191,9 +190,10 @@ static void slavio_timer_mem_writel(void *opaque, target_phys_addr_t addr, // set limit, reset counter qemu_irq_lower(s->irq); s->limit = val & TIMER_MAX_COUNT32; - if (!s->limit) - s->limit = TIMER_MAX_COUNT32; - ptimer_set_limit(s->timer, s->limit >> 9, 1); + if (s->limit == 0) /* free-run */ + ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(TIMER_MAX_COUNT32), 1); + else + ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(s->limit), 1); } break; case TIMER_COUNTER: @@ -209,9 +209,10 @@ static void slavio_timer_mem_writel(void *opaque, target_phys_addr_t addr, case TIMER_COUNTER_NORST: // set limit without resetting counter s->limit = val & TIMER_MAX_COUNT32; - if (!s->limit) - s->limit = TIMER_MAX_COUNT32; - ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(s->limit), reload); + if (s->limit == 0) /* free-run */ + ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(TIMER_MAX_COUNT32), 0); + else + ptimer_set_limit(s->timer, LIMIT_TO_PERIODS(s->limit), 0); break; case TIMER_STATUS: if (slavio_timer_is_user(s)) { -- cgit v1.2.3