]> Joshua Wise's Git repositories - netwatch.git/blame_incremental - ich2/ich2-timer.c
Manage to get a nice big packet queue going inside lwIP.
[netwatch.git] / ich2 / ich2-timer.c
... / ...
CommitLineData
1#include <pci.h>
2#include <io.h>
3#include <reg-82801b.h>
4
5static uint16_t _get_PMBASE()
6{
7 static long pmbase = -1;
8
9 if (pmbase == -1) /* Memoize it so that we don't have to hit PCI so often. */
10 pmbase = pci_read32(ICH2_LPC_BUS, ICH2_LPC_DEV, ICH2_LPC_FN, ICH2_LPC_PCI_PMBASE) & ICH2_PMBASE_MASK;
11
12 return pmbase;
13}
14
15static unsigned long _curtmr()
16{
17 return inl(_get_PMBASE() + ICH2_PMBASE_PM1_TMR) & 0xFFFFFF;
18}
19
20/* This is kind of a heuristic, since we can't get interrupts. */
21static unsigned long starttmr = 0, endtmr = 0;
22
23void oneshot_start_ms(unsigned long milliseconds)
24{
25 starttmr = _curtmr();
26 endtmr = (starttmr + milliseconds*(ICH2_PM1_TMR_FREQ/1000)) & 0xFFFFFF;
27}
28
29int oneshot_running(void)
30{
31 unsigned long time = _curtmr();
32
33 if (endtmr == 0 && starttmr == 0)
34 return 0;
35 if ((endtmr < starttmr) && ((time > starttmr) || (time < endtmr)))
36 return 1;
37 else if ((time < endtmr) && (time > starttmr))
38 return 1;
39 endtmr = starttmr = 0;
40 return 0;
41}
This page took 0.020766 seconds and 4 git commands to generate.