From 1dfe5a59f356506276df9ce446f1a2951407b6f5 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Tue, 9 Apr 2002 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 2002-04-09 --- boot/bootip.c | 2 ++ pc/devarch.c | 2 +- pc/i8253.c | 57 +++++++++++++++++++++++++------------------------- pc/mp.c | 2 -- pc/vganvidia.c | 1 + port/devenv.c | 4 +++- 6 files changed, 35 insertions(+), 33 deletions(-) diff --git a/boot/bootip.c b/boot/bootip.c index 867de5344e55b8822e629ce1a32cafc4b8878a9f..c330f8666a13577401a7ddec925175b21cae4b4d 100644 --- a/boot/bootip.c +++ b/boot/bootip.c @@ -52,6 +52,8 @@ configip(void) bind("#I", mpoint, MAFTER); bind("#l0", mpoint, MAFTER); bind("#l1", mpoint, MAFTER); + bind("#l2", mpoint, MAFTER); + bind("#l3", mpoint, MAFTER); /* let ipconfig configure the ip interface */ switch(pid = fork()){ diff --git a/pc/devarch.c b/pc/devarch.c index e4ee7a0fbb7f758b85634d28aa84c4d78b4411cf..f652e5293c4fa1b2391f0c30844dabfba61891e4 100644 --- a/pc/devarch.c +++ b/pc/devarch.c @@ -734,7 +734,7 @@ archinit(void) if(X86FAMILY(m->cpuidax) == 3 || conf.nmach > 1) conf.copymode = 1; - if(X86FAMILY(m->cpuidax) >= 5) + if(X86FAMILY(m->cpuidax) >= 5 && conf.nmach > 1) coherence = wbflush; addarchfile("cputype", 0444, cputyperead, nil); diff --git a/pc/i8253.c b/pc/i8253.c index 3d88279b4cf9319dea4bac08d399da325da8b954..bb40090d7e238a81668fb67cc0c6f636fbc6797d 100644 --- a/pc/i8253.c +++ b/pc/i8253.c @@ -51,7 +51,13 @@ enum C2speak=0x2, C2out= 0x10, + /* T2ctl bits */ + T2gate= (1<<0), /* enable T2 counting */ + T2spkr= (1<<1), /* connect T2 out to speaker */ + T2out= (1<<5), /* output of T2 */ + Freq= 1193182, /* Real clock frequency */ + Tickshift= 8, /* increase tick wriggle room */ Minusec=20, /* minimum cycles for a clock interrupt */ @@ -68,9 +74,8 @@ static struct long fastperiod; /* fastticks/hz */ long fast2freq; /* fastticks*FreqMul/Freq */ - Lock lock1; /* mutex for the following */ - ushort last1; /* last value of clock 1 */ - uvlong ticks1; /* cumulative ticks of counter 1 */ + ushort last; /* last value of clock 1 */ + uvlong ticks; /* cumulative ticks of counter 1 */ }i8253; void @@ -90,12 +95,14 @@ i8253init(void) outb(T0cntr, (Freq/HZ)>>8); /* high byte */ /* - * set time clock + * enable a longer period counter to use as a clock */ - outb(Tmode, Load1|Square); - i8253.mode = Square; - outb(T1cntr, 0xfe); /* low byte */ - outb(T1cntr, 0xff); /* high byte */ + outb(Tmode, Load2|Square); + outb(T2cntr, 0); /* low byte */ + outb(T2cntr, 0); /* high byte */ + x = inb(T2ctl); + x |= T2gate; + outb(T2ctl, x); /* * Introduce a little delay to make sure the count is @@ -241,8 +248,6 @@ clockintrsched(void) iunlock(&i8253); } -ulong i8253ding[2]; - static void clockintr0(Ureg* ureg, void *v) { @@ -255,12 +260,6 @@ clockintr0(Ureg* ureg, void *v) now = fastticks(nil); when = i8253.when; -if(i8253.last1 == 0 || i8253.last1 >= 0xffe0) - i8253ding[1]++; -else - i8253ding[0]++; - - if(now >= i8253.when){ clockintr(ureg, v); do @@ -295,23 +294,23 @@ i8253read(uvlong *hz) uvlong ticks; if(hz) - *hz = Freq<<8; + *hz = Freq<>1; - ticks = i8253.ticks1; - iunlock(&i8253.lock1); + x = i8253.last + (0x1000 - y); + i8253.last = y; + i8253.ticks += x>>1; + ticks = i8253.ticks; + iunlock(&i8253); - return ticks<<8; + return ticks<type = PcmpPROCESSOR; diff --git a/pc/vganvidia.c b/pc/vganvidia.c index 95c567c57493d7c190afde381999f41cbf638c5c..f99450e6cacee5a6d921755b3f386efff607d4b3 100644 --- a/pc/vganvidia.c +++ b/pc/vganvidia.c @@ -42,6 +42,7 @@ static ushort nvidiadid[] = { 0x0151, /* GeForce2 GTS (rev 1) */ 0x0152, /* GeForce2 Ultra */ 0x0153, /* Quadro 2 Pro */ + 0x0200, /* GeForce3 */ 0, }; diff --git a/port/devenv.c b/port/devenv.c index a3705aa8120ba0152d430e3540ffb12adc3c894c..bf6678038285fc612e7c7f6e7889d65cb888f871 100644 --- a/port/devenv.c +++ b/port/devenv.c @@ -232,7 +232,9 @@ envread(Chan *c, void *a, long n, vlong off) error(Enonexist); } - if(offset + n > e->len) + if(offset > e->len) /* protects against overflow converting vlong to ulong */ + n = 0; + else if(offset + n > e->len) n = e->len - offset; if(n <= 0) n = 0;