Browse Source

Plan 9 from Bell Labs 2011-05-27

David du Colombier 13 years ago
parent
commit
fc959f39d9

+ 2 - 0
sys/lib/sysconfig/usb/plan9.ini

@@ -1,3 +1,5 @@
+console=0
+
 bootfile=sdB0!9fat!9pccpuf.gz
 nobootprompt=local!/dev/sdXX/fossil
 nvram=/dev/sdXX/nvram

+ 3 - 1
sys/man/2/getfields

@@ -28,7 +28,9 @@ fields of the null terminated
 .SM UTF
 string
 .IR str .
-Delimiters between these fields are set to null.
+Delimiters between these fields are set to
+.SM NUL
+bytes.
 .PP
 Fields are substrings of
 .I str

+ 1 - 1
sys/man/8/mkusbboot

@@ -48,7 +48,7 @@ The image contains
 and
 .IR fossil (4)
 file systems and is configured to be bootable
-as a CPU server on
+as a CPU server with serial console on
 .B 386
 (with optional VGA)
 or

+ 1 - 1
sys/src/9/pc/devether.c

@@ -508,7 +508,7 @@ ethershutdown(void)
 		if(ether == nil)
 			continue;
 		if(ether->shutdown == nil) {
-			print("#l%d: no shutdown fuction\n", i);
+			print("#l%d: no shutdown function\n", i);
 			continue;
 		}
 		(*ether->shutdown)(ether);

+ 14 - 4
sys/src/9/pc/ether79c970.c

@@ -306,6 +306,18 @@ multicast(void* arg, uchar*, int)
 	promiscuous(arg, 1);
 }
 
+static void
+shutdown(Ether *ether)
+{
+	Ctlr *ctlr;
+
+	ctlr = ether->ctlr;
+	ilock(ctlr);
+	io32r(ctlr, Sreset);
+	io16r(ctlr, Sreset);
+	unlock(ctlr);
+}
+
 static void
 txstart(Ether* ether)
 {
@@ -514,12 +526,10 @@ reset(Ether* ether)
 	ether->irq = ctlr->pcidev->intl;
 	ether->tbdf = ctlr->pcidev->tbdf;
 	pcisetbme(ctlr->pcidev);
+	shutdown(ether);
 	ilock(ctlr);
 	ctlr->init = 1;
 
-	io32r(ctlr, Sreset);
-	io16r(ctlr, Sreset);
-
 	if(io16w(ctlr, Rap, 0), io16r(ctlr, Rdp) == 4){
 		ctlr->ior = io16r;
 		ctlr->iow = io16w;
@@ -634,7 +644,7 @@ reset(Ether* ether)
 	ether->arg = ether;
 	ether->promiscuous = promiscuous;
 	ether->multicast = multicast;
-//	ether->shutdown = shutdown;
+	ether->shutdown = shutdown;
 
 	return 0;
 }

+ 13 - 1
sys/src/9/pc/ether8139.c

@@ -379,6 +379,18 @@ rtl8139halt(Ctlr* ctlr)
 	}
 }
 
