Magic symlinks redux

M. Warner Losh imp at bsdimp.com
Sat Aug 23 02:07:43 UTC 2008


In message: <20080823013912.GA19588 at 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);


More information about the freebsd-arch mailing list