termios.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * include/asm-xtensa/termios.h
  3. *
  4. * Copied from SH.
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. *
  10. * Copyright (C) 2001 - 2005 Tensilica Inc.
  11. */
  12. #ifndef _XTENSA_TERMIOS_H
  13. #define _XTENSA_TERMIOS_H
  14. #include <uapi/asm/termios.h>
  15. /* intr=^C quit=^\ erase=del kill=^U
  16. eof=^D vtime=\0 vmin=\1 sxtc=\0
  17. start=^Q stop=^S susp=^Z eol=\0
  18. reprint=^R discard=^U werase=^W lnext=^V
  19. eol2=\0
  20. */
  21. #define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"
  22. /*
  23. * Translate a "termio" structure into a "termios". Ugh.
  24. */
  25. #define SET_LOW_TERMIOS_BITS(termios, termio, x) { \
  26. unsigned short __tmp; \
  27. get_user(__tmp,&(termio)->x); \
  28. *(unsigned short *) &(termios)->x = __tmp; \
  29. }
  30. #define user_termio_to_kernel_termios(termios, termio) \
  31. ({ \
  32. SET_LOW_TERMIOS_BITS(termios, termio, c_iflag); \
  33. SET_LOW_TERMIOS_BITS(termios, termio, c_oflag); \
  34. SET_LOW_TERMIOS_BITS(termios, termio, c_cflag); \
  35. SET_LOW_TERMIOS_BITS(termios, termio, c_lflag); \
  36. copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \
  37. })
  38. /*
  39. * Translate a "termios" structure into a "termio". Ugh.
  40. */
  41. #define kernel_termios_to_user_termio(termio, termios) \
  42. ({ \
  43. put_user((termios)->c_iflag, &(termio)->c_iflag); \
  44. put_user((termios)->c_oflag, &(termio)->c_oflag); \
  45. put_user((termios)->c_cflag, &(termio)->c_cflag); \
  46. put_user((termios)->c_lflag, &(termio)->c_lflag); \
  47. put_user((termios)->c_line, &(termio)->c_line); \
  48. copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \
  49. })
  50. #define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios2))
  51. #define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios2))
  52. #define user_termios_to_kernel_termios_1(k, u) copy_from_user(k, u, sizeof(struct termios))
  53. #define kernel_termios_to_user_termios_1(u, k) copy_to_user(u, k, sizeof(struct termios))
  54. #endif /* _XTENSA_TERMIOS_H */