xref: /original-bsd/sys/sys/ioccom.h (revision e58c8952)
1 /*-
2  * Copyright (c) 1982, 1986, 1990, 1993, 1994
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)ioccom.h	8.2 (Berkeley) 03/28/94
8  */
9 
10 #ifndef	_SYS_IOCCOM_H_
11 #define	_SYS_IOCCOM_H_
12 
13 /*
14  * Ioctl's have the command encoded in the lower word, and the size of
15  * any in or out parameters in the upper word.  The high 3 bits of the
16  * upper word are used to encode the in/out status of the parameter.
17  */
18 #define	IOCPARM_MASK	0x1fff		/* parameter length, at most 13 bits */
19 #define	IOCPARM_LEN(x)	(((x) >> 16) & IOCPARM_MASK)
20 #define	IOCBASECMD(x)	((x) & ~(IOCPARM_MASK << 16))
21 #define	IOCGROUP(x)	(((x) >> 8) & 0xff)
22 
23 #define	IOCPARM_MAX	NBPG		/* max size of ioctl, mult. of NBPG */
24 #define	IOC_VOID	0x20000000	/* no parameters */
25 #define	IOC_OUT		0x40000000	/* copy out parameters */
26 #define	IOC_IN		0x80000000	/* copy in parameters */
27 #define	IOC_INOUT	(IOC_IN|IOC_OUT)
28 #define	IOC_DIRMASK	0xe0000000	/* mask for IN/OUT/VOID */
29 
30 #define	_IOC(inout,group,num,len) \
31 	(inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num))
32 #define	_IO(g,n)	_IOC(IOC_VOID,	(g), (n), 0)
33 #define	_IOR(g,n,t)	_IOC(IOC_OUT,	(g), (n), sizeof(t))
34 #define	_IOW(g,n,t)	_IOC(IOC_IN,	(g), (n), sizeof(t))
35 /* this should be _IORW, but stdio got there first */
36 #define	_IOWR(g,n,t)	_IOC(IOC_INOUT,	(g), (n), sizeof(t))
37 
38 #endif /* !_SYS_IOCCOM_H_ */
39