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.
This commit is contained in:
Poul-Henning Kamp 2002-09-04 19:52:17 +00:00
parent bd8add3d61
commit c316aa2cec

View File

@ -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);
}