Browse Source

Plan 9 from Bell Labs 2003-11-07

David du Colombier 20 years ago
parent
commit
0a4d5a9712

+ 23 - 20
dist/replica/plan9.db

@@ -5,7 +5,7 @@
 29000/lib - 20000000775 sys sys 948037563 0
 29000/mkfile - 664 sys sys 948141302 46
 386 - 20000000775 sys sys 1010957353 0
-386/9load - 775 sys sys 1066618054 181248
+386/9load - 775 sys sys 1068156766 181788
 386/9loaddebug - 775 sys sys 1064598409 260250
 386/9loadlite - 775 sys sys 1066618055 124684
 386/9loadlitedebug - 775 sys sys 1064598410 183708
@@ -229,9 +229,9 @@
 386/bin/fortune - 775 sys sys 1064598140 66084
 386/bin/fossil - 20000000775 sys sys 1042005470 0
 386/bin/fossil/conf - 775 sys sys 1056364255 1497
-386/bin/fossil/flchk - 775 sys sys 1064598141 232263
-386/bin/fossil/flfmt - 775 sys sys 1064598142 230228
-386/bin/fossil/fossil - 775 sys sys 1066848944 345758
+386/bin/fossil/flchk - 775 sys sys 1068129393 232619
+386/bin/fossil/flfmt - 775 sys sys 1068129394 230584
+386/bin/fossil/fossil - 775 sys sys 1068129395 345623
 386/bin/freq - 775 sys sys 1064598145 60197
 386/bin/fs - 20000000775 sys sys 954380769 0
 386/bin/fs/32vfs - 775 sys sys 1064598146 95907
@@ -532,7 +532,7 @@
 386/lib/libplumb.a - 664 sys sys 1045538125 19000
 386/lib/libregexp.a - 664 sys sys 1064598468 37616
 386/lib/libscribble.a - 664 sys sys 1056364454 108138
-386/lib/libsec.a - 664 sys sys 1064598471 644080
+386/lib/libsec.a - 664 sys sys 1068129726 647418
 386/lib/libstdio.a - 664 sys sys 1056364455 128500
 386/lib/libsunrpc.a - 664 sys sys 1050868863 357292
 386/lib/libthread.a - 664 sys sys 1065139515 71512
@@ -2949,6 +2949,7 @@ rc/bin/B - 775 sys sys 945617206 645
 rc/bin/C - 775 sys sys 1045493437 788
 rc/bin/Kill - 775 sys sys 1018637942 115
 rc/bin/a: - 775 sys sys 1063856406 255
+rc/bin/ap - 775 sys sys 1068124620 651
 rc/bin/ape - 20000000775 sys sys 954039414 0
 rc/bin/ape/ar89 - 775 sys sys 945617285 308
 rc/bin/ape/c89 - 775 sys sys 945617285 39
@@ -3380,7 +3381,7 @@ sys/include/httpd.h - 664 sys sys 1014929064 5726
 sys/include/ip.h - 664 sys sys 1050702405 2908
 sys/include/keyboard.h - 664 sys sys 1014929064 799
 sys/include/libc.h - 664 sys sys 1067718922 19305
-sys/include/libsec.h - 664 sys sys 1063853592 8965
+sys/include/libsec.h - 664 sys sys 1068129557 8966
 sys/include/mach.h - 664 sys sys 1032058231 8101
 sys/include/memdraw.h - 664 sys sys 1039752978 5616
 sys/include/memlayer.h - 664 sys sys 1051031022 1851
@@ -4530,6 +4531,7 @@ sys/man/1/INDEX - 664 sys sys 1045538129 2900
 sys/man/1/INDEX.html - 664 sys sys 1026845791 15882
 sys/man/1/acid - 664 sys sys 1046201556 9731
 sys/man/1/acme - 664 sys sys 1019828741 17587
+sys/man/1/ap - 664 sys sys 1068124617 364
 sys/man/1/ar - 664 sys sys 1055701045 3149
 sys/man/1/ascii - 664 sys sys 957920005 2733
 sys/man/1/awk - 664 sys sys 944959677 10645
@@ -4654,6 +4656,7 @@ sys/man/1/tcs - 664 sys sys 952627441 2575
 sys/man/1/tee - 664 sys sys 969499886 351
 sys/man/1/tel - 664 sys sys 1045501423 941
 sys/man/1/test - 664 sys sys 1015024741 2871
+sys/man/1/thesaurus - 664 sys sys 1068121775 222
 sys/man/1/time - 664 sys sys 944959673 380
 sys/man/1/touch - 664 sys sys 1018369246 461
 sys/man/1/tr - 664 sys sys 944959675 1730
@@ -5317,7 +5320,7 @@ sys/src/9/pc/vgamga4xx.c - 664 sys sys 1015014527 11122
 sys/src/9/pc/vganeomagic.c - 664 sys sys 1032375144 10693
 sys/src/9/pc/vganvidia.c - 664 sys sys 1060269772 6545
 sys/src/9/pc/vgargb524.c - 664 sys sys 1015014527 4235
-sys/src/9/pc/vgas3.c - 664 sys sys 1064679984 12160
+sys/src/9/pc/vgas3.c - 664 sys sys 1068129423 12143
 sys/src/9/pc/vgasavage.c - 664 sys sys 1064679984 16251
 sys/src/9/pc/vgat2r4.c - 664 sys sys 1015014528 10355
 sys/src/9/pc/vgatvp3020.c - 664 sys sys 1015014528 4491
@@ -5363,7 +5366,7 @@ sys/src/9/port/devssl.c - 664 sys sys 1045063590 26100
 sys/src/9/port/devtinyfs.c - 664 sys sys 1015278339 15347
 sys/src/9/port/devtls.c - 664 sys sys 1066737478 45222
 sys/src/9/port/devuart.c - 664 sys sys 1067722718 11683
-sys/src/9/port/edf.c - 664 sys sys 1067722765 11931
+sys/src/9/port/edf.c - 664 sys sys 1068135508 12286
 sys/src/9/port/edf.h - 664 sys sys 1067722760 1124
 sys/src/9/port/error.h - 664 sys sys 1055700517 2630
 sys/src/9/port/fault.c - 664 sys sys 1067722722 6628
