#!/bin/rc # # command: /bin/boddle /n/juke/plan_9/sys/src/fs/pc /tmp/fs # srcdir: /n/juke/plan_9/sys/src/fs/pc # version: 813525539 # date: Thu Oct 12 15:18:59 EDT 1995 # myname=$0 doextract=no fn usage{ echo $myname: usage: $myname '[-X] [src-directory]' >[1=2] exit usage } fn sigint{ rm -rf 813525539 exit interrupt } while(~ $1 -*){ switch($1){ case -X doextract=yes case -* usage } shift } switch($#*){ case 0 srcdir=/sys/src/fs/pc case 1 srcdir=$1 case * usage } if(! ~ $doextract yes){ echo This shell file contains a bundle of diffs representing changes echo to original source files in the Plan 9 distribution. It will run echo against the files in echo ' ' $srcdir echo '(unless overridden by the optional source directory argument)' echo and create a directory 813525539 containing the updated files. echo It will NOT automatically update the original files. echo echo Invoke with argument -X to perform the actual extraction. exit 0 } rm -rf 813525539 mkdir 813525539 target=813525539/8253.c echo -n '813525539/8253.c: ' if(! test -f $srcdir/8253.c || ! test -r $srcdir/8253.c){ echo $srcdir/8253.c unreadable exit unreadable } sum=`{sum < $srcdir/8253.c} if(! ~ db5037461800 $sum(1)^$sum(2)){ echo $srcdir/8253.c is not the original distribution file exit original } cp $srcdir/8253.c 813525539/8253.c ed 813525539/8253.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM 8253.c' 86,113c /* * add in possible .2% error and convert to MHz */ cpumhz = (cpufreq + cpufreq/500)/1000000; . 81,84c cpufreq = loops*((t->aalcycles*Freq)/x); loopconst = (cpufreq/1000)/t->aalcycles; /* AAM+LOOP's for 1 ms */ . 79c * figure out clock frequency and a loop multiplier for delay(). . 69,76c x >>= 1; . 67c * counter goes at twice the frequency, once per transition, * i.e., twice per square wave . 65a /* find biggest loop that doesn't wrap */ incr = 16000000/(t->aalcycles*HZ*2); x = 2000; for(loops = incr; loops < 64*1024; loops += incr) { /* * 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 += Freq/HZ; if(x > Freq/(3*HZ)) break; } . 61a x86cpuid(&cpuidax, &cpuiddx); family = FAMILY(cpuidax); model = MODEL(cpuidax); for(t = x86type; t->name; t++) if((t->family == family && t->model == model) || (t->family == family && t->model == -1) || (t->family == -1)) break; cputype = t; /* * set clock for 1/HZ seconds */ . 60c * figure out what we are . 52c int x, y; /* change in counter */ int family, model, loops, incr; X86type *t; . 45,46c print("CPU is a %d MHz %s (cpuid: ax %lux dx %lux)\n", cpumhz, cputype->name, cpuidax, cpuiddx); . 42,43c void printcpufreq(void) . 37,39c /* * microsecond delay */ void microdelay(int l) { l *= loopconst; l /= 1000; if(l <= 0) l = 1; aamloop(l); . 35c l *= loopconst; if(l <= 0) l = 1; aamloop(l); } . 27a static void clockintr(Ureg *ur, void *v) { USED(v); clock(0, ur->pc); } #define STEPPING(x) ((x)&0xf) #define MODEL(x) (((x)>>4)&0xf) #define FAMILY(x) (((x)>>8)&0xf) enum { /* flags */ CpuidFPU = 0x001, /* on-chip floating point unit */ CpuidMCE = 0x080, /* machine check exception */ CpuidCX8 = 0x100, /* CMPXCHG8B instruction */ }; typedef struct { int family; int model; int aalcycles; char *name; } X86type; X86type x86type[] = { /* from the cpuid instruction */ { 4, 0, 22, "Intel486DX", }, { 4, 1, 22, "Intel486DX", }, { 4, 2, 22, "Intel486SX", }, { 4, 3, 22, "Intel486DX2", }, { 4, 4, 22, "Intel486DX2", }, { 4, 5, 22, "Intel486SL", }, { 4, 8, 22, "IntelDX4", }, { 5, 1, 23, "Pentium510", }, { 5, 2, 23, "Pentium735", }, /* family defaults */ { 3, -1, 32, "Intel386", }, { 4, -1, 22, "Intel486", }, { 5, -1, 23, "Pentium", }, /* total default */ { -1, -1, 23, "unknown", }, }; static X86type *cputype; . 26c static int cpufreq = 66000000; static int cpumhz = 66; static int loopconst = 100; static int cpuidax, cpuiddx; . 21a Trigger= 0x30, /* interrupt on terminal count */ . wq //GO.SYSIN DD VADIM 8253.c sum=`{sum < 813525539/8253.c} if(~ 61820e873701 $sum(1)^$sum(2)) echo if not{ echo 813525539/8253.c checksum error creating updated file exit checksum } target=813525539/9pcfs.c echo -n '813525539/9pcfs.c: ' if(! test -f $srcdir/9pcfs.c || ! test -r $srcdir/9pcfs.c){ echo $srcdir/9pcfs.c unreadable exit unreadable } sum=`{sum < $srcdir/9pcfs.c} if(! ~ 684354542476 $sum(1)^$sum(2)){ echo $srcdir/9pcfs.c is not the original distribution file exit original } cp $srcdir/9pcfs.c 813525539/9pcfs.c ed 813525539/9pcfs.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM 9pcfs.c' 38a printcpufreq(); . wq //GO.SYSIN DD VADIM 9pcfs.c sum=`{sum < 813525539/9pcfs.c} if(~ 9df269282493 $sum(1)^$sum(2)) echo if not{ echo 813525539/9pcfs.c checksum error creating updated file exit checksum } target=813525539/fns.h echo -n '813525539/fns.h: ' if(! test -f $srcdir/fns.h || ! test -r $srcdir/fns.h){ echo $srcdir/fns.h unreadable exit unreadable } sum=`{sum < $srcdir/fns.h} if(! ~ c6a11d731559 $sum(1)^$sum(2)){ echo $srcdir/fns.h is not the original distribution file exit original } cp $srcdir/fns.h 813525539/fns.h ed 813525539/fns.h >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM fns.h' 61,62c int x86cpuid(int*, int*); . 44a void printcpureg(void); . 4a void aamloop(int); . wq //GO.SYSIN DD VADIM fns.h sum=`{sum < 813525539/fns.h} if(~ 55825eaf1612 $sum(1)^$sum(2)) echo if not{ echo 813525539/fns.h checksum error creating updated file exit checksum } target=813525539/l.s echo -n '813525539/l.s: ' if(! test -f $srcdir/l.s || ! test -r $srcdir/l.s){ echo $srcdir/l.s unreadable exit unreadable } sum=`{sum < $srcdir/l.s} if(! ~ 18f1beb39742 $sum(1)^$sum(2)){ echo $srcdir/l.s is not the original distribution file exit original } cp $srcdir/l.s 813525539/l.s ed 813525539/l.s >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM l.s' 671a RET TEXT famd+0(SB), $4 PUSHFL CLI /* spl hi */ FMOVL b+4(FP), F0 FADDF a+0(FP), F0 FMOVL c+8(FP), F0 FMULDP F0, F1 FMOVL d+12(FP), F0 FDIVDP F0, F1 FMOVFP F0, .safe-4(SP) MOVL .safe-4(SP), AX POPFL /* splx */ RET TEXT fdf+0(SB), $4 PUSHFL CLI /* spl hi */ FMOVL b+4(FP), F0 FDIVRF a+0(FP), F0 FMOVLP F0, .safe-4(SP) MOVL .safe-4(SP), AX POPFL /* splx */ . 586a MOVL c+0(FP),CX aaml1: AAM LOOP aaml1 RET . 585a /* * basic timing loop to determine CPU frequency */ TEXT aamloop(SB),$0 . 583a POPL BX . 582c MOVL a+0(FP),CX MOVL AX,0(CX) MOVL d+4(FP),CX MOVL DX,0(CX) . 580c MOVL $(3<<8),AX MOVL $0,DX . 577c MOVL $(4<<8),AX MOVL $0,DX . 574c MOVL $1,AX /* CPUID */ BYTE $0x0F BYTE $0xA2 . 572c ANDL $0x200000,AX /* if we can't change this, there's no CPUID */ . 559c TEXT x86cpuid(SB),$0 . wq //GO.SYSIN DD VADIM l.s sum=`{sum < 813525539/l.s} if(~ 8a18317710398 $sum(1)^$sum(2)) echo if not{ echo 813525539/l.s checksum error creating updated file exit checksum } target=813525539/pc.c echo -n '813525539/pc.c: ' if(! test -f $srcdir/pc.c || ! test -r $srcdir/pc.c){ echo $srcdir/pc.c unreadable exit unreadable } sum=`{sum < $srcdir/pc.c} if(! ~ 1ff381bc6001 $sum(1)^$sum(2)){ echo $srcdir/pc.c is not the original distribution file exit original } cp $srcdir/pc.c 813525539/pc.c ed 813525539/pc.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM pc.c' 346a */ . 335a /* in assembly language . wq //GO.SYSIN DD VADIM pc.c sum=`{sum < 813525539/pc.c} if(~ dbeaed426028 $sum(1)^$sum(2)) echo if not{ echo 813525539/pc.c checksum error creating updated file exit checksum }