Browse Source

Plan 9 from Bell Labs 2011-03-19

David du Colombier 13 years ago
parent
commit
0621e58fc6

+ 2 - 1
sys/src/9/ip/tcp.c

@@ -2484,7 +2484,8 @@ tcpoutput(Conv *s)
 			usable = tcb->cwind;
 			if(tcb->snd.wnd < usable)
 				usable = tcb->snd.wnd;
-			usable -= sent;
+//			usable -= sent;
+			usable = usable >= sent? usable - sent: 0;
 		}
 		ssize = sndcnt-sent;
 		if(ssize && usable < 2)

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

@@ -1,5 +1,5 @@
 /*
- * Realtek RTL8110S/8169S.
+ * Realtek RTL8110S/8169S Gigabit Ethernet Controllers.
  * Mostly there. There are some magic register values used
  * which are not described in any datasheet or driver but seem
  * to be necessary.

+ 3 - 4
sys/src/9/pc/usbehcipc.c

@@ -191,19 +191,18 @@ scanpci(void)
 				ctlrs[i] = ctlr;
 				break;
 			}
-		if(i == Nhcis)
+		if(i >= Nhcis)
 			print("ehci: bug: more than %d controllers\n", Nhcis);
 
 		/*
 		 * currently, if we enable a second ehci controller,
 		 * we'll wedge solid after iunlock in init for the second one.
 		 */
-		if (i > 0 && i < Nhcis) {
+		if (i > 0) {
 //			iprint("usbehci: ignoring controllers after the first, "
 //				"at %#p\n", io);
 //			ctlrs[i] = nil;
-			iprint("usbehci: multiple controllers, "
-				"unclear how this can work\n");
+			iprint("usbehci: multiple controllers present\n");
 		}
 	}
 }

+ 2 - 0
sys/src/cmd/auth/mkfile

@@ -3,6 +3,7 @@
 #		programs
 #
 TARG=\
+	as\
 	asn12dsa\
 	asn12rsa\
 	authsrv\
@@ -24,6 +25,7 @@ TARG=\
 	pemdecode\
 	pemencode\
 	printnetkey\
+	readnvram\
 	rsa2csr\
 	rsa2pub\
 	rsa2ssh\

+ 36 - 0
sys/src/cmd/auth/readnvram.c

@@ -0,0 +1,36 @@
+/* readnvram */
+#include <u.h>
+#include <libc.h>
+#include <auth.h>
+#include <authsrv.h>
+
+void
+main(int, char **)
+{
+	int i;
+	Nvrsafe safe;
+
+	quotefmtinstall();
+
+	memset(&safe, 0, sizeof safe);
+	/*
+	 * readnvram can return -1 meaning nvram wasn't written,
+	 * but safe still holds good data.
+	 */
+	if(readnvram(&safe, 0) < 0 && safe.authid[0] == '\0') 
+		sysfatal("readnvram: %r");
+
+	/*
+	 *  only use nvram key if it is non-zero
+	 */
+	for(i = 0; i < DESKEYLEN; i++)
+		if(safe.machkey[i] != 0)
+			break;
+	if(i == DESKEYLEN)
+		sysfatal("bad key");
+
+	fmtinstall('H', encodefmt);
+	print("key proto=p9sk1 user=%q dom=%q !hex=%.*H !password=______\n", 
+		safe.authid, safe.authdom, DESKEYLEN, safe.machkey);
+	exits(0);
+}

+ 1 - 1
sys/src/cmd/ip/snoopy/dns.c

@@ -350,7 +350,7 @@ freealldn(void)
 	}
 }
 
-
+int debug;				/* for ndb/dns.h */
 ulong now = 0;
 
 void

+ 57 - 0
sys/src/libc/mips/atom.s

@@ -0,0 +1,57 @@
+/*
+ *	R4000 user-level atomic operations
+ */
+
+#define	LL(base, rt)	WORD	$((060<<26)|((base)<<21)|((rt)<<16))
+#define	SC(base, rt)	WORD	$((070<<26)|((base)<<21)|((rt)<<16))
+#define	NOOP		WORD	$0x27
+
+TEXT ainc(SB), 1, $-4			/* long ainc(long *); */
+TEXT _xinc(SB), 1, $-4			/* void _xinc(long *); */
+	MOVW	R1, R2			/* address of counter */
+loop:	MOVW	$1, R3
+	LL(2, 1)
+	NOOP
+	ADD	R1,R3,R3
+	SC(2, 3)
+	NOOP
+	BEQ	R3,loop
+	RET
+
+TEXT adec(SB), 1, $-4			/* long adec(long*); */
+TEXT _xdec(SB), 1, $-4			/* long _xdec(long *); */
+	MOVW	R1, R2			/* address of counter */
+loop1:	MOVW	$-1, R3
+	LL(2, 1)
+	NOOP
+	ADD	R1,R3,R3
+	MOVW	R3, R1
+	SC(2, 3)
+	NOOP
+	BEQ	R3,loop1
+	RET
+
+/*
+ * int cas(uint* p, int ov, int nv);
+ */
+TEXT cas(SB), 1, $-4
+	MOVW	ov+4(FP), R2
+	MOVW	nv+8(FP), R3
+spincas:
+	LL(1, 4)			/* R4 = *R1 */
+	NOOP
+	BNE	R2, R4, fail
+	SC(1, 3)			/* *R1 = R3 */
+	NOOP
+	BEQ	R3, spincas		/* R3 == 0 means store failed */
+	MOVW	$1, R1
+	RET
+fail:
+	MOVW	$0, R1
+	RET
+
+/* general-purpose abort */
+_trap:
+	MOVD	$0, R0
+	MOVD	0(R0), R0
+	RET

+ 1 - 0
sys/src/libc/mips/mkfile

@@ -4,6 +4,7 @@ objtype=mips
 LIB=/$objtype/lib/libc.a
 SFILES=\
 	argv0.s\
+	atom.s\
 	getcallerpc.s\
 	getfcr.s\
 	main9.s\

+ 2 - 2
sys/src/libthread/ref.c

@@ -6,11 +6,11 @@
 void
 incref(Ref *r)
 {
-	_xinc(&r->ref);
+	ainc(&r->ref);
 }
 
 long
 decref(Ref *r)
 {
-	return _xdec(&r->ref);
+	return adec(&r->ref);
 }

+ 0 - 2
sys/src/libthread/threadimpl.h

@@ -179,8 +179,6 @@ void	_threadready(Thread*);
 void*	_threadrendezvous(void*, void*);
 void	_threadsignal(void);
 void	_threadsysfatal(char*, va_list);
-long	_xdec(long*);
-void	_xinc(long*);
 void**	_workerdata(void);
 
 extern int			_threaddebuglevel;