Browse Source

Plan 9 from Bell Labs 2004-06-30

David du Colombier 20 years ago
parent
commit
2c0cde3fc2
5 changed files with 55 additions and 21 deletions
  1. 2 2
      dist/replica/_plan9.db
  2. 2 2
      dist/replica/plan9.db
  3. 2 0
      dist/replica/plan9.log
  4. 1 3
      sys/man/3/pnp
  5. 48 14
      sys/src/9/port/devpnp.c

+ 2 - 2
dist/replica/_plan9.db

@@ -4944,7 +4944,7 @@ sys/man/3/lpt - 664 sys sys 944959698 893
 sys/man/3/mnt - 664 sys sys 944959698 1994
 sys/man/3/mouse - 664 sys sys 1020313480 4276
 sys/man/3/pipe - 664 sys sys 1032640674 1145
-sys/man/3/pnp - 664 sys sys 1019864752 4645
+sys/man/3/pnp - 664 sys sys 1088560895 4547
 sys/man/3/proc - 664 sys sys 1074785156 12026
 sys/man/3/root - 664 sys sys 1046958450 632
 sys/man/3/rtc - 664 sys sys 954378857 667
@@ -5461,7 +5461,7 @@ sys/src/9/port/devmntstats.c - 664 sys sys 1014931173 4039
 sys/src/9/port/devmouse.c - 664 sys sys 1067722758 12203
 sys/src/9/port/devnmouse.c - 664 sys sys 1036812999 3738
 sys/src/9/port/devpipe.c - 664 sys sys 1077055016 5825
-sys/src/9/port/devpnp.c - 664 sys sys 1055688361 13021
+sys/src/9/port/devpnp.c - 664 sys sys 1088560907 13624
 sys/src/9/port/devproc.c - 664 sys sys 1084475128 28427
 sys/src/9/port/devroot.c - 664 sys sys 1067722764 4254
 sys/src/9/port/devsd.c - 664 sys sys 1071245428 28564

+ 2 - 2
dist/replica/plan9.db

@@ -4944,7 +4944,7 @@ sys/man/3/lpt - 664 sys sys 944959698 893
 sys/man/3/mnt - 664 sys sys 944959698 1994
 sys/man/3/mouse - 664 sys sys 1020313480 4276
 sys/man/3/pipe - 664 sys sys 1032640674 1145
-sys/man/3/pnp - 664 sys sys 1019864752 4645
+sys/man/3/pnp - 664 sys sys 1088560895 4547
 sys/man/3/proc - 664 sys sys 1074785156 12026
 sys/man/3/root - 664 sys sys 1046958450 632
 sys/man/3/rtc - 664 sys sys 954378857 667
@@ -5461,7 +5461,7 @@ sys/src/9/port/devmntstats.c - 664 sys sys 1014931173 4039
 sys/src/9/port/devmouse.c - 664 sys sys 1067722758 12203
 sys/src/9/port/devnmouse.c - 664 sys sys 1036812999 3738
 sys/src/9/port/devpipe.c - 664 sys sys 1077055016 5825
-sys/src/9/port/devpnp.c - 664 sys sys 1055688361 13021
+sys/src/9/port/devpnp.c - 664 sys sys 1088560907 13624
 sys/src/9/port/devproc.c - 664 sys sys 1084475128 28427
 sys/src/9/port/devroot.c - 664 sys sys 1067722764 4254
 sys/src/9/port/devsd.c - 664 sys sys 1071245428 28564

+ 2 - 0
dist/replica/plan9.log

@@ -15765,3 +15765,5 @@
 1088263824 14 c 386/bin/aux/vga - 775 sys sys 1088263680 300474
 1088263824 15 c 386/bin/troff - 775 sys sys 1088263705 357256
 1088263824 16 c 386/lib/ape/libap.a - 664 sys sys 1088263708 806956
+1088560880 0 c sys/man/3/pnp - 664 sys sys 1088560895 4547
+1088560880 1 c sys/src/9/port/devpnp.c - 664 sys sys 1088560907 13624

+ 1 - 3
sys/man/3/pnp

