Haiku Getting a FreeBSD Network Driver Compatibility Layer

News posted by koki on Wed, 2007-05-09 01:33

Thanks to the work of one of the most active code contributors lately, Hugo Santos, Haiku is getting a generic FreeBSD network driver compatibility layer that will allow FreeBSD network drivers to be compiled and used in Haiku with few, if any changes. At the time of this writing, not only has Hugo committed the compatibility layer to the Haiku tree, but he has also succeeded in building two FreeBSD drivers (if_em/Intel Pro 1000 and if_le/PCNet) which are now capable of running in Haiku.

Here is a quote from Hugo himself: "My original goal was to enable the use of FreeBSD drivers by just having them compiled 'as is' by the build system. This is possible with some drivers, but not all; but even for those that may require some changes in the code, the modification requirements will be minimal (most likely related to interrupt handling). The idea was to make it easy to upgrade the drivers with fixes from FreeBSD and/or upgrade to newer versions. Developing drivers can be a hard job, and developing bug free drivers even more so. The ability to use FreeBSD drivers with little to no changes in the code expands Haiku's hardware support with little burden to our pool of developers, which is a good thing. By the way, this idea was inspired by Marcus Overhagen's ipro1000 driver, which is Intel's FreeBSD driver ported to Haiku using a very specific compatibility layer."

To achieve his goal, Hugo started by copying the functions necessary for drivers from FreeBSD and creating a compatibility library. As he tried more drivers, he added more functions to the library. The Intel Pro Express 100 driver (fxp) was used as a base for requirements; Hugo then wrote Haiku-specific versions of some of these functions and changed others as required. Some original FreeBSD code is also used, as well as some of Marcus' code.

This is still work in progress and, by Hugo's own words, there is a lot more to be done and tested. Nevertheless, this is a great addition to Haiku and we are all grateful for Hugo's significant contributions.

Comments

Re: Haiku Getting a FreeBSD Network Driver Compatibility Layer

Wow neat stuff, what will the performance penalties be? Will it work for wireless cards too?

Is it this mainly possible because the stack sort of comes from freebsd?

Re: Haiku Getting a FreeBSD Network Driver Compatibility Layer

I am also intrested in wireless support. Does Haiku have any kind of wireless stack yet?

Re: Haiku Getting a FreeBSD Network Driver Compatibility Layer

nutela wrote:

Is it this mainly possible because the stack sort of comes from freebsd?

Haiku's network stack was written from scratch AFAIK, not ported. There was a lot of discussion about this decision. It's all in the mailinglist archives.

It's possible because there are similarities in a lot of places. Kernels written in the same language running on the same hardware have to implement similar services to take of hardware interrupts, manage memory, interface with peripheral devices, etc. BeOS (and thus Haiku) was very much inspired by a lot of other systems. A rehash one might say, but a very nice one! ;)

Re: Haiku Getting a FreeBSD Network Driver Compatibility Layer

Hi all. There is little to no performance penalties. And it might work in the future for wireless cards, but one step at a time.

Our network stack is written from scratch, this driver porting effort through a compatibility layer was possible because FreeBSD's drivers are neatly contained and our current network driver API permits it.

Re: Haiku Getting a FreeBSD Network Driver Compatibility Layer

Congratulations, Hugo! Fantastic work indeed.