Patch for usr.bin/config (patch1 2008/Jan/20)
* New config(5) syntax
You can prepend a "module" keyword to a device instance line in
your config file, as in:
module auich* at pci? dev ? function?
This will make an LKM for auich.
Keyword "no" and "module" can be at the same line, and "no" must
proceeds "module".
module no auich* at pci? dev ? function ?
is syntax error.
no module auich* at pci? dev ? function ?
is correct, and "module" is ignored.
* How to try
1. Apply the patch to -current source tree, and rebuild your config.
cd SRCDIR/usr.bin/config; patch < config.patch
cd SRCDIR/sys; patch -p1 < sys.patch
2. Add "module" keyword to your config file, and run the modified
config. (You can try example config files instead of changing
your config file.)
3. Change directory to kernel compile directory. You'll notice you
have subdirectory "modules" there.
4. Run "make dependmodules" (or "make dependall"). you'll get some
LKM .o files under modules directory. Try "modload -s FOO.o".
(-s will be necessary for loading later an another module
that depends on FOO)
Alternatively, you can move down to modules/FOO.work directory,
and run make to build just one module. (You may need to run
"make depend" at the kernel compile directory to prepare some
auto generated files.)
* A change to the kernel
In config-generated file "ioconf.c", data objects of type "struct
cfiattrdata" are changed from private to global. This was done in
order to use those data objects from LKMs. I think this change is
necessary also for hand-craft LKMs.
Because of this change, you may need to boot with the new kernel
from patched config to load generated LKMs.
* Changes outside src/usr.bin/config
src/sys/conf/Makefile.lkm: (new file)
template for Makefiles for LKMs.
(used for COMPILEDIR/CONFIG/modules/FOO.work/Makefile)
src/sys/conf/Makefile.kmod.inc: (new file)
included from kernel's Makefile as well as Makefile.kern.inc
src/sys/arch/i386/conf/Makefilei386
src/sys/arch amd64/conf/Makefile.amd64
add %KMOD directive to Makefile tmpelates. Currently modified only
for i386 and amd64, but should be done for other ports.
* MIST example
This is the easiest-to-try example. It generates one module from
LKM sample source at sys/lkm/dev/pci/dummy_pci. You won't need to
reboot your running kernel to try this one, because there's very
little chance you have that device in your kernel.
Don't forget to change .include line in the MIST example to include
the config file of your running kernel. LKMs won't be loaded if some
config options differ from running kernel's.
* CFR2 example
This is a more realistic example. I'm actually using the kernel
and modules from this config file now. The devices that I use
usally are kept in the kernel, and those I use not so often are
built as LKMs.
* ALLLKM example
This config file is based on GENERIC for i386, and modified to move
as many devices into LKMs as possible without changes to the driver
codes.
I've tested that the kernel and modules from this config file gets
compiled, but I haven't given a test-run to them. Some modules may
not be loadable. The kernel won't boot because it doesn't have
any console device or any root device.
In the ALLLKM config file, following devices can't become LKMs for now:
xirc: dev/pcmcia/xirc.c depends on NCOM_XIRC and NXI_XIRC
mhzc: dev/pcmcia/mhzc.c depends on NCOM_MHZC NSM_MHZC
mpu@sb: depends on NMPU
apm: requires NAPMBIOS
acpi: requires NACPI
acpiec: requires NACPIEC
audiobus, midibus: require NAUDIO and NMIDI
isa: i386 kernel unconditionally needs functions in
arch/x86/isa/clock.c.
pci: acpi implicitly requires pci.
nxp: acpi_wakeup.c calls nxpinit()
wskbd can't be an LKM with options WSDISPLAY_SCROLLSUPPORT, because
it needs NWSDISPLAY.
* Module dependencies.
Module dependency information is put in a ELF section of LKM .o
file. I wrote a wrapper script named modload.py for /sbin/modload
which reads that information from LKM file and load required modules.
modload.py -i foo.o bar.o ...
prints LKM dependencies
modload.py -A foo.o bar.o
tries to automatically load all modules specified on the command line,
and modules required by those.
For example, "modload.py -A ipw.o" will load rijndael.o, arc4.o,
and wlan.o as well as ipw.o. (This example is for LKMs from CFR2
configuration file)
Please read the modload.py script file for more information.
* Contacts
Please send questions and/or comments to
[email protected], or
[email protected]