Subject: Re: LKM
To: Sander Storms <s.storms@technology.asb.nl>
From: Thor Lancelot Simon <tls@rek.tjls.com>
List: tech-kern
Date: 10/01/2004 13:19:54
On Fri, Oct 01, 2004 at 08:48:50AM +0200, Sander Storms wrote:
> Hello,
> 
> I already posted this message some month ago, but I never got an answer.
> Either I am at the wrong
> mailing-list, or the message did not arrive properly.
> But anyway, here's my question:
> 
> I want to create a driver for a custom-made PCI-device. This device has
> always been
> put directly into the kernel (NetBSD 1.5.1 back then), and it worked
> properly.
> Now, our software-supplier upgraded to NetBSD 1.6.1 and the driver has to be
> rewritten.
> Since 1.6.1 has kernel module support, it is unlogical to hack the driver
> into the kernel again.

NetBSD 1.5.1 had kernel module support (on most if not all of the
ports that had it in 1.6.1) as well.  The question is whether the
kernel module support in NetBSD is flexible enough to do what you
want.

Unfortunately, I suspect that the answer is "no".  But I'm not sure
that matters so much; it sounds like the operating system is supplied
to you in source form, and it's not the case that you'd be able to use
an unmodified kernel module for 1.6.1 (or 1.5.1) with a later 2.0
or 2.1 or 3.1 kernel anyway -- unfortunately, we do not keep the kernel
module API/ABI stable.  So you would end up needing to change source
code anyway; in practice, you may end up needing to change *less* source
code if you simply compile your driver statically into the kernel.

If you compile your module statically into the kernel (which is the usual
case for device drivers in NetBSD) you must adapt it to changes in
the kernel API for such other kernel functionality as you use, and you
must build a new kernel when you change the driver.

If you load your module dynamically into the kernel, you must *still*
adapt it into changes in the kernel API for other kernel functionality,
*and* adapt it to changes in the module API/ABI between kernel versions,
and of course you must still recompile your module if _it_ changes.  SO
you gain a lot of extra work and avoid only the work of recompiling
the kernel (which takes a few minutes only) when you change your
device driver itself.

This does not seem like a win to me.

Thor