Browse Source

Plan 9 from Bell Labs 2006-05-05

David du Colombier 15 years ago
parent
commit
f7dda51334

+ 19 - 16
dist/replica/_plan9.db

@@ -7854,7 +7854,7 @@ sys/src/9/bitsy/wavelan.c - 664 sys sys 1116097770 27267
 sys/src/9/bitsy/wavelan.h - 664 sys sys 1037029076 27
 sys/src/9/boot - 20000000775 sys sys 1018556557 0
 sys/src/9/boot/aux.c - 664 sys sys 1063857702 2579
-sys/src/9/boot/boot.c - 664 sys sys 1130982159 6067
+sys/src/9/boot/boot.c - 664 sys sys 1146746630 6013
 sys/src/9/boot/boot.h - 664 sys sys 1063857659 1785
 sys/src/9/boot/bootauth.c - 664 sys sys 1131289783 1160
 sys/src/9/boot/bootcache.c - 664 sys sys 1063857645 1579
@@ -8025,7 +8025,7 @@ sys/src/9/pc/sd53c8xx.n - 664 sys sys 1131290556 12657
 sys/src/9/pc/sdata.c - 664 sys sys 1141793347 52244
 sys/src/9/pc/sdmv50xx.c - 664 sys sys 1131290638 25780
 sys/src/9/pc/sdmylex.c - 664 sys sys 1133068062 27806
-sys/src/9/pc/sdscsi.c - 664 sys sys 1131293342 7133
+sys/src/9/pc/sdscsi.c - 664 sys sys 1146746630 7106
 sys/src/9/pc/trap.c - 664 sys sys 1135487942 21257
 sys/src/9/pc/uarti8250.c - 664 sys sys 1102820421 13958
 sys/src/9/pc/uartisa.c - 664 sys sys 1127126907 1777
@@ -8124,9 +8124,9 @@ sys/src/9/port/netif.h - 664 sys sys 1066514947 2975
 sys/src/9/port/page.c - 664 sys sys 1131636090 11128
 sys/src/9/port/parse.c - 664 sys sys 1014931177 2026
 sys/src/9/port/pgrp.c - 664 sys sys 1138458260 4760
-sys/src/9/port/portclock.c - 664 sys sys 1146151715 4333
+sys/src/9/port/portclock.c - 664 sys sys 1146746630 4276
 sys/src/9/port/portdat.h - 664 sys sys 1143129883 22669
-sys/src/9/port/portfns.h - 664 sys sys 1138469535 11079
+sys/src/9/port/portfns.h - 664 sys sys 1146746630 11059
 sys/src/9/port/portmkfile - 664 sys sys 1131907975 2062
 sys/src/9/port/print.c - 664 sys sys 1014931178 227
 sys/src/9/port/proc.c - 664 sys sys 1138749368 28702
@@ -8143,7 +8143,7 @@ sys/src/9/port/sysproc.c - 664 sys sys 1143289632 21534
 sys/src/9/port/taslock.c - 664 sys sys 1146151714 4536
 sys/src/9/port/thwack.c - 664 sys sys 1057323394 7253
 sys/src/9/port/thwack.h - 664 sys sys 1015278340 1792
-sys/src/9/port/tod.c - 664 sys sys 1138459530 5336
+sys/src/9/port/tod.c - 664 sys sys 1146746630 5377
 sys/src/9/port/unthwack.c - 664 sys sys 1057323394 5249
 sys/src/9/port/xalloc.c - 664 sys sys 1131290051 4063
 sys/src/9/ppc - 20000000775 sys sys 1059490838 0
@@ -14367,16 +14367,16 @@ sys/src/fs/pc/8253.c - 664 sys sys 1097579039 7264
 sys/src/fs/pc/cga.c - 664 sys sys 1015110034 1484
 sys/src/fs/pc/compat.c - 664 sys sys 1140164905 1575
 sys/src/fs/pc/compat.h - 664 sys sys 1140167957 2426
-sys/src/fs/pc/dosfs.c - 664 sys sys 1146675982 16443
+sys/src/fs/pc/dosfs.c - 664 sys sys 1146784976 16619
 sys/src/fs/pc/dosfs.h - 664 sys sys 1140167937 2696
 sys/src/fs/pc/ether2114x.c - 664 sys sys 1015110044 31874
 sys/src/fs/pc/ether8139.c - 664 sys sys 1086569718 18552
 sys/src/fs/pc/ether82557.c - 664 sys sys 1141035189 30669
 sys/src/fs/pc/ether83815.c - 664 sys sys 1140335463 26764
 sys/src/fs/pc/ether83815.mii.c - 664 sys sys 1049156663 31622
-sys/src/fs/pc/etherdp83820.c - 664 sys sys 1092268058 30976
+sys/src/fs/pc/etherdp83820.c - 664 sys sys 1146355081 32045
 sys/src/fs/pc/etherelnk3.c - 664 sys sys 1015110054 42732
-sys/src/fs/pc/etherga620.c - 664 sys sys 1146675981 24749
+sys/src/fs/pc/etherga620.c - 664 sys sys 1146785153 24748
 sys/src/fs/pc/etherga620fw.h - 664 sys sys 1032126775 222295
 sys/src/fs/pc/etherif.c - 664 sys sys 1140162742 6375
 sys/src/fs/pc/etherif.h - 664 sys sys 1015110057 730
@@ -14391,33 +14391,33 @@ sys/src/fs/pc/malloc.c - 664 sys sys 1096789023 2840
 sys/src/fs/pc/mkfile - 664 sys sys 1140167942 426
 sys/src/fs/pc/mmu.c - 664 sys sys 1015110065 8414
 sys/src/fs/pc/nvr.c - 664 sys sys 1015110066 669
-sys/src/fs/pc/pc.c - 664 sys sys 1146675981 7949
+sys/src/fs/pc/pc.c - 664 sys sys 1146785006 7996
 sys/src/fs/pc/pci.c - 664 sys sys 1094949424 12118
 sys/src/fs/pc/script.i - 664 sys sys 1015110072 27323
 sys/src/fs/pc/scsi.c - 664 sys sys 1091803674 8661
 sys/src/fs/pc/scsibuslogic.c - 664 sys sys 1015110077 28645
-sys/src/fs/pc/scsincr53c8xx.c - 664 sys sys 1146675981 53427
+sys/src/fs/pc/scsincr53c8xx.c - 664 sys sys 1146785080 53665
 sys/src/fs/pc/sdata.c - 664 sys sys 1097712291 61793
-sys/src/fs/pc/sdscsi.c - 664 sys sys 1140164880 7042
+sys/src/fs/pc/sdscsi.c - 664 sys sys 1146786984 7017
 sys/src/fs/pc/toy.c - 664 sys sys 1140167948 2166
 sys/src/fs/pc/trap.c - 664 sys sys 1055699801 7946
 sys/src/fs/port - 20000000775 sys sys 1015110029 0
 sys/src/fs/port/9p1.c - 664 sys sys 1140167971 29982
 sys/src/fs/port/9p1.h - 664 sys sys 1140167972 2128
 sys/src/fs/port/9p1lib.c - 664 sys sys 1101627232 7911
-sys/src/fs/port/9p2.c - 664 sys sys 1146675939 36160
+sys/src/fs/port/9p2.c - 664 sys sys 1146785189 36265
 sys/src/fs/port/all.h - 664 sys sys 1140167977 1932
-sys/src/fs/port/auth.c - 664 sys sys 1146675939 7605
+sys/src/fs/port/auth.c - 664 sys sys 1146785221 7606
 sys/src/fs/port/chk.c - 664 sys sys 1097832483 15683
 sys/src/fs/port/clock.c - 664 sys sys 1097580538 4033
-sys/src/fs/port/con.c - 664 sys sys 1146675938 16231
+sys/src/fs/port/con.c - 664 sys sys 1146785256 16304
 sys/src/fs/port/config.c - 664 sys sys 1107835943 20264
 sys/src/fs/port/console.c - 664 sys sys 1101627646 4886
 sys/src/fs/port/data.c - 664 sys sys 1140167986 4510
 sys/src/fs/port/dentry.c - 664 sys sys 1098156404 6345
 sys/src/fs/port/devcons.c - 664 sys sys 1095983755 4451
 sys/src/fs/port/devsd.c - 664 sys sys 1097712378 10993
-sys/src/fs/port/fcmd.c - 664 sys sys 1146675938 1255
+sys/src/fs/port/fcmd.c - 664 sys sys 1146785267 1255
 sys/src/fs/port/fs.h - 664 sys sys 1140168001 682
 sys/src/fs/port/iobuf.c - 664 sys sys 1140167988 4956
 sys/src/fs/port/lib.h - 664 sys sys 1091960844 3701
@@ -14429,7 +14429,7 @@ sys/src/fs/port/portfns.h - 664 sys sys 1140167994 7526
 sys/src/fs/port/print.c - 664 sys sys 1015110022 153
 sys/src/fs/port/proc.c - 664 sys sys 1097580775 5364
 sys/src/fs/port/sd.h - 664 sys sys 1097577251 2167