@@ -5390,12 +5393,12 @@ sys/src/9/port/nulledf.c - 664 sys sys 1037669300 821
 sys/src/9/port/page.c - 664 sys sys 1055688510 8107
 sys/src/9/port/parse.c - 664 sys sys 1014931177 2026
 sys/src/9/port/pgrp.c - 664 sys sys 1067722718 3944
-sys/src/9/port/portclock.c - 664 sys sys 1067722761 4271
+sys/src/9/port/portclock.c - 664 sys sys 1068135508 4305
 sys/src/9/port/portdat.h - 664 sys sys 1067722763 22621
 sys/src/9/port/portfns.h - 664 sys sys 1067722759 11369
 sys/src/9/port/portmkfile - 664 sys sys 1067722766 2098
 sys/src/9/port/print.c - 664 sys sys 1014931178 227
-sys/src/9/port/proc.c - 664 sys sys 1067722762 24755
+sys/src/9/port/proc.c - 664 sys sys 1068135509 24818
 sys/src/9/port/qio.c - 664 sys sys 1067953182 23406
 sys/src/9/port/qlock.c - 664 sys sys 1067722765 3196
 sys/src/9/port/rdb.c - 664 sys sys 1018721202 1698
@@ -5417,14 +5420,14 @@ sys/src/9/ppc - 20000000775 sys sys 1059490838 0
 sys/src/9/ppc/blast - 664 sys sys 1067722850 659
 sys/src/9/ppc/blast.c - 664 sys sys 1059490750 1422
 sys/src/9/ppc/blast.h - 664 sys sys 1059490750 3109
-sys/src/9/ppc/clock.c - 664 sys sys 1059490750 1066
+sys/src/9/ppc/clock.c - 664 sys sys 1068135488 1032
 sys/src/9/ppc/dat.h - 664 sys sys 1067723142 4676
 sys/src/9/ppc/devether.c - 664 sys sys 1059490750 9264
 sys/src/9/ppc/devflash.c - 664 sys sys 1059490750 19885
 sys/src/9/ppc/devirq.c - 664 sys sys 1067722849 6057
 sys/src/9/ppc/devtls.c - 664 sys sys 1059490751 43721
 sys/src/9/ppc/errstr.h - 664 sys sys 1059490751 2137
-sys/src/9/ppc/etherfcc.c - 664 sys sys 1059490751 14295
+sys/src/9/ppc/etherfcc.c - 664 sys sys 1068135488 14307
 sys/src/9/ppc/etherif.h - 664 sys sys 1059490751 785
 sys/src/9/ppc/ethersaturn.c - 664 sys sys 1059490751 4321
 sys/src/9/ppc/fns.h - 664 sys sys 1067722798 4211
@@ -5435,7 +5438,7 @@ sys/src/9/ppc/l.s - 664 sys sys 1067722848 21035
 sys/src/9/ppc/lblast.h - 664 sys sys 1059490752 1694
 sys/src/9/ppc/lucu.h - 664 sys sys 1059490752 935
 sys/src/9/ppc/m8260.c - 664 sys sys 1059490752 14264
-sys/src/9/ppc/m8260.h - 664 sys sys 1059490752 20892
+sys/src/9/ppc/m8260.h - 664 sys sys 1068135488 20913
 sys/src/9/ppc/main.c - 664 sys sys 1059490752 9203
 sys/src/9/ppc/mcc.c - 664 sys sys 1059490752 9667
 sys/src/9/ppc/mem.h - 664 sys sys 1059490752 7015
@@ -5448,7 +5451,7 @@ sys/src/9/ppc/random.c - 664 sys sys 1059490753 1983
 sys/src/9/ppc/saturntimer.c - 664 sys sys 1059490753 1734
 sys/src/9/ppc/trap.c - 664 sys sys 1059490753 17248
 sys/src/9/ppc/uartsaturn.c - 664 sys sys 1059490754 7151
-sys/src/9/ppc/uartsmc.c - 664 sys sys 1059490754 11713
+sys/src/9/ppc/uartsmc.c - 664 sys sys 1068135489 11462
 sys/src/9/ppc/ucu - 664 sys sys 1067722849 672
 sys/src/9/ppc/ucu.h - 664 sys sys 1059490754 531
 sys/src/NOTICE - 444 sys sys 1018803112 63
@@ -6281,7 +6284,7 @@ sys/src/boot/pc/bootp.c - 664 sys sys 1015007948 9417
 sys/src/boot/pc/cga.c - 664 sys sys 1015007948 1362
 sys/src/boot/pc/clock.c - 664 sys sys 1015007948 5648
 sys/src/boot/pc/conf.c - 664 sys sys 1063855536 10128
-sys/src/boot/pc/console.c - 664 sys sys 1063855537 3459
+sys/src/boot/pc/console.c - 664 sys sys 1068158999 3487
 sys/src/boot/pc/dat.h - 664 sys sys 1056073257 3432
 sys/src/boot/pc/devfloppy.c - 664 sys sys 1032215913 15505
 sys/src/boot/pc/devfloppy.h - 664 sys sys 1032409559 4081
@@ -6339,7 +6342,7 @@ sys/src/boot/pc/queue.c - 664 sys sys 1015007954 566
 sys/src/boot/pc/sd.h - 664 sys sys 1032215925 2404
 sys/src/boot/pc/sd53c8xx.c - 664 sys sys 1015007954 52004
 sys/src/boot/pc/sd53c8xx.i - 664 sys sys 1015007955 27245
-sys/src/boot/pc/sdata.c - 664 sys sys 1045504828 33498
+sys/src/boot/pc/sdata.c - 664 sys sys 1068156754 35084
 sys/src/boot/pc/sdmylex.c - 664 sys sys 1015007955 28743
 sys/src/boot/pc/sdscsi.c - 664 sys sys 1018553454 6680
 sys/src/boot/pc/trap.c - 664 sys sys 1018462833 7098
@@ -6649,7 +6652,7 @@ sys/src/cmd/acme/fsys.c - 664 sys sys 1022512648 12727
 sys/src/cmd/acme/look.c - 664 sys sys 1041137125 14840
 sys/src/cmd/acme/mkfile - 664 sys sys 1058463682 543
 sys/src/cmd/acme/regx.c - 664 sys sys 1014926094 16057
