Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 16 Oct 1998 13:49:45 +0800
From:      Peter Wemm <peter@netplex.com.au>
To:        Greg Lehey <grog@lemis.com>
Cc:        Nicholas Charles Brawn <ncb05@uow.edu.au>, FreeBSD Hackers <hackers@FreeBSD.ORG>
Subject:   Re: How cam I be writing LKM ? 
Message-ID:  <199810160549.NAA15779@spinner.netplex.com.au>
In-Reply-To: Your message of "Fri, 16 Oct 1998 13:27:50 %2B0930." <19981016132750.C468@freebie.lemis.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
Greg Lehey wrote:
> On Friday, 16 October 1998 at 12:54:32 +1000, Nicholas Charles Brawn wrote:
> > On Fri, 16 Oct 1998, Greg Lehey wrote:
> >
> > [snip]
> >> The best thing to understand is: now is a very bad time to write an
> >> LKM.  They'll be going away and replaced by KLDs when the kernel goes
> >> to ELF (in the next few weeks).
> >
> > This is news to me, however as i don't keep up with -current and -stable
> > lists, it's not really a suprise.
> >
> > Ok, so are KLD's going to be present in 3.0-RELEASE? 
> 
> Sort of.  

Yes.  Only just though..  But you have to choose to use them.  If you 
use /boot/loader and compile the kernel for ELF, then you can even preload 
them.

> > Is there going to be better dox available for them than were present
> > on lkm's?
> 
> Probably not :-)

There will have to be, because the mechanism that drives KLD is also 
intended to replace the config(8) statically generated tables etc.

> > And where can I get some information on them now?
> 
> Peter Wemm seems to be spearheading the effort.  We've done some mail
> exchange, but I haven't had time to look at it in detail.  Maybe I'll
> write some documentation on it, but don't hold your breath.
> 
> > Shucks, just when I was getting the hang of writing them too... :\
> 
> The story is that there's not much difference.

Yes, at the moment.  kld is a lot more powerful because it honours things
like SYSINIT() in loaded files.  Indeed, that's how the same source and
binaries are used for producing kernels and modules.  Look at the src/sys/
modules/* code, and the corresponding src/sys/* code that the module
Makefiles build.  In particular, DECLARE_MODULE() is what is used to create
a visible module.  Files contain zero or more modules. Theoretically
modules should be self contained and self registering. I'm not so thrilled
about the naming, but I used Doug and Mikes code and had to try and make it
work together.  We've got Doug's terminology.  If I'd had (lots) more time,
I'd probably have liked to change it a bit so that a kldload "file" was
called a module, and what the present kernel code calls a module, I'd have
called a "component" or something like that.

The build process is pretty weak at the moment, it's more of a proof of
concept than meant to be particularly useful.  It's likely that a stronger
dependency and versioning mechanism will be implemented at some point soon.
Mike did a pretty good system but it wasn't integrated with the kernel 
linker and bus/device code which extensively used Doug's system in the 
alpha port.  I still want to use Mike's design at the module (component) 
level.

This is what my system looks like at the moment:

113# kldstat 
Id Refs Address  Size     Name
 1    4 0xf0100000 1406d0   kernel
 2    1 0xf0241000 486e0    nfs.ko
 3    1 0xf028a000 f758     linux.ko
 4    1 0xf089a000 a000     ibcs2.ko
114# kldstat -v
Id Refs Address  Size     Name
 1    4 0xf0100000 1406d0   kernel
        Contains modules:
                Id Name
                 1 rootbus
                 3 procfs
                 4 ufs
                 5 mfs
                 6 if_loop
                 7 ipfw
                10 aout
                11 elf
                12 execinterp
 2    1 0xf0241000 486e0    nfs.ko
        Contains modules:
                Id Name
                 2 nfs
 3    1 0xf028a000 f758     linux.ko
        Contains modules:
                Id Name
                 8 linuxaout
                 9 linuxelf
 4    1 0xf089a000 a000     ibcs2.ko
        Contains modules:
                Id Name
                13 ibcs2

This is on an ELF kernel, but I think the a.out kld's will still work.

> Greg

Cheers,
-Peter




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



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