Subject: Kernel modules
To: None <>
From: Andrew Doran <>
List: tech-kern
Date: 01/16/2008 12:48:20

I committed the module framework that I was working on. It will be a while
before I can spend more time on it, and others want to work on it, so here
it is. Ordinarily I would have sent this for review. In this case I thought
it was better to start with a working implementation in order to minimize
the level of bikeshedding.

The change is here:	

The basic idea is that a kernel facility like ext2fs should have code
difference to be loadable as a module - the initialization is the same
whether or not it is built into the kernel. All that should be needed is
some build glue like a Makefile under sys/modules. Features: it has an in
kernel loader, does module dependencies and has hooks for the boot loader
to load modules and provide them to the kernel.

Here's how to get a module loaded for testing/fun. Note that only the linker
has been tested on i386 and amd64 only:

- Build and install new libc. 
- Edit sbin/modload/Makefile, sbin/modunload/Makefile.
- Build and install sbin/modstat, modload, modunload.
- Make sure your PATH is finding /sbin/modstat and not /usr/bin/modstat.
- Compile kernel with options MODULAR.
- mkdir /modules
- cd sys/modules/example
- make
- mv example.o /modules/example
- modload example

What needs to happen for it to replace LKMs:

- Conversion of the modules under sys/lkm.
- Linker relocation code for mips, hppa.
- Some changes to improve robustness in a couple of places.
- Locking for kern_ksyms.c

Please review.