From owner-freebsd-hackers Mon Apr 22 20:10:21 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id UAA23667 for hackers-outgoing; Mon, 22 Apr 1996 20:10:21 -0700 (PDT) Received: from irz301.inf.tu-dresden.de (irz301.inf.tu-dresden.de [141.76.1.11]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id UAA23650 for ; Mon, 22 Apr 1996 20:10:14 -0700 (PDT) Received: from sax.sax.de by irz301.inf.tu-dresden.de (8.6.12/8.6.12-s1) with ESMTP id FAA19173; Tue, 23 Apr 1996 05:09:53 +0200 Received: by sax.sax.de (8.6.11/8.6.12-s1) with UUCP id FAA05251; Tue, 23 Apr 1996 05:09:53 +0200 Received: (from j@localhost) by uriah.heep.sax.de (8.7.5/8.6.9) id EAA20717; Tue, 23 Apr 1996 04:56:16 +0200 (MET DST) From: J Wunsch Message-Id: <199604230256.EAA20717@uriah.heep.sax.de> Subject: Re: Device Driver ioctl() help To: freebsd-hackers@freebsd.org (FreeBSD hackers) Date: Tue, 23 Apr 1996 04:56:16 +0200 (MET DST) Cc: jfrancis@frii.com Reply-To: joerg_wunsch@uriah.heep.sax.de (Joerg Wunsch) In-Reply-To: <199604220543.BAA01869@tap.zeus.leitch.com> from "Dave Chapeskie" at Apr 22, 96 01:43:03 am X-Phone: +49-351-2012 669 X-Mailer: ELM [version 2.4 PL24 ME8a] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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. ;-)