Module Name:    src
Committed By:   nisimura
Date:           Thu Feb 10 13:38:08 UTC 2011

Modified Files:
        src/sys/arch/sandpoint/stand/altboot: brdsetup.c dsk.c globals.h main.c
            nif.c pci.c

Log Message:
- some rework for PCI device enumeration.
- allow dual IDE/SATA devices.
- fix a typo of D-Link #define.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sandpoint/stand/altboot/brdsetup.c \
    src/sys/arch/sandpoint/stand/altboot/dsk.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sandpoint/stand/altboot/globals.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sandpoint/stand/altboot/main.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sandpoint/stand/altboot/nif.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sandpoint/stand/altboot/pci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sandpoint/stand/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.3 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.4
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.3	Tue Feb  8 00:33:05 2011
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Thu Feb 10 13:38:08 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.3 2011/02/08 00:33:05 nisimura Exp $ */
+/* $NetBSD: brdsetup.c,v 1.4 2011/02/10 13:38:08 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -101,8 +101,8 @@
 	NULL, iomegabrdfix, iomegapcifix },
     {
 	"dlink",
-	"D-Link GSM-G600",
-	BRD_DLINKGSM,
+	"D-Link DSM-G600",
+	BRD_DLINKDSM,
 	0,
 	"eumb", 0x4500, 9600,
 	NULL, dlinkbrdfix, dlinkpcifix },
@@ -215,7 +215,7 @@
 	}
 	else if (PCI_VENDOR(pcicfgread(pcimaketag(0, 16, 0), PCI_ID_REG)) ==
 	    0x1191) {				/* PCI_VENDOR_ACARD */
-		brdtype = BRD_DLINKGSM;
+		brdtype = BRD_DLINKDSM;
 	}
 
 	brdprop = brd_lookup(brdtype);
@@ -406,12 +406,12 @@
 void
 motpcifix(struct brdprop *brd)
 {
-	unsigned ide, nic, pcib, steer, val;
+	unsigned ide, net, pcib, steer, val;
 	int line;
 
 	pcib = pcimaketag(0, 11, 0);
 	ide  = pcimaketag(0, 11, 1);
-	nic  = pcimaketag(0, 15, 0);
+	net  = pcimaketag(0, 15, 0);
 
 	/*
 	 * //// WinBond PIRQ ////
@@ -492,21 +492,21 @@
 	 * //// fxp fixup ////
 	 * - use PCI pin A line 15 (fxp 0x3d/3c)
 	 */
-	val = pcicfgread(nic, 0x3c) & 0xffff0000;
-	pcidecomposetag(nic, NULL, &line, NULL);
+	val = pcicfgread(net, 0x3c) & 0xffff0000;
+	pcidecomposetag(net, NULL, &line, NULL);
 	val |= (('A' - '@') << 8) | line;
-	pcicfgwrite(nic, 0x3c, val);
+	pcicfgwrite(net, 0x3c, val);
 }
 
 void
 encpcifix(struct brdprop *brd)
 {
-	unsigned ide, irq, nic, pcib, steer, val;
+	unsigned ide, irq, net, pcib, steer, val;
 
 #define	STEER(v, b) (((v) & (b)) ? "edge" : "level")
 	pcib = pcimaketag(0, 22, 0);
 	ide  = pcimaketag(0, 22, 1);
-	nic  = pcimaketag(0, 25, 0);
+	net  = pcimaketag(0, 25, 0);
 
 	/*
 	 * //// VIA PIRQ ////
@@ -603,9 +603,9 @@
 	 * - use PCI pin A line 25 (fxp 0x3d/3c)
 	 */
 	/* 0x3d/3c - PCI pin/line */
-	val = pcicfgread(nic, 0x3c) & 0xffff0000;
+	val = pcicfgread(net, 0x3c) & 0xffff0000;
 	val |= (('A' - '@') << 8) | 25;
-	pcicfgwrite(nic, 0x3c, val);
+	pcicfgwrite(net, 0x3c, val);
 }
 
 void
