How can I fake a device ?

takawata at jp.freebsd.org takawata at jp.freebsd.org
Thu Aug 19 22:49:48 PDT 2004


In message <41257789.70508 at OTEL.net>, Iasen Kostov wrote:
>    Hi,
>I want to know is there a way to call *_probe (for device driver) with 
>fake (PCI) device that does not exists in the system ?
>First of all a cant find how "struct device" is declared (i've searched 
>even the compile/ dir) and second I think that I'll need to intercept 
>pci_get_vendor and pci_get_device funcs with my own which should detect 
>the fake device and thus will return vandor/device that I need to fake. 
>I realy don't need anything else except _probe ...

I have never tried such but grimpsed the PCI framework, 
I propose the following, though I don't imagine why you want 
to do so:

Your driver have to contain DEVICE_IDENTIFY method 
that calls device_add_child to allocate device_t object.
Then you allocate 'struct pci_devinfo' and initialize 
pci_devinfo as you like. And you have to make your 
driver as a module. Then a device object will show up on 
the device tree on your system.

You may want to have a look at pci_add_children@/sys/dev/pci/pci.c 






More information about the freebsd-hackers mailing list