]> Joshua Wise's Git repositories - netwatch.git/blobdiff - ich2/ich2-timer.c
Add a todo list entry.
[netwatch.git] / ich2 / ich2-timer.c
index b98e3817dd686f02bd2b3d8cb3ae998bbd6c688c..b8f7e1cce79e10bbf0f871c2e24312b03ce15536 100644 (file)
@@ -1,3 +1,13 @@
+/* ich2-timer.c
+ * High precision timer routines for ICH2 southbridge
+ * NetWatch system management mode administration console
+ *
+ * Copyright (c) 2008 Jacob Potter and Joshua Wise.  All rights reserved.
+ * This program is free software; you can redistribute and/or modify it under
+ * the terms found in the file LICENSE in the root of this source tree. 
+ *
+ */
+
 #include <pci.h>
 #include <io.h>
 #include <reg-82801b.h>
@@ -14,7 +24,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 +33,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;
This page took 0.02438 seconds and 4 git commands to generate.