termios.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. #ifndef _ASM_POWERPC_TERMIOS_H
  2. #define _ASM_POWERPC_TERMIOS_H
  3. /*
  4. * Liberally adapted from alpha/termios.h. In particular, the c_cc[]
  5. * fields have been reordered so that termio & termios share the
  6. * common subset in the same order (for brain dead programs that don't
  7. * know or care about the differences).
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version
  12. * 2 of the License, or (at your option) any later version.
  13. */
  14. #include <asm/ioctls.h>
  15. #include <asm/termbits.h>
  16. struct sgttyb {
  17. char sg_ispeed;
  18. char sg_ospeed;
  19. char sg_erase;
  20. char sg_kill;
  21. short sg_flags;
  22. };
  23. struct tchars {
  24. char t_intrc;
  25. char t_quitc;
  26. char t_startc;
  27. char t_stopc;
  28. char t_eofc;
  29. char t_brkc;
  30. };
  31. struct ltchars {
  32. char t_suspc;
  33. char t_dsuspc;
  34. char t_rprntc;
  35. char t_flushc;
  36. char t_werasc;
  37. char t_lnextc;
  38. };
  39. struct winsize {
  40. unsigned short ws_row;
  41. unsigned short ws_col;
  42. unsigned short ws_xpixel;
  43. unsigned short ws_ypixel;
  44. };
  45. #define NCC 10
  46. struct termio {
  47. unsigned short c_iflag; /* input mode flags */
  48. unsigned short c_oflag; /* output mode flags */
  49. unsigned short c_cflag; /* control mode flags */
  50. unsigned short c_lflag; /* local mode flags */
  51. unsigned char c_line; /* line discipline */
  52. unsigned char c_cc[NCC]; /* control characters */
  53. };
  54. /* c_cc characters */
  55. #define _VINTR 0
  56. #define _VQUIT 1
  57. #define _VERASE 2
  58. #define _VKILL 3
  59. #define _VEOF 4
  60. #define _VMIN 5
  61. #define _VEOL 6
  62. #define _VTIME 7
  63. #define _VEOL2 8
  64. #define _VSWTC 9
  65. /* line disciplines */
  66. #define N_TTY 0
  67. #define N_SLIP 1
  68. #define N_MOUSE 2
  69. #define N_PPP 3
  70. #define N_STRIP 4
  71. #define N_AX25 5
  72. #define N_X25 6 /* X.25 async */
  73. #define N_6PACK 7
  74. #define N_MASC 8 /* Reserved for Mobitex module <kaz@cafe.net> */
  75. #define N_R3964 9 /* Reserved for Simatic R3964 module */
  76. #define N_PROFIBUS_FDL 10 /* Reserved for Profibus <Dave@mvhi.com> */
  77. #define N_IRDA 11 /* Linux IrDa - http://www.cs.uit.no/~dagb/irda/irda.html */
  78. #define N_SMSBLOCK 12 /* SMS block mode - for talking to GSM data cards about SMS messages */
  79. #define N_HDLC 13 /* synchronous HDLC */
  80. #define N_SYNC_PPP 14
  81. #define N_HCI 15 /* Bluetooth HCI UART */
  82. #ifdef __KERNEL__
  83. /* ^C ^\ del ^U ^D 1 0 0 0 0 ^W ^R ^Z ^Q ^S ^V ^U */
  84. #define INIT_C_CC "\003\034\177\025\004\001\000\000\000\000\027\022\032\021\023\026\025"
  85. #endif
  86. #define FIOCLEX _IO('f', 1)
  87. #define FIONCLEX _IO('f', 2)
  88. #define FIOASYNC _IOW('f', 125, int)
  89. #define FIONBIO _IOW('f', 126, int)
  90. #define FIONREAD _IOR('f', 127, int)
  91. #define TIOCINQ FIONREAD
  92. #define TIOCGETP _IOR('t', 8, struct sgttyb)
  93. #define TIOCSETP _IOW('t', 9, struct sgttyb)
  94. #define TIOCSETN _IOW('t', 10, struct sgttyb) /* TIOCSETP wo flush */
  95. #define TIOCSETC _IOW('t', 17, struct tchars)
  96. #define TIOCGETC _IOR('t', 18, struct tchars)
  97. #define TCGETS _IOR('t', 19, struct termios)
  98. #define TCSETS _IOW('t', 20, struct termios)
  99. #define TCSETSW _IOW('t', 21, struct termios)
  100. #define TCSETSF _IOW('t', 22, struct termios)
  101. #define TCGETA _IOR('t', 23, struct termio)
  102. #define TCSETA _IOW('t', 24, struct termio)
  103. #define TCSETAW _IOW('t', 25, struct termio)
  104. #define TCSETAF _IOW('t', 28, struct termio)
  105. #define TCSBRK _IO('t', 29)
  106. #define TCXONC _IO('t', 30)
  107. #define TCFLSH _IO('t', 31)
  108. #define TIOCSWINSZ _IOW('t', 103, struct winsize)
  109. #define TIOCGWINSZ _IOR('t', 104, struct winsize)
  110. #define TIOCSTART _IO('t', 110) /* start output, like ^Q */
  111. #define TIOCSTOP _IO('t', 111) /* stop output, like ^S */
  112. #define TIOCOUTQ _IOR('t', 115, int) /* output queue size */
  113. #define TIOCGLTC _IOR('t', 116, struct ltchars)
  114. #define TIOCSLTC _IOW('t', 117, struct ltchars)
  115. #define TIOCSPGRP _IOW('t', 118, int)
  116. #define TIOCGPGRP _IOR('t', 119, int)
  117. #define TIOCEXCL 0x540C
  118. #define TIOCNXCL 0x540D
  119. #define TIOCSCTTY 0x540E
  120. #define TIOCSTI 0x5412
  121. #define TIOCMGET 0x5415
  122. #define TIOCMBIS 0x5416
  123. #define TIOCMBIC 0x5417
  124. #define TIOCMSET 0x5418
  125. #define TIOCGSOFTCAR 0x5419
  126. #define TIOCSSOFTCAR 0x541A
  127. #define TIOCLINUX 0x541C
  128. #define TIOCCONS 0x541D
  129. #define TIOCGSERIAL 0x541E
  130. #define TIOCSSERIAL 0x541F
  131. #define TIOCPKT 0x5420
  132. #define TIOCNOTTY 0x5422
  133. #define TIOCSETD 0x5423
  134. #define TIOCGETD 0x5424
  135. #define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */
  136. #define TIOCSERCONFIG 0x5453
  137. #define TIOCSERGWILD 0x5454
  138. #define TIOCSERSWILD 0x5455
  139. #define TIOCGLCKTRMIOS 0x5456
  140. #define TIOCSLCKTRMIOS 0x5457
  141. #define TIOCSERGSTRUCT 0x5458 /* For debugging only */
  142. #define TIOCSERGETLSR 0x5459 /* Get line status register */
  143. #define TIOCSERGETMULTI 0x545A /* Get multiport config */
  144. #define TIOCSERSETMULTI 0x545B /* Set multiport config */
  145. #define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */
  146. #define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
  147. /* Used for packet mode */
  148. #define TIOCPKT_DATA 0
  149. #define TIOCPKT_FLUSHREAD 1
  150. #define TIOCPKT_FLUSHWRITE 2
  151. #define TIOCPKT_STOP 4
  152. #define TIOCPKT_START 8
  153. #define TIOCPKT_NOSTOP 16
  154. #define TIOCPKT_DOSTOP 32
  155. /* modem lines */
  156. #define TIOCM_LE 0x001
  157. #define TIOCM_DTR 0x002
  158. #define TIOCM_RTS 0x004
  159. #define TIOCM_ST 0x008
  160. #define TIOCM_SR 0x010
  161. #define TIOCM_CTS 0x020
  162. #define TIOCM_CAR 0x040
  163. #define TIOCM_RNG 0x080
  164. #define TIOCM_DSR 0x100
  165. #define TIOCM_CD TIOCM_CAR
  166. #define TIOCM_RI TIOCM_RNG
  167. #define TIOCM_OUT1 0x2000
  168. #define TIOCM_OUT2 0x4000
  169. #define TIOCM_LOOP 0x8000
  170. /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
  171. #define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
  172. #ifdef __KERNEL__
  173. /*
  174. * Translate a "termio" structure into a "termios". Ugh.
  175. */
  176. #define SET_LOW_TERMIOS_BITS(termios, termio, x) { \
  177. unsigned short __tmp; \
  178. get_user(__tmp,&(termio)->x); \
  179. (termios)->x = (0xffff0000 & (termios)->x) | __tmp; \
  180. }
  181. #define user_termio_to_kernel_termios(termios, termio) \
  182. ({ \
  183. SET_LOW_TERMIOS_BITS(termios, termio, c_iflag); \
  184. SET_LOW_TERMIOS_BITS(termios, termio, c_oflag); \
  185. SET_LOW_TERMIOS_BITS(termios, termio, c_cflag); \
  186. SET_LOW_TERMIOS_BITS(termios, termio, c_lflag); \
  187. copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \
  188. })
  189. /*
  190. * Translate a "termios" structure into a "termio". Ugh.
  191. */
  192. #define kernel_termios_to_user_termio(termio, termios) \
  193. ({ \
  194. put_user((termios)->c_iflag, &(termio)->c_iflag); \
  195. put_user((termios)->c_oflag, &(termio)->c_oflag); \
  196. put_user((termios)->c_cflag, &(termio)->c_cflag); \
  197. put_user((termios)->c_lflag, &(termio)->c_lflag); \
  198. put_user((termios)->c_line, &(termio)->c_line); \
  199. copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \
  200. })
  201. #define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios))
  202. #define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios))
  203. #endif /* __KERNEL__ */
  204. #endif /* _ASM_POWERPC_TERMIOS_H */