From owner-freebsd-drivers@FreeBSD.ORG Thu Oct 27 22:07:53 2011 Return-Path: Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 05EF8106564A for ; Thu, 27 Oct 2011 22:07:52 +0000 (UTC) (envelope-from wkoszek@freebsd.czest.pl) Received: from freebsd.czest.pl (freebsd.czest.pl [212.87.224.105]) by mx1.freebsd.org (Postfix) with ESMTP id 4A8F18FC0C for ; Thu, 27 Oct 2011 22:07:51 +0000 (UTC) Received: from wkoszek-thinkpad-t410 (freebsd.czest.pl [212.87.224.105]) by freebsd.czest.pl (8.14.5/8.14.5) with ESMTP id p9RLp1lT086738 for ; Thu, 27 Oct 2011 21:51:02 GMT (envelope-from wkoszek@freebsd.czest.pl) Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: freebsd-drivers@freebsd.org References: <5E4F49720D0BAD499EE1F01232234BA873C6D8D33A@AVEXMB1.qlogic.org> Date: Thu, 27 Oct 2011 23:51:32 +0200 MIME-Version: 1.0 Content-Transfer-Encoding: Quoted-Printable From: "Wojciech A. Koszek" Organization: FreeBSD.czest.pl Message-ID: In-Reply-To: <5E4F49720D0BAD499EE1F01232234BA873C6D8D33A@AVEXMB1.qlogic.org> User-Agent: Opera Mail/11.52 (Linux) X-Greylist: Default is to whitelist mail, not delayed by milter-greylist-4.2.7 (freebsd.czest.pl [127.0.0.2]); Thu, 27 Oct 2011 21:51:02 +0000 (UTC) Subject: Re: How to add driver source to BSD source? X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Oct 2011 22:07:53 -0000 Dnia 27-10-2011 o 23:19:19 Adarsh Joshi 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.' if it's architecture= specific. You will see that there are 'optional' entries. You specify= optional and you must have coresponding: device 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//conf && config KERNEL_CONFIG cd ../compile/KERNEL_CONFIG make sys//compile/ 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/ - provide module Makefile in src/sys/modules/ 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/