Browse Source

Plan 9 from Bell Labs 2006-09-21

David du Colombier 17 years ago
parent
commit
e7bc41b074
7 changed files with 123 additions and 28 deletions
  1. 4 2
      dist/replica/_plan9.db
  2. 4 2
      dist/replica/plan9.db
  3. 5 0
      dist/replica/plan9.log
  4. 2 0
      rc/bin/uncompress
  5. 56 0
      sys/man/1/mug
  6. 11 3
      sys/src/9/pc/mkfile
  7. 41 21
      sys/src/9/pc/uartaxp.c

+ 4 - 2
dist/replica/_plan9.db

@@ -5551,6 +5551,7 @@ rc/bin/tlsclienttunnel - 775 sys sys 1024375633 153
 rc/bin/tlssrvtunnel - 775 sys sys 1024375634 175
 rc/bin/troff2gif - 775 sys sys 1127410278 164
 rc/bin/troff2png - 775 sys sys 1138456827 228
+rc/bin/uncompress - 775 sys sys 1158798931 30
 rc/bin/ups - 775 sys sys 1091021981 806
 rc/bin/uptime - 775 sys sys 1074730712 234
 rc/bin/usbstart - 775 sys sys 1044894155 81
@@ -7337,6 +7338,7 @@ sys/man/1/mk - 664 sys sys 1113743328 13198
 sys/man/1/mkdir - 664 sys sys 1082593141 717
 sys/man/1/mlmgr - 664 sys sys 1116513886 2542
 sys/man/1/ms2html - 664 sys sys 1138458899 1252
+sys/man/1/mug - 664 sys sys 1158800370 1424
 sys/man/1/nedmail - 664 sys sys 1114697978 6820
 sys/man/1/netstat - 664 sys sys 1128255431 942
 sys/man/1/news - 664 sys sys 1113743329 1151
@@ -8003,7 +8005,7 @@ sys/src/9/pc/l.s - 664 sys sys 1143129925 28552
 sys/src/9/pc/main.c - 664 sys sys 1155995697 15305
 sys/src/9/pc/mem.h - 664 sys sys 1137622431 5203
 sys/src/9/pc/memory.c - 664 sys sys 1153172671 18773
-sys/src/9/pc/mkfile - 664 sys sys 1142960857 3804
+sys/src/9/pc/mkfile - 664 sys sys 1158794206 4004
 sys/src/9/pc/mmu.c - 664 sys sys 1155995596 24115
 sys/src/9/pc/mouse.c - 664 sys sys 1098479254 7057
 sys/src/9/pc/mp.c - 664 sys sys 1146542974 17317
@@ -8037,7 +8039,7 @@ 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 1146746630 7106
 sys/src/9/pc/trap.c - 664 sys sys 1135487942 21257
-sys/src/9/pc/uartaxp.c - 664 sys sys 1155522821 17906
+sys/src/9/pc/uartaxp.c - 664 sys sys 1158803840 18862
 sys/src/9/pc/uartaxp.i - 664 sys sys 1155522709 111326
 sys/src/9/pc/uarti8250.c - 664 sys sys 1102820421 13958
 sys/src/9/pc/uartisa.c - 664 sys sys 1127126907 1777

+ 4 - 2
dist/replica/plan9.db

@@ -5551,6 +5551,7 @@ rc/bin/tlsclienttunnel - 775 sys sys 1024375633 153
 rc/bin/tlssrvtunnel - 775 sys sys 1024375634 175
 rc/bin/troff2gif - 775 sys sys 1127410278 164
 rc/bin/troff2png - 775 sys sys 1138456827 228
+rc/bin/uncompress - 775 sys sys 1158798931 30
 rc/bin/ups - 775 sys sys 1091021981 806
 rc/bin/uptime - 775 sys sys 1074730712 234
 rc/bin/usbstart - 775 sys sys 1044894155 81
@@ -7337,6 +7338,7 @@ sys/man/1/mk - 664 sys sys 1113743328 13198
 sys/man/1/mkdir - 664 sys sys 1082593141 717
 sys/man/1/mlmgr - 664 sys sys 1116513886 2542
 sys/man/1/ms2html - 664 sys sys 1138458899 1252
+sys/man/1/mug - 664 sys sys 1158800370 1424
 sys/man/1/nedmail - 664 sys sys 1114697978 6820
 sys/man/1/netstat - 664 sys sys 1128255431 942
 sys/man/1/news - 664 sys sys 1113743329 1151
