Subject: Re: porting drivers btw BSDs
To: Manuel Bouyer <bouyer@antioche.eu.org>
From: Gary Thorpe <gathorpe79@yahoo.com>
List: tech-kern
Date: 02/08/2003 13:06:49
 --- Manuel Bouyer <bouyer@antioche.eu.org> wrote: > On Tue, Feb 04,
2003 at 03:33:58PM -0200, jose correa wrote:
> > Hi, my question is how porting a driver from FreeBSD to
> > NetBSD?
> > 
> > I have a winmodem Lucent supported on FreeBSD by driver
> comms/ltmdm, but
> > NetBSD doesn't has support for them, so I am looking for docs,
> howtos,
> > mans, etc, to getting know-how on how to port from one platform to
> other one.
> 
> Unfortunably I don't think there are much docs on this specific
> subject.
> You can have a look at the section 9 manual pages, and documentation
> on www.netbsd.org
> And of course looking at existing drivers, on both OSes.
> 
> -- 
> Manuel Bouyer <bouyer@antioche.eu.org>
>      NetBSD: 24 ans d'experience feront toujours la difference
> --

I have ported the basic parts of a FreeBSD driver to NetBSD. I did not
write down my findings at the time unfortunately but here goes....

a. FreeBSD uses a different, although similar framework for attaching
devices. The "probe" and "attach" routines in NetBSD have their
equivalents on FreeBSD but I think they return different values and
have different semantics ("probe" in NetBSD doesn't store state for
example).

b. FreeBSD doesn't have an extenive MI framework. Devices seem to be
wedded to the buses they are attached to. This will mean sepearating
them into seperate parts for NetBSD.

c. NetBSD usually divides drivers into MI and bus-dependent parts. A
single MI may have several bus-dependent parts (attach lpt at isa OR
attach lpt at pnpbios). It means that lots of things in the FreeBSD
structs holding device data should be removed/moved to the bus-specific
attach parts.

d. FreeBSD has something called newbus() and thats all I know about it.
FreeBSD has "device methods" and seems to able to define an software
"interface" for a particular device (it may all just be fancy macro
tricks). I think it *may* have to do with an in-kernel linker, but I
really don't know.

I have a partial work of the FreeBSD devices 'ppc' (atppc for my code
in NetBSD), 'ppbus', and 'lpt' working on a current kernel: I can send
someone interested the code as it is now (not completely working but
all three devices probe and attach properly). I also have the original
FreeBSD code (which is also freely available from that project's
ftp/http/cvs services) so comparisons between the two can be made as
they now stand.


______________________________________________________________________ 
Post your free ad now! http://personals.yahoo.ca