-sys/src/fs/port/sub.c - 664 sys sys 1146675938 23732
+sys/src/fs/port/sub.c - 664 sys sys 1146787681 25595
 sys/src/fs/port/time.c - 664 sys sys 1140167998 6222
 sys/src/fs/port/uidgid.c - 664 sys sys 1097574050 9192
 sys/src/games - 20000000775 sys sys 1095792091 0
@@ -15627,3 +15627,6 @@ usr/glenda/lib/profile - 664 glenda glenda 1105128663 890
 usr/glenda/readme.acme - 664 glenda glenda 1019860628 4753
 usr/glenda/readme.rio - 664 glenda glenda 1019860628 6370
 usr/glenda/tmp - 20000000775 glenda glenda 1018802620 0
+sys/src/fs/pc/scsincr53c8xx.c - 664 sys sys 1146798658 53619
+sys/src/fs/port/all.h - 664 sys sys 1146798594 1888
+sys/src/fs/port/lib.h - 664 sys sys 1146798595 3791

+ 18 - 18
dist/replica/plan9.db

@@ -7854,7 +7854,7 @@ sys/src/9/bitsy/wavelan.c - 664 sys sys 1116097770 27267
 sys/src/9/bitsy/wavelan.h - 664 sys sys 1037029076 27
 sys/src/9/boot - 20000000775 sys sys 1018556557 0
 sys/src/9/boot/aux.c - 664 sys sys 1063857702 2579
-sys/src/9/boot/boot.c - 664 sys sys 1130982159 6067
+sys/src/9/boot/boot.c - 664 sys sys 1146746630 6013
 sys/src/9/boot/boot.h - 664 sys sys 1063857659 1785
 sys/src/9/boot/bootauth.c - 664 sys sys 1131289783 1160
 sys/src/9/boot/bootcache.c - 664 sys sys 1063857645 1579
@@ -8025,7 +8025,7 @@ sys/src/9/pc/sd53c8xx.n - 664 sys sys 1131290556 12657
 sys/src/9/pc/sdata.c - 664 sys sys 1141793347 52244
 sys/src/9/pc/sdmv50xx.c - 664 sys sys 1131290638 25780
 sys/src/9/pc/sdmylex.c - 664 sys sys 1133068062 27806
-sys/src/9/pc/sdscsi.c - 664 sys sys 1131293342 7133
+sys/src/9/pc/sdscsi.c - 664 sys sys 1146746630 7106
 sys/src/9/pc/trap.c - 664 sys sys 1135487942 21257
 sys/src/9/pc/uarti8250.c - 664 sys sys 1102820421 13958
 sys/src/9/pc/uartisa.c - 664 sys sys 1127126907 1777
@@ -8124,9 +8124,9 @@ sys/src/9/port/netif.h - 664 sys sys 1066514947 2975
 sys/src/9/port/page.c - 664 sys sys 1131636090 11128
 sys/src/9/port/parse.c - 664 sys sys 1014931177 2026
 sys/src/9/port/pgrp.c - 664 sys sys 1138458260 4760
-sys/src/9/port/portclock.c - 664 sys sys 1146151715 4333
+sys/src/9/port/portclock.c - 664 sys sys 1146746630 4276
 sys/src/9/port/portdat.h - 664 sys sys 1143129883 22669
-sys/src/9/port/portfns.h - 664 sys sys 1138469535 11079
+sys/src/9/port/portfns.h - 664 sys sys 1146746630 11059
 sys/src/9/port/portmkfile - 664 sys sys 1131907975 2062
 sys/src/9/port/print.c - 664 sys sys 1014931178 227
 sys/src/9/port/proc.c - 664 sys sys 1138749368 28702
@@ -8143,7 +8143,7 @@ sys/src/9/port/sysproc.c - 664 sys sys 1143289632 21534
 sys/src/9/port/taslock.c - 664 sys sys 1146151714 4536
 sys/src/9/port/thwack.c - 664 sys sys 1057323394 7253
 sys/src/9/port/thwack.h - 664 sys sys 1015278340 1792
-sys/src/9/port/tod.c - 664 sys sys 1138459530 5336
+sys/src/9/port/tod.c - 664 sys sys 1146746630 5377
 sys/src/9/port/unthwack.c - 664 sys sys 1057323394 5249
 sys/src/9/port/xalloc.c - 664 sys sys 1131290051 4063
 sys/src/9/ppc - 20000000775 sys sys 1059490838 0
@@ -14367,16 +14367,16 @@ sys/src/fs/pc/8253.c - 664 sys sys 1097579039 7264
 sys/src/fs/pc/cga.c - 664 sys sys 1015110034 1484
 sys/src/fs/pc/compat.c - 664 sys sys 1140164905 1575
 sys/src/fs/pc/compat.h - 664 sys sys 1140167957 2426
-sys/src/fs/pc/dosfs.c - 664 sys sys 1146675982 16443
+sys/src/fs/pc/dosfs.c - 664 sys sys 1146784976 16619
 sys/src/fs/pc/dosfs.h - 664 sys sys 1140167937 2696
 sys/src/fs/pc/ether2114x.c - 664 sys sys 1015110044 31874
 sys/src/fs/pc/ether8139.c - 664 sys sys 1086569718 18552
 sys/src/fs/pc/ether82557.c - 664 sys sys 1141035189 30669
 sys/src/fs/pc/ether83815.c - 664 sys sys 1140335463 26764
 sys/src/fs/pc/ether83815.mii.c - 664 sys sys 1049156663 31622
-sys/src/fs/pc/etherdp83820.c - 664 sys sys 1092268058 30976
+sys/src/fs/pc/etherdp83820.c - 664 sys sys 1146355081 32045
 sys/src/fs/pc/etherelnk3.c - 664 sys sys 1015110054 42732
-sys/src/fs/pc/etherga620.c - 664 sys sys 1146675981 24749
+sys/src/fs/pc/etherga620.c - 664 sys sys 1146785153 24748
 sys/src/fs/pc/etherga620fw.h - 664 sys sys 1032126775 222295
 sys/src/fs/pc/etherif.c - 664 sys sys 1140162742 6375
 sys/src/fs/pc/etherif.h - 664 sys sys 1015110057 730
@@ -14391,36 +14391,36 @@ sys/src/fs/pc/malloc.c - 664 sys sys 1096789023 2840
 sys/src/fs/pc/mkfile - 664 sys sys 1140167942 426
 sys/src/fs/pc/mmu.c - 664 sys sys 1015110065 8414
 sys/src/fs/pc/nvr.c - 664 sys sys 1015110066 669
-sys/src/fs/pc/pc.c - 664 sys sys 1146675981 7949
+sys/src/fs/pc/pc.c - 664 sys sys 1146785006 7996
 sys/src/fs/pc/pci.c - 664 sys sys 1094949424 12118
 sys/src/fs/pc/script.i - 664 sys sys 1015110072 27323
 sys/src/fs/pc/scsi.c - 664 sys sys 1091803674 8661
 sys/src/fs/pc/scsibuslogic.c - 664 sys sys 1015110077 28645
-sys/src/fs/pc/scsincr53c8xx.c - 664 sys sys 1146675981 53427
+sys/src/fs/pc/scsincr53c8xx.c - 664 sys sys 1146798658 53619
 sys/src/fs/pc/sdata.c - 664 sys sys 1097712291 61793
-sys/src/fs/pc/sdscsi.c - 664 sys sys 1140164880 7042
+sys/src/fs/pc/sdscsi.c - 664 sys sys 1146786984 7017
 sys/src/fs/pc/toy.c - 664 sys sys 1140167948 2166
 sys/src/fs/pc/trap.c - 664 sys sys 1055699801 7946
 sys/src/fs/port - 20000000775 sys sys 1015110029 0
 sys/src/fs/port/9p1.c - 664 sys sys 1140167971 29982
 sys/src/fs/port/9p1.h - 664 sys sys 1140167972 2128
 sys/src/fs/port/9p1lib.c - 664 sys sys 1101627232 7911
-sys/src/fs/port/9p2.c - 664 sys sys 1146675939 36160
-sys/src/fs/port/all.h - 664 sys sys 1140167977 1932
-sys/src/fs/port/auth.c - 664 sys sys 1146675939 7605
+sys/src/fs/port/9p2.c - 664 sys sys 1146785189 36265
+sys/src/fs/port/all.h - 664 sys sys 1146798594 1888
+sys/src/fs/port/auth.c - 664 sys sys 1146785221 7606
 sys/src/fs/port/chk.c - 664 sys sys 1097832483 15683
 sys/src/fs/port/clock.c - 664 sys sys 1097580538 4033
-sys/src/fs/port/con.c - 664 sys sys 1146675938 16231
+sys/src/fs/port/con.c - 664 sys sys 1146785256 16304
 sys/src/fs/port/config.c - 664 sys sys 1107835943 20264
 sys/src/fs/port/console.c - 664 sys sys 1101627646 4886
 sys/src/fs/port/data.c - 664 sys sys 1140167986 4510
 sys/src/fs/port/dentry.c - 664 sys sys 1098156404 6345
 sys/src/fs/port/devcons.c - 664 sys sys 1095983755 4451
 sys/src/fs/port/devsd.c - 664 sys sys 1097712378 10993
-sys/src/fs/port/fcmd.c - 664 sys sys 1146675938 1255
+sys/src/fs/port/fcmd.c - 664 sys sys 1146785267 1255
 sys/src/fs/port/fs.h - 664 sys sys 1140168001 682
 sys/src/fs/port/iobuf.c - 664 sys sys 1140167988 4956
