Magic symlinks redux

John Baldwin jhb at freebsd.org
Sat Aug 23 03:32:24 UTC 2008


On Friday 22 August 2008 10:05:11 pm M. Warner Losh wrote:
> 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);

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


More information about the freebsd-arch mailing list