Browse Source

ACPI: maintain path information in each pci device.

This greatly simplifies the process of walking the pci tree
to find the right IRQ mappings.

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Ronald G. Minnich 7 years ago
parent
commit
3acce25ea3
3 changed files with 14 additions and 7 deletions
  1. 11 5
      sys/src/9/386/pci.c
  2. 1 0
      sys/src/9/amd64/io.h
  3. 2 2
      sys/src/9/port/devpci.c

+ 11 - 5
sys/src/9/386/pci.c

@@ -122,7 +122,7 @@ pcibarsize(Pcidev *p, int rno)
 }
 
 static int
-pcilscan(int bno, Pcidev** list)
+pcilscan(int bno, char *path, Pcidev** list)
 {
 	Pcidev *p, *head, *tail;
 	int dno, fno, i, hdt, l, maxfno, maxubn, sbn, tbdf, ubn, capoff;
@@ -152,6 +152,7 @@ pcilscan(int bno, Pcidev** list)
 			p->tbdf = tbdf;
 			p->vid = l;
 			p->did = l>>16;
+			p->path = path;
 
 			if(pcilist != nil)
 				pcitail->list = p;
@@ -282,7 +283,9 @@ pcilscan(int bno, Pcidev** list)
 			pcicfgw32(p, PciPCR, 0xFFFF0000);
 			pcicfgw32(p, PciPBN, Maxbus<<16 | sbn<<8 | bno);
 			pcicfgw16(p, PciSPSR, 0xFFFF);
-			maxubn = pcilscan(sbn, &p->bridge);
+			char *bus = mallocz(256, 1);
+			snprint(bus, 256, "%s.%d", path, sbn);
+			maxubn = pcilscan(sbn, bus, &p->bridge);
 			pcicfgw32(p, PciPBN, maxubn<<16 | sbn<<8 | bno);
 		}
 		else {
@@ -294,9 +297,12 @@ pcilscan(int bno, Pcidev** list)
 			 * way down. Need to look more closely at
 			 * this.
 			 */
-			if(ubn > maxubn)
+			if(ubn > maxubn) {
 				maxubn = ubn;
-			pcilscan(sbn, &p->bridge);
+			}
+			char *bus = mallocz(256, 1);
+			snprint(bus, 256, "%s.%d", path, sbn);
+			pcilscan(sbn, bus, &p->bridge);
 		}
 	}
 
@@ -386,7 +392,7 @@ pcicfginit(void)
 	list = &pciroot;
 	for(bno = 0; bno <= Maxbus; bno++) {
 		sbno = bno;
-		bno = pcilscan(bno, list);
+		bno = pcilscan(bno, "0", list);
 
 		while(*list)
 			list = &(*list)->link;

+ 1 - 0
sys/src/9/amd64/io.h

@@ -332,6 +332,7 @@ typedef struct Pcidev Pcidev;
 struct Pcidev
 {
 	int	tbdf;					/* type+bus+device+function */
+	char    *path;
 	uint16_t	vid;			/* vendor ID */
 	uint16_t	did;			/* device ID */
 

+ 2 - 2
sys/src/9/port/devpci.c

@@ -198,8 +198,8 @@ pciread(Chan *c, void *va, int32_t n, int64_t offset)
 		if(p == nil)
 			error(Egreg);
 		ebuf = buf+sizeof buf-1;	/* -1 for newline */
-		w = seprint(buf, ebuf, "%.2x.%.2x.%.2x %.4x/%.4x %3d",
-			p->ccrb, p->ccru, p->ccrp, p->vid, p->did, p->intl);
+		w = seprint(buf, ebuf, "%.2x.%.2x.%.2x %.4x/%.4x %3d %s",
+			p->ccrb, p->ccru, p->ccrp, p->vid, p->did, p->intl, p->path);
 		for(i=0; i<nelem(p->mem); i++){
 			if(p->mem[i].size == 0)
 				continue;