From owner-freebsd-hackers Mon Dec 8 18:00:36 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id SAA13116 for hackers-outgoing; Mon, 8 Dec 1997 18:00:36 -0800 (PST) (envelope-from owner-freebsd-hackers) Received: from alpo.whistle.com (alpo.whistle.com [207.76.204.38]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id SAA13103 for ; Mon, 8 Dec 1997 18:00:26 -0800 (PST) (envelope-from julian@whistle.com) Received: (from daemon@localhost) by alpo.whistle.com (8.8.5/8.8.5) id RAA03949; Mon, 8 Dec 1997 17:51:43 -0800 (PST) Received: from UNKNOWN(), claiming to be "current1.whistle.com" via SMTP by alpo.whistle.com, id smtpd003945; Mon Dec 8 17:51:35 1997 Message-ID: <348CA392.61133CF4@whistle.com> Date: Mon, 08 Dec 1997 17:49:06 -0800 From: Julian Elischer Organization: Whistle Communications X-Mailer: Mozilla 3.0Gold (X11; I; FreeBSD 2.2-CURRENT i386) MIME-Version: 1.0 To: Karl Pielorz CC: hackers@freebsd.org Subject: Re: Writing Device drivers for 2.2.X etc' References: <348C8223.4FF22185@tdx.co.uk> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk Karl Pielorz wrote: > > Hi, > > I'm trying to write a device driver for an ISA signal processor card - I've > made sure there isn't one around at the moment (why re-invent the wheel? ) > - and I could do with some help... > > I downloaded some shell scripts, which at the time looked like a good idea - > they create a driver framework to work from (with all the code stubs written > for probing, creating, attaching, doing IOCTL's etc.) - but the code refers to > manually editing 'conf.c'... My 2.2.2-Release system doesn't have a conf.c ;-) you can ignore that that comment should be removed.. the driver you have (if you got a new one) should add itself into the array with the cdevsw_add() call. > > The templates also don't seem to mention major / minor device numbers either - > unless they 'were' taken care of in conf.c at some point in the past? major is in CDEV_MAJOR and the request to cdevsw_add(&dev, &${1}_cdevsw, NULL); does this. it's up to each routine (open, read, write, etc.) to interpret the minor number. the minor is available to each of these routines as: minor(dev) and in the sample I made an assumption that there was a 1:1 mapping between minor numbers and the unit number of the device If this is not true you should change the macro: #define UNIT(dev) minor(dev) /* assume one minor number per unit */ > > Can anyone point the way to some up to date (i.e. 2.2.2+ etc.) info on the net > about writing device drivers for BSD - i.e. up to date templates etc.? for > nice simple ISA cards, or just code stubs? - Or are there any drivers in BSD > which are nice and simple for using as templates allready? the templates ARE up to date (pretty much) but the comment at the end is wrong. > > Thanks in advance, send me mail ifthe templates don't help. the latest is: http://www.freebsd.org/cgi/cvsweb.cgi/src/share/examples/drivers/make_device_driver.sh?rev=1.1> (excuse the line-wrap) > Karl Pielorz > (mailto:kpielorz@tdx.co.uk)