Browse Source

Plan 9 from Bell Labs 2011-07-27

David du Colombier 12 years ago
parent
commit
5e7c4f4e34

+ 4 - 1
rc/bin/ape/grep

@@ -7,7 +7,10 @@ files=()
 argv0=$0
 while(! ~ $#* 0){
 	switch($1){
-	case -[cefinsv]
+	case -e
+		opts=($opts $1 $2)
+		shift
+	case -[cfinsv]
 		opts=($opts $1)
 	case -q
 		opts=($opts -s)

+ 2 - 1
rc/bin/ape/ln

@@ -15,7 +15,8 @@ while(! ~ $#* 0 && ~ $1 -*){
 	shift
 }
 
-if(~ $force n && test -e $2){
+
+if(~ $force n && test -e $2 && ! test -d $2){
 	echo ln: $2 destination exists >[2=1]
 	exit 'usage'
 }

+ 9 - 2
rc/bin/ape/ls

@@ -14,6 +14,7 @@
 # -c	show ctime
 # -d	dirs
 # -f	no sorting
+# -i	inode numbers
 # -l	long
 # -p	put slash after dir (-F)
 # -r	reverse
@@ -23,7 +24,7 @@
 # -1	single-column
 
 
-flagfmt='A,C,F,H,L,R,U,a,c,d,f,l,p,r,s,t,u,1'
+flagfmt='A,C,F,H,L,R,U,a,c,d,f,i,l,p,r,s,t,u,1'
 args='[file ...]'
 
 if(! ifs=() eval `{aux/getflags $*}){
@@ -36,7 +37,12 @@ fn fixlong {
 	/$cputype/bin/sed 's/^(.).(.........) . [0-9]+ /\1\2 1 /'
 }
 
+fn qid2inode {
+	/$cputype/bin/sed 's/^\(([^ ]+).*\) /\1 /'
+}
+
 post=cat
+post2=cat
 
 all=()
 # ignore -A
@@ -49,6 +55,7 @@ if(~ $flagU 1) all=($all -n)
 if(~ $flagd 1) all=($all -d)
 if(~ $flagf 1) all=($all -n)
 if(~ $flagl 1) { all=($all -l); post=fixlong }
+if(~ $flagi 1) { all=($all -q); post2=qid2inode }
 if(~ $flagp 1) all=($all -F)
 if(~ $flagr 1) all=($all -r)
 if(~ $flags 1) all=($all -s)
@@ -56,4 +63,4 @@ if(~ $flagt 1) all=($all -t)
 if(~ $flagu 1) all=($all -u)
 # ignore -1
 
-/$cputype/bin/ls $all $* | $post
+/$cputype/bin/ls $all $* | $post | $post2

+ 6 - 0
rc/bin/ape/psh

@@ -7,4 +7,10 @@ bind -b /rc/bin/ape /bin
 bind -b /$cputype/bin/ape /bin
 if(test -d /$cputype/bin/pub)
 	bind -a /$cputype/bin/pub /bin
+if(test -d /$cputype/bin/X11){
+	bind -a /$cputype/bin/X11 /bin
+	if(test ! -e /env/DISPLAY)
+		DISPLAY=:0.0
+}
+
 /bin/sh $*

+ 3 - 0
sys/src/9/kw/main.c

@@ -232,6 +232,8 @@ vlong	probeaddr(uintptr);
 static void
 spiprobe(void)
 {
+if (0) {
+/* generates repeated "spurious irqbridge interrupt: 00000010" on sheevaplug. */
 	Spiregs *rp = (Spiregs *)soc.spi;
 
 	if (probeaddr(soc.spi) < 0)
@@ -248,6 +250,7 @@ spiprobe(void)
 		print(" (no response)");
 	print(": memory reads enabled\n");
 }
+}
 
 /*
  * entered from l.s with mmu enabled.

+ 6 - 3
sys/src/9/kw/usbehci.h

@@ -34,9 +34,12 @@ enum
 	Cnports		= 0xF,		/* nport bits in Ecapio parms. */
 	Cdbgportshift	= 20,		/* debug port in Ecapio parms. */
 	Cdbgportmask	= 0xF,
-	C64		= 1,		/* 64-bits, in Ecapio capparms. */
-	Ceecpshift	= 8,		/* extended capabilities ptr. in */
-	Ceecpmask	= 8,		/* the Ecapio capparms reg. */
+
+	/* Ecapio->capparms bits */
+	C64		= 1<<0,		/* 64-bits */
+	Ceecpshift	= 8,		/* extended capabilities ptr. */
+	Ceecpmask	= (1<<8) - 1,
+
 	Clegacy		= 1,		/* legacy support cap. id */
 	CLbiossem	= 2,		/* legacy cap. bios sem. */
 	CLossem		= 3,		/* legacy cap. os sem */

+ 1 - 1
sys/src/9/omap/archomap.c

@@ -2,7 +2,7 @@
  * omap3530 SoC (e.g. beagleboard) architecture-specific stuff
  *
  * errata: usb port 3 cannot operate in ulpi mode, only serial or
- * ulpi tll mode
+ * utmi tll mode
  */
 
 #include "u.h"

+ 2 - 2
sys/src/9/omap/beagle

@@ -30,7 +30,7 @@ dev
 	mouse
 
 	uart
-#	usb
+	usb
 
 link
 	archomap
@@ -43,7 +43,7 @@ link
 	ether9221
 ## avoid tickling errata 3.1.1.183
 ##	usbohci
-#	usbehci		usbehciomap
+	usbehci		usbehciomap
 
 ip
 	tcp

+ 6 - 3
sys/src/9/omap/usbehci.h

@@ -35,9 +35,12 @@ enum
 	Cnports		= 0xF,		/* nport bits in Ecapio parms. */
 	Cdbgportshift	= 20,		/* debug port in Ecapio parms. */
 	Cdbgportmask	= 0xF,
-	C64		= 1,		/* 64-bits, in Ecapio capparms. */
-	Ceecpshift	= 8,		/* extended capabilities ptr. in */
-	Ceecpmask	= 8,		/* the Ecapio capparms reg. */
+
+	/* Ecapio->capparms bits */
+	C64		= 1<<0,		/* 64-bits */
+	Ceecpshift	= 8,		/* extended capabilities ptr. */
+	Ceecpmask	= (1<<8) - 1,
+
 	Clegacy		= 1,		/* legacy support cap. id */
 	CLbiossem	= 2,		/* legacy cap. bios sem. */
 	CLossem		= 3,		/* legacy cap. os sem */

+ 11 - 5
sys/src/9/pc/usbehci.h

@@ -31,12 +31,18 @@ typedef struct Qtree Qtree;
  */
 enum
 {
-	Cnports		= 0xF,		/* nport bits in Ecapio parms. */
-	Cdbgportshift	= 20,		/* debug port in Ecapio parms. */
+	/* Ecapio->parms reg. */
+	Cnports		= 0xF,		/* nport bits */
+	Cdbgportshift	= 20,		/* debug port */
 	Cdbgportmask	= 0xF,
-	C64		= 1,		/* 64-bits, in Ecapio capparms. */
-	Ceecpshift	= 8,		/* extended capabilities ptr. in */
-	Ceecpmask	= 8,		/* the Ecapio capparms reg. */
+
+	/* Ecapio->capparms bits */
+	C64		= 1<<0,		/* 64-bits */
+	Cpfl		= 1<<1,	/* program'ble frame list: can be <1024 */
+	Casp		= 1<<2,		/* asynch. sched. park */
+	Ceecpshift	= 8,		/* extended capabilities ptr. */
+	Ceecpmask	= (1<<8) - 1,
+
 	Clegacy		= 1,		/* legacy support cap. id */
 	CLbiossem	= 2,		/* legacy cap. bios sem. */
 	CLossem		= 3,		/* legacy cap. os sem */

+ 6 - 1
sys/src/9/pc/usbehcipc.c

@@ -15,7 +15,7 @@
 #include	"usbehci.h"
 
 static Ctlr* ctlrs[Nhcis];
-static int maxehci = 1<<30;
+static int maxehci = Nhcis;
 
 /* Isn't this cap list search in a helper function? */
 static void
@@ -169,6 +169,11 @@ scanpci(void)
 		default:
 			continue;
 		}
+		if(0 && p->vid == Vintel && p->did == 0x3b34) {
+			print("usbehci: ignoring known bad ctlr %#ux/%#ux\n",
+				p->vid, p->did);
+			continue;
+		}
 		if(io == 0){
 			print("usbehci: %x %x: failed to map registers\n",
 				p->vid, p->did);

+ 21 - 8
sys/src/9/port/usbehci.c

@@ -513,7 +513,10 @@ static Qh*
 qhlinkqh(Qh *qh, Qh *next)
 {
 	qh->next = next;
-	qh->link = PADDR(next)|Lqh;
+	if(next == nil)
+		qh->link = Lterm;
+	else
+		qh->link = PADDR(next)|Lqh;
 	coherence();
 	return qh;
 }
@@ -529,7 +532,7 @@ qhsetaddr(Qh *qh, ulong addr)
 }
 
 /*
- * return smallest power of 2 <= n
+ * return largest power of 2 <= n
  */
 static int
 flog2lower(int n)
@@ -2369,15 +2372,18 @@ epio(Ep *ep, Qio *io, void *a, long count, int mustlock)
 		ntds++;
 		/*
 		 * Use td tok, not io tok, because of setup packets.
-		 * Also, if the Td was stalled or active (previous Td
-		 * was a short packet), we must save the toggle as it is.
+		 * Also, we must save the next toggle value from the
+		 * last completed Td (in case of a short packet, or
+		 * fewer than the requested number of packets in the
+		 * Td being transferred).
 		 */
-		if(td->csw & (Tdhalt|Tdactive)){
-			if(saved++ == 0) {
+		if(td->csw & (Tdhalt|Tdactive))
+			saved++;
+		else{
+			if(!saved){
 				io->toggle = td->csw & Tddata1;
 				coherence();
 			}
-		}else{
 			tot += td->ndata;
 			if(c != nil && (td->csw & Tdtok) == Tdtokin && td->ndata > 0){
 				memmove(c, td->data, td->ndata);
@@ -3162,6 +3168,7 @@ init(Hci *hp)
 	Ctlr *ctlr;
 	Eopio *opio;
 	int i;
+	static int ctlrno;
 
 	hp->highspeed = 1;
 	ctlr = hp->aux;
@@ -3180,7 +3187,12 @@ init(Hci *hp)
 	opio->cmd |= Case;
 	coherence();
 	ehcirun(ctlr, 1);
-	opio->config = Callmine;	/* reclaim all ports */
+	/*
+	 * route all ports by default to only one ehci (the first).
+	 * it's not obvious how multiple ehcis could work and on some
+	 * machines, setting Callmine on all ehcis makes the machine seize up.
+	 */
+	opio->config = (ctlrno == 0? Callmine: 0);
 	coherence();
 
 	for (i = 0; i < hp->nports; i++)
@@ -3188,6 +3200,7 @@ init(Hci *hp)
 	iunlock(ctlr);
 	if(ehcidebug > 1)
 		dump(hp);
+	ctlrno++;
 }
 
 void

+ 5 - 3
sys/src/cmd/cpp/eval.c

@@ -2,7 +2,7 @@
 #include <libc.h>
 #include "cpp.h"
 
-#define	NSTAK	32
+#define	NSTAK	1024
 #define	SGN	0
 #define	UNS	1
 #define	UND	2
@@ -92,8 +92,8 @@ const struct pri {
 
 int	evalop(struct pri);
 struct	value tokval(Token *);
-struct value vals[NSTAK], *vp;
-enum toktype ops[NSTAK], *op;
+struct value vals[NSTAK + 1], *vp;
+enum toktype ops[NSTAK + 1], *op;
 
 /*
  * Evaluate an #if #elif #ifdef #ifndef line.  trp->tp points to the keyword.
@@ -122,6 +122,8 @@ eval(Tokenrow *trp, int kw)
 	op = ops;
 	*op++ = END;
 	for (rand=0, tp = trp->bp+ntok; tp < trp->lp; tp++) {
+		if(op >= ops + NSTAK)
+			sysfatal("cpp: can't evaluate #if: increase NSTAK");
 		switch(tp->type) {
 		case WS:
 		case NL:

+ 0 - 2
sys/src/cmd/cpp/lex.c

@@ -45,8 +45,6 @@ enum state {
 	S_STNL, S_COMNL, S_EOFCOM, S_COMMENT, S_EOB, S_WS, S_NAME
 };
 
-int	tottok;
-int	tokkind[256];
 struct	fsm {
 	int	state;		/* if in this state */
 	uchar	ch[4];		/* and see one of these characters */