Re: Auto kernel module loading

From: Terry Lambert <tlambert2_at_mindspring.com>
Date: Thu, 17 Apr 2003 00:42:28 -0700
"Alastair G. Hogge" wrote:
> What I was planning:
> Using the PCI Id database provided by Martin Mares.
> Modifying the DB to include FreeBSD (maybe any *BSD) modules for the
> matching/implemented devices.

You will probably have a problem with this, if you try to include
all devices.

Basically, any device in the boot path has to be statically linked
into the kernel.  This is because it's not possible to access the
filesystem on the other side of the device, unless it's already
in the kernel (e.g. you can't netboot with an Intel network card,
and load the driver later, unless the Intel network driver is in
the kernel so you can access kernel modules via NFS -- same for
disk drivers when booting from a disk).

FWIW, I've frequently wanted a device driver that fell back to
using the BIOS for disk I/O; wouldn't help in the network card
case, but it would let you load just about anything from the
disk you booted from, even if you had no real driver.  Replacing
the BIOS driver with "the real one" would be harder.

The closest you're going to be able to get to something like this
without a lot of work is to use the boot loader to preload the
modules.  For that to work, you are probably going to have to
put PCI support into the loader.  On the plus side, you'll be
able to leave the PCI database in a seperate file, if you are
willing to write the FORTH code to read it in the loader, and
load the drivers via the BIOS (that's what the loader.conf does,
only the loading is not conditional on a PCI ID being matched).


> Then with that info when FreeBSD loads and picks up an device id it checks the
> list, gets the info, checks if there is an module and then loads it.

See above; doesn't work for boot path devices, unless you get
the loader code involved.


> I just don't know where to start, my knowledge of the FreeBSD source tree is
> "I know my kernel config is in /sys/i386/conf/"

It's not really a "FreeBSD specific thing"; it's really a loader
and linker specific thing.  If you go the linker route, then you
have to leave the disk and network drivers in, as well as at least
one boot filesystem type (UFS, UFS2, CD9660, etc.; not NTFS or FAT32
or HFS, etc.).

If you associate the PCI ID in a simple table, rather than a
seperate ELF section in the file, you are going to have to find
some way of doing the PCI ID iteration (hard in the loader) or
BIOS I/O to load the modules (hard in the kernel).


> > www.freebsd.org, under documentation.  It has a link to the
> > programmers guide, online.
> Great :-)
> 
> I'm just installed my local copy, this will save me tieing up the phone
> constantly while resorting to an online resource.

Don't know if you got all of them; probably not the first one, at
least:

http://www3.pt.freebsd.org/tutorials/ddwg/ddwg.html
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/index.html
http://www.freebsd.org/doc/en_US.ISO8859-1/books/developers-handbook/index.html

-- Terry
Received on Wed Apr 16 2003 - 22:43:49 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:03 UTC