Home | History | Annotate | Download | only in include
      1 /*
      2  * Copyright 2012, The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *     http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15 */
     16 
     17 #ifndef _IOCTLS_PORTABLE_H_
     18 #define _IOCTLS_PORTABLE_H_
     19 
     20 /*
     21  * Derived from development/ndk/platforms/android-3/include/asm-generic/ioctl.h
     22  */
     23 #define _IOC_NRBITS_PORTABLE 8
     24 #define _IOC_TYPEBITS_PORTABLE 8
     25 #define _IOC_SIZEBITS_PORTABLE 14
     26 #define _IOC_DIRBITS_PORTABLE 2
     27 
     28 #define _IOC_NRMASK_PORTABLE ((1 << _IOC_NRBITS_PORTABLE)-1)
     29 #define _IOC_TYPEMASK_PORTABLE ((1 << _IOC_TYPEBITS_PORTABLE)-1)
     30 #define _IOC_SIZEMASK_PORTABLE ((1 << _IOC_SIZEBITS_PORTABLE)-1)
     31 #define _IOC_DIRMASK_PORTABLE ((1 << _IOC_DIRBITS_PORTABLE)-1)
     32 
     33 #define _IOC_NRSHIFT_PORTABLE 0
     34 #define _IOC_TYPESHIFT_PORTABLE (_IOC_NRSHIFT_PORTABLE+_IOC_NRBITS_PORTABLE)
     35 #define _IOC_SIZESHIFT_PORTABLE (_IOC_TYPESHIFT_PORTABLE+_IOC_TYPEBITS_PORTABLE)
     36 #define _IOC_DIRSHIFT_PORTABLE (_IOC_SIZESHIFT_PORTABLE+_IOC_SIZEBITS_PORTABLE)
     37 
     38 #define _IOC_NONE_PORTABLE 0U
     39 #define _IOC_WRITE_PORTABLE 1U
     40 #define _IOC_READ_PORTABLE 2U
     41 
     42 #define _IOC_PORTABLE(dir, type, nr, size) (                                            \
     43     ((dir) << _IOC_DIRSHIFT_PORTABLE)    |                                              \
     44     ((type) << _IOC_TYPESHIFT_PORTABLE)  |                                              \
     45     ((nr) << _IOC_NRSHIFT_PORTABLE)      |                                              \
     46     ((size) << _IOC_SIZESHIFT_PORTABLE)                                                 \
     47 )
     48 
     49 extern unsigned int __invalid_size_argument_for_IOC;
     50 
     51 #define _IOC_TYPECHECK_PORTABLE(t) (                                                    \
     52     (sizeof(t) == sizeof(t[1]) && sizeof(t) < (1 << _IOC_SIZEBITS_PORTABLE)) ?          \
     53     sizeof(t) :                                                                         \
     54     __invalid_size_argument_for_IOC                                                     \
     55 )
     56 
     57 #define _IO_PORTABLE(type, nr) _IOC_PORTABLE(_IOC_NONE_PORTABLE, (type), (nr), 0)
     58 
     59 #define _IOR_PORTABLE(type, nr, size)                                                    \
     60     _IOC_PORTABLE(_IOC_READ_PORTABLE, (type), (nr), (_IOC_TYPECHECK_PORTABLE(size)))
     61 
     62 #define _IOW_PORTABLE(type, nr, size)                                                    \
     63     _IOC_PORTABLE(_IOC_WRITE_PORTABLE, (type), (nr), (_IOC_TYPECHECK_PORTABLE(size)))
     64 
     65 #define _IOWR_PORTABLE(type, nr, size)                                                   \
     66     IOC_PORTABLE(_IOC_READ_PORTABLE |                                                    \
     67                  _IOC_WRITE_PORTABLE, (type), (nr), (IOC_TYPECHECK_PORTABLE(size)) )
     68 
     69 
     70 /*
     71  * Derived from development/ndk/platforms/android-3/arch-arm/include/asm/ioctls.h
     72  */
     73 #define TCGETS_PORTABLE     0x5401
     74 #define TCSETS_PORTABLE     0x5402
     75 #define TCSETSW_PORTABLE    0x5403
     76 #define TCSETSF_PORTABLE    0x5404
     77 #define TCGETA_PORTABLE     0x5405
     78 #define TCSETA_PORTABLE     0x5406
     79 #define TCSETAW_PORTABLE    0x5407
     80 #define TCSETAF_PORTABLE    0x5408
     81 #define TCSBRK_PORTABLE     0x5409
     82 #define TCXONC_PORTABLE     0x540A
     83 #define TCFLSH_PORTABLE     0x540B
     84 #define TIOCEXCL_PORTABLE   0x540C
     85 #define TIOCNXCL_PORTABLE   0x540D
     86 #define TIOCSCTTY_PORTABLE  0x540E
     87 #define TIOCGPGRP_PORTABLE  0x540F
     88 #define TIOCSPGRP_PORTABLE  0x5410
     89 #define TIOCOUTQ_PORTABLE   0x5411
     90 #define TIOCSTI_PORTABLE    0x5412
     91 #define TIOCGWINSZ_PORTABLE 0x5413
     92 #define TIOCSWINSZ_PORTABLE 0x5414
     93 #define TIOCMGET_PORTABLE   0x5415
     94 #define TIOCMBIS_PORTABLE   0x5416
     95 #define TIOCMBIC_PORTABLE   0x5417
     96 #define TIOCMSET_PORTABLE   0x5418
     97 #define TIOCGSOFTCAR_PORTABLE   0x5419
     98 #define TIOCSSOFTCAR_PORTABLE   0x541A
     99 #define FIONREAD_PORTABLE   0x541B
    100 #define TIOCINQ_PORTABLE    FIONREAD_PORTABLE
    101 #define TIOCLINUX_PORTABLE  0x541C
    102 #define TIOCCONS_PORTABLE   0x541D
    103 #define TIOCGSERIAL_PORTABLE    0x541E
    104 #define TIOCSSERIAL_PORTABLE    0x541F
    105 #define TIOCPKT_PORTABLE    0x5420
    106 #define FIONBIO_PORTABLE    0x5421
    107 #define TIOCNOTTY_PORTABLE  0x5422
    108 #define TIOCSETD_PORTABLE   0x5423
    109 #define TIOCGETD_PORTABLE   0x5424
    110 #define TCSBRKP_PORTABLE    0x5425
    111 #define TIOCSBRK_PORTABLE   0x5427
    112 #define TIOCCBRK_PORTABLE   0x5428
    113 #define TIOCGSID_PORTABLE   0x5429
    114 #define TIOCGPTN_PORTABLE _IOR_PORTABLE('T',0x30, unsigned int)
    115 #define TIOCSPTLCK_PORTABLE _IOW_PORTABLE('T',0x31, int)
    116 
    117 #define FIONCLEX_PORTABLE   0x5450
    118 #define FIOCLEX_PORTABLE    0x5451
    119 #define FIOASYNC_PORTABLE   0x5452
    120 #define TIOCSERCONFIG_PORTABLE  0x5453
    121 #define TIOCSERGWILD_PORTABLE   0x5454
    122 #define TIOCSERSWILD_PORTABLE   0x5455
    123 #define TIOCGLCKTRMIOS_PORTABLE 0x5456
    124 #define TIOCSLCKTRMIOS_PORTABLE 0x5457
    125 #define TIOCSERGSTRUCT_PORTABLE 0x5458
    126 #define TIOCSERGETLSR_PORTABLE  0x5459
    127 #define TIOCSERGETMULTI_PORTABLE 0x545A
    128 #define TIOCSERSETMULTI_PORTABLE 0x545B
    129 
    130 #define TIOCMIWAIT_PORTABLE     0x545C
    131 #define TIOCGICOUNT_PORTABLE    0x545D
    132 #define FIOQSIZE_PORTABLE       0x545E /* x86 differs here */
    133 
    134 #define TIOCPKT_DATA_PORTABLE       0
    135 #define TIOCPKT_FLUSHREAD_PORTABLE  1
    136 #define TIOCPKT_FLUSHWRITE_PORTABLE 2
    137 #define TIOCPKT_STOP_PORTABLE       4
    138 #define TIOCPKT_START_PORTABLE      8
    139 #define TIOCPKT_NOSTOP_PORTABLE     16
    140 #define TIOCPKT_DOSTOP_PORTABLE     32
    141 
    142 #define TIOCSER_TEMT_PORTABLE   0x01
    143 
    144 /*
    145  * Derived from development/ndk/platforms/android-3/include/sys/ioctl_compat.h
    146  */
    147 struct tchars_portable {
    148         char    t_intrc;        /* interrupt */
    149         char    t_quitc;        /* quit */
    150         char    t_startc;       /* start output */
    151         char    t_stopc;        /* stop output */
    152         char    t_eofc;         /* end-of-file */
    153         char    t_brkc;         /* input delimiter (like nl) */
    154 };
    155 
    156 struct ltchars_portable {
    157         char    t_suspc;        /* stop process signal */
    158         char    t_dsuspc;       /* delayed stop process signal */
    159         char    t_rprntc;       /* reprint line */
    160         char    t_flushc;       /* flush output (toggles) */
    161         char    t_werasc;       /* word erase */
    162         char    t_lnextc;       /* literal next character */
    163 };
    164 
    165 struct sgttyb_portable {
    166         char    sg_ispeed;      /* input speed */
    167         char    sg_ospeed;      /* output speed */
    168         char    sg_erase;       /* erase character */
    169         char    sg_kill;        /* kill character */
    170         short   sg_flags;       /* mode flags */
    171 };
    172 
    173 #ifdef USE_OLD_TTY
    174 # define TIOCGETD_PORTABLE   _IOR_PORTABLE('t', 0, int)       /* get line discipline */
    175 # define TIOCSETD_PORTABLE   _IOW_PORTABLE('t', 1, int)       /* set line discipline */
    176 #else
    177 # define OTIOCGETD_PORTABLE  _IOR_PORTABLE('t', 0, int)       /* get line discipline */
    178 # define OTIOCSETD_PORTABLE  _IOW_PORTABLE('t', 1, int)       /* set line discipline */
    179 #endif
    180 
    181 /* hang up on last close */
    182 #define TIOCHPCL_PORTABLE    _IO_PORTABLE('t', 2)
    183 
    184 /* get parameters -- gtty */
    185 #define TIOCGETP_PORTABLE    _IOR_PORTABLE('t', 8,struct sgttyb_portable)
    186 
    187 /* set parameters -- stty */
    188 #define TIOCSETP_PORTABLE    _IOW_PORTABLE('t', 9,struct sgttyb_portable)
    189 
    190 /* as above, but no flushtty*/
    191 #define TIOCSETN_PORTABLE    _IOW_PORTABLE('t',10,struct sgttyb_portable)
    192 
    193 /* set special characters */
    194 #define TIOCSETC_PORTABLE    _IOW_PORTABLE('t',17,struct tchars_portable)
    195 
    196 /* get special characters */
    197 #define TIOCGETC_PORTABLE    _IOR_PORTABLE('t',18,struct tchars_portable)
    198 
    199 /* bis local mode bits */
    200 #define TIOCLBIS_PORTABLE    _IOW_PORTABLE('t', 127, int)
    201 
    202 /* bic local mode bits */
    203 #define TIOCLBIC_PORTABLE    _IOW_PORTABLE('t', 126, int)
    204 
    205 /* set entire local mode word */
    206 #define TIOCLSET_PORTABLE    _IOW_PORTABLE('t', 125, int)
    207 
    208 /* get local modes */
    209 #define TIOCLGET_PORTABLE    _IOR_PORTABLE('t', 124, int)
    210 
    211 /* set local special chars*/
    212 #define TIOCSLTC_PORTABLE    _IOW_PORTABLE('t',117,struct ltchars_portable)
    213 
    214 /* get local special chars*/
    215 #define TIOCGLTC_PORTABLE    _IOR_PORTABLE('t',116,struct ltchars_portable)
    216 
    217  /* for hp300 -- sans int arg */
    218 #define OTIOCCONS_PORTABLE   _IO_PORTABLE('t', 98)
    219 
    220 /*
    221  * Derived from development/ndk/platforms/android-3/arch-arm/include/asm/sockios.h
    222  */
    223 #define FIOSETOWN_PORTABLE 0x8901
    224 #define SIOCSPGRP_PORTABLE 0x8902
    225 #define FIOGETOWN_PORTABLE 0x8903
    226 #define SIOCGPGRP_PORTABLE 0x8904
    227 #define SIOCATMARK_PORTABLE 0x8905
    228 #define SIOCGSTAMP_PORTABLE 0x8906
    229 
    230 #endif /* _IOCTLS_PORTABLE_H */
    231