Date: Fri, 22 Aug 2008 22:41:51 -0400 From: John Baldwin <jhb@freebsd.org> To: freebsd-arch@freebsd.org Cc: brueffer@freebsd.org, brooks@freebsd.org, rpaulo@freebsd.org, ivoras@freebsd.org Subject: Re: Magic symlinks redux Message-ID: <200808222241.52325.jhb@freebsd.org> In-Reply-To: <20080822.200511.1137957320.imp@bsdimp.com> References: <20080822.160107.511563083.imp@bsdimp.com> <20080823013912.GA19588@epsilon.local> <20080822.200511.1137957320.imp@bsdimp.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Friday 22 August 2008 10:05:11 pm M. Warner Losh wrote: > 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); It might be nice to drive it by hints so users can tweak it on the fly. Maybe something like: hint.pci0.<slot>.<func>.vendor=XXXXX Then users can simply add entries to /boot/loader.conf w/o needing any recompiles for new device IDs that the driver can handle using an existing device id. The lookup table you have still requires patching source somewhere which probably defeats the purpose. -- John Baldwin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200808222241.52325.jhb>