-sys/src/cmd/acme/rows.c - 664 sys sys 1016833877 14726
+sys/src/cmd/acme/rows.c - 664 sys sys 1068140772 14637
 sys/src/cmd/acme/scrl.c - 664 sys sys 1014926095 3072
 sys/src/cmd/acme/text.c - 664 sys sys 1045504840 24133
 sys/src/cmd/acme/time.c - 664 sys sys 1014926095 1783
@@ -6720,7 +6723,7 @@ sys/src/cmd/auth/factotum/p9sk1.c - 664 sys sys 1048614974 9606
 sys/src/cmd/auth/factotum/pass.c - 664 sys sys 1048614974 1511
 sys/src/cmd/auth/factotum/rpc.c - 664 sys sys 1044829590 11147
 sys/src/cmd/auth/factotum/rsa.c - 664 sys sys 1048614986 3462
-sys/src/cmd/auth/factotum/secstore.c - 664 sys sys 1048614989 14894
+sys/src/cmd/auth/factotum/secstore.c - 664 sys sys 1068129501 14932
 sys/src/cmd/auth/factotum/sshrsa.c - 664 sys sys 1048614985 3396
 sys/src/cmd/auth/factotum/util.c - 664 sys sys 1048614988 17031
 sys/src/cmd/auth/factotum/wep.c - 664 sys sys 1048614986 2205
@@ -7293,7 +7296,7 @@ sys/src/cmd/file.c - 664 sys sys 1065017417 20590
 sys/src/cmd/fmt.c - 664 sys sys 1025298248 3897
 sys/src/cmd/fortune.c - 664 sys sys 1035832953 1674
 sys/src/cmd/fossil - 20000000775 sys sys 1042005512 0
-sys/src/cmd/fossil/9.h - 664 sys sys 1066098099 4163
+sys/src/cmd/fossil/9.h - 664 sys sys 1068129294 4165
 sys/src/cmd/fossil/9auth.c - 664 sys sys 1061530721 3393
 sys/src/cmd/fossil/9dir.c - 664 sys sys 1042005502 1995
 sys/src/cmd/fossil/9excl.c - 664 sys sys 1042005502 1887
@@ -7302,7 +7305,7 @@ sys/src/cmd/fossil/9fsys.c - 664 sys sys 1061530721 29881
 sys/src/cmd/fossil/9lstn.c - 664 sys sys 1042005503 2865
 sys/src/cmd/fossil/9p.c - 664 sys sys 1066098096 21486
 sys/src/cmd/fossil/9ping.c - 664 sys sys 1042005503 1563
-sys/src/cmd/fossil/9proc.c - 664 sys sys 1063855223 15345
+sys/src/cmd/fossil/9proc.c - 664 sys sys 1068129294 15100
 sys/src/cmd/fossil/9srv.c - 664 sys sys 1066098097 3682
 sys/src/cmd/fossil/9user.c - 664 sys sys 1066098098 17239
 sys/src/cmd/fossil/Ccli.c - 664 sys sys 1042005504 1624

+ 23 - 0
dist/replica/plan9.log

@@ -14166,3 +14166,26 @@
 1068053491 1 c rc/bin/iwhois - 775 sys sys 1068053163 584
 1068055291 0 a rc/bin/thesaurus - 775 sys sys 1068054167 246
 1068087698 0 c rc/bin/fshalt - 775 sys sys 1068087338 1092
+1068121917 0 a sys/man/1/thesaurus - 664 sys sys 1068121775 222
+1068125518 0 a rc/bin/ap - 775 sys sys 1068124620 651
+1068125518 1 a sys/man/1/ap - 664 sys sys 1068124617 364
+1068130919 0 c 386/bin/fossil/flchk - 775 sys sys 1068129393 232619
+1068130919 1 c 386/bin/fossil/flfmt - 775 sys sys 1068129394 230584
+1068130919 2 c 386/bin/fossil/fossil - 775 sys sys 1068129395 345623
+1068130919 3 c 386/lib/libsec.a - 664 sys sys 1068129726 647418
+1068130919 4 c sys/include/libsec.h - 664 sys sys 1068129557 8966
+1068130919 5 c sys/src/9/pc/vgas3.c - 664 sys sys 1068129423 12143
+1068130919 6 c sys/src/cmd/auth/factotum/secstore.c - 664 sys sys 1068129501 14932
+1068130919 7 c sys/src/cmd/fossil/9.h - 664 sys sys 1068129294 4165
+1068130919 8 c sys/src/cmd/fossil/9proc.c - 664 sys sys 1068129294 15100
+1068136320 0 c sys/src/9/port/edf.c - 664 sys sys 1068135508 12286
+1068136320 1 c sys/src/9/port/portclock.c - 664 sys sys 1068135508 4305
+1068136320 2 c sys/src/9/port/proc.c - 664 sys sys 1068135509 24818
+1068136320 3 c sys/src/9/ppc/clock.c - 664 sys sys 1068135488 1032
+1068136320 4 c sys/src/9/ppc/etherfcc.c - 664 sys sys 1068135488 14307
+1068136320 5 c sys/src/9/ppc/m8260.h - 664 sys sys 1068135488 20913
+1068136320 6 c sys/src/9/ppc/uartsmc.c - 664 sys sys 1068135489 11462
+1068141721 0 c sys/src/cmd/acme/rows.c - 664 sys sys 1068140772 14637
+1068157925 0 c 386/9load - 775 sys sys 1068156766 181788
+1068157925 1 c sys/src/boot/pc/sdata.c - 664 sys sys 1068156754 35084
+1068159726 0 c sys/src/boot/pc/console.c - 664 sys sys 1068158999 3487

+ 37 - 0
rc/bin/ap

