Browse Source

Plan 9 from Bell Labs 2007-08-21

David du Colombier 16 years ago
parent
commit
40f3385bcb

+ 6 - 6
dist/replica/_plan9.db

@@ -407,7 +407,7 @@
 386/bin/snap - 775 sys sys 1178939753 316147
 386/bin/snapfs - 775 sys sys 1179372105 390366
 386/bin/sniffer - 775 sys sys 1038443185 99028
-386/bin/snoopy - 775 sys sys 1186112232 190558
+386/bin/snoopy - 775 sys sys 1187639427 190560
 386/bin/sort - 775 sys sys 1178568303 81057
 386/bin/spin - 775 sys sys 1186543935 769291
 386/bin/split - 775 sys sys 1181507270 75811
@@ -7502,7 +7502,7 @@ sys/man/2/arg - 664 sys sys 1139744263 2184
 sys/man/2/arith3 - 664 sys sys 1162102967 4393
 sys/man/2/assert - 664 sys sys 1102868467 377
 sys/man/2/atof - 664 sys sys 1171668702 2778
-sys/man/2/auth - 664 sys sys 1171094909 7540
+sys/man/2/auth - 664 sys sys 1187643286 7538
 sys/man/2/authsrv - 664 sys sys 1171690308 4505
 sys/man/2/bin - 664 sys sys 985023077 1880
 sys/man/2/bind - 664 sys sys 1015091518 4685
@@ -7566,7 +7566,7 @@ sys/man/2/iounit - 664 sys sys 1015091523 1001
 sys/man/2/ip - 664 sys sys 1178598000 7246
 sys/man/2/isalpharune - 664 sys sys 1015091523 1059
 sys/man/2/keyboard - 664 sys sys 950892860 2065
-sys/man/2/lock - 664 sys sys 1174844415 5704
+sys/man/2/lock - 664 sys sys 1187644134 5705
 sys/man/2/mach - 664 sys sys 1080179298 7995
 sys/man/2/malloc - 664 sys sys 1102093069 4763
 sys/man/2/matrix - 664 sys sys 950892861 6090
@@ -7626,7 +7626,7 @@ sys/man/2/string - 664 sys sys 1055701090 5306
 sys/man/2/stringsize - 664 sys sys 952627482 1409
 sys/man/2/subfont - 664 sys sys 956345937 5140
 sys/man/2/symbol - 664 sys sys 950892874 9423
-sys/man/2/thread - 664 sys sys 1181168564 11712
+sys/man/2/thread - 664 sys sys 1187645645 11918
 sys/man/2/time - 664 sys sys 1182980757 736
 sys/man/2/tmpfile - 664 sys sys 1048637161 1157
 sys/man/2/wait - 664 sys sys 1163004064 2525
@@ -7989,7 +7989,7 @@ sys/src/9/ip/netlog.c - 664 sys sys 1184794933 4004
 sys/src/9/ip/nullmedium.c - 664 sys sys 1086406910 492
 sys/src/9/ip/pktmedium.c - 664 sys sys 1084331746 1314
 sys/src/9/ip/ptclbsum.c - 664 sys sys 1022588099 1243
-sys/src/9/ip/rudp.c - 664 sys sys 1184946959 21529
+sys/src/9/ip/rudp.c - 664 sys sys 1187631835 21591
 sys/src/9/ip/tcp.c - 664 sys sys 1186406232 65963
 sys/src/9/ip/tripmedium.c - 664 sys sys 1045063515 7136
 sys/src/9/ip/udp.c - 664 sys sys 1184946959 13316
@@ -12594,7 +12594,7 @@ sys/src/cmd/ip/snoopy/eap_identity.c - 664 sys sys 1128179537 50
 sys/src/cmd/ip/snoopy/eapol.c - 664 sys sys 1128179537 1890
 sys/src/cmd/ip/snoopy/eapol_key.c - 664 sys sys 1128179537 2025
 sys/src/cmd/ip/snoopy/ether.c - 664 sys sys 1181425746 2077