+static void
+rtl8139shutdown(Ether *edev)
+{
+	Ctlr *ctlr;
+
+	ctlr = edev->ctlr;
+	ilock(&ctlr->ilock);
+	rtl8139halt(ctlr);
+	rtl8139reset(ctlr);
+	iunlock(&ctlr->ilock);
+}
+
 static void
 rtl8139init(Ether* edev)
 {
@@ -815,7 +827,7 @@ rtl8139pnp(Ether* edev)
 	edev->arg = edev;
 	edev->promiscuous = rtl8139promiscuous;
 	edev->multicast = rtl8139multicast;
-//	edev->shutdown = rtl8139shutdown;
+	edev->shutdown = rtl8139shutdown;
 
 	/*
 	 * This should be much more dynamic but will do for now.

+ 7 - 1
sys/src/9/pc/ether8169.c

@@ -613,6 +613,12 @@ rtl8169reset(Ctlr* ctlr)
 	return 0;
 }
 
+static void
+rtl8169shutdown(Ether *ether)
+{
+	rtl8169reset(ether->ctlr);
+}
+
 static void
 rtl8169replenish(Ctlr* ctlr)
 {
@@ -1231,7 +1237,7 @@ rtl8169pnp(Ether* edev)
 	edev->arg = edev;
 	edev->promiscuous = rtl8169promiscuous;
 	edev->multicast = rtl8169multicast;
-//	edev->shutdown = rtl8169shutdown;
+	edev->shutdown = rtl8169shutdown;
 
 	rtl8169link(edev);
 

+ 1 - 0
sys/src/9/pc/ethersmc.c

@@ -769,6 +769,7 @@ reset(Ether* ether)
 	ether->ifstat = ifstat;
 	ether->promiscuous = promiscuous;
 	ether->multicast = multicast;
+	ether->shutdown = chipreset;
 	ether->arg = ether;
 	iunlock(ctlr);
 	return 0;

+ 7 - 1
sys/src/9/pc/ethervgbe.c

@@ -1109,6 +1109,12 @@ vgbemulticast(void*, uchar*, int)
 {
 }
 
+static void
+vgbeshutdown(Ether* ether)
+{
+	vgbereset(ether->ctlr);
+}
+
 static int
 vgbepnp(Ether* edev)
 {
@@ -1146,7 +1152,7 @@ vgbepnp(Ether* edev)
 	edev->ifstat = vgbeifstat;
 //	edev->promiscuous = vgbepromiscuous;
 	edev->multicast = vgbemulticast;
-//	edev->shutdown = vgbeshutdown;
+	edev->shutdown = vgbeshutdown;
 	edev->ctl = vgbectl;
 
 	edev->arg = edev;

+ 13 - 0
sys/src/9/pc/wavelan.c

@@ -1173,6 +1173,18 @@ w_interrupt(Ureg* ,void* arg)
 	iunlock(ctlr);
 }
 
+static void
+w_shutdown(Ether* ether)
+{
+	Ctlr *ctlr;
+
+	ctlr = ether->ctlr;
+	w_intdis(ctlr);
+	if(w_cmd(ctlr,WCmdIni,0))
+		iprint("#l%d: init failed\n", ether->ctlrno);
+	w_intdis(ctlr);
+}
+
 int
 wavelanreset(Ether* ether, Ctlr *ctlr)
 {
@@ -1239,6 +1251,7 @@ wavelanreset(Ether* ether, Ctlr *ctlr)
 	ether->power = w_power;
 	ether->promiscuous = w_promiscuous;
 	ether->multicast = w_multicast;
+	ether->shutdown = w_shutdown;
 	ether->scanbs = w_scanbs;
 	ether->arg = ether;
 

+ 5 - 5
sys/src/9/port/devproc.c

@@ -132,16 +132,16 @@ static char *sname[]={ "Text", "Data", "Bss", "Stack", "Shared", "Phys", };
 
 /*
  * Qids are, in path:
- *	 4 bits of file type (qids above)
- *	23 bits of process slot number + 1
+ *	 5 bits of file type (qids above)
+ *	26 bits of process slot number + 1
  *	     in vers,
  *	32 bits of pid, for consistency checking
  * If notepg, c->pgrpid.path is pgrp slot, .vers is noteid.
  */
 #define	QSHIFT	5	/* location in qid of proc slot # */
 
-#define	QID(q)		((((ulong)(q).path)&0x0000001F)>>0)
-#define	SLOT(q)		(((((ulong)(q).path)&0x07FFFFFE0)>>QSHIFT)-1)
+#define	QID(q)		((((ulong)(q).path) & ((1<<QSHIFT)-1)) >> 0)
+#define	SLOT(q)		(((((ulong)(q).path) & ~(1UL<<31)) >> QSHIFT) - 1)
 #define	PID(q)		((q).vers)
 #define	NOTEID(q)	((q).vers)
 
@@ -288,7 +288,7 @@ _proctrace(Proc* p, Tevent etype, vlong ts)
 static void
 procinit(void)
 {
-	if(conf.nproc >= (1<<(16-QSHIFT))-1)
+	if(conf.nproc >= (1<<(31-QSHIFT))-1)
 		print("warning: too many procs for devproc\n");
 	addclock0link((void (*)(void))profclock, 113);	/* Relative prime to HZ */
 }

+ 3 - 1
sys/src/cmd/ip/tftpd.c

@@ -54,6 +54,7 @@ enum
 	 * notably IP/UDP and TFTP, using worst-case (IPv6) sizes.
 	 */
 	Bandtblksz	= Bandtmtu - 40 - 8,
+	Bcavium		= 1432,		/* cavium's u-boot demands this size */
 };
 
 typedef struct Opt Opt;
@@ -282,10 +283,11 @@ options(int fd, char *buf, char *file, ushort oper, char *p, int dlen)
 			 * (1400 bytes for tcp mss of 1300 bytes),
 			 * so offer at most bandt's mtu minus headers,
 			 * to avoid failure of pxe booting via viaduct.
