termios.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _M32R_TERMIOS_H
  3. #define _M32R_TERMIOS_H
  4. #include <linux/module.h>
  5. #include <uapi/asm/termios.h>
  6. /* intr=^C quit=^\ erase=del kill=^U
  7. eof=^D vtime=\0 vmin=\1 sxtc=\0
  8. start=^Q stop=^S susp=^Z eol=\0
  9. reprint=^R discard=^U werase=^W lnext=^V
  10. eol2=\0
  11. */
  12. #define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"
  13. /*
  14. * Translate a "termio" structure into a "termios". Ugh.
  15. */
  16. #define SET_LOW_TERMIOS_BITS(termios, termio, x) { \
  17. unsigned short __tmp; \
  18. get_user(__tmp,&(termio)->x); \
  19. *(unsigned short *) &(termios)->x = __tmp; \
  20. }
  21. #define user_termio_to_kernel_termios(termios, termio) \
  22. ({ \
  23. SET_LOW_TERMIOS_BITS(termios, termio, c_iflag); \
  24. SET_LOW_TERMIOS_BITS(termios, termio, c_oflag); \
  25. SET_LOW_TERMIOS_BITS(termios, termio, c_cflag); \
  26. SET_LOW_TERMIOS_BITS(termios, termio, c_lflag); \
  27. copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \
  28. })
  29. /*
  30. * Translate a "termios" structure into a "termio". Ugh.
  31. */
  32. #define kernel_termios_to_user_termio(termio, termios) \
  33. ({ \
  34. put_user((termios)->c_iflag, &(termio)->c_iflag); \
  35. put_user((termios)->c_oflag, &(termio)->c_oflag); \
  36. put_user((termios)->c_cflag, &(termio)->c_cflag); \
  37. put_user((termios)->c_lflag, &(termio)->c_lflag); \
  38. put_user((termios)->c_line, &(termio)->c_line); \
  39. copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \
  40. })
  41. #define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios2))
  42. #define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios2))
  43. #define user_termios_to_kernel_termios_1(k, u) copy_from_user(k, u, sizeof(struct termios))
  44. #define kernel_termios_to_user_termios_1(u, k) copy_to_user(u, k, sizeof(struct termios))
  45. #endif /* _M32R_TERMIOS_H */