Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 08 Dec 1997 17:49:06 -0800
From:      Julian Elischer <julian@whistle.com>
To:        Karl Pielorz <kpielorz@tdx.co.uk>
Cc:        hackers@freebsd.org
Subject:   Re: Writing Device drivers for 2.2.X etc'
Message-ID:  <348CA392.61133CF4@whistle.com>
References:  <348C8223.4FF22185@tdx.co.uk>

next in thread | previous in thread | raw e-mail | index | archive | help
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? <g>)
> - 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)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?348CA392.61133CF4>