root/include/linux/ioctl.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 /* $Id: ioctl.h,v 1.5 1993/07/19 21:53:50 root Exp root $
   2  *
   3  * linux/ioctl.h for Linux by H.H. Bergman.
   4  */
   5 
   6 #ifndef _LINUX_IOCTL_H
   7 #define _LINUX_IOCTL_H
   8 
   9 
  10 /* ioctl command encoding: 32 bits total, command in lower 16 bits,
  11  * size of the parameter structure in the lower 14 bits of the
  12  * upper 16 bits.
  13  * Encoding the size of the parameter structure in the ioctl request
  14  * is useful for catching programs compiled with old versions
  15  * and to avoid overwriting user space outside the user buffer area.
  16  * The highest 2 bits are reserved for indicating the ``access mode''.
  17  * NOTE: This limits the max parameter size to 16kB -1 !
  18  */
  19 
  20 #define IOC_VOID        0x00000000      /* param in size field */
  21 #define IOC_IN          0x40000000      /* user --> kernel */
  22 #define IOC_OUT         0x80000000      /* kernel --> user */
  23 #define IOC_INOUT       (IOC_IN | IOC_OUT)      /* both */
  24 #define IOCSIZE_MASK    0x3fff0000      /* size (max 16k-1 bytes) */
  25 #define IOCSIZE_SHIFT   16              /* how to get the size */
  26 #define IOCSIZE_MAX     ((PAGE_SIZE-1)&(IOCSIZE_MASK >> IOC_SHIFT))
  27 #define IOCCMD_MASK     0x0000ffff      /* command code */
  28 #define IOCCMD_SHIFT    0
  29 #define IOCPARM_MASK IOCCMD_MASK
  30 #define IOCPARM_SHIFT IOCCMD_SHIFT
  31 
  32 #define IOC_SIZE(cmd)   (((cmd) & IOCSIZE_MASK) >> IOCSIZE_SHIFT)
  33 #define IOCBASECMD(cmd) ((cmd) & ~IOCPARM_MASK)
  34 #define IOCGROUP(cmd)   (((cmd) >> 8) & 0xFF)
  35 
  36 #ifndef _IO
  37 /* _IO(magic, subcode); size field is zero and the 
  38  * subcode determines the command.
  39  */
  40 #define _IO(c,d)        (IOC_VOID | ((c)<<8) | (d)) /* param encoded */
  41 #endif
  42 
  43 #ifndef _IOW
  44 /* _IOXX(magic, subcode, arg_t); where arg_t is the type of the
  45  * (last) argument field in the ioctl call, if present.
  46  */
  47 #define _IOW(c,d,t)     (IOC_IN | ((sizeof(t)<<16) & IOCSIZE_MASK) | \
  48                                   ((c)<<8) | (d))
  49 #define _IOR(c,d,t)     (IOC_OUT | ((sizeof(t)<<16) & IOCSIZE_MASK) | \
  50                                    ((c)<<8) | (d))
  51 /* WR rather than RW to avoid conflict with stdio.h */
  52 #define _IOWR(c,d,t)    (IOC_INOUT | ((sizeof(t)<<16) & IOCSIZE_MASK) | \
  53                                      ((c)<<8) | (d))
  54 #endif /* !_IOW */
  55 
  56 #endif /* _LINUX_IOCTL_H */
  57 

/* [previous][next][first][last][top][bottom][index][help] */