| plan 9 kernel history: overview | file list | diff list |
1994/0716/pc/clock.c (diff list | history)
| 1994/0715/sys/src/9/pc/clock.c:27,48 – 1994/0716/sys/src/9/pc/clock.c:27,36 (short | long | prev | next) | ||
|
switch from delay to aamloop (XXX why?)
rsc Fri Mar 4 12:44:25 2005 | ||
| 1992/0923 | Freq= 1193182, /* Real clock frequency */ | |
| 1991/0705 | }; | |
| 1992/0923 |
| |
| 1994/0716 | static int cpufreq = 66; static int cputype = 486; static int loopconst = 100; | |
| 1992/0923 | ||
| 1991/0719 |
| |
| 1992/0923 |
| |
| 1991/0719 |
| |
| 1992/0923 |
| |
| 1991/0719 | ||
| 1992/0923 |
| |
| 1991/0719 |
| |
| 1993/1124 | static void clock(Ureg *ur, void *arg) { | |
| 1994/0715/sys/src/9/pc/clock.c:95,131 – 1994/0716/sys/src/9/pc/clock.c:83,103 | ||
| 1994/0512 | splhi(); | |
| 1993/1124 | } | |
| 1994/0716 | ||
| 1994/0302 | /* | |
| 1994/0610 |
| |
| 1994/0716 | * delay for l milliseconds more or less. delayloop is set by * clockinit() to match the actual CPU speed. | |
| 1994/0302 | */ | |
| 1994/0716 | void delay(int l) | |
| 1994/0302 | { | |
| 1994/0610 |
| |
| 1994/0302 |
| |
| 1994/0716 | aamloop(l*loopconst); } | |
| 1994/0302 | void printcpufreq(void) { | |
| 1994/0610 |
| |
| 1994/0302 |
| |
| 1994/0716 | print("CPU is a %ud Hz %d\n", cpufreq, cputype); | |
| 1994/0302 | } | |
| 1991/0704 | void | |
| 1994/0715/sys/src/9/pc/clock.c:132,137 – 1994/0716/sys/src/9/pc/clock.c:104,110 | ||
| 1991/0704 | clockinit(void) { | |
| 1992/0923 | ulong x, y; /* change in counter */ | |
| 1994/0716 | ulong cycles, loops; | |
| 1992/0922 | ||
| 1991/0709 | /* * set vector for clock interrupts | |
| 1994/0715/sys/src/9/pc/clock.c:146,157 – 1994/0716/sys/src/9/pc/clock.c:119,140 | ||
| 1991/0709 | outb(T0cntr, (Freq/HZ)>>8); /* high byte */ | |
| 1992/0922 | /* | |
| 1992/0923 |
| |
| 1994/0716 | * measure time for the loop * * MOVL loops,CX * aaml1: AAM * LOOP aaml1 * * the time for the loop should be independent from external * cache's and memory system since it fits in the execution * prefetch buffer. * | |
| 1992/0922 | */ | |
| 1994/0716 | loops = 10000; | |
| 1992/0922 | outb(Tmode, Latch0); | |
| 1992/0923 | x = inb(T0cntr); x |= inb(T0cntr)<<8; | |
| 1994/0716 | aamloop(loops); | |
| 1992/0923 | outb(Tmode, Latch0); y = inb(T0cntr); y |= inb(T0cntr)<<8; | |
| 1994/0715/sys/src/9/pc/clock.c:158,166 – 1994/0716/sys/src/9/pc/clock.c:141,165 | ||
| 1992/0923 | x -= y; /* | |
| 1993/0915 |
| |
| 1994/0716 | * counter goes at twice the frequency, once per transition, * i.e., twice per the square wave | |
| 1992/0923 | */ | |
| 1994/0716 | x >>= 1; /* * figure out clock frequency and a loop multiplier for delay(). */ switch(cputype = x86()){ case 386: cycles = 30; break; case 486: cycles = 24; break; default: cycles = 23; break; } cpufreq = (cycles*loops) * (Freq/x); loopconst = (cpufreq/1000)/cycles; /* AAM+LOOP's for 1 ms */ | |
| 1991/0808 | } | |