@@ -0,0 +1,37 @@
+#!/bin/rc
+#
+#	get AP news headline list or the given story
+#
+
+tmp=/tmp/tmp.$pid
+wire='http://www.newsday.com/news/nationworld/wire'
+if ( ~ $#* 0 )
+	hget $wire |
+		htmlfmt -a -w 100 |
+		sed -n '
+			/AP News Wire/,$d
+			/reddot\.gif/ {
+				N
+				s/\n/ /g
+				s/\[image [^\]]*] *//
+				s/\[\/news\/nationworld\/wire\//|/
+				s/,[0-9]+,[0-9]+\.story.*$//
+				p
+		}' |
+		awk -F '|' '{
+			s = "";
+			for (i = 2; i <= NF; i++)
+				s = s " " $i;
+			printf("%-40s %s\n", s, $1);
+		}'
+
+if not 
+	hget $wire/^$1^.story |
+		htmlfmt |
+		sed '
+			1,/^AP News Alert/d
+			s/.*(Copyright .* The Associated Press).*$/\1/p
+			/Copyright .* The Associated Press/,$d
+		'
+
+

+ 1 - 1
sys/include/libsec.h

@@ -133,7 +133,7 @@ enum
 typedef struct DigestState DigestState;
 struct DigestState
 {
-	ulong len;
+	uvlong len;
 	u32int state[5];
 	uchar buf[128];
 	int blen;

+ 16 - 0
sys/man/1/ap

@@ -0,0 +1,16 @@
+.TH AP 1
+.SH NAME
+ap \- fetch Associated Press news articles
+.SH SYNOPSIS
+.B ap
+[
+.BI article-name
+]
+.SH DESCRIPTION
+.I ap
+fetches Associated Press news articles from http://www.newsday.com.
+Without any arguments it provides a two collum list of article keys and descriptions.
+When envoked with an article key it fetches that article.
+.PP
+.SH SOURCE
+.B /rc/bin/ap

+ 11 - 0
sys/man/1/thesaurus

@@ -0,0 +1,11 @@
+.TH THESAURUS 1
+.SH NAME
+thesaurus \- search online thesaurus
+.SH SYNOPSIS
+.B thesaurus
+.BI word
+.SH DESCRIPTION
+.I thesaurus
+searches the online thesaurus at http://thesaurus.reference.com
+.SH SOURCE
+.B /rc/cmd/thesaurus

+ 1 - 2
sys/src/9/pc/vgas3.c

@@ -15,7 +15,7 @@
 enum {
 	PCIS3		= 0x5333,		/* PCI VID */
 
-	SAVAGE3D	= 0x8A20,	/* PCI DID */
+	SAVAGE3D	= 0x8A20,		/* PCI DID */
 	SAVAGE3DMV	= 0x8A21,
 	SAVAGE4		= 0x8A22,
 	PROSAVAGEP	= 0x8A25,
@@ -325,7 +325,6 @@ s3move(VGAscr* scr, Point p)
 	vgaxo(Crtx, 0x4E, xo);
 	vgaxo(Crtx, 0x4F, yo);
 	vgaxo(Crtx, 0x48, (y>>8) & 0x07);
-	s3vsyncactive();
 
 	return 0;
 }

+ 33 - 8
sys/src/9/port/edf.c

@@ -209,16 +209,26 @@ releaseintr(Ureg*, Timer *t)
 		release(p);
 		edfunlock();
 		ready(p);
-		sched();
-//		if (up){
-//			up->delaysched++;
- //			delayedscheds++;
-//		}
+		if (up){
+			up->delaysched++;
+			delayedscheds++;
+		}
 		return;
 	case Running:
 		release(p);
 		edfrun(p, 1);
 		break;
+	case Wakeme:
+		release(p);
+		edfunlock();
+		if (p->trend)
+			wakeup(p->trend);
+		p->trend = nil;
+		if (up){
+			up->delaysched++;
+			delayedscheds++;
+		}
+		return;
 	}
 	edfunlock();
 }
@@ -396,6 +406,12 @@ edfstop(Proc *p)
 	}
 }
 
+static int
+yfn(void *)
+{
+	return todget(nil) >= up->edf->r;
+}
+
 void
 edfyield(void)
 {
@@ -403,14 +419,23 @@ edfyield(void)
 	Edf *e;
 	void	(*pt)(Proc*, int);
 
+	edflock();
 	e = up->edf;
 	if(pt = proctrace)
 		pt(up, SYield);
-	now = todget(nil);
+	while(e->t < now)
+		e->t += e->T;
+	e->r = e->t;
 	e->flags |= Yield;
 	e->d = now;
-	DPRINT("%t edfyield %lud\n", now, up->pid);
-	sched();
+	up->tns = e->t;
+	up->tf = releaseintr;
+	up->tmode = Tabsolute;
+	up->ta = up;
+	up->trend = &up->sleep;
+	timeradd(up);
+	edfunlock();
+	sleep(&up->sleep, yfn, nil);
 }
 
 int

+ 21 - 18
sys/src/9/port/portclock.c

@@ -18,7 +18,7 @@ ulong intrcount[MAXMACH];
 ulong fcallcount[MAXMACH];
 
 static uvlong
-tadd(Timers *tt, Timer *nt, uvlong now)
+tadd(Timers *tt, Timer *nt)
 {
 	Timer *t, **last;
 
@@ -30,13 +30,13 @@ tadd(Timers *tt, Timer *nt, uvlong now)
 		break;
 	case Trelative:
 		assert(nt->tns > 0);
-		nt->twhen = now + ns2fastticks(nt->tns);
+		nt->twhen = fastticks(nil) + ns2fastticks(nt->tns);
 		break;
 	case Tabsolute:
 		nt->twhen = tod2fastticks(nt->tns);
 		break;
 	case Tperiodic:
-		assert(nt->tns > 0);
+		assert(nt->tns >= 100000);	/* At least 100 µs period */
 		if(nt->twhen == 0){
 			/* look for another timer at same frequency for combining */
 			for(t = tt->head; t; t = t->tnext){
@@ -46,9 +46,9 @@ tadd(Timers *tt, Timer *nt, uvlong now)
 			if (t)
 				nt->twhen = t->twhen;
 			else
-				nt->twhen = now + ns2fastticks(nt->tns);
-		}else
-			nt->twhen = now + ns2fastticks(nt->tns);
+				nt->twhen = fastticks(nil);
+		}
+		nt->twhen += ns2fastticks(nt->tns);
 		break;
 	}
 
@@ -84,7 +84,7 @@ timeradd(Timer *nt)
 		timerdel(nt);
 	tt = &timers[m->machno];
 	ilock(tt);
