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 IOCCMD_MASK     0x0000ffff      /* command code */
  27 #define IOCCMD_SHIFT    0
  28 
  29 
  30 /* _IO(magic, subcode); size field is zero and the 
  31  * subcode determines the command.
  32  */
  33 #define _IO(c,d)        (IOC_VOID | ((c)<<8) | (d)) /* param encoded */
  34 
  35 /* _IOXX(magic, subcode, arg_t); where arg_t is the type of the
  36  * (last) argument field in the ioctl call, if present.
  37  */
  38 #define _IOW(c,d,t)     (IOC_IN | ((sizeof(t)<<16) & IOCSIZE_MASK) | \
  39                                   ((c)<<8) | (d))
  40 #define _IOR(c,d,t)     (IOC_OUT | ((sizeof(t)<<16) & IOCSIZE_MASK) | \
  41                                    ((c)<<8) | (d))
  42 /* WR rather than RW to avoid conflict with stdio.h */
  43 #define _IOWR(c,d,t)    (IOC_INOUT | ((sizeof(t)<<16) & IOCSIZE_MASK) | \
  44                                      ((c)<<8) | (d))
  45 
  46 #endif /* _LINUX_IOCTL_H */
  47 

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