@@ -8003,7 +8005,7 @@ sys/src/9/pc/l.s - 664 sys sys 1143129925 28552
 sys/src/9/pc/main.c - 664 sys sys 1155995697 15305
 sys/src/9/pc/mem.h - 664 sys sys 1137622431 5203
 sys/src/9/pc/memory.c - 664 sys sys 1153172671 18773
-sys/src/9/pc/mkfile - 664 sys sys 1142960857 3804
+sys/src/9/pc/mkfile - 664 sys sys 1158794206 4004
 sys/src/9/pc/mmu.c - 664 sys sys 1155995596 24115
 sys/src/9/pc/mouse.c - 664 sys sys 1098479254 7057
 sys/src/9/pc/mp.c - 664 sys sys 1146542974 17317
@@ -8037,7 +8039,7 @@ 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 1146746630 7106
 sys/src/9/pc/trap.c - 664 sys sys 1135487942 21257
-sys/src/9/pc/uartaxp.c - 664 sys sys 1155522821 17906
+sys/src/9/pc/uartaxp.c - 664 sys sys 1158803840 18862
 sys/src/9/pc/uartaxp.i - 664 sys sys 1155522709 111326
 sys/src/9/pc/uarti8250.c - 664 sys sys 1102820421 13958
 sys/src/9/pc/uartisa.c - 664 sys sys 1127126907 1777

+ 5 - 0
dist/replica/plan9.log

@@ -30479,3 +30479,8 @@
 1158618607 1 c sys/src/cmd/vac/vtdump.c - 664 sys sys 1158618245 7166
 1158618607 2 c sys/src/cmd/venti/copy.c - 664 sys sys 1158618341 3488
 1158620407 0 c sys/src/cmd/venti/copy.c - 664 sys sys 1158618908 3713
+1158793206 0 c sys/src/9/pc/uartaxp.c - 664 sys sys 1158793015 18808
+1158795007 0 c sys/src/9/pc/mkfile - 664 sys sys 1158794206 4004
+1158800407 0 a rc/bin/uncompress - 775 sys sys 1158798931 30
+1158800407 1 a sys/man/1/mug - 664 sys sys 1158800370 1424
+1158804006 0 c sys/src/9/pc/uartaxp.c - 664 sys sys 1158803840 18862

+ 2 - 0
rc/bin/uncompress

@@ -0,0 +1,2 @@
+#!/bin/rc
+exec compress -d $*

+ 56 - 0
sys/man/1/mug