-	when = tadd(tt, nt, fastticks(nil));
+	when = tadd(tt, nt);
 	if(when)
 		timerset(when);
 	iunlock(tt);
@@ -165,6 +165,7 @@ timerintr(Ureg *u, uvlong)
 	callhzclock = 0;
 	tt = &timers[m->machno];
 	now = fastticks(nil);
+	when = 0;
 	ilock(tt);
 	while(t = tt->head){
 		when = t->twhen;
@@ -174,6 +175,11 @@ timerintr(Ureg *u, uvlong)
 			m->splpc = pc;	/* for kernel profiling */
 			if(callhzclock)
 				hzclock(u);
+			else if (up && up->delaysched){
+				spllo();
+				sched();
+				splhi();
+			}
 			return;
 		}
 		tt->head = t->tnext;
@@ -181,16 +187,13 @@ timerintr(Ureg *u, uvlong)
 		t->tt = nil;
 		fcallcount[m->machno]++;
 		iunlock(tt);
-		if(t->tf){
+		if(t->tf)
 			(*t->tf)(u, t);
-			splhi();
-		} else
+		else
 			callhzclock++;
 		ilock(tt);
-		if(t->tmode == Tperiodic){
-			t->twhen += ns2fastticks(t->tns);
-			tadd(tt, t, now);
-		}
+		if(t->tmode == Tperiodic)
+			tadd(tt, t);
 	}
 	iunlock(tt);
 }
@@ -213,7 +216,7 @@ void
 addclock0link(void (*f)(void), int ms)
 {
 	Timer *nt;
-	uvlong ft;
+	uvlong when;
 
 	/* Synchronize to hztimer if ms is 0 */
 	nt = malloc(sizeof(Timer));
@@ -224,10 +227,10 @@ addclock0link(void (*f)(void), int ms)
 	nt->tt = nil;
 	nt->tf = (void (*)(Ureg*, Timer*))f;
 
-	ft = fastticks(nil);
-
 	ilock(&timers[0]);
-	tadd(&timers[0], nt, ft);
+	when = tadd(&timers[0], nt);
+	if(when)
+		timerset(when);
 	iunlock(&timers[0]);
 }
 

+ 2 - 1
sys/src/9/port/proc.c

@@ -676,6 +676,7 @@ twakeup(Ureg*, Timer *t)
 	}
 }
 
+/* Sleep until todget() >= ns.  NOTE: ns is not an interval */
 void
 tnsleep(Rendez *r, int (*fn)(void*), void *arg, vlong ns)
 {
@@ -683,7 +684,7 @@ tnsleep(Rendez *r, int (*fn)(void*), void *arg, vlong ns)
 		timerdel(up);
 	up->tns = ns;
 	up->tf = twakeup;
-	up->tmode = Trelative;
+	up->tmode = Tabsolute;
 	up->ta = up;
 	up->trend = r;
 	up->tfn = fn;

+ 1 - 2
sys/src/9/ppc/clock.c

@@ -15,6 +15,7 @@ delayloopinit(void)
 	uvlong x;
 
 	/* initial value for loopconst set in machinit */
+	m->loopconst = 1000;
 	v = getdec();
 	delay(1000);
 	v -= getdec();
@@ -49,8 +50,6 @@ clockintr(Ureg *)
 		v = 0;
 	}
 	putdec(clkreload-v);
-
-//	timerintr(ureg, 0);		We now use the 8260 fast clock
 }
 
 void

+ 1 - 0
sys/src/9/ppc/etherfcc.c

@@ -430,6 +430,7 @@ fccsetup(Ctlr *ctlr, FCC *fcc, uchar *ea)
 	/* Turn Ethernet off */
 	fcc->gfmr &= ~(ENR | ENT);
 
+	ioplock();
 	switch(ctlr->port) {
 	default:
 		iopunlock();

+ 1 - 0
sys/src/9/ppc/m8260.h

@@ -655,3 +655,4 @@ BD*	bdalloc(int);
 void	cpmop(int, int, int);
 void	ioplock(void);
 void	iopunlock(void);
+void	kreboot(ulong);

+ 8 - 18
sys/src/9/ppc/uartsmc.c

@@ -140,15 +140,16 @@ smcinit(Uart *uart)
 	/* step 0: disable rx/tx */
 	smc->smcmr &= ~3;
 
+	ioplock();
+
 	/* step 1, Using Port D */
-	if (ud->smcno == 0){
-		iomem->port[SMC1PORT].ppar |= SMRXD1|SMTXD1;
-		iomem->port[SMC1PORT].pdir |= SMTXD1;
-		iomem->port[SMC1PORT].pdir &= ~SMRXD1;
-		iomem->port[SMC1PORT].psor &= ~(SMRXD1|SMTXD1);
-	}else{
+	if (ud->smcno != 0)
 		panic("Don't know how to set Port D bits");
-	}
+	iomem->port[SMC1PORT].ppar |= SMRXD1|SMTXD1;
+	iomem->port[SMC1PORT].pdir |= SMTXD1;
+	iomem->port[SMC1PORT].pdir &= ~SMRXD1;
+	iomem->port[SMC1PORT].psor &= ~(SMRXD1|SMTXD1);
+
 	/* step 2: set up brgc1 */
 	iomem->brgc[ud->smcno]  = baudgen(uart->baud) | 0x10000;
 
@@ -643,9 +644,6 @@ dbgputc(int c)
 	BD *tbdf;
 	Imap *imap;
 	char *addr;
-	uchar smcm;
-	SMC *smc;
-	IMM *io;
 
 	/* Should work as long as Imap is mapped at 0xf0000000 (INTMEM) */
 
@@ -653,11 +651,6 @@ dbgputc(int c)
 	su = (Uartsmc *)(INTMEM | imap->param[0].smcbase);
 	tbdf = (BD *)(INTMEM | su->tbase);
 
-	io = (IMM*)IOMEM;
-	smc = io->smc;
-	smcm = smc->smcm;	/* save interrupt state */
-	smc->smcm = 0;		/* turn interrupts off */
-
 	/* Wait for last character to go.
 	*/
 	while (tbdf->status & BDReady)
@@ -672,8 +665,5 @@ dbgputc(int c)
 	while (tbdf->status & BDReady)
 		;
 
-	smc->smce = ce_Txb;	/* clear xmit events */
-	smc->smcm = smcm;	/* restore interrupts */
-
 	delay(300);
 }

