Questions about kernel infrastructure

Hi everyone,

I have some questions regarding the kernel infrastructure when it comes to device drivers. I hope I may have some of them answered.

As has been stated in other threads, I am writing a device driver for Braille displays for FreeBSD. A braille display is an electronic device capable of rendering letters, numbers etc. into braille dots for a blind person to read. At the current state of its development, my driver supports two separate displays. Here are the questions:
1) Is it possible to have the source code for a device driver in multiple files? One file per Braille display, for example?
2) How does one add a custom device driver to the base source tree?
The reason I want to do this is to see how early my device will be detected, so if I could add it into the kernel somehow, that would be ideal. If I could load it too upon bootup, that would also be great. Could I do this with loader.conf?

I look forward to receiving any reply.

All the best,

Peter.
FreeBSD 9.0-BETA3 (on a test machine) and FreeBSD 8.2 on my development laptop.
 
Almost all drivers work the same way, if they're not built into the kernel they'll be built as modules. In principle there's no functional difference between the two. Modules get loaded by loader(8) before the kernel actually starts.
 
Yes, it is possible - and pretty often done - to split driver's source code into multiple source files.

As for adding a new driver - I'm not sure if there is any documentation for this. Basically, you create a new directory in sys/dev/ (or sys/dev/usb/, if it's a USB device), then add some glue code in order to connect it to the kernel build infrastructure. Easiest way to figure this out is to grep after existing driver, i.e. 'vxge'.

For development, however, this is not neccessary. Just create a directory, put your sources there, add Makefile based on Makefiles found in sys/modules/whatever (sys/modules/ti/Makefile looks simple), go to that directory, do "make" and then use kldload to load your module into the running kernel.
 
Back
Top