Learning to write FreeBSD Device Drivers

Andrew P. infofarmer at gmail.com
Sat Oct 22 05:03:17 PDT 2005

On 10/21/05, Peter Clutton <peterclutton at gmail.com> wrote:
> Hi everyone, hope this isn't too off topic. I'm a sysadmin who taught
> myself programming (and have worked as a PHP ad MYSQL developer) and
> really want to develop my FreeBSD skills, and hopefully one day be
> able to give something back to FreeBSD.
> I want to start writing device drivers, and would love any pointers to
> resources and tips from anyone. At the moment I'm reading a good C
> primer, along with The Design and Implementation of The FreeBSD
> Operating System ( a great book), and browsing the relevant sections
> in the Handbook and the source code. I'm wondering what else i could
> look at to help "join the ends" if you know what i mean.
> I know there is a comprehensive book on writing device drivers for
> Linux, would it help conceptually, or at all (i know the system calls
> are different) to read this as a beginning? Would looking at two
> drivers for the same hardware, for Linux and FreeBSD, looking at the
> difference, and maybe first try porting a new one be a good idea? Are
> there any other good resources anyone could point me to? I hope you
> don't think I'm too focused on linux resources, if I wanted to take
> the easy way, I'd be interested in it, but i much prefer FreeBSD.
> Any tips or pointers to resources would be much appreciated!! Thanks in advance.
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"

First of all, I haven't developed any serious thing for
any OS. As a matter of fact, I haven't written anything
in C/C++ in five years. But in the absence of a better
reply - this is my response.

I think that the best way to get involved into the
FreeBSD project is to install the OS on your desktop,
use it on your servers, help others on mailing lists,
write some ports (as an active user you'll have to do
that sooner or later), preen through pr-database
trying to find solutions, submit many patches, become
a committer - and there you are: involved.

There's a lot of reading on writing good code. Drivers
are quite a narrow field, but you can't begin to write
them without understanding how almost everything
else works. Writing a driver demands a more
comprehensive understanding of OS intrinsics than
most of other aspects. You'll definitely want to
work on other parts of kernel code before going on
to drivers.

Looking at the source of drivers for other systems
actually helps very very much. It's much easier to
port a driver, say, from OpenBSD than it is from
Linux, but you don't have to port anything. I bet
that reading a driver written for Solaris, HP-UX
or any other system will provide you with some
nice ideas that can be used in FreeBSD.

You can read as many books as you like, but
nothing will do you more good than reading
and understanding thoroughly a few existing

More information about the freebsd-questions mailing list