termios.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. struct winsize {
  36. unsigned short ws_row;
  37. unsigned short ws_col;
  38. unsigned short ws_xpixel;
  39. unsigned short ws_ypixel;
  40. };
  41. /* line disciplines */
  42. #define N_TTY 0
  43. #define N_SLIP 1
  44. #define N_MOUSE 2
  45. #define N_PPP 3
  46. #define N_STRIP 4
  47. #define N_AX25 5
  48. #define N_X25 6
  49. #define N_6PACK 7
  50. #define N_MASC 8 /* Reserved for Mobitex module <kaz@cafe.net> */
  51. #define N_R3964 9 /* Reserved for Simatic R3964 module */
  52. #define N_PROFIBUS_FDL 10 /* Reserved for Profibus <Dave@mvhi.com> */
  53. #define N_IRDA 11 /* Linux IrDa - http://irda.sourceforge.net/ */
  54. #define N_SMSBLOCK 12 /* SMS block mode - for talking to GSM data cards about SMS messages */
  55. #define N_HDLC 13 /* synchronous HDLC */
  56. #define N_SYNC_PPP 14 /* synchronous PPP */
  57. #define N_HCI 15 /* Bluetooth HCI UART */
  58. #ifdef __KERNEL__
  59. #include <linux/module.h>
  60. /*
  61. * c_cc characters in the termio structure. Oh, how I love being
  62. * backwardly compatible. Notice that character 4 and 5 are
  63. * interpreted differently depending on whether ICANON is set in
  64. * c_lflag. If it's set, they are used as _VEOF and _VEOL, otherwise
  65. * as _VMIN and V_TIME. This is for compatibility with OSF/1 (which
  66. * is compatible with sysV)...
  67. */
  68. #define _VMIN 4
  69. #define _VTIME 5
  70. /* intr=^C quit=^\ erase=del kill=^U
  71. eof=^D eol=\0 eol2=\0 sxtc=\0
  72. start=^Q stop=^S susp=^Z dsusp=^Y
  73. reprint=^R discard=^U werase=^W lnext=^V
  74. vmin=\1 vtime=\0
  75. */
  76. #define INIT_C_CC "\003\034\177\025\004\000\000\000\021\023\032\031\022\025\027\026\001"
  77. /*
  78. * Translate a "termio" structure into a "termios". Ugh.
  79. */
  80. #define user_termio_to_kernel_termios(termios, termio) \
  81. ({ \
  82. unsigned short tmp; \
  83. get_user(tmp, &(termio)->c_iflag); \
  84. (termios)->c_iflag = (0xffff0000 & ((termios)->c_iflag)) | tmp; \
  85. get_user(tmp, &(termio)->c_oflag); \
  86. (termios)->c_oflag = (0xffff0000 & ((termios)->c_oflag)) | tmp; \
  87. get_user(tmp, &(termio)->c_cflag); \
  88. (termios)->c_cflag = (0xffff0000 & ((termios)->c_cflag)) | tmp; \
  89. get_user(tmp, &(termio)->c_lflag); \
  90. (termios)->c_lflag = (0xffff0000 & ((termios)->c_lflag)) | tmp; \
  91. copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \
  92. 0; \
  93. })
  94. /*
  95. * Translate a "termios" structure into a "termio". Ugh.
  96. *
  97. * Note the "fun" _VMIN overloading.
  98. */
  99. #define kernel_termios_to_user_termio(termio, termios) \
  100. ({ \
  101. put_user((termios)->c_iflag, &(termio)->c_iflag); \
  102. put_user((termios)->c_oflag, &(termio)->c_oflag); \
  103. put_user((termios)->c_cflag, &(termio)->c_cflag); \
  104. put_user((termios)->c_lflag, &(termio)->c_lflag); \
  105. put_user((termios)->c_line, &(termio)->c_line); \
  106. copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \
  107. if (!((termios)->c_lflag & ICANON)) { \
  108. put_user((termios)->c_cc[VMIN], &(termio)->c_cc[_VMIN]); \
  109. put_user((termios)->c_cc[VTIME], &(termio)->c_cc[_VTIME]); \
  110. } \
  111. 0; \
  112. })
  113. #define user_termios_to_kernel_termios(k, u) \
  114. ({ \
  115. get_user((k)->c_iflag, &(u)->c_iflag); \
  116. get_user((k)->c_oflag, &(u)->c_oflag); \
  117. get_user((k)->c_cflag, &(u)->c_cflag); \
  118. get_user((k)->c_lflag, &(u)->c_lflag); \
  119. get_user((k)->c_line, &(u)->c_line); \
  120. copy_from_user((k)->c_cc, (u)->c_cc, NCCS); \
  121. if((k)->c_lflag & ICANON) { \
  122. get_user((k)->c_cc[VEOF], &(u)->c_cc[VEOF]); \
  123. get_user((k)->c_cc[VEOL], &(u)->c_cc[VEOL]); \
  124. } else { \
  125. get_user((k)->c_cc[VMIN], &(u)->c_cc[_VMIN]); \
  126. get_user((k)->c_cc[VTIME], &(u)->c_cc[_VTIME]); \
  127. } \
  128. 0; \
  129. })
  130. #define kernel_termios_to_user_termios(u, k) \
  131. ({ \
  132. put_user((k)->c_iflag, &(u)->c_iflag); \
  133. put_user((k)->c_oflag, &(u)->c_oflag); \
  134. put_user((k)->c_cflag, &(u)->c_cflag); \
  135. put_user((k)->c_lflag, &(u)->c_lflag); \
  136. put_user((k)->c_line, &(u)->c_line); \
  137. copy_to_user((u)->c_cc, (k)->c_cc, NCCS); \
  138. if(!((k)->c_lflag & ICANON)) { \
  139. put_user((k)->c_cc[VMIN], &(u)->c_cc[_VMIN]); \
  140. put_user((k)->c_cc[VTIME], &(u)->c_cc[_VTIME]); \
  141. } else { \
  142. put_user((k)->c_cc[VEOF], &(u)->c_cc[VEOF]); \
  143. put_user((k)->c_cc[VEOL], &(u)->c_cc[VEOL]); \
  144. } \
  145. 0; \
  146. })
  147. #endif /* __KERNEL__ */
  148. #endif /* _SPARC_TERMIOS_H */