OpenBSD Journal

OpenBSD driver development hints

Contributed by jj on from the driving-miss-daisy dept.

The slides from OpenCON are coming in fast now.
One of those is Jonathan Grays device driver presentation, which covers quite a few aspects of driver development.

The presentation is here. It starts out with the points on why BLOBs are evil and real documentation is important, goes on to point out where in the source tree various files go and how config(8) put them all together.

Then it goes into how the actual driver initializes itself and in what order things are done in a driver. The differences between interrupt based communication and polled are shown, as are the userland communication interfaces. It also touches the bus_space and bus_dma functions, but in order to understand them, you really need to read the manual pages and probably code using it, since it's non-trivial and can't really be explained in two slides.

After that, a few hints on mbufs, subsystems you may encounter and misc functions for sleeping/delays and locking.

Jonathan then shows some ways to aid in debugging kernel code, what options there are and how to add debugging code non-intrusively.

A quick pass on how reverse engineering works shows the complexity of it, and really gives you a hint on why real documentation is so valuable if you didn't get it in the first place.

Some guidelines for stuff to do, and not to do follows, with a special page on kernel subroutine stack usage, a topic that has gotten a bit of extra attention lately. Other guidelines are shorter dos and donts, all designed to make the writing experience better for all involved.

After that, a list of vendors that are only "open to business", from Sun to FreeBSD via Linux, where blobs and secrets seem accepted by the masses.

A "Future Work" ends this presentation, with topics and suggestions for improvements where OpenBSD could get better in order to help out people that write drivers.

All in all, a very nice presentation which touches lots of aspects of driver development.
Wish I was there to hear it.

(Comments are closed)


Comments
  1. By Anonymous Coward (74.130.128.79) on

    This is a really great presentation.. in fact I'd love to see a bound copy of all the papers in that directory. I wonder whether something like that help with funding? I'd pay very well for it.

  2. By Marius (81.181.89.58) on

    Very nice presentation !
    Thank you.

  3. By Anonymous Coward (207.112.196.106) on

    it'd be nice if there was an explanation of copyrights too. for instance, i don't see enough difference between: http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/dev/usb/ugensa.c?rev=1.8&content-type=text/plain and http://www.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/dev/usb/umsm.c?rev=1.3&content-type=text/plain to warrant a change in the copyright.

    Comments
    1. By Anonymous Coward (74.12.77.28) on

      > it'd be nice if there was an explanation of copyrights too.
      > for instance, i don't see enough difference between:
      http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/dev/usb/ugensa.c?rev=1.8&content-type=text/plain
      > and
      http://www.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/dev/usb/umsm.c?rev=1.3&content-type=text/plain
      > to warrant a change in the copyright.

      have you tried running diff on the two files to see the difference?

      Comments
      1. By Anonymous Coward (207.112.196.106) on

        > > it'd be nice if there was an explanation of copyrights too. > > for instance, i don't see enough difference between: > http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/dev/usb/ugensa.c?rev=1.8&content-type=text/plain > > and > http://www.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/dev/usb/umsm.c?rev=1.3&content-type=text/plain > > to warrant a change in the copyright. > > have you tried running diff on the two files to see the difference? have you? there's spacing changes, braces changes, etc. no significant changes at all.

        Comments
        1. By tedu (69.12.168.114) on

          > > > it'd be nice if there was an explanation of copyrights too.
          > > > for instance, i don't see enough difference between:
          > > http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/dev/usb/ugensa.c?rev=1.8&content-type=text/plain
          > > > and
          > > http://www.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/dev/usb/umsm.c?rev=1.3&content-type=text/plain
          > > > to warrant a change in the copyright.
          > >
          > > have you tried running diff on the two files to see the difference?
          >
          > have you? there's spacing changes, braces changes, etc. no significant changes at all.

          because 90% of the code is mechanical. what differences could there be?

        2. By Anonymous Coward (203.217.30.85) on


          > > have you tried running diff on the two files to see the difference?
          >
          > have you? there's spacing changes, braces changes, etc.
          > no significant changes at all.

          Most of the code in the driver is boilerplate USB driver stuff, all of the USB drivers share this. The actual device-specific stuff is only 20 lines or so (mainly the for() loop in umsm.c) and guess what? It is the part the differs most between the two drivers...

    2. By Anonymous Coward (87.238.80.64) on

      > it'd be nice if there was an explanation of copyrights too.
      > for instance, i don't see enough difference between:
      > http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/dev/usb/ugensa.c?rev=1.8&content-type=text/plain and
      > http://www.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/dev/usb/umsm.c?rev=1.3&content-type=text/plain
      > to warrant a change in the copyright.
      

      http://www.gnu.org/philosophy/bsd.html

      Link above explains problem with 4 clauses BSD license. That's one I see as a difference, but I know that I still don't have clear understanding of copyright. For example, what is the difference between:

      Copyright (c) 2006 Jonathan Gray 
      and
      Copyright (c) 2006 Jonathan Gray 
      All rights reserved.

      Comments
      1. By tedu (69.12.168.114) on

        For example, what is the difference between:
        > Copyright (c) 2006 Jonathan Gray
        > and
        > Copyright (c) 2006 Jonathan Gray
        > All rights reserved.

        depends on where you live and what treaties your country has signed.

        Comments
        1. By Anonymous Coward (87.238.80.64) on

          > For example, what is the difference between:
          > > Copyright (c) 2006 Jonathan Gray
          > > and
          > > Copyright (c) 2006 Jonathan Gray
          > > All rights reserved.
          >
          > depends on where you live and what treaties your country has signed.

          OpenBSD's license.template doesn't use `All rights reserved.' like most licenses I saw on web. How it looks in Canada or Europe?

Credits

Copyright © - Daniel Hartmeier. All rights reserved. Articles and comments are copyright their respective authors, submission implies license to publish on this web site. Contents of the archive prior to as well as images and HTML templates were copied from the fabulous original deadly.org with Jose's and Jim's kind permission. This journal runs as CGI with httpd(8) on OpenBSD, the source code is BSD licensed. undeadly \Un*dead"ly\, a. Not subject to death; immortal. [Obs.]