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

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