-sys/src/cmd/ip/snoopy/filter.y - 664 sys sys 1138463389 1739
+sys/src/cmd/ip/snoopy/filter.y - 664 sys sys 1187631889 1753
 sys/src/cmd/ip/snoopy/gre.c - 664 sys sys 1139667373 3327
 sys/src/cmd/ip/snoopy/hdlc.c - 664 sys sys 1128179537 4285
 sys/src/cmd/ip/snoopy/icmp.c - 664 sys sys 1148279205 2970

+ 6 - 6
dist/replica/plan9.db

@@ -407,7 +407,7 @@
 386/bin/snap - 775 sys sys 1178939753 316147
 386/bin/snapfs - 775 sys sys 1179372105 390366
 386/bin/sniffer - 775 sys sys 1038443185 99028
-386/bin/snoopy - 775 sys sys 1186112232 190558
+386/bin/snoopy - 775 sys sys 1187639427 190560
 386/bin/sort - 775 sys sys 1178568303 81057
 386/bin/spin - 775 sys sys 1186543935 769291
 386/bin/split - 775 sys sys 1181507270 75811
@@ -7502,7 +7502,7 @@ sys/man/2/arg - 664 sys sys 1139744263 2184
 sys/man/2/arith3 - 664 sys sys 1162102967 4393
 sys/man/2/assert - 664 sys sys 1102868467 377
 sys/man/2/atof - 664 sys sys 1171668702 2778
-sys/man/2/auth - 664 sys sys 1171094909 7540
+sys/man/2/auth - 664 sys sys 1187643286 7538
 sys/man/2/authsrv - 664 sys sys 1171690308 4505
 sys/man/2/bin - 664 sys sys 985023077 1880
 sys/man/2/bind - 664 sys sys 1015091518 4685
@@ -7566,7 +7566,7 @@ sys/man/2/iounit - 664 sys sys 1015091523 1001
 sys/man/2/ip - 664 sys sys 1178598000 7246
 sys/man/2/isalpharune - 664 sys sys 1015091523 1059
 sys/man/2/keyboard - 664 sys sys 950892860 2065
-sys/man/2/lock - 664 sys sys 1174844415 5704
+sys/man/2/lock - 664 sys sys 1187644134 5705
 sys/man/2/mach - 664 sys sys 1080179298 7995
 sys/man/2/malloc - 664 sys sys 1102093069 4763
 sys/man/2/matrix - 664 sys sys 950892861 6090
@@ -7626,7 +7626,7 @@ sys/man/2/string - 664 sys sys 1055701090 5306
 sys/man/2/stringsize - 664 sys sys 952627482 1409
 sys/man/2/subfont - 664 sys sys 956345937 5140
 sys/man/2/symbol - 664 sys sys 950892874 9423
-sys/man/2/thread - 664 sys sys 1181168564 11712
+sys/man/2/thread - 664 sys sys 1187645645 11918
 sys/man/2/time - 664 sys sys 1182980757 736
 sys/man/2/tmpfile - 664 sys sys 1048637161 1157
 sys/man/2/wait - 664 sys sys 1163004064 2525
@@ -7989,7 +7989,7 @@ sys/src/9/ip/netlog.c - 664 sys sys 1184794933 4004
 sys/src/9/ip/nullmedium.c - 664 sys sys 1086406910 492
 sys/src/9/ip/pktmedium.c - 664 sys sys 1084331746 1314
 sys/src/9/ip/ptclbsum.c - 664 sys sys 1022588099 1243
-sys/src/9/ip/rudp.c - 664 sys sys 1184946959 21529
+sys/src/9/ip/rudp.c - 664 sys sys 1187631835 21591
 sys/src/9/ip/tcp.c - 664 sys sys 1186406232 65963
 sys/src/9/ip/tripmedium.c - 664 sys sys 1045063515 7136
 sys/src/9/ip/udp.c - 664 sys sys 1184946959 13316
@@ -12594,7 +12594,7 @@ sys/src/cmd/ip/snoopy/eap_identity.c - 664 sys sys 1128179537 50
 sys/src/cmd/ip/snoopy/eapol.c - 664 sys sys 1128179537 1890
 sys/src/cmd/ip/snoopy/eapol_key.c - 664 sys sys 1128179537 2025
 sys/src/cmd/ip/snoopy/ether.c - 664 sys sys 1181425746 2077
