Browse Source

Plan 9 from Bell Labs 2006-12-03

David du Colombier 14 years ago
parent
commit
acedb12047
5 changed files with 27 additions and 34 deletions
  1. 2 2
      dist/replica/_plan9.db
  2. 2 2
      dist/replica/plan9.db
  3. 2 0
      dist/replica/plan9.log
  4. 6 9
      sys/src/cmd/usb/lib/setup.c
  5. 15 21
      sys/src/cmd/usb/lib/usb.h

+ 2 - 2
dist/replica/_plan9.db

@@ -14108,8 +14108,8 @@ sys/src/cmd/usb/lib/device.c - 664 sys sys 1144905083 3073
 sys/src/cmd/usb/lib/dump.c - 664 sys sys 1163722010 12983
 sys/src/cmd/usb/lib/fmt.c - 664 sys sys 1091204978 291
 sys/src/cmd/usb/lib/mkfile - 664 sys sys 1091204979 204
-sys/src/cmd/usb/lib/setup.c - 664 sys sys 1091204978 1953
-sys/src/cmd/usb/lib/usb.h - 664 sys sys 1163721974 7129
+sys/src/cmd/usb/lib/setup.c - 664 sys sys 1165044747 1936
+sys/src/cmd/usb/lib/usb.h - 664 sys sys 1165044715 7066
 sys/src/cmd/usb/lib/util.c - 664 sys sys 1091204978 523
 sys/src/cmd/usb/misc - 20000000775 sys sys 1091205037 0
 sys/src/cmd/usb/misc/mkfile - 664 sys sys 1091205037 274

+ 2 - 2
dist/replica/plan9.db

@@ -14108,8 +14108,8 @@ sys/src/cmd/usb/lib/device.c - 664 sys sys 1144905083 3073
 sys/src/cmd/usb/lib/dump.c - 664 sys sys 1163722010 12983
 sys/src/cmd/usb/lib/fmt.c - 664 sys sys 1091204978 291
 sys/src/cmd/usb/lib/mkfile - 664 sys sys 1091204979 204
-sys/src/cmd/usb/lib/setup.c - 664 sys sys 1091204978 1953
-sys/src/cmd/usb/lib/usb.h - 664 sys sys 1163721974 7129
+sys/src/cmd/usb/lib/setup.c - 664 sys sys 1165044747 1936
+sys/src/cmd/usb/lib/usb.h - 664 sys sys 1165044715 7066
 sys/src/cmd/usb/lib/util.c - 664 sys sys 1091204978 523
 sys/src/cmd/usb/misc - 20000000775 sys sys 1091205037 0
 sys/src/cmd/usb/misc/mkfile - 664 sys sys 1091205037 274

+ 2 - 0
dist/replica/plan9.log

@@ -31761,3 +31761,5 @@
 1164861005 0 c sys/man/4/fossil - 664 sys sys 1164860933 9587
 1164861005 1 c sys/man/6/venti.conf - 664 sys sys 1164860945 1929
 1164861005 2 c sys/man/8/venti - 664 sys sys 1164860929 5434
+1165046406 0 c sys/src/cmd/usb/lib/setup.c - 664 sys sys 1165044747 1936
+1165046406 1 c sys/src/cmd/usb/lib/usb.h - 664 sys sys 1165044715 7066

+ 6 - 9
sys/src/cmd/usb/lib/setup.c

@@ -30,7 +30,7 @@ setupcmd(Endpt *e, int type, int req, int value, int index, byte *data, int coun
 	}
 	n = write(fd, wp, 8+count);
 	if (n < 0) {
-		fprint(2, "setupreq: write err: %r\n");
+		fprint(2, "setupcmd: write err: %r\n");
 		return -1;
 	}
 	if (n != 8+count) {
@@ -79,26 +79,23 @@ int
 setupreply(Endpt *e, void *buf, int nb)
 {
 	uchar *p;
-	int i, fd;
+	int i, fd, nr;
 	char err[32];
 
 	fd = e->dev->setup;
 	if(fd < 0)
 		sysfatal("RSC: this used to use the global usbsetup0\n");
-	for(;;){
-		nb = read(fd, buf, nb);
-		if (nb >= 0)
-			break;
+	while ((nr = read(fd, buf, nb)) < 0) {
 		rerrstr(err, sizeof err);
 		if (strcmp(err, "interrupted") != 0)
 			break;
 	}
 	p = buf;
 	if (debugdebug) {
-		fprint(2, "in\t%d\t[%d]", fd, nb);
-		for(i=0; i<nb; i++)
+		fprint(2, "in\t%d\t[%d]", fd, nr);
+		for(i=0; i<nr; i++)
 			fprint(2, " %.2ux", p[i]);
 		fprint(2, "\n");
 	}
-	return nb;
+	return nr;
 }

+ 15 - 21
sys/src/cmd/usb/lib/usb.h

@@ -4,10 +4,10 @@
  */
 
 enum {
-	Dbginfo = 0x01,
-	Dbgfs = 0x02,
-	Dbgproc = 0x04,
-	Dbgcontrol = 0x08,
+	Dbginfo =	0x01,
+	Dbgfs =		0x02,
+	Dbgproc =	0x04,
+	Dbgcontrol =	0x08,
 };
 
 extern int debug, debugdebug, verbose;
@@ -38,26 +38,20 @@ typedef struct Endpt Endpt;
 
 typedef struct Namelist Namelist;
 
-#ifndef nelem
-#define	nelem(x)	(sizeof((x))/sizeof((x)[0]))
-#endif
-
 #define	GET2(p)	((((p)[1]&0xFF)<<8)|((p)[0]&0xFF))
 #define	PUT2(p,v)	{((p)[0] = (v)); ((p)[1] = (v)>>8);}
 
 enum
 {
-	TokIN = 0x69,
-	TokOUT = 0xE1,
-	TokSETUP = 0x2D,
-
 	/* request type */
 	RH2D = 0<<7,
 	RD2H = 1<<7,
-	Rstandard = 0<<5,
-	Rclass = 1<<5,
+
+	Rstandard = 0<<5,	/* types */
+	Rclass =  1<<5,
 	Rvendor = 2<<5,
-	Rdevice = 0,
+
+	Rdevice = 0,		/* recipients */
 	Rinterface = 1,
 	Rendpt = 2,
 	Rother = 3,
@@ -247,9 +241,9 @@ struct Device
 {
 	Ref;
 	int	ctlrno;
-	int	ctl;
-	int	setup;
-	int	status;
+	int	ctl;		/* fd */
+	int	setup;		/* fd */
+	int	status;		/* fd */
 	int	state;
 	int	id;
 	int	class;
@@ -257,13 +251,13 @@ struct Device
 	int	ls;		/* low speed */
 	ulong	csp;		/* USB class/subclass/proto */
 	int	nconf;
-	int	nif;		/* number of interfaces (sum of per-conf `nif's) */
+	int	nif;		/* # of interfaces (sum of per-conf `nif's) */
 	int	vid;		/* vendor id */
 	int	did;		/* product (device) id */
 	Dconf*	config[16];
 	Endpt*	ep[Nendpt];
-//	Device*	setupfd;	/* for usbprobe */
-//	Device*	cfd;		/* for usbprobe */
+	Device*	setupfd;	/* for usbprobe */
+	Device*	cfd;		/* for usbprobe */
 };
 
 /*