break termios.h, ioctl.h up into filio.h, sockio.h, ttycom.h
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Mon, 28 Mar 1994 22:34:06 +0000 (14:34 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Mon, 28 Mar 1994 22:34:06 +0000 (14:34 -0800)
termios.h, ioccom.h and ioctl.h, a la SunOS
date and time created 94/03/28 07:34:06 by bostic

SCCS-vsn: sys/sys/ioccom.h 8.1

usr/src/sys/sys/ioccom.h [new file with mode: 0644]

diff --git a/usr/src/sys/sys/ioccom.h b/usr/src/sys/sys/ioccom.h
new file mode 100644 (file)
index 0000000..7ac4a8c
--- /dev/null
@@ -0,0 +1,43 @@
+/*-
+ * Copyright (c) 1982, 1986, 1990, 1993, 1994
+ *     The Regents of the University of California.  All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * %sccs.include.redist.c%
+ *
+ *     @(#)ioccom.h    8.1 (Berkeley) %G%
+ */
+
+#ifndef        _SYS_IOCCOM_H_
+#define        _SYS_IOCCOM_H_
+
+/*
+ * Ioctl's have the command encoded in the lower word, and the size of
+ * any in or out parameters in the upper word.  The high 3 bits of the
+ * upper word are used to encode the in/out status of the parameter.
+ */
+#define        IOCPARM_MASK    0x1fff          /* parameter length, at most 13 bits */
+#define        IOCPARM_LEN(x)  (((x) >> 16) & IOCPARM_MASK)
+#define        IOCBASECMD(x)   ((x) & ~(IOCPARM_MASK << 16))
+#define        IOCGROUP(x)     (((x) >> 8) & 0xff)
+
+#define        IOCPARM_MAX     NBPG            /* max size of ioctl, mult. of NBPG */
+#define        IOC_VOID        0x20000000      /* no parameters */
+#define        IOC_OUT         0x40000000      /* copy out parameters */
+#define        IOC_IN          0x80000000      /* copy in parameters */
+#define        IOC_INOUT       (IOC_IN|IOC_OUT)
+#define        IOC_DIRMASK     0xe0000000      /* mask for IN/OUT/VOID */
+
+#define        _IOC(inout,group,num,len) \
+       (inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num))
+#define        _IO(g,n)        _IOC(IOC_VOID,  (g), (n), 0)
+#define        _IOR(g,n,t)     _IOC(IOC_OUT,   (g), (n), sizeof(t))
+#define        _IOW(g,n,t)     _IOC(IOC_IN,    (g), (n), sizeof(t))
+/* this should be _IORW, but stdio got there first */
+#define        _IOWR(g,n,t)    _IOC(IOC_INOUT, (g), (n), sizeof(t))
+
+#endif /* !_SYS_IOCCOM_H_ */