-sys/src/fs/port/lib.h - 664 sys sys 1091960844 3701
+sys/src/fs/port/lib.h - 664 sys sys 1146798595 3791
 sys/src/fs/port/lrand.c - 664 sys sys 1091803568 1093
 sys/src/fs/port/main.c - 664 sys sys 1140167990 7639
 sys/src/fs/port/mkfile - 664 sys sys 1140167991 214
@@ -14429,7 +14429,7 @@ sys/src/fs/port/portfns.h - 664 sys sys 1140167994 7526
 sys/src/fs/port/print.c - 664 sys sys 1015110022 153
 sys/src/fs/port/proc.c - 664 sys sys 1097580775 5364
 sys/src/fs/port/sd.h - 664 sys sys 1097577251 2167
-sys/src/fs/port/sub.c - 664 sys sys 1146675938 23732
+sys/src/fs/port/sub.c - 664 sys sys 1146787681 25595
 sys/src/fs/port/time.c - 664 sys sys 1140167998 6222
 sys/src/fs/port/uidgid.c - 664 sys sys 1097574050 9192
 sys/src/games - 20000000775 sys sys 1095792091 0

+ 20 - 0
dist/replica/plan9.log

@@ -29606,3 +29606,23 @@
 1146677452 6 c sys/src/fs/port/con.c - 664 sys sys 1146675938 16231
 1146677452 7 c sys/src/fs/port/fcmd.c - 664 sys sys 1146675938 1255
 1146677452 8 c sys/src/fs/port/sub.c - 664 sys sys 1146675938 23732
+1146747672 0 c sys/src/9/boot/boot.c - 664 sys sys 1146746630 6013
+1146747672 1 c sys/src/9/pc/sdscsi.c - 664 sys sys 1146746630 7106
+1146747672 2 c sys/src/9/port/portclock.c - 664 sys sys 1146746630 4276
+1146747672 3 c sys/src/9/port/portfns.h - 664 sys sys 1146746630 11059
+1146747672 4 c sys/src/9/port/tod.c - 664 sys sys 1146746630 5377
+1146785483 0 c sys/src/fs/pc/dosfs.c - 664 sys sys 1146784976 16619
+1146785483 1 c sys/src/fs/pc/etherga620.c - 664 sys sys 1146785153 24748
+1146785483 2 c sys/src/fs/pc/pc.c - 664 sys sys 1146785006 7996
+1146785483 3 c sys/src/fs/pc/scsincr53c8xx.c - 664 sys sys 1146785080 53665
+1146785483 4 c sys/src/fs/port/9p2.c - 664 sys sys 1146785189 36265
+1146785483 5 c sys/src/fs/port/auth.c - 664 sys sys 1146785221 7606
+1146785483 6 c sys/src/fs/port/con.c - 664 sys sys 1146785256 16304
+1146785483 7 c sys/src/fs/port/fcmd.c - 664 sys sys 1146785267 1255
+1146785483 8 c sys/src/fs/port/sub.c - 664 sys sys 1146785401 25655
+1146787284 0 c sys/src/fs/pc/etherdp83820.c - 664 sys sys 1146355081 32045
+1146787284 1 c sys/src/fs/pc/sdscsi.c - 664 sys sys 1146786984 7017
+1146789084 0 c sys/src/fs/port/sub.c - 664 sys sys 1146787681 25595
+1146799887 0 c sys/src/fs/pc/scsincr53c8xx.c - 664 sys sys 1146798658 53619
+1146799887 1 c sys/src/fs/port/all.h - 664 sys sys 1146798594 1888
+1146799887 2 c sys/src/fs/port/lib.h - 664 sys sys 1146798595 3791

+ 13 - 17
sys/src/9/boot/boot.c

@@ -173,14 +173,15 @@ boot(int argc, char *argv[])
 	fatal(cmd);
 }
 
-Method*
+static Method*
 findmethod(char *a)
 {
 	Method *mp;
 	int i, j;
 	char *cp;
 
-	i = strlen(a);
+	if((i = strlen(a)) == 0)
+		return nil;
 	cp = strchr(a, '!');
 	if(cp)
 		i = cp - a;
@@ -193,7 +194,7 @@ findmethod(char *a)
 	}
 	if(mp->name)
 		return mp;
-	return 0;
+	return nil;
 }
 
 /*
@@ -237,23 +238,18 @@ rootserver(char *arg)
 		strcpy(reply, method->name);
 
 	/* parse replies */
-	for(;;){
+	do{
 		outin(prompt, reply, sizeof(reply));
-		if(strlen(reply) == 0)
-			continue;
 		mp = findmethod(reply);
-		if(mp){
-	    HaveMethod:
-			bargc = tokenize(reply, bargv, Nbarg-2);
-			bargv[bargc] = nil;
-			cp = strchr(reply, '!');
-			if(cp)
-				strcpy(sys, cp+1);
-			return mp;
-		}
-	}
+	}while(mp == nil);
 
-	return 0;		/* not reached */
+HaveMethod:
+	bargc = tokenize(reply, bargv, Nbarg-2);
+	bargv[bargc] = nil;
+	cp = strchr(reply, '!');
+	if(cp)
+		strcpy(sys, cp+1);
+	return mp;
 }
 
 static void

+ 7 - 7
sys/src/9/pc/sdscsi.c

@@ -130,10 +130,10 @@ scsirio(SDreq* r)
 	r->status = ~0;
 	switch(r->unit->dev->ifc->rio(r)){
 	default:
-		return -1;
+		break;
 	case SDcheck:
 		if(!(r->flags & SDvalidsense))
-			return -1;
+			break;
 		switch(r->sense[2] & 0x0F){
 		case 0x00:		/* no sense */
 		case 0x01:		/* recovered error */
@@ -148,16 +148,16 @@ scsirio(SDreq* r)
 				return 2;
 			if(r->sense[12] == 0x29)
 				return 2;
-			return -1;
+			break;
 		case 0x02:		/* not ready */
 			/*
 			 * If no medium present, bail out.
 			 * If unit is becoming ready, rather than not
 			 * not ready, wait a little then poke it again. 				 */
 			if(r->sense[12] == 0x3A)
-				return 1;
+				break;
 			if(r->sense[12] != 0x04 || r->sense[13] != 0x01)
-				return -1;
+				break;
 
 			while(waserror())
 				;
@@ -166,9 +166,9 @@ scsirio(SDreq* r)
 			scsitest(r);
 			return 2;
 		default:
-			return -1;
+			break;
 		}
-		return -1;
+		break;
 	case SDok:
 		return 0;
 	}

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

@@ -210,8 +210,7 @@ timersinit(void)
 	Timer *t;
 
 	/*
-	 * This is only called on the bootstrap processor; hence,
-	 * the Hzclock will only be active on that processor
+	 * T->tf == nil means the HZ clock for this processor.
 	 */
 	todinit();
 	t = malloc(sizeof(*t));

+ 0 - 1
sys/src/9/port/portfns.h

@@ -334,7 +334,6 @@ ulong		tk2ms(ulong);
 #define		TK2MS(x) ((x)*(1000/HZ))
 uvlong		tod2fastticks(vlong);
 vlong		todget(vlong*);
-void		todfix(void);
 void		todsetfreq(vlong);
 void		todinit(void);
 void		todset(vlong, vlong, int);

+ 11 - 7
sys/src/9/port/tod.c

@@ -5,8 +5,9 @@
 #include	"fns.h"
 #include	"../port/error.h"
 
-/* compute nanosecond epoch time from the fastest ticking clock
- * on the system.  converting the time to nanoseconds requires
+/*
+ * Compute nanosecond epoch time from the fastest ticking clock
+ * on the system.  Converting the time to nanoseconds requires
  * the following formula
  *
  *	t = (((1000000000<<31)/f)*ticks)>>31
@@ -30,11 +31,11 @@
  */
 
 /* frequency of the tod clock */
