From 7c2b0b76d719f83699161f77270c5b1c8fef0d53 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Tue, 1 Nov 1994 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1994-11-01 --- pc/clock.c | 83 +++++++++++++++++++++++++++--------------------------- pc/l.s | 8 ++++-- 2 files changed, 47 insertions(+), 44 deletions(-) diff --git a/pc/clock.c b/pc/clock.c index b90df8e2784a64e7f8c0718da22b0b8eed58f26f..190a852ac47ebe77f97872918dfff255b4752af5 100644 --- a/pc/clock.c +++ b/pc/clock.c @@ -127,8 +127,8 @@ delay(int l) void printcpufreq(void) { - print("CPU is a %ud Hz %d (CPUID: AX=0x%8.8lux, DX=0x%8.8lux)\n", - cpufreq, cputype, cpuidax, cpuiddx); + print("CPU is a %d MHz %s (cpuid: ax %lux dx %lux)\n", + cpumhz, cputype->name, cpuidax, cpuiddx); } int @@ -170,45 +170,46 @@ clockinit(void) outb(T0cntr, (Freq/HZ)>>8); /* high byte */ /* use biggest loop that works */ - for(loops = 10000; ; loops += 5000) { - /* - * measure time for the loop - * - * MOVL loops,CX - * aaml1: AAM - * LOOP aaml1 - * - * the time for the loop should be independent of external - * cache and memory system since it fits in the execution - * prefetch buffer. - * - */ - outb(Tmode, Latch0); - x = inb(T0cntr); - x |= inb(T0cntr)<<8; - aamloop(loops); - outb(Tmode, Latch0); - y = inb(T0cntr); - y |= inb(T0cntr)<<8; - x -= y; - - if(x < 0) - x += 2^16; - if(x > (2^15)) - break; - - /* - * counter goes at twice the frequency, once per transition, - * i.e., twice per square wave - */ - x >>= 1; - - /* - * figure out clock frequency and a loop multiplier for delay(). - */ - cpufreq = loops*((t->aalcycles*Freq)/x); - loopconst = (cpufreq/1000)/t->aalcycles; /* AAM+LOOP's for 1 ms */ - } while(x > 0); + if(t->family == 3) + loops = 10000; + else + loops = 30000; + + /* + * measure time for the loop + * + * MOVL loops,CX + * aaml1: AAM + * LOOP aaml1 + * + * the time for the loop should be independent of external + * cache and memory system since it fits in the execution + * prefetch buffer. + * + */ + outb(Tmode, Latch0); + x = inb(T0cntr); + x |= inb(T0cntr)<<8; + aamloop(loops); + outb(Tmode, Latch0); + y = inb(T0cntr); + y |= inb(T0cntr)<<8; + x -= y; + + if(x < 0) + x += 2^16; + + /* + * counter goes at twice the frequency, once per transition, + * i.e., twice per square wave + */ + x >>= 1; + + /* + * figure out clock frequency and a loop multiplier for delay(). + */ + cpufreq = loops*((t->aalcycles*Freq)/x); + loopconst = (cpufreq/1000)/t->aalcycles; /* AAM+LOOP's for 1 ms */ /* * add in possible .1% error and convert to MHz diff --git a/pc/l.s b/pc/l.s index 8fd75f7b7f690176dd1aabe141430bb44fd0d912..02a5d3068d14261faaf5ca90d1187dcd1c6a6994 100644 --- a/pc/l.s +++ b/pc/l.s @@ -600,10 +600,12 @@ is386: MOVL $(3<<8),AX MOVL $0,DX done: - MOVL AX, a+0(FP) - MOVL DX, d+4(FP) - POPL BX + MOVL a+0(FP),CX + MOVL AX,0(CX) + MOVL d+4(FP),CX + MOVL DX,0(CX) POPFL + POPL BX RET /*