@@ -0,0 +1,56 @@
+.TH MUG 1
+.SH NAME
+mug - convert an image to a face icon
+.SH SYNOPSIS
+.B mug
+[
+.I file
+]
+.SH DESCRIPTION
+.I Mug
+reads a Plan 9
+.IR image (6)
+from
+.I file
+(or standard input if there is no
+.IR file )
+and 
+displays a working version of the icon
+a gray ramp,
+and a larger image (the `crop box'),
+all derived from
+.IR file .
+Selecting
+.L Write
+from the button-3 menu will write the icon in
+.IR face (6)
+format to standard output.
+.LP
+Imagine a 3x3 grid on the crop box.  You can move an
+edge or corner of the box by putting the mouse in the
+corresponding section of the grid and dragging.
+Dragging in the middle box in the grid translates the
+crop box.  The mouse cursor changes to tell you where you are.
+.LP
+The bar in the gray ramp controls the map from picture
+gray levels to the output levels.  The values along the
+bar are mapped to 0 through 255 in the output.  You can
+move the bar vertically by grabbing the midsection or
+adjust the width by grabbing an endpoint.
+.LP
+The current icon is shown in the bottom left corner,
+surrounded by eight small empty boxes.  You can save the
+settings as they are by dragging the current icon into
+one of the other boxes.  You can restore the settings by
+dragging an icon from one of the periphery boxes into the middle.
+.SH EXAMPLES
+Convert a JPEG image into a face icon.
+.IP
+.EX
+jpg -c plus.jpg | mug >plus.1
+.EE
+.SH SEE ALSO
+.IR faces (1),
+.IR jpg (1),
+.IR face (6),
+.IR image (6)

+ 11 - 3
sys/src/9/pc/mkfile

@@ -112,9 +112,7 @@ wavelan.$O:			wavelan.c ../pc/wavelan.c ../pc/wavelan.h
 etherwavelan.$O:		etherwavelan.c ../pc/wavelan.h
 devusb.$O usbuhci.$O usbohci.$O: usb.h
 trap.$O:			/sys/include/tos.h
-
-sd53c8xx.i:	sd53c8xx.n
-	aux/na $prereq > $target
+uartaxp.$O:			uartaxp.i
 
 init.h:		../port/initcode.c init9.c
 	$CC ../port/initcode.c
@@ -142,6 +140,16 @@ apbootstrap.h:	apbootstrap.s mem.h
 		sed -e '1,2d' -e 's/^[0-9a-f]+ //' -e 's/ ([0-9a-f][0-9a-f])/0x\1,/g'
 	 echo '};'} > $target
 
+sd53c8xx.i:	sd53c8xx.n
+	aux/na $prereq > $target
+
+uartaxp.i:	a100p.cp
+	{echo 'static uchar uartaxpcp[] = {'
+	 xd -1x $prereq |
+		sed -e 's/^[0-9a-f]+ //' -e '/^$/d' -e 's/ ([0-9a-f][0-9a-f])/0x\1,/g'
+	 echo '};'
+	} > $target
+
 acid:V:
 	8c -a -w -I. i8253.c>acid
 

+ 41 - 21
sys/src/9/pc/uartaxp.c

@@ -207,7 +207,7 @@ typedef struct Ctlr {
 	uchar*	mem;
 	Gcb*	gcb;
 
-	int	im;
+	int	im;		/* interrupt mask */
 	Cc	cc[16];
 } Ctlr;
 
@@ -222,7 +222,7 @@ extern PhysUart axpphysuart;
 static int
 axpccdone(void* ccb)
 {
-	return !((Ccb*)ccb)->cc;
+	return !((Ccb*)ccb)->cc;	/* hw sets ccb->cc to zero */
 }
 
 static void
@@ -235,13 +235,12 @@ axpcc(Cc* cc, int cmd)
 	ccb = cc->ccb;
 	ccb->cc = cmd;
 
-	if(!cc->ctlr->im){
+	if(!cc->ctlr->im)
 		for(timeo = 0; timeo < 1000000; timeo++){
 			if(!ccb->cc)
 				break;
 			microdelay(1);
 		}
-	}
 	else
 		tsleep(cc, axpccdone, ccb, 1000);
 
@@ -322,6 +321,10 @@ axpdtr(Uart* uart, int on)
 	ccb->mc = mc;
 }
 
+/*
+ * can be called from uartstageinput() during an input interrupt,
+ * with uart->rlock ilocked or the uart qlocked, sometimes both.
+ */
 static void
 axprts(Uart* uart, int on)
 {
@@ -499,6 +502,7 @@ axpbreak(Uart* uart, int ms)
 	ccb->mc = mc & ~Ab;
 }
 
+/* only called from interrupt service */
 static void
 axpmc(Cc* cc)
 {
@@ -532,12 +536,13 @@ axpmc(Cc* cc)
 	}
 }
 
+/* called from uartkick() with uart->tlock ilocked */
 static void
 axpkick(Uart* uart)
 {
 	Cc *cc;
 	Ccb *ccb;
-	uchar *ep, *mem, *rp, *wp;
+	uchar *ep, *mem, *rp, *wp, *bp;
 
 	if(uart->cts == 0 || uart->blocked)
 		return;
@@ -546,20 +551,26 @@ axpkick(Uart* uart)
 	ccb = cc->ccb;
 
 	mem = (uchar*)cc->ctlr->gcb;
+	bp = mem + ccb->obsa;
 	rp = mem + ccb->obrp;
 	wp = mem + ccb->obwp;
 	ep = mem + ccb->obea;
-
-	while(wp != rp-1){
+	while(wp != rp-1 && (rp != bp || wp != ep)){
+		/*
+		 * if we've exhausted the uart's output buffer,
+		 * ask for more from the output queue, and quit if there
+		 * isn't any.
+		 */
 		if(uart->op >= uart->oe && uartstageoutput(uart) == 0)
 			break;
-		if(wp > ep)
-			wp = mem + ccb->obsa;
 		*wp++ = *(uart->op++);
+		if(wp > ep)
+			wp = bp;
 		ccb->obwp = wp - mem;
 	}
 }
 
+/* only called from interrupt service */
 static void
 axprecv(Cc* cc)
 {
@@ -574,52 +585,56 @@ axprecv(Cc* cc)
 	ep = mem + ccb->ibea;
 
 	while(rp != wp){
+		uartrecv(cc, *rp++);		/* ilocks cc->tlock */
 		if(rp > ep)
 			rp = mem + ccb->ibsa;
-		uartrecv(cc, *rp++);
 		ccb->ibrp = rp - mem;
 	}
-
 }
 
 static void
 axpinterrupt(Ureg*, void* arg)
 {
+	int work;
 	Cc *cc;
 	Ctlr *ctlr;
 	u32int ics;
 	u16int r, sr;
 
+	work = 0;
 	ctlr = arg;
 	ics = csr32r(ctlr, Ics);
 	if(ics & 0x0810C000)
 		print("%s: unexpected interrupt %#ux\n", ctlr->name, ics);
-	if(!(ics & 0x00002000))
+	if(!(ics & 0x00002000)) {
+		print("%s: non-doorbell interrupt\n", ctlr->name);
+		// ctlr->gcb->gcw2 = 0x0001;	/* set Gintack */
 		return;
+	}
 
 //	while(work to do){
 		cc = ctlr->cc;
 		for(sr = xchgw(&ctlr->gcb->isr, 0); sr != 0; sr >>= 1){
 			if(sr & 0x0001)
-				axprecv(cc);
+				work++, axprecv(cc);
 			cc++;
 		}
 		cc = ctlr->cc;
 		for(sr = xchgw(&ctlr->gcb->osr, 0); sr != 0; sr >>= 1){
 			if(sr & 0x0001)
-				uartkick(&cc->Uart);
+				work++, uartkick(&cc->Uart);
 			cc++;
 		}
 		cc = ctlr->cc;
 		for(sr = xchgw(&ctlr->gcb->csr, 0); sr != 0; sr >>= 1){
 			if(sr & 0x0001)
-				wakeup(cc);
+				work++, wakeup(cc);
 			cc++;
 		}
 		cc = ctlr->cc;
 		for(sr = xchgw(&ctlr->gcb->msr, 0); sr != 0; sr >>= 1){
 			if(sr & 0x0001)
-				axpmc(cc);
+				work++, axpmc(cc);
 			cc++;
 		}
 		cc = ctlr->cc;
@@ -632,12 +647,17 @@ axpinterrupt(Ureg*, void* arg)
 					cc->perr++;
 				if(r & Fe)
 					cc->ferr++;
+				if (r & (Oe|Pe|Fe))
+					work++;
 			}
 			cc++;
 		}
 //	}
-	csr32w(ctlr, Pdb, 1);
-	ctlr->gcb->gcw2 = 0x0001;
+	/* only meaningful if we don't share the irq */
+	if (0 && !work)
+		print("%s: interrupt with no work\n", ctlr->name);
+	csr32w(ctlr, Pdb, 1);		/* clear doorbell interrupt */
+	ctlr->gcb->gcw2 = 0x0001;	/* set Gintack */
 }
 
 static void
@@ -803,11 +823,10 @@ axpalloc(int ctlrno, Pcidev* pcidev)
 		print("%s: control programme too big\n", ctlr->name);
 		return axpdealloc(ctlr);
 	}
-	/* TODO: is this right for more than 1 card? */
+	/* TODO: is this right for more than 1 card? devastar does the same */
 	csr32w(ctlr, Remap, 0xA0000001);
 	for(i = 0; i < sizeof(uartaxpcp); i++)
 		ctlr->mem[i] = uartaxpcp[i];
-
 	/*
 	 * Execute downloaded code and wait for it
 	 * to signal ready.
@@ -845,7 +864,7 @@ axpalloc(int ctlrno, Pcidev* pcidev)
 		cc->uartno = i;
 		cc->ctlr = ctlr;
 
-		cc->regs = cc;
+		cc->regs = cc;		/* actually Uart->regs */
 		seprint(name, name+sizeof(name), "uartaxp%d%2.2d", ctlrno, i);
 		kstrdup(&cc->name, name);
 		cc->freq = 0;
@@ -861,6 +880,7 @@ axpalloc(int ctlrno, Pcidev* pcidev)
 	}
 	ctlr->cc[n-1].next = nil;
 
+	ctlr->next = nil;
 	if(axpctlrhead != nil)
 		axpctlrtail->next = ctlr;
 	else