From 79de1b98fbeb6d568b655d0c901007ef9a77a365 Mon Sep 17 00:00:00 2001 From: Joshua Wise Date: Sun, 5 Oct 2008 01:29:21 -0400 Subject: [PATCH] Fix 'i r retard' bug in timer --- ich2/ich2-timer.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ich2/ich2-timer.c b/ich2/ich2-timer.c index b98e381..9934589 100644 --- a/ich2/ich2-timer.c +++ b/ich2/ich2-timer.c @@ -14,7 +14,7 @@ static uint16_t _get_PMBASE() static unsigned long _curtmr() { - return inl(_get_PMBASE + ICH2_PMBASE_PM1_TMR) & 0xFFFFFF; + return inl(_get_PMBASE() + ICH2_PMBASE_PM1_TMR) & 0xFFFFFF; } /* This is kind of a heuristic, since we can't get interrupts. */ @@ -23,16 +23,18 @@ static unsigned long starttmr = 0, endtmr = 0; void oneshot_start_ms(unsigned long milliseconds) { starttmr = _curtmr(); - endtmr = (starttmr + milliseconds*(ICH2_PM1_TMR_FREQ/1000)) % 0xFFFFFF; + endtmr = (starttmr + milliseconds*(ICH2_PM1_TMR_FREQ/1000)) & 0xFFFFFF; } int oneshot_running(void) { + unsigned long time = _curtmr(); + if (endtmr == 0 && starttmr == 0) return 0; - if ((endtmr < starttmr) && ((_curtmr() > starttmr) || (_curtmr() < endtmr))) + if ((endtmr < starttmr) && ((time > starttmr) || (time < endtmr))) return 1; - else if ((_curtmr() < endtmr) && (_curtmr() > starttmr)) + else if ((time < endtmr) && (time > starttmr)) return 1; endtmr = starttmr = 0; return 0; -- 2.43.0