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.3 (Berkeley) 01/09/95 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 args, mult. of NBPG */ 24 /* no parameters */ 25 #define IOC_VOID (unsigned long)0x20000000 26 /* copy parameters out */ 27 #define IOC_OUT (unsigned long)0x40000000 28 /* copy parameters in */ 29 #define IOC_IN (unsigned long)0x80000000 30 /* copy paramters in and out */ 31 #define IOC_INOUT (IOC_IN|IOC_OUT) 32 /* mask for IN/OUT/VOID */ 33 #define IOC_DIRMASK (unsigned long)0xe0000000 34 35 #define _IOC(inout,group,num,len) \ 36 (inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num)) 37 #define _IO(g,n) _IOC(IOC_VOID, (g), (n), 0) 38 #define _IOR(g,n,t) _IOC(IOC_OUT, (g), (n), sizeof(t)) 39 #define _IOW(g,n,t) _IOC(IOC_IN, (g), (n), sizeof(t)) 40 /* this should be _IORW, but stdio got there first */ 41 #define _IOWR(g,n,t) _IOC(IOC_INOUT, (g), (n), sizeof(t)) 42 43 #endif /* !_SYS_IOCCOM_H_ */ 44