Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 02 Oct 1998 17:54:42 -0700
From:      Mike Smith <mike@smith.net.au>
To:        Greg Lehey <grog@lemis.com>
Cc:        Mike Smith <mike@smith.net.au>, Alfred Perlstein <bright@hotjobs.com>, freebsd-current@FreeBSD.ORG
Subject:   Re: ELF kernel? 
Message-ID:  <199810030054.RAA02994@dingo.cdrom.com>
In-Reply-To: Your message of "Sat, 03 Oct 1998 10:01:01 %2B0930." <19981003100101.H2176@freebie.lemis.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
> On Friday,  2 October 1998 at 17:33:01 -0700, Mike Smith wrote:
> >>>>> I use 'strip -g' for ELF kernels.  If your kernel is a.out, you probably
> >>>>> need 'strip -aout -d'.
> >>>>
> >>>> any idea on the expected cutover to ELF kernels?
> >>>
> >>> Perhaps Sunday or so.  There are a few variables left, but no more than
> >>> a couple of days before it's ready.
> >>
> >> Oh.  What does that mean for LKMs?
> >
> > They become KLD modules.  The actual source-level changes are pretty
> > minimal.
> 
> Where can I find out about them?  Where do they go in the tree?  Do I
> need to commit any additional modules?

The in-tree LKM modules are being converted as an exercise and 
demonstration over the next couple of days.  I've been writing some 
documentation on converting an LKM module as well as writing for KLD 
from scratch.  Modules by default live in src/sys/modules.

The most common module instances are:

CDEV_MODULE, BDEV_MODULE (defined in conf.h)
DRIVER_MODULE (defined in bus.h)

and the basic DECLARE_MODULE (in module.h), which lets you roll your 
own.

Here's a trivial KLD module.

foomodule.c:
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/systm.h>

static int 
foomodule_event(module_t mod, modeventtype_t type, void *junk)
{
	switch(type) {
	case MOD_LOAD:
		uprintf("foomodule loaded\n");
		break;
	case MOD_UNLOAD:
		uprintf("foomodule unloaded\n");
		break;
	}
	return(0);
}

moduledata_t foomodule_data = {
	"foomodule",
	foomodule_event,
	NULL
};

DECLARE_MODULE(foo, foomodule_data, SI_SUB_DRIVERS, SI_ORDER_MIDDLE);

Makefile:

KMOD=	foomod
SRCS=	foomod.c
KLDMOD=	yes
NOMAN=	yes

.include <bsd.kmod.mk>

In other words, it's very similar to the current LKM model from this 
end.  Note that to link a.out KLD modules you'll need to link your 
a.out kernel with '-forcedynamic'.  This isn't a problem with the ELF 
kernel.

-- 
\\  Sometimes you're ahead,       \\  Mike Smith
\\  sometimes you're behind.      \\  mike@smith.net.au
\\  The race is long, and in the  \\  msmith@freebsd.org
\\  end it's only with yourself.  \\  msmith@cdrom.com



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



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