@@ -32,7 +32,7 @@ These are a control file
 which may be read for a textual summary of the device function,
 and a `raw' file
 .RL ( /dev/pci/\fIbus\fP.\fIdev\fP.\fIfn\fPraw )
-which may be read to obtain the raw contents of PCI configuration space.
+which may be used to read or write the raw contents of PCI configuration space.
 .PP
 The first field of a PCI control file contains the class, sub-class and
 programming interface values for the device function, expressed
@@ -135,8 +135,6 @@ grep '^03' /dev/pci/*ctl
 .SH SOURCE
 .B /sys/src/9/port/devpnp.c
 .SH BUGS
-There is currently no way to write to PCI configuration space,
-or to perform reads of less than 32 bits.
 Access to the I/O and memory regions of a PCI device is not provided.
 .PP
 The ability to set a Plug 'n' Play card's configurable settings has not been

+ 48 - 14
sys/src/9/port/devpnp.c

@@ -367,7 +367,7 @@ pcigen(Chan *c, int t, int tbdf, Dir *dp)
 		return 1;
 	case Qpciraw:
 		sprint(up->genbuf, "%d.%d.%draw", BUSBNO(tbdf), BUSDNO(tbdf), BUSFNO(tbdf));
-		devdir(c, q, up->genbuf, 128, eve, 0444, dp);
+		devdir(c, q, up->genbuf, 128, eve, 0660, dp);
 		return 1;
 	}
 	return -1;
@@ -552,17 +552,22 @@ pnpread(Chan *c, void *va, long n, vlong offset)
 			return 0;
 		if(n+offset > 256)
 			n = 256-offset;
-		if(offset%4)
-			error(Ebadarg);
 		r = offset;
-		for(i = 0; i+4 <= n; i+=4) {
+		if(!(r & 3) && n == 4){
 			x = pcicfgr32(p, r);
-			a[0] = x;
-			a[1] = (x>>8);
-			a[2] = (x>>16);
-			a[3] = (x>>24);
-			a += 4;
-			r += 4;
+			PBIT32(a, x);
+			return 4;
+		}
+		if(!(r & 1) && n == 2){
+			x = pcicfgr16(p, r);
+			PBIT16(a, x);
+			return 2;
+		}
+		for(i = 0; i <  n; i++){
+			x = pcicfgr8(p, r);
+			PBIT8(a, x);
+			a++;
+			r++;
 		}
 		return i;
 	default:
@@ -572,15 +577,17 @@ pnpread(Chan *c, void *va, long n, vlong offset)
 }
 
 static long
-pnpwrite(Chan *c, void *a, long n, vlong)
+pnpwrite(Chan *c, void *va, long n, vlong offset)
 {
-	int csn;
 	Card *cp;
-	ulong port;
-	char buf[256];
+	Pcidev *p;
+	ulong port, x;
+	char *a, buf[256];
+	int csn, i, r, tbdf;
 
 	if(n >= sizeof(buf))
 		n = sizeof(buf)-1;
+	a = va;
 	strncpy(buf, a, n);
 	buf[n] = 0;
 
@@ -615,6 +622,33 @@ pnpwrite(Chan *c, void *a, long n, vlong)
 		if(!wrconfig(cp, buf))
 			error(Ebadctl);
 		break;
+	case Qpciraw:
+		tbdf = MKBUS(BusPCI, 0, 0, 0)|BUSBDF((ulong)c->qid.path);
+		p = pcimatchtbdf(tbdf);
+		if(p == nil)
+			error(Egreg);
+		if(offset > 256)
+			return 0;
+		if(n+offset > 256)
+			n = 256-offset;
+		r = offset;
+		if(!(r & 3) && n == 4){
+			x = GBIT32(a);
+			pcicfgw32(p, r, x);
+			return 4;
+		}
+		if(!(r & 1) && n == 2){
+			x = GBIT16(a);
+			pcicfgw16(p, r, x);
+			return 2;
+		}
+		for(i = 0; i <  n; i++){
+			x = GBIT8(a);
+			pcicfgw8(p, r, x);
+			a++;
+			r++;
+		}
+		return i;
 	default:
 		error(Egreg);
 	}