[Asterisk-bsd] zaptel device open semantics?

Jeff Rizzo riz+asterisk at boogers.sf.ca.us
Sun Nov 7 14:50:36 CST 2004


Hi-

I'm currently working on porting some of the zaptel drivers to NetBSD, 
and I'm pretty far along... I have compiling code for zaptel, wcfxs, and 
ztdummy.  However, I'm now realizing that the 'zaptel' piece is doing 
something funky, and I hope that someone here can explain to me how it's 
expecting to operate, so I can translate that into NetBSD semantics... I 
expect that once I have this piece, I should have something working 
(FSVO "working") within a few days.

I'm coming at this from a position of not being terribly familiar with 
FreeBSD driver internals,  (in fact, everything I know about them I've 
learned in the process of doing this port) so please be as explicit as 
possible in any explanation.

 From what I can tell of the way the drivers fit together, the "zaptel" 
driver is the one that actually handles the device open, and calls 
routines in the hardware-specific drivers to handle the actual work - 
this makes a certain amount of sense.  What I don't understand is that 
the cdevsw structure only defines an "open" routine - no close, no read, 
etc...:

static struct cdevsw zt_devsw = {
#if __FreeBSD_version >= 502103
                .d_version = D_VERSION,
#endif
                .d_open                 = ztopen,
                .d_name                 = "zaptel",
                .d_maj                  = ZT_MAJOR
};

OK, so the zaptel driver handles opens.  How is a device read (for 
example) then handled?  I see a number of functions which look promising 
in the 'struct fileops':

static struct fileops zt_fileops = {
        .fo_close = zt_close,
        .fo_ioctl = zt_ioctl,
        .fo_read = zt_read,
        .fo_write = zt_write,
        .fo_poll =  zt_poll,
        .fo_stat = zt_stat,
        .fo_kqfilter = zt_kqfilter
};

... but I'm unclear how these functions then get called.  Obviously, I'm 
missing something pretty fundamental here, so if someone could whack me 
with a clue-by-four, I'd greatly appreciate it.

(I'm sure I'll have a lot more questions, so if someone who's familiar 
with the workings would like to contact me privately and offer to help, 
I'd be grateful - riz at boogers.sf.ca.us.

Thanks in advance,
+j



More information about the Asterisk-BSD mailing list