Subject: Re: LKM & autoconf ?
To: None <collver1@comcast.net>
From: Quentin Garnier <netbsd@quatriemek.com>
List: tech-kern
Date: 09/23/2003 07:11:18
Le Mon, 22 Sep 2003 19:52:58 -0700
collver1@comcast.net a ecrit :
> I am thinking about writing a NetBSD driver, and the manual pages on the
> subject look very promising. Since I have never written one before, I
> have some questions.
>
> Is the autoconfiguration framework readily used from an LKM? Would
> someone point me to a good example of a character device LKM that uses
> autoconf?
I don't really understand your question. autoconf(9) is mainly about
managing device drivers in a tree. Being a character device is an
unrelated issue.
Our LKM subsystem provides a way to write character device drivers which
is quite independent from autoconf(9): the LKM receives a major device
number that can be used by userland to access the device.
For a single driver that works quite well, and you don't need autoconf(9),
you just call the probe and attach routines in one shot in the module init
function. Of course there will be no real autoconf(9) attachment.
It is possible, though, to use autoconf(9) although it is a bit
complicated for a single device IMO. I have an example of how autoconf(9)
can be used by LKMs, but it requires ksyms.
(Well, it's not entirely true. They can be linked together as a single LKM
and then loaded. But it means two copies of all that code if you have,
like me, two sound cards. Though the code could be changed to allow
linking on all of them, including every driver for every device, and
adding all the autoconf(9) entries in one step in the LKM init function.)
This is the output of modstat on my workstation:
Type Id Offset Loadaddr Size Info Rev Module Name
MISC 0 - d401f000 0004 d401f400 2 pcilkm
MISC 1 - d4053000 0010 d4056e40 2 ac97
MISC 2 - d408b000 0004 d408bb68 2 mulaw
MISC 3 - d40c0000 0010 d40c34b8 2 aurateconv
MISC 4 - d40f9000 0004 d40f9358 2 auconv
DEV 5 -1/42 d412d000 0018 d4132420 2 audio
MISC 6 - d4057000 000c d405974c 2 auich
MISC 7 - d4082000 0010 d4085f0c 2 emuxki
DEV 8 -1/111 d408a000 0004 d408a4a0 2 mmr
DEV 9 -1/180 d4242000 03e4 d432c880 2 nvidia
As you can guess, my kernel doesn't contain any audio code, it is all
provided by LKMs. Note that nvidia doesn't use autoconf, but rather the
previous version of pcilkm.
The code for pcilkm and those modules can be found there:
http://cubidou.nerim.net/pcilkm.tgz
http://cubidou.nerim.net/NVIDIA_NetBSD-1.0-3203-0.tgz
And a dmesg:
http://cubidou.nerim.net/dmesg.gz
--
Quentin Garnier - cube@cubidou.net - cube@NetBSD.org
"Feels like I'm fiddling while Rome is burning down.
Should I lay my fiddle down and take a rifle from the ground ?"
Leigh Nash/Sixpence None The Richer, Paralyzed, Divine Discontents, 2002.