Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 25 May 2013 21:19:08 -0700
From:      John-Mark Gurney <jmg@funkthat.com>
To:        Jesus Alejandro Padilla <jesalepad@gmail.com>
Cc:        freebsd-drivers@freebsd.org
Subject:   Re: Getting a list of all drivers
Message-ID:  <20130526041908.GF90852@funkthat.com>
In-Reply-To: <CAFYqdVtaBS=4sPr783WhEZ9QbY1CpLqwH-6MOs=jUo1y_XRSLg@mail.gmail.com>
References:  <CAFYqdVtaBS=4sPr783WhEZ9QbY1CpLqwH-6MOs=jUo1y_XRSLg@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Jesus Alejandro Padilla wrote this message on Tue, May 21, 2013 at 20:31 -0400:
> I?m trying to get a comprehensive list of all the drivers in FreeBSD (I?m
> talking about all the drivers available, not only the ones installed in my
> system). I was thinking of getting them from the kernel source code (/sys),
> but I?ve had some problems. Here?s what I?ve tried so far.
> 
>    - Get all loadable kernel modules. The problem with this approach is
>    that there are many modules that are not drivers (like MAC policies).
>    - Get the ?device? entries in the GENERIC and NOTES configuration files.
>    However, this has the same problem as the loadable kernel modules; there
>    are ?devices? that are not drivers, and I think that these files don?t
>    contain all drivers, only the ones that will be compiled statically with
>    the kernel, right?
>    - Get the modules under /sys/dev. The problem is that there are other
>    drivers that are outside this folder.
> 
> Do you know if there?s a better way of building this list? Is there a file,
> like a MAINTAINERS file that contains this information up to date? I?d
> really appreciate any help.
> 
> Thank you very much!
> 
> Alex
> 
> PS: I know that some proprietary drivers, like Nvidia's, might be hard to
> get, but I?d like to get at least all the list of the drivers included in
> the kernel source code (/sys).

Getting the complete list might be a bit hard.  When I did my How
to Write a FreeBSD Device Driver for BSDCan, I put together an awk
script (I can't seem to find it right now) that would extract all
the DRIVER_MODULE like lines, and build up a dot graph:
http://people.freebsd.org/~jmg/drivers/driver.tree.pdf

There are also lines:
EARLY_DRIVER_MODULE
EARLY_DRIVER_MODULE_ORDERED
DRIVER_MODULE_ORDERED

The lines are like:
DRIVER_MODULE(musbotg, atmelarm, musbotg_driver, musbotg_devclass, 0, 0);

where the first arg, musbotg is the driver, and atmelarm is the bus
it conencts to...  A single driver can connect to multiple busses...
A good example of that is a driver like ed:
if_ed_cbus.c:DRIVER_MODULE(ed, isa, ed_cbus_driver, ed_devclass, 0, 0);
if_ed_isa.c:DRIVER_MODULE(ed, isa, ed_isa_driver, ed_devclass, 0, 0);
if_ed_pccard.c:DRIVER_MODULE(ed, pccard, ed_pccard_driver, ed_devclass, 0, 0);
if_ed_pccard.c:DRIVER_MODULE(miibus, ed, miibus_driver, miibus_devclass, 0, 0);
if_ed_pci.c:DRIVER_MODULE(ed, pci, ed_pci_driver, ed_devclass, 0, 0);

It connects to isa, pci and pccard, but it has a subbus which is the
miibus..

The difficulty is that there isn't too much distinction between a
driver and a bus...  You can't just look for all the leaves, since as
I just demonstrated, ed is a driver, but it has a subbus...

Good luck!

-- 
  John-Mark Gurney				Voice: +1 415 225 5579

     "All that I will do, has been done, All that I have, has not."



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130526041908.GF90852>