Subject: PCI Sub-vendor/sub-product IDs
To: None <tech-kern@netbsd.org>
From: Quentin Garnier <cube@cubidou.net>
List: tech-kern
Date: 04/17/2006 02:33:35
--ey/N+yb7u/X9mFhi
Content-Type: multipart/mixed; boundary="vni90+aGYgRvsTuO"
Content-Disposition: inline


--vni90+aGYgRvsTuO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hi folks,

While I'm glad auich.c has been fixed for some motherboards, I'm a bit
disgusted by the use of raw IDs for sub-vendor and sub-product matching.

I'm proposing the attached patch to store them in pcidevs (and I leave
the auich.c changes as an exercise to the reader).  I'm not 100%
positive that the 0x161f sub-vendor ID used in auich.c is always
Rioworks but I'd say it's likely enough to be true.  The patch leaves
the option to have "subvendor" entries, anyway.

Should pci_findvendor(9) and pci_devinfo(9) be change to have one more
parameter that asks for sub-product stuff, or can it wait for when it's
actually useful?

Comments?

--=20
Quentin Garnier - cube@cubidou.net - cube@NetBSD.org
"When I find the controls, I'll go where I like, I'll know where I want
to be, but maybe for now I'll stay right here on a silent sea."
KT Tunstall, Silent Sea, Eye to the Telescope, 2004.

--vni90+aGYgRvsTuO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="pcidevs.diff"
Content-Transfer-Encoding: quoted-printable

Index: devlist2h.awk
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/src/sys/dev/pci/devlist2h.awk,v
retrieving revision 1.12
diff -u -r1.12 devlist2h.awk
--- devlist2h.awk	11 Dec 2005 12:22:49 -0000	1.12
+++ devlist2h.awk	17 Apr 2006 00:32:34 -0000
@@ -30,7 +30,7 @@
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
 BEGIN {
-	nproducts =3D nvendors =3D blanklines =3D 0
+	nproducts =3D nvendors =3D nsubproducts =3D nsubvendors =3D blanklines =
=3D 0
 	dfile=3D"pcidevs_data.h"
 	hfile=3D"pcidevs.h"
 }
@@ -149,6 +149,96 @@
=20
 	next
 }
