Date: Mon, 22 Apr 1996 01:43:03 -0400 (EDT) From: Dave Chapeskie <dchapes@zeus.leitch.com> To: jfrancis@frii.com Cc: hackers@FreeBSD.ORG Subject: Device Driver ioctl() help Message-ID: <199604220543.BAA01869@tap.zeus.leitch.com> In-Reply-To: <199604220432.WAA06308@deimos.frii.com>
next in thread | previous in thread | raw e-mail | index | archive | help
In message <199604220432.WAA06308@deimos.frii.com> jfrancis@frii.com writes: >#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 needed; _IOR when you need data returned from the driver; _IOW when you want data passed into the driver; and _IOWR to pass the data both ways. > In my user-level code, I can call `ioctl(fd,STUFF,0x69)'. In Ack!! RTFM, ioctl's third argument is a pointer. ie: header: #define MYDEV_CMD1 _IOW(0,1,int) user code: int arg = 42; ioctl(fd,MYDEV_CMD1,&arg) driver code: int mydev_ioctl(dev_t dev, int cmd, caddr_t data, int flags, struct proc *p) { switch(cmd) { case MYDEV_CMD1: if( *(int*)data == 42 ) .... >Obviously I'm missing something, but none >of the kernel books I have tell me what, and I can't seem to sort it >out. 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. -- Dave Chapeskie Leitch Technology International Inc. Email: dchapes@zeus.leitch.com
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199604220543.BAA01869>