Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Aug 2008 20:05:11 -0600 (MDT)
From:      "M. Warner Losh" <imp@bsdimp.com>
To:        rpaulo@FreeBSD.org
Cc:        brooks@FreeBSD.org, ivoras@FreeBSD.org, brueffer@FreeBSD.org, freebsd-arch@FreeBSD.org
Subject:   Re: Magic symlinks redux
Message-ID:  <20080822.200511.1137957320.imp@bsdimp.com>
In-Reply-To: <20080823013912.GA19588@epsilon.local>
References:  <20080822.160107.511563083.imp@bsdimp.com> <20080822225119.GA65119@onelab2.iet.unipi.it> <20080823013912.GA19588@epsilon.local>

next in thread | previous in thread | raw e-mail | index | archive | help
In message: <20080823013912.GA19588@epsilon.local>
: I hope this is what Warner was trying to say.

More or less the following, with a less lame way of getting the table
into the kernel, and maybe more fields than vendor/device....

The reason this works is that the pci_get_vendor and pci_get_device
read out of the area pointed to by cfg.

Warner

Index: pci.c
===================================================================
--- pci.c	(revision 182024)
+++ pci.c	(working copy)
@@ -419,6 +419,33 @@
 #undef REG
 }
 
+static struct pci_remap_entry
+{
+	uint16_t vendor;
+	uint16_t device;
+	uint16_t mapped_vendor;
+	uint16_t mapped_device;
+} pci_remap[] =
+{
+	{ 0x1039, 0x0901, 0x1039, 0x0900 }	/* Map sis 901 to sis 900 */
+};
+static int pci_remap_entries = 1;
+
+static void
+pci_apply_remap_table(pcicfgregs *cfg)
+{
+	int i;
+
+	for (i = 0; i < pci_remap_entries; i++) {
+		if (cfg->vendor == pci_remap[i].vendor &&
+		    cfg->device == pci_remap[i].device) {
+			cfg->vendor = pci_remap[i].mapped_vendor;
+			cfg->device = pci_remap[i].mapped_device;
+			return;
+		}
+	}
+}
+
 /* read configuration header into pcicfgregs structure */
 struct pci_devinfo *
 pci_read_device(device_t pcib, int d, int b, int s, int f, size_t size)
@@ -465,6 +492,7 @@
 
 		pci_fixancient(cfg);
 		pci_hdrtypedata(pcib, b, s, f, cfg);
+		pci_apply_remap_table(cfg);
 
 		if (REG(PCIR_STATUS, 2) & PCIM_STATUS_CAPPRESENT)
 			pci_read_extcap(pcib, cfg);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080822.200511.1137957320.imp>