+			 * there's an exception for the cavium's u-boot.
 			 */
 			else if (oper == Tftp_READ &&
 			    cistrcmp(p, "blksize") == 0 &&
-			    blksize > Bandtblksz) {
+			    blksize > Bandtblksz && blksize != Bcavium) {
 				blksize = Bandtblksz;
 				sprint(bp, "%d", blksize);
 				syslog(dbg, flog,

+ 23 - 12
sys/src/libauthsrv/readnvram.c

@@ -137,7 +137,7 @@ static char *nvrfile = nil, *cputype = nil;
 static void
 findnvram(Nvrwhere *locp)
 {
-	char *nvrlen, *nvroff, *v[2];
+	char *nvrlen, *nvroff, *nvrcopy, *v[2];
 	int fd, i, safeoff, safelen;
 
 	if (nvrfile == nil)
@@ -156,7 +156,8 @@ findnvram(Nvrwhere *locp)
 	safelen = -1;
 	if(nvrfile != nil && *nvrfile != '\0'){
 		/* accept device and device!file */
-		i = gettokens(nvrfile, v, nelem(v), "!");
+		nvrcopy = strdup(nvrfile);
+		i = gettokens(nvrcopy, v, nelem(v), "!");
 		if (i < 1) {
 			i = 1;
 			v[0] = "";
@@ -185,9 +186,10 @@ findnvram(Nvrwhere *locp)
 				fd = -1;
 			}
 		}
+		free(nvrcopy);
 		free(nvroff);
 		free(nvrlen);
-	}else
+	}else{
 		for(i=0; i<nelem(nvtab); i++){
 			if(strcmp(cputype, nvtab[i].cputype) != 0)
 				continue;
@@ -203,8 +205,12 @@ findnvram(Nvrwhere *locp)
 					continue;
 				}
 			}
+			nvrfile = strdup(nvtab[i].file);
 			break;
 		}
+		if(i >= nelem(nvtab))		/* tried them all? */
+			werrstr("");		/* ignore failed opens */
+	}
 	locp->fd = fd;
 	locp->safelen = safelen;
 	locp->safeoff = safeoff;
@@ -231,7 +237,7 @@ readnvram(Nvrsafe *safep, int flag)
 	else if (loc.safelen > sizeof buf)
 		loc.safelen = sizeof buf;
 	if (loc.safeoff < 0) {
-		fprint(2, "readnvram: couldn't find nvram\n");
+		fprint(2, "readnvram: can't find nvram\n");
 		if(!(flag&NVwritemem))
 			memset(safep, 0, sizeof(*safep));
 		safe = safep;
@@ -245,14 +251,18 @@ readnvram(Nvrsafe *safep, int flag)
 		safe = safep;
 	else {
 		memset(safep, 0, sizeof(*safep));
+		werrstr("");
 		if(loc.fd < 0
 		|| seek(loc.fd, loc.safeoff, 0) < 0
 		|| read(loc.fd, buf, loc.safelen) != loc.safelen){
 			err = 1;
 			if(flag&(NVwrite|NVwriteonerr))
-				if(loc.fd < 0)
+				if(loc.fd < 0 && nvrfile != nil)
 					fprint(2, "can't open %s: %r\n", nvrfile);
-				else if (seek(loc.fd, loc.safeoff, 0) < 0)
+				else if(loc.fd < 0){
+					/* this will have been printed above */
+					// fprint(2, "can't find nvram: %r\n");
+				}else if (seek(loc.fd, loc.safeoff, 0) < 0)
 					fprint(2, "can't seek %s to %d: %r\n",
 						nvrfile, loc.safeoff);
 				else
@@ -267,9 +277,9 @@ readnvram(Nvrsafe *safep, int flag)
 
 			/* verify data read */
 			err |= check(safe->machkey, DESKEYLEN, safe->machsum,
-						"bad nvram key");
+						"bad authentication password");
 //			err |= check(safe->config, CONFIGLEN, safe->configsum,
-//						"bad secstore key");
+//						"bad secstore password");
 			err |= check(safe->authid, ANAMELEN, safe->authidsum,
 						"bad authentication id");
 			err |= check(safe->authdom, DOMLEN, safe->authdomsum,
@@ -288,15 +298,15 @@ readnvram(Nvrsafe *safep, int flag)
 					sizeof safe->authid);
 			readcons("authdom", nil, 0, safe->authdom,
 					sizeof safe->authdom);
-			readcons("secstore key", nil, 1, safe->config,
-					sizeof safe->config);
 			for(;;){
-				if(readcons("password", nil, 1, in, sizeof in)
-				    == nil)
+				if(readcons("auth password", nil, 1, in,
+				    sizeof in) == nil)
 					goto Out;
 				if(passtokey(safe->machkey, in))
 					break;
 			}
+			readcons("secstore password", nil, 1, safe->config,
+					sizeof safe->config);
 		}
 
 		// safe->authsum = nvcsum(safe->authkey, DESKEYLEN);
@@ -306,6 +316,7 @@ readnvram(Nvrsafe *safep, int flag)
 		safe->authdomsum = nvcsum(safe->authdom, sizeof safe->authdom);
 
 		*(Nvrsafe*)buf = *safe;
+		werrstr("");
 		if(loc.fd < 0
 		|| seek(loc.fd, loc.safeoff, 0) < 0
 		|| write(loc.fd, buf, loc.safelen) != loc.safelen){