Subject: Re: driver writer wannabe needs a few hints
To: Martin Husemann <martin@duskware.de>
From: Jon Buller <jon@bullers.net>
List: tech-kern
Date: 12/12/2002 13:56:47
In message <20021212210151.GA1605@drowsy.duskware.de>, Martin Husemann writes:
>On Thu, Dec 12, 2002 at 11:36:10AM -0800, Jon Buller wrote:
>
>> struct dbri_softc {
>
>Wow, cool, a dbri driver!

Don't hold your breath.  I have a wife and two kids who require
more of my time than necessary for writing a driver. 8^)  I also
have never been "on the other side" of a syscall before, and I only
have man pages, 3 pdf documents (the codec, sbus/dbri, and suns
isdn card) and the linux-2.4.? driver source.

I did get some of the docs from the linux guys, and their blessing
to use as much of it as I could.  So I'm not too worried about
someone saying you need to GPL the kernel if 4 lines of code look
close to the linux stuff.  (And NetBSD will only be about 5 years
behind on this driver.)

>I always planned to add support for the isdn part in it. That would probably
>mean
>
>dbri0 at sbus...
>dbriaudio0 at dbri0
>audio0 at dbriaudio0
>drbisdn0 at dbri0: bri 0
>
>But we can separate this later, if you didn't already split it.

I figured that would be likely. But right now, it just matches the
sbus name, and attach just returns.  (The boot messages changed
from "SUNW,DBRIe not configured" to "SUNW,DBRIe ...", but that is
the only difference right now.

I was going to work on attaching audio next, but got lost when I
didn't see anthing in files.sparc (or files.sbus) that would do
"attach audio at xxx".  Audio(9) didn't give a lot of hints on that
either, but I did see the audio_hw_if stuff and was convinced this
will be a non-productive learning exercise only. 8^)

>For your questions: look at the CFATTACH_DECL() macros in all the drivers,
>that is what replaces the ca_* static structs. Since the audio device 
>attaching at your driver will be the one to need a /dev/ node, you don't
>need to handle sparc/conf/majors.sparc.

I was looking at arch/sparc/dev/audioamd.c and it was doing struct
cfattach xxx { ... };  But it was compiling, and mine wasn't.  Then
updated my source, and didn't see any changes, and it still compiled,
and mine still didn't.  Now I just looked at dev/sbus/bpp.c and
found CFATTACH_DECL and updated my code to use it.  My dbri.c file
compiles now!  (And I checked audioamd.c and it now uses CFATTACH_DECL,
so I must have missed something, but I swear that is the way it
happened, the order it happened in, and there were no additional
steps left out.)

Jon