+NF > 0 && $1 =3D=3D "subvendor" {
+	nsubvendors++
+
+	subvendors[nsubvendors, 1] =3D $2;	# name
+	subvendors[nsubvendors, 2] =3D $3;	# id
+	printf("#define\tPCI_SUBVENDOR_%s\t%s", subvendors[subnvendors, 1],
+	    subvendors[nsubvendors, 2]) > hfile
+
+	i =3D 3; f =3D 4;
+
+	# comments
+	ocomment =3D oparen =3D 0
+	if (f <=3D NF) {
+		printf("\t\t/* ") > hfile
+		ocomment =3D 1;
+	}
+	while (f <=3D NF) {
+		if ($f =3D=3D "#") {
+			printf("(") > hfile
+			oparen =3D 1
+			f++
+			continue
+		}
+		if (oparen) {
+			printf("%s", $f) > hfile
+			if (f < NF)
+				printf(" ") > hfile
+			f++
+			continue
+		}
+		subvendors[nsubvendors, i] =3D $f
+		printf("%s", subvendors[nsubvendors, i]) > hfile
+		if (f < NF)
+			printf(" ") > hfile
+		i++; f++;
+	}
+	if (oparen)
+		printf(")") > hfile
+	if (ocomment)
+		printf(" */") > hfile
+	printf("\n") > hfile
+
+	next
+}
+NF > 0 && $1 =3D=3D "subproduct" {
+	nsubproducts++
+
+	subproducts[nsubproducts, 1] =3D $2;	# vendor (or subvendor) name
+	subproducts[nsubproducts, 2] =3D $3;	# subproduct id
+	subproducts[nsubproducts, 3] =3D $4;	# id
+	printf("#define\tPCI_SUBPRODUCT_%s_%s\t%s",
+	    subproducts[nsubproducts, 1], subproducts[nsubproducts, 2],
+	    subproducts[nsubproducts, 3]) > hfile
+
+	i=3D4; f =3D 5;
+
+	# comments
+	ocomment =3D oparen =3D 0
+	if (f <=3D NF) {
+		printf("\t\t/* ") > hfile
+		ocomment =3D 1;
+	}
+	while (f <=3D NF) {
+		if ($f =3D=3D "#") {
+			printf("(") > hfile
+			oparen =3D 1
+			f++
+			continue
+		}
+		if (oparen) {
+			printf("%s", $f) > hfile
+			if (f < NF)
+				printf(" ") > hfile
+			f++
+			continue
+		}
+		subproducts[nsubproducts, i] =3D $f
+		printf("%s", subproducts[nsubproducts, i]) > hfile
+		if (f < NF)
+			printf(" ") > hfile
+		i++; f++;
+	}
+	if (oparen)
+		printf(")") > hfile
+	if (ocomment)
+		printf(" */") > hfile
+	printf("\n") > hfile
+
+	next
+}
 {
 	if ($0 =3D=3D "")
 		blanklines++
@@ -208,6 +298,60 @@
 	printf("};\n") > dfile
 	printf("const int pci_nproducts =3D %d;\n", nproducts) >dfile
=20
+	printf("\n") > dfile
+
+	if (nsubvendors) {
+		printf("static const struct pci_vendor pci_subvendors[] =3D {\n"\
+		    ) > dfile
+		for (i =3D 1; i <=3D nsubvendors; i++) {
+			printf("\t{\n") > dfile
+			printf("\t    PCI_SUBVENDOR_%s,\n", subvendors[i, 1]) \
+			    > dfile
+
+			printf("\t    \"") > dfile
+			j =3D 3;
+			needspace =3D 0;
+			while ((i, j) in subvendors) {
+				if (needspace)
+					printf(" ") > dfile
+				printf("%s", subvendors[i, j]) > dfile
+				needspace =3D 1
+				j++
+			}
+			printf("\",\n") > dfile
+			printf("\t},\n") > dfile
+		}
+		printf("};\n") > dfile
+		printf("const int pci_nsubvendors =3D %d;\n", nsubvendors) \
+		    > dfile
+
+		printf("\n") > dfile
+	}
+
+	printf("static const struct pci_product pci_subproducts[] =3D {\n") \
+	    > dfile
+	for (i =3D 1; i <=3D nsubproducts; i++) {
+		printf("\t{\n") > dfile
+		printf("\t    PCI_VENDOR_%s, PCI_SUBPRODUCT_%s_%s,\n",
+		    subproducts[i, 1], subproducts[i, 1], subproducts[i, 2]) \
+		    > dfile
+
+		printf("\t    \"") > dfile
+		j =3D 4;
+		needspace =3D 0;
+		while ((i, j) in subproducts) {
+			if (needspace)
+				printf(" ") > dfile
+			printf("%s", subproducts[i, j]) > dfile
+			needspace =3D 1
+			j++
+		}
+		printf("\",\n") > dfile
+		printf("\t},\n") > dfile
+	}
+	printf("};\n") > dfile
+	printf("const int pci_nsubproducts =3D %d;\n", nsubproducts) >dfile
+
 	close(dfile)
 	close(hfile)
 }
Index: pcidevs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/src/sys/dev/pci/pcidevs,v
retrieving revision 1.780
diff -u -r1.780 pcidevs
--- pcidevs	6 Apr 2006 04:06:52 -0000	1.780
+++ pcidevs	17 Apr 2006 00:32:36 -0000
@@ -577,6 +577,7 @@
 vendor BLUESTEEL	0x15ab	Bluesteel Networks
 vendor VMWARE		0x15ad	VMware
 vendor AGILENT		0x15bc	Agilent Technologies
+vendor RIOWORKS 	0x161f	Rioworks	=09
 vendor EUMITCOM		0x1638	Eumitcom
 vendor NETSEC		0x1660	NetSec
 vendor SIBYTE		0x166d	Broadcom (SiByte)
