Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 23 Apr 1996 04:56:16 +0200 (MET DST)
From:      J Wunsch <j@uriah.heep.sax.de>
To:        freebsd-hackers@freebsd.org (FreeBSD hackers)
Cc:        jfrancis@frii.com
Subject:   Re: Device Driver ioctl() help
Message-ID:  <199604230256.EAA20717@uriah.heep.sax.de>
In-Reply-To: <199604220543.BAA01869@tap.zeus.leitch.com> from "Dave Chapeskie" at Apr 22, 96 01:43:03 am

next in thread | previous in thread | raw e-mail | index | archive | help
As Dave Chapeskie wrote:

> >#define JOY_SETTIMEOUT    _IOW('J', 1, int)    /* set timeout */
> [...]
> >	Ok, it looks like the 'J' has something to do with a "group",
> >but what kind of group?  How is this value chosen and what does it do?
> 
>     Get a good book on writing device drivers.  Typically you just use
> group 0 unless you know what you're doing. _IO is used when no data is

Hmm, i think the idea behind the `group' (and partially the `cmd')
value is to be semi-random, in order to reduce the probability of an
accidental ioctl name space clash with the ioctl of a foreign driver.
(Since BSD also encodes the lenth and IO direction of the third
parameter into the actual CMD, name space collisions are seldom
compared to V7 UNIX anyway.)  The convention was to pick a letter that
is roughly related to your driver as `group'.  That's why the joystick
driver is using `J'.

>     I think you need a better book.  I can't recommend one at the moment
> since I'm not at work where my bookshelf is.

I think this is already covered well in the old ``Daemon book'' (The
4.3BSD Operating System.  Design and Implementation.)  Don't use a
SysV book, SysV uses the old V7 UNIX algorithm where each and every
driver is responsible to perform the copyin()/copyout() itself.

Perhaps the easiest way is to pick several examples from existing BSD
drivers (not just one only).

-- 
cheers, J"org

joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199604230256.EAA20717>