diff options
author | phk <phk@FreeBSD.org> | 2002-09-04 19:52:17 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2002-09-04 19:52:17 +0000 |
commit | 27e53f19b6cfd4ea1e6031886923a38c9baa0fb9 (patch) | |
tree | f9214c687900669867b74139b07e64eb539a87ee /sys | |
parent | e4b26c3c82341dd5ddf18a750f8eecaa4bab1b7b (diff) | |
download | FreeBSD-src-27e53f19b6cfd4ea1e6031886923a38c9baa0fb9.zip FreeBSD-src-27e53f19b6cfd4ea1e6031886923a38c9baa0fb9.tar.gz |
On the ElanSC520 CPU use general purpose timer#2 as timecounter.
This is a vast improvement over the i8254, since it is a simple
memory load rather than a comples sequence of interrupt blocking,
multiple input/output instructions, and wrap-around detection.
I have not bothered to time the fundamental timecounter get routine,
but gettimeofday(2) is 10% faster with the ELAN timecounte.
The downside is that HZ=100 is not enough, 150 or more recommended,
I use 250 myself.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/i386/i386/elan-mmcr.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/sys/i386/i386/elan-mmcr.c b/sys/i386/i386/elan-mmcr.c index eff46a5..809f17b 100644 --- a/sys/i386/i386/elan-mmcr.c +++ b/sys/i386/i386/elan-mmcr.c @@ -34,6 +34,21 @@ uint16_t *elan_mmcr; + +static unsigned +elan_get_timecount(struct timecounter *tc) +{ + return (elan_mmcr[0xc84 / 2]); +} + +static struct timecounter elan_timecounter = { + elan_get_timecount, + 0, + 0xffff, + 33333333 / 4, + "ELAN" +}; + void init_AMD_Elan_sc520(void) { @@ -57,6 +72,10 @@ init_AMD_Elan_sc520(void) &new, sizeof new, NULL); printf("sysctl machdep.i8254_freq=%d returns %d\n", new, i); + + /* Start GP timer #2 and use it as timecounter, hz permitting */ + elan_mmcr[0xc82 / 2] = 0xc001; + tc_init(&elan_timecounter); } |