@@ -1555,6 +1556,11 @@
 /* ESS Technology products */
 product ESSTECH2 MAESTRO1	0x0100	Maestro 1 PCI Audio Accelerator
=20
+/* Rioworks products */
+subproduct RIOWORKS GW7326GZ	0x202f	Gateway 7326GZ
+subproduct RIOWORKS GW4028GZ	0x203a	Gateway 4028GZ
+subproduct RIOWORKS KVAZAR3592XT	0x204c	Kvazar-Micro Senator 3592XT
+
 /* Eumitcom products */
 product EUMITCOM WL11000P	0x1100	WL11000P PCI WaveLAN/IEEE 802.11
=20
@@ -2895,6 +2901,10 @@
 product SONY	CXD1947A	0x8009	CXD1947A IEEE 1394 Host Controller
 product SONY	CXD3222		0x8039	CXD3222 IEEE 1394 Host Controller
 product SONY	MEMSTICK	0x808a	Memory Stick I/F Controller
+subproduct SONY	VAIOPCGTR	0x8144	VAIO PCG-TR
+subproduct SONY	S1XP		0x8197	S1XP
+subproduct SONY	VAIOT		0x81c0	VAIO Type T
+subproduct SONY VAIOVGNB1XP	0x81c5	VAIO VGN-B1XP
=20
 /* Sun Microsystems products */
 product SUN EBUS	0x1000	PCIO Ebus2
Index: pcidevs.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/src/sys/dev/pci/pcidevs.h,v
retrieving revision 1.781
diff -u -r1.781 pcidevs.h
--- pcidevs.h	6 Apr 2006 04:07:31 -0000	1.781
+++ pcidevs.h	17 Apr 2006 00:32:38 -0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcidevs.h,v 1.781 2006/04/06 04:07:31 simonb Exp $	*/
+/*	$NetBSD$	*/
=20
 /*
  * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
@@ -584,6 +584,7 @@
 #define	PCI_VENDOR_BLUESTEEL	0x15ab		/* Bluesteel Networks */
 #define	PCI_VENDOR_VMWARE	0x15ad		/* VMware */
 #define	PCI_VENDOR_AGILENT	0x15bc		/* Agilent Technologies */
+#define	PCI_VENDOR_RIOWORKS	0x161f		/* Rioworks */
 #define	PCI_VENDOR_EUMITCOM	0x1638		/* Eumitcom */
 #define	PCI_VENDOR_NETSEC	0x1660		/* NetSec */
 #define	PCI_VENDOR_SIBYTE	0x166d		/* Broadcom (SiByte) */
@@ -1562,6 +1563,11 @@
 /* ESS Technology products */
 #define	PCI_PRODUCT_ESSTECH2_MAESTRO1	0x0100		/* Maestro 1 PCI Audio Accel=
erator */
=20
+/* Rioworks products */
+#define	PCI_SUBPRODUCT_RIOWORKS_GW7326GZ	0x202f		/* Gateway 7326GZ */
+#define	PCI_SUBPRODUCT_RIOWORKS_GW4028GZ	0x203a		/* Gateway 4028GZ */
+#define	PCI_SUBPRODUCT_RIOWORKS_KVAZAR3592XT	0x204c		/* Kvazar-Micro Senat=
or 3592XT */
+
 /* Eumitcom products */
 #define	PCI_PRODUCT_EUMITCOM_WL11000P	0x1100		/* WL11000P PCI WaveLAN/IEEE=
 802.11 */
=20
@@ -2902,6 +2908,10 @@
 #define	PCI_PRODUCT_SONY_CXD1947A	0x8009		/* CXD1947A IEEE 1394 Host Contr=
oller */
 #define	PCI_PRODUCT_SONY_CXD3222	0x8039		/* CXD3222 IEEE 1394 Host Control=
ler */
 #define	PCI_PRODUCT_SONY_MEMSTICK	0x808a		/* Memory Stick I/F Controller */
