Subject: FreeBSD 5/6/7 kernel emulator for NetBSD 2.x
To: None <email@example.com, firstname.lastname@example.org>
From: Hans Petter Selasky <email@example.com>
Date: 10/24/2005 22:35:47
I have made an effort on making a FreeBSD 5/6/7 kernel emulator for NetBSD
2.x. Many device drivers are shared between these two operating systems, and
I think a lot of work can be saved when it comes to porting code and patches
forth and back. Currently this emulator makes my FreeBSD PCI ISDN driver load
and run on NetBSD. I have chosen to make FreeBSD 5+ the standard for several
- all drivers are dynamically linked through use of the "section attribute" in
the "C" compiler.
- "/dev" is a file system that can be manipulated from the kernel, without
intervention from "mknod".
- All I/O resources are allocated through a single function,
- And more.
Here is a case in which such a kernel emulator can be used:
I think it is a good idea that FreeBSD and NetBSD shares as many USB drivers
as possible. But sharing USB device drivers like
"/usr/src/sys/dev/usb/ulpt.c", is difficult, because two quite different
interfaces are used to create devices in "/dev/". And it is not only this,
but also how USB device drivers register in the kernel so that they get
probed. Here one has tried to hide system differences by using macros.
I think one should rather have some external library that hides these system
differences, so that there is only one branch for the USB device drivers, for
both NetBSD and FreeBSD, and probably the other *BSD's aswell, if possible.
That means a branch without "ifdefs" for every operating system it is
supposed to compile on. Then one has got to choose the library interface, and
I would say that "FreeBSD 5+ specific" is the best candidate so far.
I see that one can move many USB drivers over to FreeBSD, merge everything
together, expand all the macros in "/usr/src/sys/dev/usb/usb_port.h", and
then copy it back to NetBSD which then must have a FreeBSD kernel emulator in
the kernel. When the drivers are updated later, it will be very easy to cross
port the changes, and at the same time the USB system is brought out of the
Giant lock. Also it will be easier to create portable USB kernel device
Anyone have any opinion about what system is better to use as a standard in
- Implements FreeBSD's devfs on NetBSD.
- Support for mutexes, mtx_xxxx() and msleep()
- Support for probe/attach and general use of PCI devices
- Support for SYSINIT()
- Support for DRIVER_MODULE()
- And some other things found in FreeBSD 5/6/7
Here is a tarball (only tested on i386 and compatible, NetBSD 2.x):