-#define TODFREQ	1000000000ULL
+#define TODFREQ		1000000000ULL
 #define MicroFREQ	1000000ULL
 
 struct {
-	int		init;		// true if initialized
+	int	init;		// true if initialized
 	ulong	cnt;
 	Lock;
 	uvlong	multiplier;	// ns = off + (multiplier*ticks)>>31
@@ -50,6 +51,8 @@ struct {
 	ulong	send;		// ...
 } tod;
 
+static void todfix(void);
+
 void
 todinit(void)
 {
@@ -180,7 +183,7 @@ tod2fastticks(vlong ns)
 /*
  *  called regularly to avoid calculation overflows
  */
-void
+static void
 todfix(void)
 {
 	vlong ticks, diff;
@@ -239,8 +242,9 @@ us2fastticks(uvlong us)
 	return res;
 }
 
-//  convert milliseconds to fast ticks
-//
+/*
+ *  convert milliseconds to fast ticks
+ */
 uvlong
 ms2fastticks(ulong ms)
 {

+ 32 - 29
sys/src/fs/pc/dosfs.c

@@ -24,7 +24,7 @@ struct Clustbuf
 {
 	int	flags;
 	int	age;
-	long	sector;
+	Devsize	sector;
 	uchar *	iobuf;
 	Dos *	dos;
 	int	size;
@@ -50,11 +50,12 @@ static void
 writeclust(Clustbuf *p)
 {
 	Dos *dos;
-	int addr;
+	Off addr;
 
 	dos = p->dos;
 	addr = (p->sector+dos->start)*dos->sectbytes;
-	chat("writeclust @ %ld addr %d...", p->sector, addr);
+	chat("writeclust @ %lld addr %lld...", (Wideoff)p->sector,
+		(Wideoff)addr);
 	if((*dos->seek)(dos->dev, addr) < 0)
 		panic("writeclust: seek");
 	if((*dos->write)(dos->dev, p->iobuf, p->size) != p->size)
@@ -83,11 +84,11 @@ syncclust(void)
  *  get an io buffer, possibly with valid data
  */
 static Clustbuf*
-getclust0(Dos *dos, long sector)
+getclust0(Dos *dos, Off sector)
 {
 	Clustbuf *p, *oldest;
 
-	chat("getclust0 @ %ld\n", sector);
+	chat("getclust0 @ %lld\n", (Wideoff)sector);
 
 	/*
 	 *  if we have it, just return it
@@ -98,7 +99,7 @@ getclust0(Dos *dos, long sector)
 		if(sector == p->sector && dos == p->dos){
 			if(p->flags & LOCKED)
 				panic("getclust0 locked");
-			chat("getclust0 %ld in cache\n", sector);
+			chat("getclust0 %lld in cache\n", (Wideoff)sector);
 			p->flags |= LOCKED;
 			return p;
 		}
@@ -133,10 +134,10 @@ getclust0(Dos *dos, long sector)
  *  get an io block from an io buffer
  */
 static Clustbuf*
-getclust(Dos *dos, long sector)
+getclust(Dos *dos, Off sector)
 {
 	Clustbuf *p;
-	int addr;
+	Off addr;
 
 	p = getclust0(dos, sector);
 	if(p->dos){
@@ -144,12 +145,12 @@ getclust(Dos *dos, long sector)
 		return p;
 	}
 	addr = (sector+dos->start)*dos->sectbytes;
-	chat("getclust seek addr %d\n", addr);
+	chat("getclust seek addr %lld\n", (Wideoff)addr);
 	if((*dos->seek)(dos->dev, addr) < 0){
 		chat("can't seek block\n");
 		return 0;
 	}
-	chat("getclust read addr %d\n", addr);
+	chat("getclust read addr %lld\n", (Wideoff)addr);
 	if((*dos->read)(dos->dev, p->iobuf, p->size) != p->size){
 		chat("can't read block\n");
 		return 0;
@@ -158,7 +159,7 @@ getclust(Dos *dos, long sector)
 	p->age = MACHP(0)->ticks;
 	p->dos = dos;
 	p->sector = sector;
-	chat("getclust %ld read\n", sector);
+	chat("getclust %lld read\n", (Wideoff)sector);
 	return p;
 }
 
@@ -167,7 +168,7 @@ getclust(Dos *dos, long sector)
  *  any current data is discarded.
  */
 static Clustbuf*
-getclustz(Dos *dos, long sector)
+getclustz(Dos *dos, Off sector)
 {
 	Clustbuf *p;
 
@@ -177,7 +178,7 @@ getclustz(Dos *dos, long sector)
 	p->sector = sector;
 	memset(p->iobuf, 0, p->size);
 	p->flags |= MOD;
-	chat("getclustz %ld\n", sector);
+	chat("getclustz %lld\n", (Wideoff)sector);
 	return p;
 }
 
@@ -192,7 +193,7 @@ putclust(Clustbuf *p)
 	if((p->flags & (MOD|IMMED)) == (MOD|IMMED))
 		writeclust(p);
 	p->flags &= ~LOCKED;
-	chat("putclust @ sector %ld...", p->sector);
+	chat("putclust @ sector %lld...", (Wideoff)p->sector);
 }
 
 /*
@@ -252,7 +253,7 @@ fatwalk(Dos *dos, int n)
 static void
 fatwrite(Dos *dos, int n, int val)
 {
-	ulong k, sect;
+	Off k, sect;
 	Clustbuf *p;
 	int i, o;
 
@@ -343,13 +344,13 @@ fatalloc(Dos *dos)
  *  map a file's logical sector address to a physical sector address
  */
 static long
-fileaddr(Dosfile *fp, long ltarget, Clustbuf *pdir)
+fileaddr(Dosfile *fp, Off ltarget, Clustbuf *pdir)
 {
 	Dos *dos = fp->dos;
 	Dosdir *dp;
-	long p;
+	Off p;
 
-	chat("fileaddr %8.8s %ld\n", fp->name, ltarget);
+	chat("fileaddr %8.8s %lld\n", fp->name, (Wideoff)ltarget);
 	/*
 	 *  root directory is contiguous and easy
 	 */
@@ -357,7 +358,7 @@ fileaddr(Dosfile *fp, long ltarget, Clustbuf *pdir)
 		if(ltarget*dos->sectbytes >= dos->rootsize*sizeof(Dosdir))
 			return -1;
 		p = dos->rootaddr + ltarget;
-		chat("fileaddr %ld -> %ld\n", ltarget, p);
+		chat("fileaddr %lld -> %lld\n", (Wideoff)ltarget, (Wideoff)p);
 		return p;
 	}
 	if(fp->pstart == 0){	/* empty file */
@@ -366,7 +367,7 @@ fileaddr(Dosfile *fp, long ltarget, Clustbuf *pdir)
 		p = fatalloc(dos);
 		if(p <= 0)
 			return -1;
-		chat("fileaddr initial alloc %ld\n", p);
+		chat("fileaddr initial alloc %lld\n", (Wideoff)p);
 		dp = (Dosdir *)(pdir->iobuf + fp->odir);
 		puttime(dp);
 		dp->start[0] = p;
@@ -407,7 +408,7 @@ fileaddr(Dosfile *fp, long ltarget, Clustbuf *pdir)
 	 *  clusters start at 2 instead of 0 (why? - presotto)
 	 */
 	p = dos->dataaddr + (fp->pcurrent-2)*dos->clustsize;
-	chat("fileaddr %ld -> %ld\n", ltarget, p);
+	chat("fileaddr %lld -> %lld\n", (Wideoff)ltarget, (Wideoff)p);
 	return p;
 }
 
@@ -456,7 +457,7 @@ doswalk(Dosfile *fp, char *name)
 	char dname[8], dext[3];
 	Clustbuf *p;
 	Dosdir *dp;
-	long o, addr;
+	Off o, addr;
 
 	if((fp->attr & DOSDIR) == 0){
 		chat("walking non-directory!\n");
@@ -635,7 +636,8 @@ dosinit(Dos *dos)
 	dos->root.attr = DOSDIR;
 	dos->root.length = dos->rootsize*sizeof(Dosdir);
 	dos->root.pstart = 0;
-	dos->root.pcurrent = dos->root.lcurrent = 0;
+	dos->root.lcurrent = 0;
+	dos->root.pcurrent = 0;
 	dos->root.offset = 0;
 
 	syncclust();
@@ -665,7 +667,7 @@ nextelem(char *path, char *elem)
 static void
 puttime(Dosdir *d)
 {
-	ulong secs;
+	Timet secs;
 	Rtc rtc;
 	ushort x;
 
@@ -694,8 +696,9 @@ dosopen(Dos *dos, char *path, Dosfile *fp)
 			print("%s not found\n", element);
 			return 0;
 		case 1:
-			print("found %s attr 0x%ux start 0x%lux len %ld\n",
-				element, fp->attr, fp->pstart, fp->length);
+			print("found %s attr 0x%ux start 0x%llux len %lld\n",
+				element, fp->attr, (Wideoff)fp->pstart,
+				(Wideoff)fp->length);
 			break;
 		}
 	}
@@ -710,7 +713,7 @@ dosopen(Dos *dos, char *path, Dosfile *fp)
 long
 dosread(Dosfile *fp, void *a, long n)
 {
-	long addr, k, o;
+	Off addr, k, o;
 	Clustbuf *p;
 	uchar *to;
 
@@ -755,7 +758,7 @@ dosread(Dosfile *fp, void *a, long n)
 long
 doswrite(Dosfile *fp, void *a, long n)
 {
-	long blksize, addr, k, o;
+	Off blksize, addr, k, o;
 	Clustbuf *p, *pdir;
 	Dosdir *dp;
 	uchar *from;
@@ -825,7 +828,7 @@ dostrunc(Dosfile *fp)
 {
 	Clustbuf *pdir;
 	Dosdir *dp;
-	int p, np;
+	Off p, np;
 
 	if(fp->attr & DOSDIR){
 		print("trunc dir\n");

+ 78 - 25
sys/src/fs/pc/etherdp83820.c

@@ -563,15 +563,17 @@ dp83820rbfree(Block *bp)
 static void
 dp83820halt(Ctlr* ctlr)
 {
-	int i;
+	int i, timeo;
 
 	ilock(&ctlr->ilock);
 	csr32w(ctlr, Imr, 0);
 	csr32w(ctlr, Ier, 0);
 	csr32w(ctlr, Cr, Rxd|Txd);
-	/* TODO: limit this; don't wait forever with a lock held */
-	while(csr32r(ctlr, Cr) & (Rxe|Txe))
-		;
+	for(timeo = 0; timeo < 1000; timeo++){
+		if(!(csr32r(ctlr, Cr) & (Rxe|Txe)))
+			break;
+		microdelay(1);
+	}
 	csr32w(ctlr, Mibc, Frz);
 	iunlock(&ctlr->ilock);
 
@@ -678,7 +680,8 @@ dp83820init(Ether* edev)
 		csr32w(ctlr, Rfcr, i);
 		csr32w(ctlr, Rfdr, (edev->ea[i+1]<<8)|edev->ea[i]);
 	}
-	csr32w(ctlr, Rfcr, Rfen|Aab|Apm);
+	/* for now, accept all multicast packets */
+	csr32w(ctlr, Rfcr, Rfen|Aab|Apm|Aam);
 
 	ctlr->rxcfg = Stripcrc|(((2*(ETHERMINTU+4))/8)<<RxdrthSHFT);
 	ctlr->imr |= Rxorn|Rxidle|Rxearly|Rxdesc|Rxok;
@@ -717,6 +720,12 @@ dp83820init(Ether* edev)
 	iunlock(&ctlr->ilock);
 }
 
+/* multicast already on, don't need to do anything */
+static void
+multicast(void*, uchar*, int)
+{
+}
+
 static void
 dp83820attach(Ether* edev)
 {
@@ -740,6 +749,7 @@ err:
 			free(ctlr->alloc);
 			ctlr->alloc = nil;
 		}
+		qunlock(&ctlr->alock);
 		nexterror();
 	}
 
@@ -767,7 +777,12 @@ err:
 	 * allocate receive Blocks+buffers, add all to receive Block+buffer pool
 	 */
 	for(ctlr->nrb = 0; ctlr->nrb < Nrb; ctlr->nrb++){
-		bp = iallocb(Rbsz);
+		if((bp = iallocb(Rbsz)) == nil) {
+			print(
+		"dp83820attach: iallocb failed with %d rcv bufs allocated\n",
+				ctlr->nrb);
+			error(Enomem);
+		}
 #ifdef FS
 		bp->flags |= Mbrcvbuf;
 #endif
@@ -860,17 +875,17 @@ dp83820interrupt(Ureg*, void* arg)
 	Ctlr *ctlr;
 	Desc *desc;
 	Ether *edev;
-	int i, isr, r, x, rcvd = 0;
+	int cmdsts, i, isr, r, x, rcvd = 0;
 
 	edev = arg;
 	ctlr = edev->ctlr;
 
 	for(isr = csr32r(ctlr, Isr); isr & ctlr->imr; isr = csr32r(ctlr, Isr)){
-		if(isr & (Rxorn|Rxidle|Rxearly|Rxdesc|Rxok)){
+		if(isr & (Rxorn|Rxidle|Rxearly|Rxerr|Rxdesc|Rxok)){
 			x = ctlr->rdx;
 			desc = &ctlr->rd[x];
-			while(desc->cmdsts & Own){
-				if((desc->cmdsts & Ok) && desc->bp != nil){
+			while((cmdsts = desc->cmdsts) & Own){
+				if((cmdsts & Ok) && desc->bp != nil){
 					/* unlink rcv. Block from Desc */
 					bp = desc->bp;
 					desc->bp = nil;
@@ -898,7 +913,19 @@ dp83820interrupt(Ureg*, void* arg)
 				ctlr->rxidle++;
 			}
 
-			isr &= ~(Rxorn|Rxidle|Rxearly|Rxdesc|Rxok);
+			isr &= ~(Rxorn|Rxidle|Rxearly|Rxerr|Rxdesc|Rxok);
+		}
+
+		if(isr & Txurn){
+			x = (ctlr->txcfg & TxdrthMASK)>>TxdrthSHFT;
+			r = (ctlr->txcfg & FlthMASK)>>FlthSHFT;
+			if(x < ((TxdrthMASK)>>TxdrthSHFT)
+			&& x < (2048/32 - r)){
+				ctlr->txcfg &= ~TxdrthMASK;
+				x++;
+				ctlr->txcfg |= x<<TxdrthSHFT;
+				csr32w(ctlr, Txcfg, ctlr->txcfg);
+			}
 		}
 
 		if(isr & (Txurn|Txidle|Txdesc|Txok)){
@@ -971,7 +998,7 @@ dp83820ifstat(Ether* edev, void* a, long n, ulong offset)
 		l += snprint(p+l, READSTR-l, " %4.4uX", ctlr->eeprom[i]);
 	}
 	l += snprint(p+l, READSTR-l, "\n");
-
+	USED(l);
 	if(0 && ctlr->mii != nil && (phy = ctlr->mii->curphy) != nil){
 		l += snprint(p+l, READSTR, "phy:");
 		for(i = 0; i < NMiiPhyr; i++){
@@ -1066,6 +1093,28 @@ reread:
 	return data;
 }
 
+static void
+resetctlr(Ctlr *ctlr)
+{
+	csr32w(ctlr, Cr, Rst);
+	delay(1);
+	/* TODO: limit this; don't wait forever */
+	while(csr32r(ctlr, Cr) & Rst)
+		delay(1);
+
+	atc93c46r(ctlr, 0);
+}
+
+static void
+shutdown(Ether* ether)
+{
+	Ctlr *ctlr = ether->ctlr;
+
+print("ether83820 shutting down\n");
+	csr32w(ctlr, Cr, Txd|Rxd);	/* disable transceiver */
+	resetctlr(ctlr);
+}
+
 int
 dp83820reset(Ctlr* ctlr)
 {
@@ -1078,13 +1127,7 @@ dp83820reset(Ctlr* ctlr)
 	 * of the Cfg and Gpior bits which should be cleared by
 	 * the reset.
 	 */
-	csr32w(ctlr, Cr, Rst);
-	delay(1);
-	/* TODO: limit this; don't wait forever */
-	while(csr32r(ctlr, Cr) & Rst)
-		delay(1);
-
-	atc93c46r(ctlr, 0);
+	resetctlr(ctlr);
 	sum = 0;
 	for(i = 0; i < 0x0E; i++){
 		r = atc93c46r(ctlr, i);
@@ -1151,7 +1194,7 @@ enum {
 static void
 dp83820pci(void)
 {
-	int port;
+	void *mem;
 	Pcidev *p;
 	Ctlr *ctlr;
 
@@ -1163,18 +1206,20 @@ dp83820pci(void)
 		switch((p->did<<16)|p->vid){
 		default:
 			continue;
-		case (0x0022<<16)|0x100B:	/* DP83820 (Gig-NIC) */
+		case (0x0022<<16)|0x100B:	/* NS DP83820 (Gig-NIC) */
+/*		case (0x1032<<16)|0x1737:	/* linksys eg1032 */
 			break;
 		}
 
-		port = upamalloc(p->mem[1].bar & ~0x0F, p->mem[1].size, 0);
-		if(port == 0){
+		/* cast for FS */
+		mem = (void *)vmap(p->mem[1].bar & ~0x0F, p->mem[1].size);
+		if(mem == 0){
 			print("DP83820: can't map %8.8lux\n", p->mem[1].bar);
 			continue;
 		}
 		/* malloc only zeroes storage if Npadlong!=0, so use mallocz */
 		ctlr = mallocz(sizeof(Ctlr), 1);
-		ctlr->port = port;
+		ctlr->port = p->mem[1].bar & ~0x0F;
 		ctlr->pcidev = p;
 		ctlr->id = (p->did<<16)|p->vid;
 
@@ -1190,7 +1235,7 @@ dp83820pci(void)
 			continue;
 		}
 #endif
-		ctlr->nic = KADDR(ctlr->port);
+		ctlr->nic = mem;
 		if(dp83820reset(ctlr)){
 			free(ctlr);
 			continue;
@@ -1255,6 +1300,8 @@ dp83820pnp(Ether* edev)
 #ifndef FS
 	edev->ifstat = dp83820ifstat;
 	edev->arg = edev;
+	edev->shutdown = shutdown;
+	edev->multicast = multicast;
 	edev->promiscuous = dp83820promiscuous;
 #endif
 	return 0;
@@ -1266,4 +1313,10 @@ etherdp83820link(void)
 {
 	addethercard("DP83820", dp83820pnp);
 }
+
+void
+etherdp83820bothlink(void)
+{
+	etherdp83820link();
+}
 #endif

+ 5 - 5
sys/src/fs/pc/etherga620.c

@@ -473,7 +473,7 @@ ga620interrupt(Ureg*, void* arg)
 			return;
 	}
 	if(DoCountTicks)
-		rdtsc(&tsc0);
+		cycles(&tsc0);
 
 	ctlr->interrupts++;
 	csr32w(ctlr, Hi, 1);
@@ -493,7 +493,7 @@ ga620interrupt(Ureg*, void* arg)
 	csr32w(ctlr, Hi, 0);
 
 	if(DoCountTicks){
-		rdtsc(&tsc1);
+		cycles(&tsc1);
 		ctlr->ticks += tsc1-tsc0;
 	}
 }
@@ -603,9 +603,9 @@ ga620init(Ether* edev)
 	sethost64(&ctlr->gib->srcb.addr, ctlr->sr);
 	if(DoHardwareCksum)
 		flags = TcpUdpCksum|NoPseudoHdrCksum|HostRing;
-	else 
+	else
 		flags = HostRing;
-	if(DoCoalUpdateOnly) 
+	if(DoCoalUpdateOnly)
 		flags |= CoalUpdateOnly;
 	ctlr->gib->srcb.control = (Nsr<<16)|flags;
 	sethost64(&ctlr->gib->scp, ctlr->sci);
@@ -693,7 +693,7 @@ ga620init(Ether* edev)
 	 * A unique index for this controller and the maximum packet
 	 * length expected.
 	 * For now only standard packets are expected.
-	 */ 
+	 */
 	csr32w(ctlr, Ifx, 1);
 	csr32w(ctlr, IfMTU, ETHERMAXTU+4);
 

+ 2 - 2
sys/src/fs/pc/pc.c

@@ -118,7 +118,7 @@ cistrcmp(char* a, char* b)
 	for(;;){
 		ac = *a++;
 		bc = *b++;
-	
+
 		if(ac >= 'A' && ac <= 'Z')
 			ac = 'a' + (ac - 'A');
 		if(bc >= 'A' && bc <= 'Z')
@@ -170,7 +170,7 @@ getconf(char *name)
 
 /* memory map */
 /* the file server kernel will only see MAXMEG megabytes of RAM at most.  */
-#define MAXMEG 1024
+#define MAXMEG 1791		/* 1.75GB-1MB, to avoid overshooting 1.75GB */
 
 char mmap[MAXMEG+2];
 Mconf mconf;

+ 32 - 26
sys/src/fs/pc/scsincr53c8xx.c

@@ -13,7 +13,7 @@
  * Read/write mismatch recovery may fail on 53c1010s. Really need to get a manual.
 */
 
-#define MAXTARGET	8		/* can be 8 or 16 */
+#define MAXTARGET	16		/* can be 8 or 16 */
 
 /* Define one or the other ... */
 //#define CPU
@@ -187,7 +187,7 @@ typedef struct Ncr {
 	uchar dcntl;
 
 	uchar adder[4];	/* 3c */
-	
+
 	uchar sien0;	/* 40 */
 	uchar sien1;
 	uchar sist0;
@@ -421,7 +421,7 @@ oprint(char *format, ...)
 		debuglast = debugbuf;
 	debuglast = doprint(debuglast, debugbuf + (DEBUGSIZE - 1), format, (&format + 1));
 	splx(s);
-	iflush();	
+	iflush();
 }
 #endif
 
@@ -510,7 +510,7 @@ dumpncrregs(Controller *c, int intr)
 		else
 			KPRINT("\n");
 	}
-}	
+}
 
 static int
 chooserate(Controller *c, int tpf, int *scfp, int *xferpp)
@@ -830,7 +830,7 @@ softreset(Controller *c)
 
 	n->stime0 = 0xdd;		/* about 0.5 second timeout on each device */
 	n->scntl0 |= 0x8;		/* Enable parity checking */
-	
+
 	/* continued setup */
 	n->sien0 = 0x8f;
 	n->sien1 = 0x04;
@@ -940,7 +940,7 @@ msgsm(Dsa *dsa, Controller *c, int msg, int *cont, int *wakeme)
 			return;
 		}
 		break;
-		
+
 	case NeitherDone:
 	case WideDone:
 	case BothDone:
@@ -1154,14 +1154,12 @@ write_mismatch_recover(Controller *c, Ncr *n, Dsa *dsa)
 static void
 interrupt(Ureg *ur, void *a)
 {
-	uchar istat;
+	int wakeme = 0, cont = -1;
+	uchar istat, dstat;
 	ushort sist;
-	uchar dstat;
-	int wakeme = 0;
-	int cont = -1;
-	Dsa *dsa;
 	Controller *c = a;
 	Ncr *n = c->n;
+	Dsa *dsa;
 
 	USED(ur);
 	if (DEBUG(1))
@@ -1197,8 +1195,11 @@ interrupt(Ureg *ur, void *a)
 
 	sist = (n->sist1<<8)|n->sist0;	/* BUG? can two-byte read be inconsistent? */
 	dstat = n->dstat;
+
 	dsa = (Dsa *)DMASEG_TO_KADDR(legetl(n->dsa));
 	c->running = 0;
+	if (dsa == nil || dsa == (Dsa *)-1)
+		panic("53c8xx: dsa == %ld in interrupt; bad controller", (long)dsa);
 	if (istat & Sip) {
 		if (DEBUG(1))
 			IPRINT("sist = %.4x\n", sist);
@@ -1285,7 +1286,7 @@ interrupt(Ureg *ur, void *a)
 				 * 2. It's not SCSI-II compliant. The new phase will be other
 				 *    than message_in. We should also indicate that the device
 				 *    is asynchronous, if it's the SDTR that got ignored
-				 * 
+				 *
 				 * For now, if the phase switch is not to message_in, and
 				 * and it happens after IDENTIFY and before SDTR, we
 				 * notify the negotiation state machine.
@@ -1500,13 +1501,18 @@ interrupt(Ureg *ur, void *a)
 			IPRINT("%.8lux %.8lux %.8lux\n",
 			    *(ulong *)(addr - 12), *(ulong *)(addr - 8), *(ulong *)(addr - 4));
 			USED(addr, dbc);
-			dsa->p9status = STATUS_FAIL;
+			if (dsa)
+				dsa->p9status = STATUS_FAIL;
 			wakeme = 1;
 		}
 		/*else*/ if (dstat & Bf) {
-			IPRINT(PRINTPREFIX "%d/%d: Bus Fault\n", dsa->target, dsa->lun);
+			if (dsa == nil)
+				print(PRINTPREFIX "Bus Fault with dsa==0\n");
+			else {
+				print(PRINTPREFIX "%d/%d: Bus Fault\n", dsa->target, dsa->lun);
+				dsa->p9status = STATUS_FAIL;
+			}
 			dumpncrregs(c, 1);
-			dsa->p9status = STATUS_FAIL;
 			wakeme = 1;
 		}
 	}
@@ -1514,7 +1520,7 @@ interrupt(Ureg *ur, void *a)
 		ncrcontinue(c);
 	else if (cont >= 0)
 		start(c, cont);
-	if (wakeme){
+	if (wakeme && dsa){
 		if(dsa->p9status == 0xffff)
 			dsa->p9status = STATUS_FAIL;
 		wakeup(dsa);
@@ -1531,8 +1537,6 @@ done(void *arg)
 	return ((Dsa *)arg)->p9status != 0xffff;
 }
 
-#define offsetof(s, t) ((ulong)&((s *)0)->t)
-
 static int
 xfunc(Controller *c, enum na_external x, unsigned long *v)
 {
@@ -1558,6 +1562,9 @@ xfunc(Controller *c, enum na_external x, unsigned long *v)
 	case X_dsa_head:
 		*v = DMASEG(&c->dsalist.head[0]);
 		break;
+	case X_ssid_mask:
+		*v = SSIDMASK(c);
+		break;
 	}
 	return 1;
 }
@@ -1675,7 +1682,7 @@ io(Controller *c, uchar target, uchar lun, int rw, uchar *cmd, int cmdlen, uchar
 	d->scsi_id_buf[2] = target;
 	d->scsi_id_buf[3] = c->scntl3[target];
 	synctodsa(d, c);
-	
+
 	bc = 0;
 
 	d->msg_out[bc] = 0x80 | lun;
@@ -1744,7 +1751,7 @@ io(Controller *c, uchar target, uchar lun, int rw, uchar *cmd, int cmdlen, uchar
 			dumpwritedata(data, datalen);
 	}
 
-	setmovedata(&d->status_buf, DMASEG(&d->status), 1);	
+	setmovedata(&d->status_buf, DMASEG(&d->status), 1);
 
 	d->p9status = 0xffff;
 	d->parityerror = 0;
@@ -1831,7 +1838,7 @@ exec(Scsi *p, int rw)
 	    p->cmd.base, p->cmd.lim - p->cmd.base,
 	    p->data.base, p->data.lim - p->data.base, &transferred);
 	p->data.ptr = p->data.base + transferred;
-	return p->status;	
+	return p->status;
 }
 #endif
 
@@ -1882,7 +1889,7 @@ cribbios(Controller *c)
 {
 	c->bios.scntl3 = c->n->scntl3;
 	c->bios.stest2 = c->n->stest2;
-	print(PRINTPREFIX "bios scntl3(%.2x) stest2(%.2x)\n", c->bios.scntl3, c->bios.stest2);
+	KPRINT(PRINTPREFIX "bios scntl3(%.2x) stest2(%.2x)\n", c->bios.scntl3, c->bios.stest2);
 }
 
 static int
@@ -2005,7 +2012,6 @@ scanpci(void)
 		ap = (Adapter*)mb->data;
 		ap->pcidev = p;
 		ap->port = p->mem[0].bar & ~0x01;
-
 		if(adapter == nil)
 			adapter = mb;
 		else
@@ -2100,7 +2106,7 @@ init(Controller* ctlr, ISAConf* isa, int differential)
 		 */
 		/*
 		 * should allocate memory and copy na_script into it for
-		 * multiple controllers here 
+		 * multiple controllers here
 		 * single controller version uses the microcode in place
 		 */
 		ctlr->script = na_script;
@@ -2123,10 +2129,10 @@ init(Controller* ctlr, ISAConf* isa, int differential)
 
 	isa->port = (ulong)KADDR(regpa);
 	isa->irq = pcidev->intl;
-	
+
 	synctabinit(ctlr);
 	cribbios(ctlr);
-	/*	
+	/*
 	intrenable(isa->irq, interrupt, ctlr, pcidev->tbdf);
 	 */
 	setvec(IRQBASE + isa->irq, interrupt, ctlr);

+ 0 - 2
sys/src/fs/pc/sdscsi.c

@@ -167,11 +167,9 @@ scsirio(SDreq* r)
 		default:
 			return -1;
 		}
-		return -1;
 	case SDok:
 		return 0;
 	}
-	return -1;
 }
 
 int

+ 79 - 86
sys/src/fs/port/9p2.c

@@ -1,7 +1,7 @@
 #include "all.h"
 
 /*
- * stuff from /sys/ninclude/libc.h for 9P2000
+ * stuff from /sys/include/libc.h for 9P2000
  */
 #define	STATMAX	65535U	/* max length of machine-independent stat structure */
 #define	DIRMAX	(sizeof(Dir)+STATMAX)	/* max length of Dir structure */
@@ -60,7 +60,7 @@ void
 mkqid9p1(Qid9p1* qid9p1, Qid* qid)
 {
 	if(qid->path & 0xFFFFFFFF00000000LL)
-		panic("mkqid9p1: path %lluX\n", qid->path);
+		panic("mkqid9p1: path %lluX\n", (Wideoff)qid->path);
 	qid9p1->path = qid->path & 0xFFFFFFFF;
 	if(qid->type & QTDIR)
 		qid9p1->path |= QPDIR;
@@ -184,7 +184,6 @@ version(Chan* chan, Fcall* f, Fcall* r)
 		r->version = "unknown";
 
 	fileinit(chan);
-
 	return 0;
 }
 
@@ -204,7 +203,7 @@ auth(Chan* chan, Fcall* f, Fcall* r)
 
 	if(cons.flags & authdisableflag)
 		return Eauthdisabled;
-	
+
 	error = 0;
 	aname = f->aname;
 
@@ -238,7 +237,7 @@ auth(Chan* chan, Fcall* f, Fcall* r)
 		goto out;
 	}
 	r->aqid = file->qid;
-	
+
 out:
 	if((cons.flags & attachflag) && error)
 		print("9p2: auth %s %T SUCK EGGS --- %s\n",
@@ -248,7 +247,6 @@ out:
 		if(error)
 			freefp(file);
 	}
-
 	return error;
 }
 
@@ -260,7 +258,7 @@ authorize(Chan* chan, Fcall* f)
 	int db;
 
 	db = cons.flags & authdebugflag;
- 
+
 	if(strcmp(f->uname, "none") == 0){
 		uid = strtouid(f->uname);
 		if(db)
@@ -312,7 +310,7 @@ attach(Chan* chan, Fcall* f, Fcall* r)
 	Dentry *d;
 	File *file;
 	Filsys *fs;
-	long raddr;
+	Off raddr;
 	int error, u;
 
 	aname = f->aname;
@@ -356,11 +354,8 @@ attach(Chan* chan, Fcall* f, Fcall* r)
 		error = Ealloc;
 		goto out;
 	}
-	if(iaccess(file, d, DEXEC)){
-		error = Eaccess;
-		goto out;
-	}
-	if(file->uid == 0 && fs->dev->type == Devro) {
+	if (iaccess(file, d, DEXEC) ||
+	    file->uid == 0 && fs->dev->type == Devro) {
 		/*
 		 * 'none' not allowed on dump
 		 */
@@ -395,7 +390,6 @@ out:
 		if(error)
 			freefp(file);
 	}
-
 	return error;
 }
 
@@ -437,7 +431,7 @@ walkname(File* file, char* wname, Qid* wqid)
 	Iobuf *p, *p1;
 	Dentry *d, *d1;
 	int error, slot;
-	long addr, qpath;
+	Off addr, qpath;
 
 	p = p1 = nil;
 
@@ -529,9 +523,8 @@ setdot:
 		}
 		for(slot = 0; slot < DIRPERBUF; slot++){
 			d1 = getdir(p1, slot);
-			if(!(d1->mode & DALLOC))
-				continue;
-			if(strncmp(wname, d1->name, NAMELEN) != 0)
+			if (!(d1->mode & DALLOC) ||
+			    strncmp(wname, d1->name, NAMELEN) != 0)
 				continue;
 			/*
 			 * update walk path
@@ -841,7 +834,7 @@ create(Chan* chan, Fcall* f, Fcall* r)
 	Dentry *d, *d1;
 	File *file;
 	int error, slot, slot1, fmod, wok;
-	long addr, addr1, path;
+	Off addr, addr1, path;
 	Tlock *t;
 	Wpath *w;
 
@@ -1044,7 +1037,8 @@ read(Chan* chan, Fcall* f, Fcall* r, uchar* data)
 	File *file;
 	Dentry *d, *d1;
 	Tlock *t;
-	long addr, offset, start, tim;
+	Off addr, offset, start;
+	Timet tim;
 	int error, iounit, nread, count, n, o, slot;
 	Msgbuf *dmb;
 	Dir dir;
@@ -1159,59 +1153,58 @@ dread:
 	}
 
 	dmb = mballoc(iounit, chan, Mbreply1);
-
-dread1:
-	if(p == nil){
-		/*
-		 * This is just a check to ensure the entry hasn't
-		 * gone away during the read of each directory block.
-		 */
-		p = getbuf(file->fs->dev, file->addr, Bread);
-		if(p == nil || checktag(p, Tdir, QPNONE)){
-			error = Ealloc;
-			goto out1;
+	for (;;) {
+		if(p == nil){
+			/*
+			 * This is just a check to ensure the entry hasn't
+			 * gone away during the read of each directory block.
+			 */
+			p = getbuf(file->fs->dev, file->addr, Bread);
+			if(p == nil || checktag(p, Tdir, QPNONE)){
+				error = Ealloc;
+				goto out1;
+			}
+			d = getdir(p, file->slot);
+			if(d == nil || !(d->mode & DALLOC)){
+				error = Ealloc;
+				goto out1;
+			}
 		}
-		d = getdir(p, file->slot);
-		if(d == nil || !(d->mode & DALLOC)){
-			error = Ealloc;
+		p1 = dnodebuf1(p, d, addr, 0, file->uid);
+		p = nil;
+		if(p1 == nil)
 			goto out1;
-		}
-	}
-	p1 = dnodebuf1(p, d, addr, 0, file->uid);
-	p = nil;
-	if(p1 == nil)
-		goto out1;
-	if(checktag(p1, Tdir, QPNONE)){
-		error = Ephase;
-		putbuf(p1);
-		goto out1;
-	}
-
-	for(; slot < DIRPERBUF; slot++){
-		d1 = getdir(p1, slot);
-		if(!(d1->mode & DALLOC))
-			continue;
-		mkdir9p2(&dir, d1, dmb->data);
-		if((n = convD2M(&dir, data+nread, iounit - nread)) <= BIT16SZ){
+		if(checktag(p1, Tdir, QPNONE)){
+			error = Ephase;
 			putbuf(p1);
 			goto out1;
 		}
-		start += n;
-		if(start < offset)
-			continue;
-		if(count < n){
-			putbuf(p1);
-			goto out1;
+
+		for(; slot < DIRPERBUF; slot++){
+			d1 = getdir(p1, slot);
+			if(!(d1->mode & DALLOC))
+				continue;
+			mkdir9p2(&dir, d1, dmb->data);
+			n = convD2M(&dir, data+nread, iounit - nread);
+			if(n <= BIT16SZ){
+				putbuf(p1);
+				goto out1;
+			}
+			start += n;
+			if(start < offset)
+				continue;
+			if(count < n){
+				putbuf(p1);
+				goto out1;
+			}
+			count -= n;
+			nread += n;
+			offset += n;
 		}
-		count -= n;
-		nread += n;
-		offset += n;
+		putbuf(p1);
+		slot = 0;
+		addr++;
 	}
-	putbuf(p1);
-	slot = 0;
-	addr++;
-	goto dread1;
-
 out1:
 	mbfree(dmb);
 	if(error == 0){
@@ -1244,7 +1237,8 @@ write(Chan* chan, Fcall* f, Fcall* r)
 	Dentry *d;
 	File *file;
 	Tlock *t;
-	long offset, addr, tim, qpath;
+	Off offset, addr, qpath;
+	Timet tim;
 	int count, error, nwrite, o, n;
 
 	error = 0;
@@ -1282,11 +1276,8 @@ write(Chan* chan, Fcall* f, Fcall* r)
 		goto out;
 	}
 
-	if((p = getbuf(file->fs->dev, file->addr, Bread|Bmod)) == nil){
-		error = Ealloc;
-		goto out;
-	}
-	if((d = getdir(p, file->slot)) == nil || !(d->mode & DALLOC)){
+	if ((p = getbuf(file->fs->dev, file->addr, Bread|Bmod)) == nil ||
+	    (d = getdir(p, file->slot)) == nil || !(d->mode & DALLOC)) {
 		error = Ealloc;
 		goto out;
 	}
@@ -1414,6 +1405,7 @@ stat(Chan* chan, Fcall* f, Fcall* r, uchar* data)
 	if((file = filep(chan, f->fid, 0)) == nil)
 		return Efid;
 	if(file->qid.type & QTAUTH){
+		memset(&dentry, 0, sizeof dentry);
 		d = &dentry;
 		mkqid9p1(&d->qid, &file->qid);
 		strcpy(d->name, "#¿");
@@ -1436,7 +1428,7 @@ stat(Chan* chan, Fcall* f, Fcall* r, uchar* data)
 		}
 		if(error = mkqidcmp(&file->qid, d))
 			goto out;
-	
+
 		if(d->qid.path == QPROOT)	/* stat of root gives time */
 			d->atime = time();
 	}
@@ -1462,7 +1454,7 @@ wstat(Chan* chan, Fcall* f, Fcall*, char* strs)
 	Iobuf *p, *p1;
 	Dentry *d, *d1;
 	File *file;
-	int error, gid, gl, muid, op, slot, tsync, uid;
+	int error, err, gid, gl, muid, op, slot, tsync, uid;
 	long addr;
 	Dir dir;
 
@@ -1591,19 +1583,16 @@ wstat(Chan* chan, Fcall* f, Fcall*, char* strs)
 	else
 		dir.mtime = d->mtime;
 
-	if(dir.length != ~0){
-		if(dir.length != d->size){
-			/*
-			 * Currently, can't change length.
-			op = 1;
-			 */
+	if(dir.length == ~(Off)0)
+		dir.length = d->size;
+	else {
+		if (dir.length < 0) {
 			error = Ewstatl;
 			goto out;
-		}
+		} else if(dir.length != d->size)
+			op = 1;
 		tsync = 0;
 	}
-	else
-		dir.length = d->size;
 
 	/*
 	 * Check for permission to change .mode, .mtime or .length,
@@ -1682,9 +1671,8 @@ wstat(Chan* chan, Fcall* f, Fcall*, char* strs)
 			}
 			for(slot = 0; slot < DIRPERBUF; slot++){
 				d = getdir(p, slot);
-				if(!(d->mode & DALLOC))
-					continue;
-				if(strncmp(dir.name, d->name, sizeof(d->name)))
+				if(!(d->mode & DALLOC) ||
+				   strncmp(dir.name, d->name, sizeof d->name))
 					continue;
 				error = Eexist;
 				goto out;
@@ -1753,6 +1741,11 @@ wstat(Chan* chan, Fcall* f, Fcall*, char* strs)
 		d->mode = mkmode9p1(dir.mode);
 		file->qid.type = mktype9p2(d->mode);
 		d->mtime = dir.mtime;
+		if (dir.length < d->size) {
+			err = dtrunclen(p, d, dir.length, uid);
+			if (error == 0)
+				error = err;
+		}
 		d->size = dir.length;
 		if(dir.name != d->name)
 			strncpy(d->name, dir.name, sizeof(d->name));

+ 0 - 1
sys/src/fs/port/all.h

@@ -5,7 +5,6 @@
 
 #define	CHAT(cp)	((cons.flags&chatflag)||(cp&&(((Chan*)cp)->flags&chatflag)))
 #define	QID9P1(a,b)	(Qid9p1){(a),(b)}
-#define	nelem(x)	(sizeof(x)/sizeof((x)[0]))
 
 #define	QPDIR		0x80000000L
 #define	QPNONE		0

+ 1 - 1
sys/src/fs/port/auth.c

@@ -210,7 +210,7 @@ struct	Auth
 	int	inuse;
 	char	uname[NAMELEN];	/* requestor's remote user name */
 	char	aname[NAMELEN];	/* requested aname */
-	short	uid;		/* uid decided on */
+	Userid	uid;		/* uid decided on */
 	int	phase;
 	char	cchal[CHALLEN];
 	char	tbuf[TICKETLEN+AUTHENTLEN];	/* server ticket */

+ 27 - 31
sys/src/fs/port/con.c

@@ -1,7 +1,7 @@
 #include	"all.h"
 #include	"mem.h"
 
-static	char	conline[100];
+static	char	conline[2*Maxword];
 static	Command	command[100];
 static	Flag	flag[35];
 static	void	installcmds(void);
@@ -104,7 +104,7 @@ cmd_install(char *arg0, char *help, void (*func)(int, char*[]))
 void
 cmd_exec(char *arg)
 {
-	char line[100], *s;
+	char line[2*Maxword], *s;
 	char *argv[10];
 	int argc, i, c;
 
@@ -420,8 +420,7 @@ static
 void
 cmd_date(int argc, char *argv[])
 {
-	ulong ct;
-	long t;
+	Timet ct, t;
 	char *arg;
 
 	if(argc <= 1)
@@ -556,23 +555,24 @@ cmd_disallow(int, char**)
 }
 
 void
-ckblock(Device *d, long a, int typ, long qpath)
+ckblock(Device *d, Off a, int typ, Off qpath)
 {
 	Iobuf *p;
 
 	if(a) {
 		p = getbuf(d, a, Bread);
-		checktag(p, typ, qpath);
-		if(p)
+		if(p) {
+			checktag(p, typ, qpath);
 			putbuf(p);
+		}
 	}
 }
 
 void
-doclean(Iobuf *p, Dentry *d, int n, long a)
+doclean(Iobuf *p, Dentry *d, int n, Off a)
 {
 	int i, mod, typ;
-	long qpath;
+	Off qpath;
 
 	mod = 0;
 	qpath = d->qid.path;
@@ -580,29 +580,24 @@ doclean(Iobuf *p, Dentry *d, int n, long a)
 	if(d->mode & DDIR)
 		typ = Tdir;
 	for(i=0; i<NDBLOCK; i++) {
-		print("dblock[%d] = %ld\n", i, d->dblock[i]);
+		print("dblock[%d] = %lld\n", i, (Wideoff)d->dblock[i]);
 		ckblock(p->dev, d->dblock[i], typ, qpath);
 		if(i == n) {
 			d->dblock[i] = a;
 			mod = 1;
-			print("dblock[%d] modified %ld\n", i, a);
+			print("dblock[%d] modified %lld\n", i, (Wideoff)a);
 		}
 	}
 
-	print("iblock[%d] = %ld\n", NDBLOCK, d->iblock);
-	ckblock(p->dev, d->iblock, Tind1, qpath);
-	if(NDBLOCK == n) {
-		d->iblock = a;
-		mod = 1;
-		print("iblock[%d] modified %ld\n", NDBLOCK, a);
-	}
-
-	print("diblock[%d] = %ld\n", NDBLOCK+1, d->diblock);
-	ckblock(p->dev, d->diblock, Tind2, qpath);
-	if(NDBLOCK+1 == n) {
-		d->diblock = a;
-		mod = 1;
-		print("diblock[%d] modified %ld\n", NDBLOCK+1, a);
+	/* add NDBLOCK so user can cite block address by index */
+	for (i = 0; i < NIBLOCK; i++) {
+		print("iblocks[%d] = %lld\n", NDBLOCK+i, (Wideoff)d->iblocks[i]);
+		ckblock(p->dev, d->iblocks[i], Tind1+i, qpath);
+		if(NDBLOCK+i == n) {
+			d->iblocks[i] = a;
+			mod = 1;
+			print("iblocks[%d] modified %lld\n", NDBLOCK+i, (Wideoff)a);
+		}
 	}
 
 	if(mod)
@@ -614,7 +609,7 @@ void
 cmd_clean(int argc, char *argv[])
 {
 	int n;
-	long a;
+	Off a;
 	Iobuf *p;
 	Dentry *d;
 	File *f;
@@ -674,8 +669,8 @@ void
 cmd_version(int, char *[])
 {
 
-	print("%s as of %T\n", service, mktime);
-	print("	last boot %T\n", boottime);
+	print("%d-bit %s as of %T\n", sizeof(Off)*8 - 1, service, mktime);
+	print("\tlast boot %T\n", boottime);
 }
 
 static
@@ -760,7 +755,7 @@ static
 void
 cmd_time(int argc, char *argv[])
 {
-	long t1, t2;
+	Timet t1, t2;
 	int i;
 
 	t1 = MACHP(0)->ticks;
@@ -886,11 +881,12 @@ walkto(char *name)
 	}
 }
 
-long
+/* needs to parse and return vlongs to cope with new larger block numbers */
+vlong
 number(char *arg, int def, int base)
 {
 	int c, sign, any;
-	long n;
+	vlong n;
 
 	if(arg == 0)
 		return def;

+ 2 - 0
sys/src/fs/port/lib.h

@@ -1,6 +1,8 @@
 /*
  * functions (possibly) linked in, complete, from libc.
  */
+#define	nelem(x)	(sizeof(x)/sizeof((x)[0]))
+#define offsetof(s, m)	(ulong)(&(((s*)0)->m))
 
 /*
  * mem routines

File diff suppressed because it is too large
+ 375 - 306
sys/src/fs/port/sub.c


Some files were not shown because too many files changed in this diff