Date: Thu, 27 Oct 2011 23:51:32 +0200 From: "Wojciech A. Koszek" <wkoszek@freebsd.czest.pl> To: freebsd-drivers@freebsd.org Subject: Re: How to add driver source to BSD source? Message-ID: <op.v305n6y90do8pi@wkoszek-thinkpad-t410> In-Reply-To: <5E4F49720D0BAD499EE1F01232234BA873C6D8D33A@AVEXMB1.qlogic.org> References: <5E4F49720D0BAD499EE1F01232234BA873C6D8D33A@AVEXMB1.qlogic.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Dnia 27-10-2011 o 23:19:19 Adarsh Joshi <adarsh.joshi@qlogic.com> napisa= =C5=82(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 th= e 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 devic= e 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 m= issing 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_CONF= IG, Makefile for building the kernel and some .c files, which will get li= nked 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 - providin= g the Makefile. -- = Wojciech A. Koszek wkoszek@freebsd.czest.pl http://FreeBSD.czest.pl/~wkoszek/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?op.v305n6y90do8pi>