termios.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /* $Id: termios.h,v 1.32 2001/06/01 08:12:11 davem Exp $ */
  2. #ifndef _SPARC_TERMIOS_H
  3. #define _SPARC_TERMIOS_H
  4. #include <asm/ioctls.h>
  5. #include <asm/termbits.h>
  6. #if defined(__KERNEL__) || defined(__DEFINE_BSD_TERMIOS)
  7. struct sgttyb {
  8. char sg_ispeed;
  9. char sg_ospeed;
  10. char sg_erase;
  11. char sg_kill;
  12. short sg_flags;
  13. };
  14. struct tchars {
  15. char t_intrc;
  16. char t_quitc;
  17. char t_startc;
  18. char t_stopc;
  19. char t_eofc;
  20. char t_brkc;
  21. };
  22. struct ltchars {
  23. char t_suspc;
  24. char t_dsuspc;
  25. char t_rprntc;
  26. char t_flushc;
  27. char t_werasc;
  28. char t_lnextc;
  29. };
  30. #endif /* __KERNEL__ */
  31. struct sunos_ttysize {
  32. int st_lines; /* Lines on the terminal */
  33. int st_columns; /* Columns on the terminal */
  34. };
  35. /* Used for packet mode */
  36. #define TIOCPKT_DATA 0
  37. #define TIOCPKT_FLUSHREAD 1
  38. #define TIOCPKT_FLUSHWRITE 2
  39. #define TIOCPKT_STOP 4
  40. #define TIOCPKT_START 8
  41. #define TIOCPKT_NOSTOP 16
  42. #define TIOCPKT_DOSTOP 32
  43. struct winsize {
  44. unsigned short ws_row;
  45. unsigned short ws_col;
  46. unsigned short ws_xpixel;
  47. unsigned short ws_ypixel;
  48. };
  49. /* line disciplines */
  50. #define N_TTY 0
  51. #define N_SLIP 1
  52. #define N_MOUSE 2
  53. #define N_PPP 3
  54. #define N_STRIP 4
  55. #define N_AX25 5
  56. #define N_X25 6
  57. #define N_6PACK 7
  58. #define N_MASC 8 /* Reserved for Mobitex module <kaz@cafe.net> */
  59. #define N_R3964 9 /* Reserved for Simatic R3964 module */
  60. #define N_PROFIBUS_FDL 10 /* Reserved for Profibus <Dave@mvhi.com> */
  61. #define N_IRDA 11 /* Linux IrDa - http://irda.sourceforge.net/ */
  62. #define N_SMSBLOCK 12 /* SMS block mode - for talking to GSM data cards about SMS messages */
  63. #define N_HDLC 13 /* synchronous HDLC */
  64. #define N_SYNC_PPP 14 /* synchronous PPP */
  65. #define N_HCI 15 /* Bluetooth HCI UART */
  66. #ifdef __KERNEL__
  67. #include <linux/module.h>
  68. /*
  69. * c_cc characters in the termio structure. Oh, how I love being
  70. * backwardly compatible. Notice that character 4 and 5 are
  71. * interpreted differently depending on whether ICANON is set in
  72. * c_lflag. If it's set, they are used as _VEOF and _VEOL, otherwise
  73. * as _VMIN and V_TIME. This is for compatibility with OSF/1 (which
  74. * is compatible with sysV)...
  75. */
  76. #define _VMIN 4
  77. #define _VTIME 5
  78. /* intr=^C quit=^\ erase=del kill=^U
  79. eof=^D eol=\0 eol2=\0 sxtc=\0
  80. start=^Q stop=^S susp=^Z dsusp=^Y
  81. reprint=^R discard=^U werase=^W lnext=^V
  82. vmin=\1 vtime=\0
  83. */
  84. #define INIT_C_CC "\003\034\177\025\004\000\000\000\021\023\032\031\022\025\027\026\001"
  85. /*
  86. * Translate a "termio" structure into a "termios". Ugh.
  87. */
  88. #define user_termio_to_kernel_termios(termios, termio) \
  89. ({ \
  90. unsigned short tmp; \
  91. get_user(tmp, &(termio)->c_iflag); \
  92. (termios)->c_iflag = (0xffff0000 & ((termios)->c_iflag)) | tmp; \
  93. get_user(tmp, &(termio)->c_oflag); \
  94. (termios)->c_oflag = (0xffff0000 & ((termios)->c_oflag)) | tmp; \
  95. get_user(tmp, &(termio)->c_cflag); \
  96. (termios)->c_cflag = (0xffff0000 & ((termios)->c_cflag)) | tmp; \
  97. get_user(tmp, &(termio)->c_lflag); \
  98. (termios)->c_lflag = (0xffff0000 & ((termios)->c_lflag)) | tmp; \
  99. copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \
  100. 0; \
  101. })
  102. /*
  103. * Translate a "termios" structure into a "termio". Ugh.
  104. *
  105. * Note the "fun" _VMIN overloading.
  106. */
  107. #define kernel_termios_to_user_termio(termio, termios) \
  108. ({ \
  109. put_user((termios)->c_iflag, &(termio)->c_iflag); \
  110. put_user((termios)->c_oflag, &(termio)->c_oflag); \
  111. put_user((termios)->c_cflag, &(termio)->c_cflag); \
  112. put_user((termios)->c_lflag, &(termio)->c_lflag); \
  113. put_user((termios)->c_line, &(termio)->c_line); \
  114. copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \
  115. if (!((termios)->c_lflag & ICANON)) { \
  116. put_user((termios)->c_cc[VMIN], &(termio)->c_cc[_VMIN]); \
  117. put_user((termios)->c_cc[VTIME], &(termio)->c_cc[_VTIME]); \
  118. } \
  119. 0; \
  120. })
  121. #define user_termios_to_kernel_termios(k, u) \
  122. ({ \
  123. get_user((k)->c_iflag, &(u)->c_iflag); \
  124. get_user((k)->c_oflag, &(u)->c_oflag); \
  125. get_user((k)->c_cflag, &(u)->c_cflag); \
  126. get_user((k)->c_lflag, &(u)->c_lflag); \
  127. get_user((k)->c_line, &(u)->c_line); \
  128. copy_from_user((k)->c_cc, (u)->c_cc, NCCS); \
  129. if((k)->c_lflag & ICANON) { \
  130. get_user((k)->c_cc[VEOF], &(u)->c_cc[VEOF]); \
  131. get_user((k)->c_cc[VEOL], &(u)->c_cc[VEOL]); \
  132. } else { \
  133. get_user((k)->c_cc[VMIN], &(u)->c_cc[_VMIN]); \
  134. get_user((k)->c_cc[VTIME], &(u)->c_cc[_VTIME]); \
  135. } \
  136. 0; \
  137. })
  138. #define kernel_termios_to_user_termios(u, k) \
  139. ({ \
  140. put_user((k)->c_iflag, &(u)->c_iflag); \
  141. put_user((k)->c_oflag, &(u)->c_oflag); \
  142. put_user((k)->c_cflag, &(u)->c_cflag); \
  143. put_user((k)->c_lflag, &(u)->c_lflag); \
  144. put_user((k)->c_line, &(u)->c_line); \
  145. copy_to_user((u)->c_cc, (k)->c_cc, NCCS); \
  146. if(!((k)->c_lflag & ICANON)) { \
  147. put_user((k)->c_cc[VMIN], &(u)->c_cc[_VMIN]); \
  148. put_user((k)->c_cc[VTIME], &(u)->c_cc[_VTIME]); \
  149. } else { \
  150. put_user((k)->c_cc[VEOF], &(u)->c_cc[VEOF]); \
  151. put_user((k)->c_cc[VEOL], &(u)->c_cc[VEOL]); \
  152. } \
  153. 0; \
  154. })
  155. #endif /* __KERNEL__ */
  156. #endif /* _SPARC_TERMIOS_H */