-sys/src/cmd/ip/snoopy/filter.y - 664 sys sys 1138463389 1739
+sys/src/cmd/ip/snoopy/filter.y - 664 sys sys 1187631889 1753
 sys/src/cmd/ip/snoopy/gre.c - 664 sys sys 1139667373 3327
 sys/src/cmd/ip/snoopy/hdlc.c - 664 sys sys 1128179537 4285
 sys/src/cmd/ip/snoopy/icmp.c - 664 sys sys 1148279205 2970

+ 6 - 0
dist/replica/plan9.log

@@ -50005,3 +50005,9 @@
 1187328604 0 c sys/src/libsec/port/aes.c - 664 sys sys 1187327457 63962
 1187361004 0 c sys/games/lib/fortunes - 664 sys sys 1187359457 266564
 1187380804 0 c 386/lib/libsec.a - 664 sys sys 1187380500 646784
+1187632803 0 c sys/src/9/ip/rudp.c - 664 sys sys 1187631835 21591
+1187632803 1 c sys/src/cmd/ip/snoopy/filter.y - 664 sys sys 1187631889 1753
+1187640003 0 c 386/bin/snoopy - 775 sys sys 1187639427 190560
+1187643603 0 c sys/man/2/auth - 664 sys sys 1187643286 7538
+1187645404 0 c sys/man/2/lock - 664 sys sys 1187644134 5705
+1187647203 0 c sys/man/2/thread - 664 sys sys 1187645645 11918

+ 1 - 1
sys/man/2/auth

@@ -134,7 +134,7 @@ and recreates the namespace using the file
 (default
 .BR /lib/nnamespace ).
 It uses
-.I auth_userpassword
+.I auth_userpasswd
 and
 .IR auth_chuid .
 .PP

+ 1 - 1
sys/man/2/lock

@@ -271,7 +271,7 @@ protecting the
 is the same
 .B QLock
 used for the 
-.B Rendez ;
+.BR Rendez ;
 this ensures that wakeups are not missed.
 .SH SOURCE
 .B /sys/src/libc/port/lock.c

+ 26 - 17
sys/man/2/thread

@@ -129,9 +129,9 @@ int	threadnotify(int (*f)(void*, char*), int in)
 The thread library provides parallel programming support similar to that
 of the languages
 Alef and Newsqueak.
-Threads
+.I Threads
 and
-procs
+.I procs
 occupy a shared address space,
 communicating and synchronizing through
 .I channels
@@ -139,7 +139,7 @@ and shared variables.
 .PP
 A
 .I proc
-is a Plan 9 process that contains one or more cooperatively scheduled
+is a Plan 9 process that contains one or more cooperatively-scheduled
 .IR threads .
 Programs using threads must replace
 .I main
@@ -161,7 +161,7 @@ initialized to the desired value
 .B mainstacksize
 .B =
 .BR 1024 ).
-.PP
+.SS Creation
 .I Threadcreate
 creates a new thread in the calling proc, returning a unique integer
 identifying the thread; the thread
@@ -217,8 +217,8 @@ terminates all procs in the program,
 using
 .I status
 as the exit status.
-.PP
-The threads in a proc are coroutines, scheduled nonpreemptively
+.SS Scheduling
+The threads in a proc are coroutines, scheduled non-preemptively
 in a round-robin fashion.
 A thread must explicitly relinquish control of the processor
 before another thread in the same proc is run.
@@ -236,7 +236,13 @@ and
 .I send
 and
 .IR recv \(emsee
-their descriptions further on).
+their descriptions further on),
+plus these from
+.IR lock (2):
+.IR qlock ,
+.IR rlock ,
+.IR wlock ,
+.IR rsleep .
 Procs are scheduled by the operating system.
 Therefore, threads in different procs can preempt one another
 in arbitrary ways and should synchronize their
@@ -287,7 +293,7 @@ and
 .I threadkillgrp
 will not terminate a thread that never relinquishes
 the processor.
-.PP
+.SS Names and per-thread data
 Primarily for debugging,
 threads can have string names associated with them.
 .I Threadgetname
@@ -306,7 +312,7 @@ per-thread storage.
 Similarly, 
 .I procdata
 returns a pointer to a per-proc pointer.