+ 2 - 0
sys/src/boot/pc/console.c

@@ -153,6 +153,8 @@ getstr(char *prompt, char *buf, int size, char *def, int timeout)
 		switch(len){
 		case 0:
 			/* RETURN */
+			if(isdefault)
+				break;
 			continue;
 		case -1:
 			/* ^U typed */

+ 50 - 6
sys/src/boot/pc/sdata.c

@@ -429,10 +429,10 @@ ataidentify(int cmdport, int ctlport, int dev, int pkt, void* info)
 static Drive*
 atadrive(int cmdport, int ctlport, int dev)
 {
-	ushort *sp;
 	Drive *drive;
 	int as, i, pkt;
 	uchar buf[512], *p;
+	ushort iconfig, *sp;
 
 	atadebug(0, 0, "identify: port 0x%uX dev 0x%2.2uX\n", cmdport, dev);
 	pkt = 1;
@@ -465,8 +465,18 @@ retry:
 	}
 
 	drive->secsize = 512;
-	if((drive->info[Iconfig] & 0xC000) == 0x8000){
-		if(drive->info[Iconfig] & 0x01)
+
+	/*
+	 * Beware the CompactFlash Association feature set.
+	 * Now, why this value in Iconfig just walks all over the bit
+	 * definitions used in the other parts of the ATA/ATAPI standards
+	 * is a mystery and a sign of true stupidity on someone's part.
+	 * Anyway, the standard says if this value is 0x848A then it's
+	 * CompactFlash and it's NOT a packet device.
+	 */
+	iconfig = drive->info[Iconfig];
+	if(iconfig != 0x848A && (iconfig & 0xC000) == 0x8000){
+		if(iconfig & 0x01)
 			drive->pkt = 16;
 		else
 			drive->pkt = 12;
@@ -495,8 +505,7 @@ retry:
 
 	if(DEBUG & DbgCONFIG){
 		print("dev %2.2uX port %uX config %4.4uX capabilities %4.4uX",
-			dev, cmdport,
-			drive->info[Iconfig], drive->info[Icapabilities]);
+			dev, cmdport, iconfig, drive->info[Icapabilities]);
 		print(" mwdma %4.4uX", drive->info[Imwdma]);
 		if(drive->info[Ivalid] & 0x04)
 			print(" udma %4.4uX", drive->info[Iudma]);
@@ -1356,21 +1365,56 @@ atapnp(void)
 			break;
 		case (0x4D38<<16)|0x105A:	/* Promise PDC20262 */
 		case (0x4D30<<16)|0x105A:	/* Promise PDC202xx */
+		case (0x4D68<<16)|0x105A:	/* Promise PDC20268 */
+			pi = 0x85;
+			break;
 		case (0x0004<<16)|0x1103:	/* HighPoint HPT-370 */
 			pi = 0x85;
+			/*
+			 * Turn off fast interrupt prediction.
+			 */
+			if((r = pcicfgr8(p, 0x51)) & 0x80)
+				pcicfgw8(p, 0x51, r & ~0x80);
+			if((r = pcicfgr8(p, 0x55)) & 0x80)
+				pcicfgw8(p, 0x55, r & ~0x80);
 			break;
 		case (0x0640<<16)|0x1095:	/* CMD 640B */
 			/*
 			 * Bugfix code here...
 			 */
 			break;
+		case (0x7441<<16)|0x1022:	/* AMD 768 */
+			/*
+			 * Set:
+			 *	0x41	prefetch, postwrite;
+			 *	0x43	FIFO configuration 1/2 and 1/2;
+			 *	0x44	status register read retry;
+			 *	0x46	DMA read and end of sector flush.
+			 */
+			r = pcicfgr8(p, 0x41);
+			pcicfgw8(p, 0x41, r|0xF0);
+			r = pcicfgr8(p, 0x43);
+			pcicfgw8(p, 0x43, (r & 0x90)|0x2A);
+			r = pcicfgr8(p, 0x44);
+			pcicfgw8(p, 0x44, r|0x08);
+			r = pcicfgr8(p, 0x46);
+			pcicfgw8(p, 0x46, (r & 0x0C)|0xF0);
+			break;
 		case (0x0646<<16)|0x1095:	/* CMD 646 */
 		case (0x0571<<16)|0x1106:	/* VIA 82C686 */
 		case (0x0211<<16)|0x1166:	/* ServerWorks IB6566 */
 		case (0x1230<<16)|0x8086:	/* 82371FB (PIIX) */
-		case (0x248A<<16)|0x8086:	/* 82801BAM ICH2-M */
 		case (0x7010<<16)|0x8086:	/* 82371SB (PIIX3) */
 		case (0x7111<<16)|0x8086:	/* 82371[AE]B (PIIX4[E]) */
+		case (0x2411<<16)|0x8086:	/* 82801AA (ICH) */
+		case (0x2421<<16)|0x8086:	/* 82801AB (ICH0) */
+		case (0x244A<<16)|0x8086:	/* 82801BA (ICH2, Mobile) */
+		case (0x244B<<16)|0x8086:	/* 82801BA (ICH2, High-End) */
+		case (0x248A<<16)|0x8086:	/* 82801CA (ICH3, Mobile) */
+		case (0x248B<<16)|0x8086:	/* 82801CA (ICH3, High-End) */
+		case (0x24CA<<16)|0x8086:	/* 82801DBM (ICH4, Mobile) */
+		case (0x24CB<<16)|0x8086:	/* 82801DB (ICH4, High-End) */
+		case (0x24DB<<16)|0x8086:	/* 82801EB (ICH5) */
 			break;
 		}
 

+ 0 - 3
sys/src/cmd/acme/rows.c

@@ -375,9 +375,6 @@ rowdump(Row *row, char *file)
 					0, 0,
 					100*(w->r.min.y-c->r.min.y)/Dy(c->r),
 					fontname);
-			}else if(strlen(a) == 0){	/* don't save unnamed windows */
-				free(a);
-				continue;
 			}else if((w->dirty==FALSE && access(a, 0)==0) || w->isdir){
 				dumped = FALSE;
 				t->file->dumpid = w->id;

+ 4 - 3
sys/src/cmd/auth/factotum/secstore.c

@@ -187,7 +187,7 @@ static int
 SC_write(SConn *conn, uchar *buf, int n)
 {
 	SS *ss = (SS*)(conn->chan);
-	uchar count[2], digest[SHA1dlen];
+	uchar count[2], digest[SHA1dlen], enc[Maxmsg+1];
 	int len;
 
 	if(n <= 0 || n > Maxmsg+1){
@@ -206,9 +206,10 @@ SC_write(SConn *conn, uchar *buf, int n)
 	if(ss->alg){
 		hash(ss->out.secret, buf, n, ss->out.seqno, digest);
 		rc4(&ss->out.rc4, digest, SHA1dlen);
-		rc4(&ss->out.rc4, buf, n);
+		memcpy(enc, buf, n);
+		rc4(&ss->out.rc4, enc, n);
 		if(write(ss->fd, digest, SHA1dlen) != SHA1dlen ||
-				write(ss->fd, buf, n) != n){
+				write(ss->fd, enc, n) != n){
 			werrstr("!SC_write error on send");
 			return -1;
 		}

+ 2 - 2
sys/src/cmd/fossil/9.h

@@ -28,8 +28,8 @@ struct Msg {
 
 	int	state;
 
-	Msg*	fnext;			/* proc flush */
-	Msg*	fprev;
+	Msg*	behind;			/* proc flush */
+	Msg*	before;
 };
 
 enum {

+ 110 - 121
sys/src/cmd/fossil/9proc.c

@@ -101,7 +101,7 @@ static void
 msgFree(Msg* m)
 {
 	assert(m->rwnext == nil);
-	assert(m->fnext == nil && m->fprev == nil);
+	assert(m->behind == nil && m->before == nil);
 
 	vtLock(mbox.alock);
 	if(mbox.nmsg > mbox.maxmsg){
@@ -167,39 +167,49 @@ msgMunlink(Msg* m)
 }
 
 static void
-msgUnlinkUnlockAndFree(Msg* m)
+msgUnlinkAndFree(Msg* m)
 {
 	/*
-	 * Unlink the message from the flush and message queues,
-	 * unlock the connection message lock and free the message.
+	 * Unlink the message from the flush
+	 * and message lists, and free the message.
 	 * Called with con->mlock locked.
 	 */
-	if(m->fprev != nil)
-		m->fprev->fnext = m->fnext;
-	if(m->fnext != nil)
-		m->fnext->fprev = m->fprev;
-	m->fprev = m->fnext = nil;
+	if(m->behind){
+		m->behind->before = nil;
+		m->behind = nil;
+	}
+	if(m->before){
+		m->before->behind = nil;
+		m->before = nil;
+	}
 
 	msgMunlink(m);
-	vtUnlock(m->con->mlock);
 	msgFree(m);
 }
 
 void
 msgFlush(Msg* m)
 {
-	Msg *old;
 	Con *con;
+	Msg *old;
 
 	con = m->con;
 
-fprint(2, "msgFlush %F\n", &m->t);
+	if(Dflag)
+		fprint(2, "msgFlush %F\n", &m->t);
 
 	/*
+	 * If this Tflush has been flushed, nothing to do.
 	 * Look for the message to be flushed in the
 	 * queue of all messages still on this connection.
+	 * If it's not found must assume Elvis has already
+	 * left the building and reply normally.
 	 */
 	vtLock(con->mlock);
+	if(m->state == MsgF){
+		vtUnlock(con->mlock);
+		return;
+	}
 	for(old = con->mhead; old != nil; old = old->mnext)
 		if(old->t.tag == m->t.oldtag)
 			break;
@@ -210,72 +220,48 @@ fprint(2, "msgFlush %F\n", &m->t);
 		return;
 	}
 
-fprint(2, "\tmsgFlush found %F\n", &old->t);
+	if(Dflag)
+		fprint(2, "\tmsgFlush found %F\n", &old->t);
 
 	/*
 	 * Found it.
-	 *
-	 * Easy case is no 9P processing done yet,
-	 * message is on the read queue.
-	 * Mark the message as flushed and let the read
-	 * process throw it away after after pulling
-	 * it off the read queue.
+	 * There are two cases where the old message can be
+	 * truly flushed and no reply to the original message given.
+	 * The first is when the old message is in MsgR state; no
+	 * processing has been done yet and it is still on the read
+	 * queue. The second is if old is a Tflush, which doesn't
+	 * affect the server state. In both cases, put the old
+	 * message into MsgF state and let MsgProc or MsgWrite
+	 * toss it after pulling it off the appropriate queue.
 	 */
-	if(old->state == MsgR){
+	if(old->state == MsgR || old->t.type == Tflush){
 		old->state = MsgF;
 		if(Dflag)
-			fprint(2, "msgFlush: change %d from MsgR to MsgF\n", m->t.oldtag);
-		vtUnlock(con->mlock);
-		return;
+			fprint(2, "msgFlush: change %d from MsgR to MsgF\n",
+				m->t.oldtag);
 	}
 
 	/*
-	 * Flushing flushes.
-	 * Since they don't affect the server state, flushes
-	 * can be deleted when in Msg9 or MsgW state.
+	 * Link this flush message and the old message
+	 * so we can coalesce multiple flushes (if there are
+	 * multiple Tflush messages for a particular pending
+	 * request, it is only necessary to respond to the last
+	 * one, so any previous can be removed) and to be
+	 * sure flushes wait for their corresponding old
+	 * message to go out first.
 	 */
-	if(old->t.type == Tflush){
-		/*
-		 * For Msg9 state, the old message may
-		 * or may not be on the write queue.
-		 * Mark the message as flushed and let
-		 * the write process throw it away after
-		 * after pulling it off the write queue.
-		 */
-		if(old->state == Msg9){
-			old->state = MsgF;
-			if(Dflag)
-				fprint(2, "msgFlush: change %d from Msg9 to MsgF\n", m->t.oldtag);
-			vtUnlock(con->mlock);
-			return;
-		}
-		assert(old->state == MsgW);
-
-		/*
-		 * A flush in MsgW state implies it is waiting
-		 * for its corresponding old message to be written,
-		 * so it can be deleted right here, right now...
-		 * right here, right now... right here, right now...
-		 * right about now... the funk soul brother.
-		 */
+	if(old->behind){
 		if(Dflag)
-			fprint(2, "msgFlush: delete pending flush %F\n", &old->t);
-		msgUnlinkUnlockAndFree(old);
-		return;
+			fprint(2, "msgFlush: remove %d from %d list\n",
+				old->behind->t.tag, old->t.tag);
+		msgUnlinkAndFree(old->behind);
 	}
+	old->behind = m;
+	m->before = old;
 
-	/*
-	 * Must wait for the old message to be written.
-	 * Add m to old's flush queue.
-	 * Old is the head of its own flush queue.
-	 */
-	m->fprev = old;
-	m->fnext = old->fnext;
-	if(m->fnext)
-		m->fnext->fprev = m;
-	old->fnext = m;
 	if(Dflag)
-		fprint(2, "msgFlush: add %d to %d queue\n", m->t.tag, old->t.tag);
+		fprint(2, "msgFlush: add %d to %d queue\n",
+			m->t.tag, old->t.tag);
 	vtUnlock(con->mlock);
 }
 
@@ -311,37 +297,39 @@ msgProc(void*)
 		e = nil;
 
 		/*
-		 * If the message has been flushed before any
-		 * 9P processing has started, just throw it away.
+		 * If the message has been flushed before
+		 * any 9P processing has started, mark it so
+		 * none will be attempted.
 		 */
 		vtLock(con->mlock);
-		if(m->state == MsgF){
-			msgUnlinkUnlockAndFree(m);
-			continue;
-		}
-		m->state = Msg9;
+		if(m->state == MsgF)
+			e = "flushed";
+		else
+			m->state = Msg9;
 		vtUnlock(con->mlock);
 
-		/*
-		 * explain this
-		 */
-		vtLock(con->lock);
-		if(m->t.type == Tversion){
-			con->version = m;
-			con->state = ConDown;
-			while(con->mhead != m)
-				vtSleep(con->rendez);
-			assert(con->state == ConDown);
-			if(con->version == m){
-				con->version = nil;
-				con->state = ConInit;
+		if(e == nil){
+			/*
+			 * explain this
+			 */
+			vtLock(con->lock);
+			if(m->t.type == Tversion){
+				con->version = m;
+				con->state = ConDown;
+				while(con->mhead != m)
+					vtSleep(con->rendez);
+				assert(con->state == ConDown);
+				if(con->version == m){
+					con->version = nil;
+					con->state = ConInit;
+				}
+				else
+					e = "Tversion aborted";
 			}
-			else
-				e = "Tversion aborted";
+			else if(con->state != ConUp)
+				e = "connection not ready";
+			vtUnlock(con->lock);
 		}
-		else if(con->state != ConUp)
-			e = "connection not ready";
-		vtUnlock(con->lock);
 
 		/*
 		 * Dispatch if not error already.
@@ -356,7 +344,6 @@ msgProc(void*)
 		else
 			m->r.type = m->t.type+1;
 
-
 		/*
 		 * Put the message (with reply) on the
 		 * write queue and wakeup the write process.
@@ -447,46 +434,51 @@ static int
 _msgWrite(Msg* m)
 {
 	Con *con;
-	int eof, n;
-
-	con = m->con;
+	int eof, msgw, n;
 
 	/*
-	 * An Rflush with a .fprev implies it is on a flush queue waiting for
-	 * its corresponding 'oldtag' message to go out first, so punt
-	 * until the 'oldtag' message goes out (see below).
+	 * A message with .before set implies it is waiting
+	 * for the .before message to go out first, so punt
+	 * until the .before message goes out (see below).
 	 */
-	if(m->r.type == Rflush && m->fprev != nil){
-		fprint(2, "msgWrite %p: delay r %F\n", con, &m->r);
+	con = m->con;
+	if(m->before != nil){
+		if(Dflag)
+			fprint(2, "msgWrite %p: delay r %F\n", con, &m->r);
 		return 0;
 	}
+	if(m->state == MsgF)
+		msgw = 0;
+	else
+		msgw = 1;
 
 	msgMunlink(m);
 	vtUnlock(con->mlock);
 
-	/*
-	 * TODO: optimise this copy away somehow for
-	 * read, stat, etc.
-	 */
-	assert(n = convS2M(&m->r, con->data, con->msize));
-	if(write(con->fd, con->data, n) != n)
-		eof = 1;
-	else
-		eof = 0;
+	eof = 0;
+	if(msgw){
+		/*
+		 * TODO: optimise this copy away somehow for
+		 * read, stat, etc.
+		 */
+		assert(n = convS2M(&m->r, con->data, con->msize));
+		if(write(con->fd, con->data, n) != n)
+			eof = 1;
+	}
 
 	if(Dflag)
-		fprint(2, "msgWrite %p: r %F\n", con, &m->r);
+		fprint(2, "msgWrite %d: r %F\n", msgw, &m->r);
 
 	/*
-	 * Just wrote a reply. If it has any flushes waiting
+	 * Message written or flushed. If it has anything waiting
 	 * for it to have gone out, recurse down the list writing
 	 * them out too.
 	 */
 	vtLock(con->mlock);
-	if(m->fnext != nil){
-		m->fnext->fprev = nil;
-		eof += _msgWrite(m->fnext);
-		m->fnext = nil;
+	if(m->behind != nil){
+		m->behind->before = nil;
+		eof += _msgWrite(m->behind);
+		m->behind = nil;
 	}
 	msgFree(m);
 
@@ -521,16 +513,13 @@ msgWrite(void* v)
 		vtUnlock(con->wlock);
 
 		/*
-		 * Throw the message away if it's a flushed flush,
-		 * otherwise change its state and try to write it out.
+		 * If the message hasn't been flushed,
+		 * change its state so it will be written
+		 * out.
 		 */
 		vtLock(con->mlock);
-		if(m->state == MsgF){
-			assert(m->t.type == Tflush);
-			msgUnlinkUnlockAndFree(m);
-			continue;
-		}
-		m->state = MsgW;
+		if(m->state != MsgF)
+			m->state = MsgW;
 		eof = _msgWrite(m);
 		vtUnlock(con->mlock);