00001 /** 00002 * 00003 $Id: ioctl.h,v 1.5 1993/07/19 21:53:50 root Exp root $ 00004 * 00005 * linux/ioctl.h for Linux by H.H. Bergman. 00006 00007 00008 */ 00009 00010 #ifndef _LINUX_IOCTL_H 00011 #define _LINUX_IOCTL_H 00012 00013 00014 /** 00015 * 00016 ioctl command encoding: 32 bits total, command in lower 16 bits, 00017 * size of the parameter structure in the lower 14 bits of the 00018 * upper 16 bits. 00019 * Encoding the size of the parameter structure in the ioctl request 00020 * is useful for catching programs compiled with old versions 00021 * and to avoid overwriting user space outside the user buffer area. 00022 * The highest 2 bits are reserved for indicating the ``access mode''. 00023 * NOTE: This limits the max parameter size to 16kB -1 ! 00024 00025 00026 */ 00027 00028 #define IOC_VOID 0x00000000 ///< param in size field 00029 #define IOC_IN 0x40000000 ///< user --> kernel 00030 #define IOC_OUT 0x80000000 ///< kernel --> user 00031 #define IOC_INOUT (IOC_IN | IOC_OUT) ///< both 00032 #define IOCSIZE_MASK 0x3fff0000 ///< size (max 16k-1 bytes) 00033 #define IOCSIZE_SHIFT 16 ///< how to get the size 00034 #define IOCCMD_MASK 0x0000ffff ///< command code 00035 #define IOCCMD_SHIFT 0 00036 00037 00038 /** 00039 * 00040 _IO(magic, subcode); size field is zero and the 00041 * subcode determines the command. 00042 00043 00044 */ 00045 #define _IO(c,d) (IOC_VOID | ((c)<<8) | (d)) ///< param encoded 00046 00047 /** 00048 * 00049 _IOXX(magic, subcode, arg_t); where arg_t is the type of the 00050 * (last) argument field in the ioctl call, if present. 00051 00052 00053 */ 00054 #define _IOW(c,d,t) (IOC_IN | ((sizeof(t)<<16) & IOCSIZE_MASK) | \ 00055 ((c)<<8) | (d)) 00056 #define _IOR(c,d,t) (IOC_OUT | ((sizeof(t)<<16) & IOCSIZE_MASK) | \ 00057 ((c)<<8) | (d)) 00058 /// WR rather than RW to avoid conflict with stdio.h 00059 #define _IOWR(c,d,t) (IOC_INOUT | ((sizeof(t)<<16) & IOCSIZE_MASK) | \ 00060 ((c)<<8) | (d)) 00061 00062 #endif // _LINUX_IOCTL_H 00063
1.4.6-5