*BSD News Article 72620


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.mira.net.au!news.mel.connect.com.au!munnari.OZ.AU!spool.mu.edu!usenet.eel.ufl.edu!news-res.gsl.net!news.gsl.net!news.mathworks.com!uunet!inXS.uu.net!news.artisoft.com!usenet
From: Terry Lambert <terry@lambert.org>
Newsgroups: comp.unix.bsd.netbsd.misc,comp.unix.programmer
Subject: Re: S: sample device driver LKM
Date: Tue, 02 Jul 1996 17:20:54 -0700
Organization: Me
Lines: 42
Message-ID: <31D9BCE6.6C344BCE@lambert.org>
References: <199607030100023204807@q700.hf.org>
NNTP-Posting-Host: hecate.artisoft.com
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 2.01 (X11; I; Linux 1.1.76 i486)
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.netbsd.misc:3911 comp.unix.programmer:39030

Hauke Fath wrote:
] the one example that Terry Lambert has left out in
] {*BSD}/usr/share/lkm is a sample device driver. As I
] still have difficulties in understanding what an LKM
] actually sees of the kernel I am looking for a sample device
] driver implemented as LKM - preferably a block driver.

There is a replacement console drive called "World21", which
is loaded as an LKM.

There is also an interruptless LPT driver that was distributed
as part of the sameles; it was probably not maintained, and was
removed.

Device drivers were supported in the initial code as *either*
character *or* block devices -- not both.  If you need both, you
will need to create a "generic" module.

The device drivers work by replacing the cdevsw/bdevsw entry for
a reserved empty device slot.  It is recognized by reference to
an LKM supplied "enodev" function.


In general, the entire kernel environment is available to all
LKM's.  It is unwise to use more than a minimal set of system
entry points, since it will reduce the chances of the LKM
working from revision to revision of the OS.

FreeBSD is moving towards a devfs implementation of devices,
which will remove the need for cdevsw/bdevsw entirely, and
replace major/minor numbers in the specfs with vnodes in a
devfs, which you index by looking up in the directory hierarchy.
This is the prefereed method for adding device drivers as LKM's:
call the initialization entry points for devfs that each statically
linked driver calls anyway.


                                        Terry Lambert
                                        terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.