How to add driver source to BSD source?
Wojciech A. Koszek
wkoszek at freebsd.czest.pl
Thu Oct 27 22:07:53 UTC 2011
Dnia 27-10-2011 o 23:19:19 Adarsh Joshi <adarsh.joshi at qlogic.com> napisał(a):
> Hi all,
>
> I am new to BSD, so kindly bare me if I am being stupid.
>
> I am trying to add my driver source code to the FreeBSD source with the intention of building kernel.debug for KGDB.
>
> I have included the driver source and the Makefile in /usr/src/sys/dev and module directories and I have modified the /usr/src/sys/amd64/conf/MYKERNEL (MYKERNEL copied from GENERIC) to include the appropriate device name.
>
> But when I try to do
>
> Config -g MYKERNEL
>
> It gives an error saying my device is unknown. I am pretty sure I am missing something but I am not sure what exactly is it. Any suggestions?
>
> Thank you
> regards
> Adarsh
>
>
Adarsh,
In order to insert new driver in the FreeBSD tree you have to:
- modify src/sys/conf/files
'files' if the device is generic. 'files.<arch>' if it's architecture
specific. You will see that there are 'optional' entries. You specify
optional <driver> and you must have coresponding:
device <driver>
in your kernel configuration file. In other words, you insert e.g.:
dev/sample/sample.c optional sample
in 'files' and:
device sample
in the kernel configuration.
config(8) will read 'files*' stuff and generate appropriate meta-data
files. If you build the kernel by hand:
cd sys/<arch>/conf && config KERNEL_CONFIG
cd ../compile/KERNEL_CONFIG
make
sys/<arch>/compile/<KERNEL_CONFIG> will have stuff created by config(8).
Basically opt_*.h files with potential options taken from KERNEL_CONFIG,
Makefile for building the kernel and some .c files, which will get linked
to the kernel image.
- provide source code in src/sys/dev/<driver>
- provide module Makefile in src/sys/modules/<driver>
For getting KLD module working. You must have that to get .ko
module.
The procedure explained in first two steps is necessary if you want to
compile the kernel driver staticly into the kernel ELF file. For
development, you may want to work with modules (aka kernel loadable
modules aka .ko files). For this, you only need the last step - providing
the Makefile.
--
Wojciech A. Koszek
wkoszek at freebsd.czest.pl
http://FreeBSD.czest.pl/~wkoszek/
More information about the freebsd-drivers
mailing list