-.PP
+.SS Executing new programs
 .I Procexecl
 and
 .I procexec
@@ -354,7 +360,7 @@ These
 structures have been allocated with
 .IR malloc (2)
 and should be freed after use.
-.PP
+.SS Channels
 A
 .B Channel
 is a buffered or unbuffered queue for fixed-size messages.
@@ -516,7 +522,7 @@ The string delivered by
 is allocated with
 .IR malloc (2)
 and should be freed upon receipt.
-.PP
+.SS Errors, notes and resources
 Thread library functions do not return on failure;
 if errors occur, the entire program is aborted.
 .PP
@@ -562,19 +568,22 @@ same rendezvous group; do not change the rendezvous
 group with
 .IR rfork .
 .SH FILES
+.TF /sys/lib/acid/thread
+.TP
 .B /sys/lib/acid/thread
-contains useful
+useful
 .IR acid (1)
 functions for debugging threaded programs.
-.PP
+.TP
 .B /sys/src/libthread/example.c
-contains a full example program.
-.PP
+a full example program.
+.TP
 .B /mnt/temp
-is used as a place to create pipes by
+a place to create pipes by
 .IR procexec .
 .SH SOURCE
 .B /sys/src/libthread
 .SH SEE ALSO
 .IR intro (2),
-.IR ioproc (2)
+.IR ioproc (2),
+.IR lock (2)

+ 1 - 0
sys/src/9/ip/rudp.c

@@ -1,4 +1,5 @@
 /*
+ *  Reliable User Datagram Protocol, currently only for IPv4.
  *  This protocol is compatible with UDP's packet format.
  *  It could be done over UDP if need be.
  */

+ 61 - 28
sys/src/9/pc/uartpci.c

@@ -10,8 +10,11 @@ extern PhysUart i8250physuart;
 extern PhysUart pciphysuart;
 extern void* i8250alloc(int, int, int);
 
+static Uart *perlehead, *perletail;
+
 static Uart*
-uartpci(int ctlrno, Pcidev* p, int barno, int n, int freq, char* name)
+uartpci(int ctlrno, Pcidev* p, int barno, int n, int freq, char* name,
+	int iosize)
 {
 	int i, io;
 	void *ctlr;
@@ -26,10 +29,9 @@ uartpci(int ctlrno, Pcidev* p, int barno, int n, int freq, char* name)
 	}
 
 	head = uart = malloc(sizeof(Uart)*n);
-
 	for(i = 0; i < n; i++){
 		ctlr = i8250alloc(io, p->intl, p->tbdf);
-		io += 8;
+		io += iosize;
 		if(ctlr == nil)
 			continue;
 
@@ -43,16 +45,50 @@ uartpci(int ctlrno, Pcidev* p, int barno, int n, int freq, char* name)
 		uart++;
 	}
 
+	if (head) {
+		if(perlehead != nil)
+			perletail->next = head;
+		else
+			perlehead = head;
+		for(perletail = head; perletail->next != nil;
+		    perletail = perletail->next)
+			;
+	}
 	return head;
 }
 
