Writing Drivers for NetBSD - of index.html
Writing Drivers for NetBSD - of index.html
Writing Drivers for NetBSD - of index.html
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
1 PREFACE 4<br />
1 Preface<br />
This document is intended to teach the basics <strong>of</strong> Unix-Kernelprogramming to a<br />
beginning Programmer with basic C knowledge. As an example, a device driver<br />
<strong>for</strong> a floppy drive under <strong>NetBSD</strong> was chosen, as the hardware and necessary documentation<br />
was available but the driver itself missing. <strong>NetBSD</strong> was chosen as the<br />
target operating system, as it lends itself perfectly as a teaching example due to its<br />
clearly structured source code and well defined interfaces.<br />
Un<strong>for</strong>tunately, there is hardly any specific documentation on Unix-<br />
Kernelprogramming under <strong>NetBSD</strong> apart from references to the functions in section<br />
9 <strong>of</strong> the <strong>NetBSD</strong> manual pages. These manual pages are however missing<br />
an introduction, a document that clarifies the connection between the various<br />
functions. This document attempts to provide such an introduction, to act as the<br />
necessary glue between the individual parts. There<strong>for</strong>e, I will reference external<br />
documents, particularly section 9 <strong>of</strong> the <strong>NetBSD</strong> manual pages in many places.<br />
This document is mainly based on the experiences I made when I wrote the driver<br />
rf(4) 1 <strong>for</strong> the UnixBus / QBus RX211 8” floppy controller.<br />
8” floppy? Those things existed? Yes. Those were the first floppies, built at<br />
the end <strong>of</strong> the 60s / beginning <strong>of</strong> the 70s. UniBus / QBus? Whatsdat? That’s the<br />
most common bus found in VAXen 2 . The VAX was the machine <strong>of</strong> the late 70s<br />
up until the beginning <strong>of</strong> the 90s. Then it was obsoleted by the Alpha architecture.<br />
BSD Unix has a long and glorious history on the VAX. [McK 99] But why am I<br />
writing a driver today <strong>for</strong> such antiquated technology? In the end, it doesn’t really<br />
matter if I explain the necessary steps using the latest 1GBit/s Ethernetcard <strong>for</strong><br />
a PCIX Bus or anything else. The underlying principles are the same. Besides,<br />
the hardware used in this example is relatively simplistic, so that we can see the<br />
essential aspects instead <strong>of</strong> being hindered by PeeCee idiocrasy.<br />
The following chapter gives a short overview <strong>of</strong> the autoconf(9) concept in<br />
<strong>NetBSD</strong>. Some details have been omitted, and I refer to the according manual<br />
pages to avoid duplication <strong>of</strong> in<strong>for</strong>mation.<br />
The third chapter documents the implementation <strong>of</strong> the autoconf(9) interface<br />
<strong>of</strong> rf(4).<br />
The fourth and last chapter covers the actual driver, i.e. the functionality <strong>of</strong><br />
the driver carrying the data from and to the physical device.<br />
In the appendix, you will find the complete source code <strong>of</strong> the driver as well<br />
1 RX01/02 Floppy<br />
2 plural <strong>for</strong> VAX