PDA

View Full Version : Driver development


WeakSauceIII
05-31-2008, 03:01 AM
Can someone please post complete instructions on how to write a driver from scratch?

kidding...

I have done some development in windows on this topic and am researching the BSD way. I have the book "the design and implementation of the FreeBSD operating system" and it has a lot of good detailed info on the hardware setup and seems to be mostly relatable to OpenBSD. I also have the book "Writing Unix device drivers" by george pajari. It's dated (around 1991) and specific to UNIX system V but gives detailed walkthroughs and source code for all drivers types explaining the code line by line. It also seems to be at least 70% relatable to BSD. The combination of these two gets me real close. My question is this, where can i get the hardware specs for a device? I mean the low level control registers and such. I know that most of that is proprietary and not available which is what makes it hard to make OBSD compatible drivers but for the hardware that is open does anyone know a good site or resource? I'm not even sure what to call it. I searched for technical specs, driver specs ect... on intel and other sites but i can't find what I'm looking for. Of course the source code for OBSD drivers is a great resource as well.

BSDfan666
05-31-2008, 04:23 AM
There is no global index of "hardware specifications", you can find datasheets online from various sites but the best place is the hardware manufactures website.

Again, not every vendor releases datasheets.. and when they do, sometimes they're not very informative.

I'm not aware of any books related to writing drivers for OpenBSD, familiarity with the kernel would likely help, even though the BSD's are similar, kernel-level API's have changed (Which is why porting drivers between BSD's is not always easy..).

Take things on a case by case basis, if you're working on a driver for a.. USB sound card, find out as much as you can, docs, resources (previous implementations), and perhaps contact a developer and ask for advice.

It's assumed you know a great deal about the C programming language, and perhaps about the bus the device is connected to, PCI/USB/i2c etc.

Have fun, search the mailing lists... cvs commits.. etc.. Google is nice.

ocicat
05-31-2008, 05:24 AM
I have the book "the design and implementation of the FreeBSD operating system" and it has...
Although there is some overlap between the "4.4" & "FreeBSD" books, be aware that the older volume may be of greater use to OpenBSD:

http://marc.info/?l=openbsd-misc&m=114616081523335&w=2

FWIW.

WeakSauceIII
05-31-2008, 06:51 AM
bought it, 8$ on amazon.

thanks

robbak
05-31-2008, 08:05 AM
Generally speaking, if the manufacturer provided such low-level specs, the drivers would have been written long ago. The big problem with hardware support is that they are unavailable.
Occasionally, they make them available under Non-Disclosure Agreements, which allows someone who agreed to them to write drivers. If they are able under that agreement to release the source, then others can study the source and reconstruct some of the information, to implement a driver in anther OS. The licensing of that source code is often another impediment. Arg, it's a mess.

Generally, getting low-level info on hardware is like pulling teeth. It's like they don't want customers.

ocicat
05-31-2008, 08:18 AM
Occasionally, they make them available under Non-Disclosure Agreements...
...which the OpenBSD project will not tolerate. Specifications are either freely available without encumbrance, or the hardware has to be reverse-engineered which can take a longer period of time. This is the principal reason that OpenBSD offers a smaller number of drivers in comparison to other projects.