+static Uart *
+ultraport16si(Pcidev *p, int ctlrno, ulong freq)
+{
+	int io, i;
+	char *name;
+	Uart *uart;
+
+	name = "Ultraport16si";			/* 16L788 UARTs */
+	io = p->mem[4].bar & ~1;
+	if (ioalloc(io, p->mem[4].size, 0, name) < 0) {
+		print("uartpci: can't get IO space to set %s to rs-232\n", name);
+		return nil;
+	}
+	for (i = 0; i < 16; i++) {
+		outb(io, i << 4);
+		outb(io, (i << 4) + 1);	/* set to RS232 mode  (Don't ask!) */
+	}
+
+	uart = uartpci(ctlrno, p, 2, 8, freq, name, 16);
+	if(uart)
+		uart = uartpci(ctlrno, p, 3, 8, freq, name, 16);
+	return uart;
+}
+
 static Uart*
 uartpcipnp(void)
 {
 	Pcidev *p;
 	char *name;
-	int ctlrno, n, subid;
-	Uart *head, *tail, *uart;
+	int ctlrno, subid;
+	ulong freq;
+	Uart *uart;
 
 	/*
 	 * Loop through all PCI devices looking for simple serial
@@ -60,20 +96,23 @@ uartpcipnp(void)
 	 * are familiar. All suitable devices are configured to
 	 * simply point to the generic i8250 driver.
 	 */
-	head = tail = nil;
+	perlehead = perletail = nil;
 	ctlrno = 0;
 	for(p = pcimatch(nil, 0, 0); p != nil; p = pcimatch(p, 0, 0)){
 		if(p->ccrb != 0x07 || p->ccru > 2)
 			continue;
 
-		switch((p->did<<16)|p->vid){
+		switch(p->did<<16 | p->vid){
 		default:
 			continue;
 		case (0x9835<<16)|0x9710:	/* StarTech PCI2S550 */
-			uart = uartpci(ctlrno, p, 0, 1, 1843200, "PCI2S550-0");
+			uart = uartpci(ctlrno, p, 0, 1, 1843200, "PCI2S550-0", 8);
 			if(uart == nil)
 				continue;
-			uart->next = uartpci(ctlrno, p, 1, 1, 1843200, "PCI2S550-1");
+			uart->next = uartpci(ctlrno, p, 1, 1, 1843200,
+				"PCI2S550-1", 8);
+			if(uart->next == nil)
+				continue;
 			break;
 		case (0x950A<<16)|0x1415:	/* Oxford Semi OX16PCI954 */
 			/*
@@ -88,9 +127,8 @@ uartpcipnp(void)
 			default:
 				continue;
 			case (0x2000<<16)|0x131F:/* SIIG CyberSerial PCIe */
-				uart = uartpci(ctlrno, p, 0, 1, 18432000, "CyberSerial-1S");
-					if(uart == nil)
-						continue;
+				uart = uartpci(ctlrno, p, 0, 1, 18432000,
+					"CyberSerial-1S", 8);
 				break;
 			}
 			break;
@@ -104,42 +142,37 @@ uartpcipnp(void)
 			 */
 			subid = pcicfgr16(p, PciSVID);
 			subid |= pcicfgr16(p, PciSID)<<16;
+			freq = 7372800;
 			switch(subid){
 			default:
 				continue;
 			case (0x0011<<16)|0x12E0:	/* Perle PCI-Fast16 */
-				n = 16;
 				name = "PCI-Fast16";
+				uart = uartpci(ctlrno, p, 2, 16, freq, name, 8);
 				break;
 			case (0x0021<<16)|0x12E0:	/* Perle PCI-Fast8 */
-				n = 8;
 				name = "PCI-Fast8";
+				uart = uartpci(ctlrno, p, 2, 8, freq, name, 8);
 				break;
 			case (0x0031<<16)|0x12E0:	/* Perle PCI-Fast4 */
-				n = 4;
 				name = "PCI-Fast4";
+				uart = uartpci(ctlrno, p, 2, 4, freq, name, 8);
 				break;
 			case (0x0021<<16)|0x155F:	/* Perle Ultraport8 */
-				n = 8;
 				name = "Ultraport8";	/* 16C754 UARTs */
+				uart = uartpci(ctlrno, p, 2, 8, freq, name, 8);
+				break;
+			case (0x0241<<16)|0x155F:	/* Perle Ultraport16 */
+				uart = ultraport16si(p, ctlrno, 4 * freq);
 				break;
 			}
-			uart = uartpci(ctlrno, p, 2, n, 7372800, name);
-			if(uart == nil)
-				continue;
 			break;
 		}
-
-		if(head != nil)
-			tail->next = uart;
-		else
-			head = uart;
-		for(tail = uart; tail->next != nil; tail = tail->next)
-			;
-		ctlrno++;
+		if(uart)
+			ctlrno++;
 	}
 
-	return head;
+	return perlehead;
 }
 
 PhysUart pciphysuart = {

+ 3 - 1
sys/src/cmd/ip/snoopy/filter.y

@@ -64,10 +64,12 @@ yylex(void)
 	char *p;
 	int c;
 
-	if(yylp == nil || *yylp == 0)
+	if(yylp == nil)
 		return 0;
 	while(isspace(*yylp))
 		yylp++;
+	if(*yylp == 0)
+		return 0;
 
 	yylval = newfilter();