Driver accessing other drivers/devices ?

M. Warner Losh imp at bsdimp.com
Sat Aug 23 06:49:30 UTC 2008


In message: <10fba67b0808220034t2b9598cekbad7c976eed6975f at mail.gmail.com>
            "Alex Hornung" <ahornung at gmail.com> writes:
: Hello,
: 
: I need to access the hard disk from within a driver that is not a FS.
: I would also need to get a list of PCI devices connected. Is there a
: way I can access these devices directly, at least in the first case,
: issuing directly ATA/IDE commands to the hard disk?

There's always ata_if.m...

: In the case of PCI it would be even nicer to be able to communicate
: with the pci driver... but if that's not possible, it's also ok if I
: can access the PCI bus controller directly. The driver I'm writing is
: not a PCI or PCI device driver either.
: 
: Hope someone can help me out on this one, it's important that there's
: no user-space code...

Generally, you don't want to scan the PCI bus to look for drivers to
talk to.  That's bad kharma and likely begging to be abused.

Having said that, I've had cooperative drivers in the kernel before.
They usually look for each other and send messages to each other with
kobj.  It is better to look for "friend0" that you know can receive
messages.  kobj adds a layer of protection since it will gracefully
give an error when you can't do it.

Hey, wait, ata_if is kobj...  You could likely expand it to allow
queueing of commands and such.

Warner


More information about the freebsd-hackers mailing list