Subject: Various NetBSD kernel questions to help with port of FreeBSD "zaptel"
To: None <tech-kern@netbsd.org>
From: Jeff Rizzo <riz@redcrowgroup.com>
List: tech-kern
Date: 11/07/2004 10:24:29
Hi-

For the last couple weeks, I've thrown myself into finally doing some 
driver work in the kernel, because I'd like to be able to run Asterisk 
(http://www.asteriskpbx.org/) with PSTN interfacing support under 
NetBSD.  The "zaptel" drivers have been ported (at least in part) to 
FreeBSD from Linux, and I've been working on getting the framework and 
one of the hardware drivers working under NetBSD.   I've learned quite a 
bit, to the point where I think I can finally ask the right questions.  
:-) 

First, I should probably explain the setup of the drivers themselves, 
since a big question I have is regarding how I should handle this 
particular kind of setup under NetBSD.  There is a main "zaptel" driver 
which does not attach to any hardware, but appears to provide a 
framework under which hardware drivers for various boards (FXS, FXO, 
T1/E1, etc) register themselves.  Under FreeBSD (and I assume Linux, 
though I haven't worked directly with the Linux drivers), the drivers 
are in kernel modules which get loaded;  the zaptel module first, then 
the hardware drivers (like the "wcfxs," which is the one I'm working 
with now). 

If I'm understanding the setup correctly, the hardware drivers (wcfxs, 
etc) don't actually have their own cdevsw structures, since they 
register with zaptel, and zaptel dispatches the various calls (open, 
close, ioctl, etc), to the appropriate hardware.   I've initially tried 
to set "zaptel" up as a pseudo-device, but now I'm running into trouble 
because pseudo-devices attach _after_ all the hardware has probed, so my 
hardware isn't being attached.

Does anyone have any suggestions for another way to set this up, or 
pointers to other drivers in NetBSD which do similar things?  I could 
also use a good documentation pointer for how files.* and majors.* 
should be set up to achieve different things;  I've read config(9) and 
autoconf(9) and driver(9), but I'm still a little vague on some of the 
details...

Apologies for the scattered nature of this email... I feel like I'm 
_really_ close to having something working, but I'm missing some key 
detail, but I'm not sure what the detail is.  I'd be more than happy to 
share what code I've got so far with someone, but it's in a bit of a 
state at the moment, so I'm not posting it publically... just ask, and 
I'll send you what I've got.

Thanks,
+j

-- 
Jeff Rizzo                                         riz@redcrowgroup.com
Red Crow Group LLC                                 http://www.redcrowgroup.com/
+1 415 550 0310