termios.h 6.5 KB

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