@@ -630,17 +630,17 @@
 void
 kuropcifix(struct brdprop *brd)
 {
-	unsigned ide, nic, usb, val;
+	unsigned dsk, net, usb, val;
 
-	nic = pcimaketag(0, 11, 0);
-	val = pcicfgread(nic, 0x3c) & 0xffffff00;
+	net = pcimaketag(0, 11, 0);
+	val = pcicfgread(net, 0x3c) & 0xffffff00;
 	val |= 11;
-	pcicfgwrite(nic, 0x3c, val);
+	pcicfgwrite(net, 0x3c, val);
 
-	ide = pcimaketag(0, 12, 0);
-	val = pcicfgread(ide, 0x3c) & 0xffffff00;
+	dsk = pcimaketag(0, 12, 0);
+	val = pcicfgread(dsk, 0x3c) & 0xffffff00;
 	val |= 12;
-	pcicfgwrite(ide, 0x3c, val);
+	pcicfgwrite(dsk, 0x3c, val);
 
 	usb = pcimaketag(0, 14, 0);
 	val = pcicfgread(usb, 0x3c) & 0xffffff00;
@@ -677,12 +677,12 @@
 void
 synopcifix(struct brdprop *brd)
 {
-	unsigned ide, nic, usb, val;
+	unsigned dsk, net, usb, val;
 
-	ide = pcimaketag(0, 13, 0);
-	val = pcicfgread(ide, 0x3c) & 0xffffff00;
+	dsk = pcimaketag(0, 13, 0);
+	val = pcicfgread(dsk, 0x3c) & 0xffffff00;
 	val |= 13;
-	pcicfgwrite(ide, 0x3c, val);
+	pcicfgwrite(dsk, 0x3c, val);
 
 	usb = pcimaketag(0, 14, 0);
 	val = pcicfgread(usb, 0x3c) & 0xffffff00;
@@ -699,10 +699,10 @@
 	val |= 14;
 	pcicfgwrite(usb, 0x3c, val);
 
-	nic = pcimaketag(0, 15, 0);
-	val = pcicfgread(nic, 0x3c) & 0xffffff00;
+	net = pcimaketag(0, 15, 0);
+	val = pcicfgread(net, 0x3c) & 0xffffff00;
 	val |= 15;
-	pcicfgwrite(nic, 0x3c, val);
+	pcicfgwrite(net, 0x3c, val);
 }
 
 void
@@ -716,12 +716,12 @@
 void
 qnappcifix(struct brdprop *brd)
 {
-	unsigned ide, nic, usb, val;
+	unsigned dsk, net, usb, val;
 
-	ide = pcimaketag(0, 13, 0);
-	val = pcicfgread(ide, 0x3c) & 0xffffff00;
+	dsk = pcimaketag(0, 13, 0);
+	val = pcicfgread(dsk, 0x3c) & 0xffffff00;
 	val |= 13;
-	pcicfgwrite(ide, 0x3c, val);
+	pcicfgwrite(dsk, 0x3c, val);
 
 	usb = pcimaketag(0, 14, 0);
 	val = pcicfgread(usb, 0x3c) & 0xffffff00;
@@ -738,10 +738,10 @@
 	val |= 14;
 	pcicfgwrite(usb, 0x3c, val);
 
-	nic = pcimaketag(0, 15, 0);
-	val = pcicfgread(nic, 0x3c) & 0xffffff00;
+	net = pcimaketag(0, 15, 0);
+	val = pcicfgread(net, 0x3c) & 0xffffff00;
 	val |= 15;
-	pcicfgwrite(nic, 0x3c, val);
+	pcicfgwrite(net, 0x3c, val);
 }
 
 void
@@ -754,12 +754,12 @@
 void
 iomegapcifix(struct brdprop *brd)
 {
-	unsigned ide, nic, usb, val;
+	unsigned dsk, net, usb, val;
 
-	ide = pcimaketag(0, 13, 0);
-	val = pcicfgread(ide, 0x3c) & 0xffffff00;
+	dsk = pcimaketag(0, 13, 0);
+	val = pcicfgread(dsk, 0x3c) & 0xffffff00;
 	val |= 13;
-	pcicfgwrite(ide, 0x3c, val);
+	pcicfgwrite(dsk, 0x3c, val);
 
 	usb = pcimaketag(0, 14, 0);
 	val = pcicfgread(usb, 0x3c) & 0xffffff00;
@@ -776,10 +776,10 @@
 	val |= 14;
 	pcicfgwrite(usb, 0x3c, val);
 
-	nic = pcimaketag(0, 15, 0);
-	val = pcicfgread(nic, 0x3c) & 0xffffff00;
+	net = pcimaketag(0, 15, 0);
+	val = pcicfgread(net, 0x3c) & 0xffffff00;
 	val |= 15;
-	pcicfgwrite(nic, 0x3c, val);
+	pcicfgwrite(net, 0x3c, val);
 }
 
 void
@@ -792,7 +792,7 @@
 void
 dlinkpcifix(struct brdprop *brd)
 {
-	unsigned usb, nic, ide, val;
+	unsigned usb, net, dsk, val;
 
 	usb = pcimaketag(0, 14, 0);
 	val = pcicfgread(usb, 0x3c) & 0xffffff00;
@@ -809,15 +809,15 @@
 	val |= 14;
 	pcicfgwrite(usb, 0x3c, val);
 
-	nic = pcimaketag(0, 15, 0);
-	val = pcicfgread(nic, 0x3c) & 0xffffff00;
+	net = pcimaketag(0, 15, 0);
+	val = pcicfgread(net, 0x3c) & 0xffffff00;
 	val |= 15;
-	pcicfgwrite(nic, 0x3c, val);
+	pcicfgwrite(net, 0x3c, val);
 
-	ide = pcimaketag(0, 16, 0);
-	val = pcicfgread(ide, 0x3c) & 0xffffff00;
+	dsk = pcimaketag(0, 16, 0);
+	val = pcicfgread(dsk, 0x3c) & 0xffffff00;
 	val |= 16;
-	pcicfgwrite(ide, 0x3c, val);
+	pcicfgwrite(dsk, 0x3c, val);
 }
 
 void
Index: src/sys/arch/sandpoint/stand/altboot/dsk.c
diff -u src/sys/arch/sandpoint/stand/altboot/dsk.c:1.3 src/sys/arch/sandpoint/stand/altboot/dsk.c:1.4
--- src/sys/arch/sandpoint/stand/altboot/dsk.c:1.3	Thu Jan 27 17:38:04 2011
+++ src/sys/arch/sandpoint/stand/altboot/dsk.c	Thu Feb 10 13:38:08 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: dsk.c,v 1.3 2011/01/27 17:38:04 phx Exp $ */
+/* $NetBSD: dsk.c,v 1.4 2011/02/10 13:38:08 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -68,15 +68,15 @@
 	char *name;
 	int (*match)(unsigned, void *);
 	void *(*init)(unsigned, void *);
-	void *priv;
 };
 
 static struct dskdv ldskdv[] = {
-	{ "pciide", pciide_match, pciide_init, },
-	{ "siisata", siisata_match, siisata_init, },
+	{ "pciide", pciide_match, pciide_init },
+	{ "siisata", siisata_match, siisata_init },
 };
 static int ndskdv = sizeof(ldskdv)/sizeof(ldskdv[0]);
 
+static int disk_scan(void *);
 static int probe_drive(struct dkdev_ata *, int);
 static void drive_ident(struct disk *, char *);
 static char *mkident(char *, int);
@@ -90,11 +90,14 @@
 static struct disk ldisk[4];
 
 int
-dskdv_init(unsigned tag, void **cookie)
+dskdv_init(void *self)
 {
+	struct pcidev *pci = self;
 	struct dskdv *dv;
+	unsigned tag;
 	int n;
 
+	tag = pci->bdf;
 	for (n = 0; n < ndskdv; n++) {
 		dv = &ldskdv[n];
 		if ((*dv->match)(tag, NULL) > 0)
@@ -102,16 +105,15 @@
 	}
 	return 0;
   found:
-	dv->priv = (*dv->init)(tag, NULL);
-	*cookie = dv;
+	pci->drv = (*dv->init)(tag, NULL);
+	disk_scan(pci->drv);
 	return 1;
 }
 
-int
-disk_scan(void *cookie)
+static int
+disk_scan(void *drv)
 {
-	struct dskdv *dv = cookie;
-	struct dkdev_ata *l = dv->priv;
+	struct dkdev_ata *l = drv;
 	struct disk *d;
 	int n, ndrive;
 

Index: src/sys/arch/sandpoint/stand/altboot/globals.h
diff -u src/sys/arch/sandpoint/stand/altboot/globals.h:1.4 src/sys/arch/sandpoint/stand/altboot/globals.h:1.5
--- src/sys/arch/sandpoint/stand/altboot/globals.h:1.4	Tue Feb  8 00:33:05 2011
+++ src/sys/arch/sandpoint/stand/altboot/globals.h	Thu Feb 10 13:38:08 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: globals.h,v 1.4 2011/02/08 00:33:05 nisimura Exp $ */
+/* $NetBSD: globals.h,v 1.5 2011/02/10 13:38:08 nisimura Exp $ */
 
 #ifdef DEBUG
 #define	DPRINTF(x)	printf x
@@ -20,7 +20,7 @@
 #define BRD_QNAPTS101		101
 #define BRD_SYNOLOGY		102
 #define BRD_STORCENTER		103
-#define BRD_DLINKGSM		104
+#define BRD_DLINKDSM		104
 #define BRD_UNKNOWN		-1
 
 struct brdprop {
@@ -64,12 +64,17 @@
 void delay(unsigned);
 
 /* PCI stuff */
+struct pcidev {
+	unsigned bdf;	/* bus.dev.func */
+	unsigned pvd;	/* device ID */
+	void *drv;	/* driver */
+};
 void  pcisetup(void);
 void  pcifixup(void);
 unsigned pcimaketag(int, int, int);
 void  pcidecomposetag(unsigned, int *, int *, int *);
 int   pcifinddev(unsigned, unsigned, unsigned *);
-int   pcilookup(unsigned, unsigned [][2], int);
+int   pcilookup(unsigned, struct pcidev *, int);
 unsigned pcicfgread(unsigned, int);
 void  pcicfgwrite(unsigned, int, unsigned);
 
@@ -86,6 +91,7 @@
 #define  PCI_CLASS_RAID			0x0104
 #define  PCI_CLASS_SATA			0x0106
 #define  PCI_CLASS_MISCSTORAGE		0x0180
+#define  PCI_CLASS_USB			0x0c03
 #define PCI_BHLC_REG			0x0c
 #define  PCI_HDRTYPE_TYPE(r)		(((r) >> 16) & 0x7f)
 #define  PCI_HDRTYPE_MULTIFN(r)		((r) & (0x80 << 16))
@@ -117,7 +123,7 @@
 int net_close(struct open_file *);
 int net_strategy(void *, int, daddr_t, size_t, void *, size_t *);
 
-int netif_init(unsigned);
+int netif_init(void *);
 int netif_open(void *); 
 int netif_close(int); 
 
@@ -133,8 +139,7 @@
 NIF_DECL(skg);
 
 /* DSK support */
-int dskdv_init(unsigned, void **);
-int disk_scan(void *);
+int dskdv_init(void *);
 
 int dsk_open(struct open_file *, ...);
 int dsk_close(struct open_file *);

Index: src/sys/arch/sandpoint/stand/altboot/main.c
diff -u src/sys/arch/sandpoint/stand/altboot/main.c:1.5 src/sys/arch/sandpoint/stand/altboot/main.c:1.6
--- src/sys/arch/sandpoint/stand/altboot/main.c:1.5	Thu Jan 27 17:38:04 2011
+++ src/sys/arch/sandpoint/stand/altboot/main.c	Thu Feb 10 13:38:08 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.5 2011/01/27 17:38:04 phx Exp $ */
+/* $NetBSD: main.c,v 1.6 2011/02/10 13:38:08 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -91,6 +91,11 @@
 void main(int, char **);
 extern char bootprog_name[], bootprog_rev[];
 
+struct pcidev lata[2];
+struct pcidev lnif[1];
+struct pcidev lusb[3];
+int nata, nnif, nusb;
+
 int brdtype;
 uint32_t busclock, cpuclock;
 
@@ -102,11 +107,8 @@
 {
 	struct brdprop *brdprop;
 	unsigned long marks[MARK_MAX];
-	unsigned lata[1][2], lnif[1][2];
-	unsigned tag, dsk;
-	int b, d, f, fd, howto, i, n;
+	int n, i, fd, howto;
 	char *bname;
-	void *dev;
 
 	printf("\n");
 	printf(">> %s altboot, revision %s\n", bootprog_name, bootprog_rev);
@@ -115,43 +117,54 @@
 	printf(">> %s, cpu %u MHz, bus %u MHz, %dMB SDRAM\n", brdprop->verbose,
 	    cpuclock / 1000000, busclock / 1000000, bi_mem.memsize >> 20);
 
-	n = pcilookup(PCI_CLASS_IDE, lata, sizeof(lata)/sizeof(lata[0]));
-	if (n == 0)
-		n = pcilookup(PCI_CLASS_MISCSTORAGE, lata,
-		    sizeof(lata)/sizeof(lata[0]));
-	if (n == 0) {
-		dsk = ~0;
-		DPRINTF(("No IDE found!\n"));
-	}
-	else {
-		dsk = lata[0][1];
-		pcidecomposetag(dsk, &b, &d, &f);
-		DPRINTF(("%04x.%04x IDE %02d:%02d:%02d\n",
-		    PCI_VENDOR(lata[0][0]), PCI_PRODUCT(lata[0][0]),
-		    b, d, f));
-	}
-
-	n = pcilookup(PCI_CLASS_ETH, lnif, sizeof(lnif)/sizeof(lnif[0]));
-	if (n == 0) {
-		tag = ~0;
-		DPRINTF(("no NIC found\n"));
+	nata = pcilookup(PCI_CLASS_IDE, lata, 2);
+	if (nata == 0)
+		nata = pcilookup(PCI_CLASS_MISCSTORAGE, lata, 2);
+	nnif = pcilookup(PCI_CLASS_ETH, lnif, 1);
+	nusb = pcilookup(PCI_CLASS_USB, lusb, 3);
+
+#ifdef DEBUG
+	if (nata == 0)
+		printf("No IDE/SATA found\n");
+	else for (n = 0; n < nata; n++) {
+		int b, d, f, bdf, pvd;
+		bdf = lata[n].bdf;
+		pvd = lata[n].pvd;
+		pcidecomposetag(bdf, &b, &d, &f);
+		printf("%04x.%04x DSK %02d:%02d:%02d\n",
+		    PCI_VENDOR(pvd), PCI_PRODUCT(pvd), b, d, f);
 	}
+	if (nnif == 0)
+		printf("no NET found\n");
 	else {
-		tag = lnif[0][1];
-		pcidecomposetag(tag, &b, &d, &f);
-		DPRINTF(("%04x.%04x NIC %02d:%02d:%02d\n",
-		    PCI_VENDOR(lnif[0][0]), PCI_PRODUCT(lnif[0][0]),
-		    b, d, f));
+		int b, d, f, bdf, pvd;
+		bdf = lnif[0].bdf;
+		pvd = lnif[0].pvd;
+		pcidecomposetag(bdf, &b, &d, &f);
+		printf("%04x.%04x NET %02d:%02d:%02d\n",
+		    PCI_VENDOR(pvd), PCI_PRODUCT(pvd), b, d, f);
+	}
+	if (nusb == 0)
+		printf("no USB found\n");
+	else for (n = 0; n < nusb; n++) {
+		int b, d, f, bdf, pvd;
+		bdf = lusb[0].bdf;
+		pvd = lusb[0].pvd;
+		pcidecomposetag(bdf, &b, &d, &f);
+		printf("%04x.%04x USB %02d:%02d:%02d\n",
+		    PCI_VENDOR(pvd), PCI_PRODUCT(pvd), b, d, f);
 	}
+#endif
 
 	pcisetup();
 	pcifixup();
 
-	if (dskdv_init(dsk, &dev) == 0 || disk_scan(dev) == 0)
-		printf("no IDE/SATA device driver was found\n");
+	if (dskdv_init(&lata[0]) == 0
+	    || (nata == 2 && dskdv_init(&lata[1]) == 0))
+		printf("IDE/SATA device driver was not found\n");
 
-	if (netif_init(tag) == 0)
-		printf("no NIC device driver was found\n");
+	if (netif_init(&lnif[0]) == 0)
+		printf("no NET device driver was found\n");
 
 	howto = RB_AUTOBOOT;		/* default is autoboot = 0 */
 

Index: src/sys/arch/sandpoint/stand/altboot/nif.c
diff -u src/sys/arch/sandpoint/stand/altboot/nif.c:1.1 src/sys/arch/sandpoint/stand/altboot/nif.c:1.2
--- src/sys/arch/sandpoint/stand/altboot/nif.c:1.1	Sun Jan 23 01:05:30 2011
+++ src/sys/arch/sandpoint/stand/altboot/nif.c	Thu Feb 10 13:38:08 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: nif.c,v 1.1 2011/01/23 01:05:30 nisimura Exp $ */
+/* $NetBSD: nif.c,v 1.2 2011/02/10 13:38:08 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -62,15 +62,18 @@
 static int nnifdv = sizeof(lnifdv)/sizeof(lnifdv[0]);
 
 int
-netif_init(unsigned tag)
+netif_init(void *self)
 {
+	struct pcidev *pci = self;
 	struct iodesc *s;
 	struct nifdv *dv;
+	unsigned tag;
 	int n;
 	uint8_t enaddr[6];
 	extern struct btinfo_net bi_net;
 	extern struct btinfo_rootdevice bi_rdev;
 
+	tag = pci->bdf;
 	for (n = 0; n < nnifdv; n++) {
 		dv = &lnifdv[n];
 		if ((*dv->match)(tag, NULL) > 0)
@@ -78,11 +81,10 @@
 	}
 	return 0;
   found:
-	dv->priv = (*dv->init)(tag, enaddr);
+	pci->drv = dv->priv = (*dv->init)(tag, enaddr);
 	s = &netdesc;
 	s->io_netif = dv;
 	memcpy(s->myea, enaddr, sizeof(s->myea));
-
 	/* build btinfo to identify NIF device */
 	snprintf(bi_net.devname, sizeof(bi_net.devname), dv->name);
 	memcpy(bi_net.mac_address, enaddr, sizeof(bi_net.mac_address));

Index: src/sys/arch/sandpoint/stand/altboot/pci.c
diff -u src/sys/arch/sandpoint/stand/altboot/pci.c:1.2 src/sys/arch/sandpoint/stand/altboot/pci.c:1.3
--- src/sys/arch/sandpoint/stand/altboot/pci.c:1.2	Thu Jan 27 17:38:04 2011
+++ src/sys/arch/sandpoint/stand/altboot/pci.c	Thu Feb 10 13:38:08 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: pci.c,v 1.2 2011/01/27 17:38:04 phx Exp $ */
+/* $NetBSD: pci.c,v 1.3 2011/02/10 13:38:08 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -44,7 +44,7 @@
 		int (*)(int, int, int, unsigned long), unsigned long);
 static int _pcilookup(int,
 		int (*)(int, int, int, unsigned long), unsigned long,
-		unsigned [][2], int, int);
+		struct pcidev *, int, int);
 static int deviceinit(int, int, int, unsigned long);
 static void memassign(int, int, int);
 static int devmatch(int, int, int, unsigned long);
@@ -70,11 +70,12 @@
 int
 pcifinddev(unsigned vend, unsigned prod, unsigned *tag)
 {
-	unsigned pciid, target[1][2];
+	unsigned pciid;
+	struct pcidev target;
 
 	pciid = PCI_DEVICE(vend, prod);
-	if (_pcilookup(0, devmatch, pciid, target, 0, 1)) {
-		*tag = target[0][1];
+	if (_pcilookup(0, devmatch, pciid, &target, 0, 1)) {
+		*tag = target.bdf;
 		return 0;
 	}
 	*tag = ~0;
@@ -84,7 +85,7 @@
 int
 pcilookup(type, list, max)
 	unsigned type;
-	unsigned list[][2];
+	struct pcidev *list;
 	int max;
 {
 
@@ -334,7 +335,7 @@
 }
 
 static int
-_pcilookup(int bus, int (*match)(int, int, int, unsigned long), unsigned long data, unsigned list[][2], int index, int limit)
+_pcilookup(int bus, int (*match)(int, int, int, unsigned long), unsigned long data, struct pcidev *list, int index, int limit)
 {
 	int device, function, nfuncs;
 	unsigned pciid, bhlcr, class;
@@ -363,8 +364,8 @@
 			if (PCI_VENDOR(pciid) == 0)
 				continue;
 			if ((*match)(bus, device, function, data)) {
-				list[index][0] = pciid;
-				list[index][1] =
+				list[index].pvd = pciid;
+				list[index].bdf =
 				     pcimaketag(bus, device, function);
 				index += 1;
 				if (index >= limit)

Reply via email to