+#define	PCI_SUBPRODUCT_SONY_VAIOPCGTR	0x8144		/* VAIO PCG-TR */
+#define	PCI_SUBPRODUCT_SONY_S1XP	0x8197		/* S1XP */
+#define	PCI_SUBPRODUCT_SONY_VAIOT	0x81c0		/* VAIO Type T */
+#define	PCI_SUBPRODUCT_SONY_VAIOVGNB1XP	0x81c5		/* VAIO VGN-B1XP */
=20
 /* Sun Microsystems products */
 #define	PCI_PRODUCT_SUN_EBUS	0x1000		/* PCIO Ebus2 */
Index: pcidevs_data.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/src/sys/dev/pci/pcidevs_data.h,v
retrieving revision 1.780
diff -u -r1.780 pcidevs_data.h
--- pcidevs_data.h	6 Apr 2006 04:07:31 -0000	1.780
+++ pcidevs_data.h	17 Apr 2006 00:32:41 -0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcidevs_data.h,v 1.780 2006/04/06 04:07:31 simonb Exp $	*/
+/*	$NetBSD$	*/
=20
 /*
  * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
@@ -2148,6 +2148,10 @@
 	    "Agilent Technologies",
 	},
 	{
+	    PCI_VENDOR_RIOWORKS,
+	    "Rioworks",
+	},
+	{
 	    PCI_VENDOR_EUMITCOM,
 	    "Eumitcom",
 	},
@@ -2356,7 +2360,7 @@
 	    "INVALID VENDOR ID",
 	},
 };
-const int pci_nvendors =3D 579;
+const int pci_nvendors =3D 580;
=20
 static const struct pci_product pci_products[] =3D {
 	{
@@ -11189,3 +11193,35 @@
 	},
 };
 const int pci_nproducts =3D 2207;
+
+static const struct pci_product pci_subproducts[] =3D {
+	{
+	    PCI_VENDOR_RIOWORKS, PCI_SUBPRODUCT_RIOWORKS_GW7326GZ,
+	    "Gateway 7326GZ",
+	},
+	{
+	    PCI_VENDOR_RIOWORKS, PCI_SUBPRODUCT_RIOWORKS_GW4028GZ,
+	    "Gateway 4028GZ",
+	},
+	{
+	    PCI_VENDOR_RIOWORKS, PCI_SUBPRODUCT_RIOWORKS_KVAZAR3592XT,
+	    "Kvazar-Micro Senator 3592XT",
+	},
+	{
+	    PCI_VENDOR_SONY, PCI_SUBPRODUCT_SONY_VAIOPCGTR,
+	    "VAIO PCG-TR",
+	},
+	{
+	    PCI_VENDOR_SONY, PCI_SUBPRODUCT_SONY_S1XP,
+	    "S1XP",
+	},
+	{
+	    PCI_VENDOR_SONY, PCI_SUBPRODUCT_SONY_VAIOT,
+	    "VAIO Type T",
+	},
+	{
+	    PCI_VENDOR_SONY, PCI_SUBPRODUCT_SONY_VAIOVGNB1XP,
+	    "VAIO VGN-B1XP",
+	},
+};
+const int pci_nsubproducts =3D 7;

--vni90+aGYgRvsTuO--

--ey/N+yb7u/X9mFhi
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (NetBSD)

iQEVAwUBRELiX9goQloHrPnoAQIAcAgAnX3USIicQI9vjMcaxsYqF8HqA64g0ORd
CZlXdUvdwBilGY7vakTrDKvmF+t21KZWJiscpn2y9JUrYB2BAwmoVVZFc2vPY+Zw
DaYVDlBRdT1Vvz+J3GcKR2bHyyhbeynRCcLyAoWzCkpeToegPWOCVHcoF+wqovmz
b5xj+bmvE1kqqu73ZUjl6kR8uXsAbY2Nx6eu9iqluUhBBCYCy2ie2BZDjuAsLjaB
QGCiIHuPXORgUggHYgbrbldYVMGfVdwRswis5JIYNk0ssm929xR6/SgrFFVAU6Yi
3qZujdON6B6LDSNW4O9d/hnS5C+afdpZngM7+Pwl8o6+N57IzT1aXA==
=TwNI
-----END PGP SIGNATURE-----

--ey/N+yb7u/X9mFhi--