termios.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. #ifdef __KERNEL__
  42. #include <linux/module.h>
  43. /*
  44. * c_cc characters in the termio structure. Oh, how I love being
  45. * backwardly compatible. Notice that character 4 and 5 are
  46. * interpreted differently depending on whether ICANON is set in
  47. * c_lflag. If it's set, they are used as _VEOF and _VEOL, otherwise
  48. * as _VMIN and V_TIME. This is for compatibility with OSF/1 (which
  49. * is compatible with sysV)...
  50. */
  51. #define _VMIN 4
  52. #define _VTIME 5
  53. /* intr=^C quit=^\ erase=del kill=^U
  54. eof=^D eol=\0 eol2=\0 sxtc=\0
  55. start=^Q stop=^S susp=^Z dsusp=^Y
  56. reprint=^R discard=^U werase=^W lnext=^V
  57. vmin=\1 vtime=\0
  58. */
  59. #define INIT_C_CC "\003\034\177\025\004\000\000\000\021\023\032\031\022\025\027\026\001"
  60. /*
  61. * Translate a "termio" structure into a "termios". Ugh.
  62. */
  63. #define user_termio_to_kernel_termios(termios, termio) \
  64. ({ \
  65. unsigned short tmp; \
  66. get_user(tmp, &(termio)->c_iflag); \
  67. (termios)->c_iflag = (0xffff0000 & ((termios)->c_iflag)) | tmp; \
  68. get_user(tmp, &(termio)->c_oflag); \
  69. (termios)->c_oflag = (0xffff0000 & ((termios)->c_oflag)) | tmp; \
  70. get_user(tmp, &(termio)->c_cflag); \
  71. (termios)->c_cflag = (0xffff0000 & ((termios)->c_cflag)) | tmp; \
  72. get_user(tmp, &(termio)->c_lflag); \
  73. (termios)->c_lflag = (0xffff0000 & ((termios)->c_lflag)) | tmp; \
  74. copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \
  75. 0; \
  76. })
  77. /*
  78. * Translate a "termios" structure into a "termio". Ugh.
  79. *
  80. * Note the "fun" _VMIN overloading.
  81. */
  82. #define kernel_termios_to_user_termio(termio, termios) \
  83. ({ \
  84. put_user((termios)->c_iflag, &(termio)->c_iflag); \
  85. put_user((termios)->c_oflag, &(termio)->c_oflag); \
  86. put_user((termios)->c_cflag, &(termio)->c_cflag); \
  87. put_user((termios)->c_lflag, &(termio)->c_lflag); \
  88. put_user((termios)->c_line, &(termio)->c_line); \
  89. copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \
  90. if (!((termios)->c_lflag & ICANON)) { \
  91. put_user((termios)->c_cc[VMIN], &(termio)->c_cc[_VMIN]); \
  92. put_user((termios)->c_cc[VTIME], &(termio)->c_cc[_VTIME]); \
  93. } \
  94. 0; \
  95. })
  96. #define user_termios_to_kernel_termios(k, u) \
  97. ({ \
  98. get_user((k)->c_iflag, &(u)->c_iflag); \
  99. get_user((k)->c_oflag, &(u)->c_oflag); \
  100. get_user((k)->c_cflag, &(u)->c_cflag); \
  101. get_user((k)->c_lflag, &(u)->c_lflag); \
  102. get_user((k)->c_line, &(u)->c_line); \
  103. copy_from_user((k)->c_cc, (u)->c_cc, NCCS); \
  104. if((k)->c_lflag & ICANON) { \
  105. get_user((k)->c_cc[VEOF], &(u)->c_cc[VEOF]); \
  106. get_user((k)->c_cc[VEOL], &(u)->c_cc[VEOL]); \
  107. } else { \
  108. get_user((k)->c_cc[VMIN], &(u)->c_cc[_VMIN]); \
  109. get_user((k)->c_cc[VTIME], &(u)->c_cc[_VTIME]); \
  110. } \
  111. 0; \
  112. })
  113. #define kernel_termios_to_user_termios(u, k) \
  114. ({ \
  115. put_user((k)->c_iflag, &(u)->c_iflag); \
  116. put_user((k)->c_oflag, &(u)->c_oflag); \
  117. put_user((k)->c_cflag, &(u)->c_cflag); \
  118. put_user((k)->c_lflag, &(u)->c_lflag); \
  119. put_user((k)->c_line, &(u)->c_line); \
  120. copy_to_user((u)->c_cc, (k)->c_cc, NCCS); \
  121. if(!((k)->c_lflag & ICANON)) { \
  122. put_user((k)->c_cc[VMIN], &(u)->c_cc[_VMIN]); \
  123. put_user((k)->c_cc[VTIME], &(u)->c_cc[_VTIME]); \
  124. } else { \
  125. put_user((k)->c_cc[VEOF], &(u)->c_cc[VEOF]); \
  126. put_user((k)->c_cc[VEOL], &(u)->c_cc[VEOL]); \
  127. } \
  128. 0; \
  129. })
  130. #endif /* __KERNEL__ */
  131. #endif /* _SPARC_TERMIOS_H */