termios.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #ifndef _UAPI_ASM_TERMIOS_H
  2. #define _UAPI_ASM_TERMIOS_H
  3. #include <asm/termbits.h>
  4. #include <asm/ioctls.h>
  5. struct winsize {
  6. unsigned short ws_row;
  7. unsigned short ws_col;
  8. unsigned short ws_xpixel;
  9. unsigned short ws_ypixel;
  10. };
  11. #define NCC 8
  12. struct termio {
  13. unsigned short c_iflag; /* input mode flags */
  14. unsigned short c_oflag; /* output mode flags */
  15. unsigned short c_cflag; /* control mode flags */
  16. unsigned short c_lflag; /* local mode flags */
  17. unsigned char c_line; /* line discipline */
  18. unsigned char c_cc[NCC]; /* control characters */
  19. };
  20. /* modem lines */
  21. #define TIOCM_LE 0x001
  22. #define TIOCM_DTR 0x002
  23. #define TIOCM_RTS 0x004
  24. #define TIOCM_ST 0x008
  25. #define TIOCM_SR 0x010
  26. #define TIOCM_CTS 0x020
  27. #define TIOCM_CAR 0x040
  28. #define TIOCM_RNG 0x080
  29. #define TIOCM_DSR 0x100
  30. #define TIOCM_CD TIOCM_CAR
  31. #define TIOCM_RI TIOCM_RNG
  32. #define TIOCM_OUT1 0x2000
  33. #define TIOCM_OUT2 0x4000
  34. #define TIOCM_LOOP 0x8000
  35. #define TIOCM_MODEM_BITS TIOCM_OUT2 /* IRDA support */
  36. /*
  37. * Translate a "termio" structure into a "termios". Ugh.
  38. */
  39. #define SET_LOW_TERMIOS_BITS(termios, termio, x) { \
  40. unsigned short __tmp; \
  41. get_user(__tmp, &(termio)->x); \
  42. *(unsigned short *) &(termios)->x = __tmp; \
  43. }
  44. #define user_termio_to_kernel_termios(termios, termio) \
  45. ({ \
  46. SET_LOW_TERMIOS_BITS(termios, termio, c_iflag); \
  47. SET_LOW_TERMIOS_BITS(termios, termio, c_oflag); \
  48. SET_LOW_TERMIOS_BITS(termios, termio, c_cflag); \
  49. SET_LOW_TERMIOS_BITS(termios, termio, c_lflag); \
  50. copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \
  51. })
  52. /*
  53. * Translate a "termios" structure into a "termio". Ugh.
  54. */
  55. #define kernel_termios_to_user_termio(termio, termios) \
  56. ({ \
  57. put_user((termios)->c_iflag, &(termio)->c_iflag); \
  58. put_user((termios)->c_oflag, &(termio)->c_oflag); \
  59. put_user((termios)->c_cflag, &(termio)->c_cflag); \
  60. put_user((termios)->c_lflag, &(termio)->c_lflag); \
  61. put_user((termios)->c_line, &(termio)->c_line); \
  62. copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \
  63. })
  64. #define user_termios_to_kernel_termios(k, u) \
  65. copy_from_user(k, u, sizeof(struct termios2))
  66. #define kernel_termios_to_user_termios(u, k) \
  67. copy_to_user(u, k, sizeof(struct termios2))
  68. #define user_termios_to_kernel_termios_1(k, u) \
  69. copy_from_user(k, u, sizeof(struct termios))
  70. #define kernel_termios_to_user_termios_1(u, k) \
  71. copy_to_user(u, k, sizeof(struct termios))
  72. #endif /* _UAPI_ASM_TERMIOS_H */