termios.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #ifndef _ASM_POWERPC_TERMIOS_H
  2. #define _ASM_POWERPC_TERMIOS_H
  3. /*
  4. * Liberally adapted from alpha/termios.h. In particular, the c_cc[]
  5. * fields have been reordered so that termio & termios share the
  6. * common subset in the same order (for brain dead programs that don't
  7. * know or care about the differences).
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version
  12. * 2 of the License, or (at your option) any later version.
  13. */
  14. #include <asm/ioctls.h>
  15. #include <asm/termbits.h>
  16. struct sgttyb {
  17. char sg_ispeed;
  18. char sg_ospeed;
  19. char sg_erase;
  20. char sg_kill;
  21. short sg_flags;
  22. };
  23. struct tchars {
  24. char t_intrc;
  25. char t_quitc;
  26. char t_startc;
  27. char t_stopc;
  28. char t_eofc;
  29. char t_brkc;
  30. };
  31. struct ltchars {
  32. char t_suspc;
  33. char t_dsuspc;
  34. char t_rprntc;
  35. char t_flushc;
  36. char t_werasc;
  37. char t_lnextc;
  38. };
  39. struct winsize {
  40. unsigned short ws_row;
  41. unsigned short ws_col;
  42. unsigned short ws_xpixel;
  43. unsigned short ws_ypixel;
  44. };
  45. #define NCC 10
  46. struct termio {
  47. unsigned short c_iflag; /* input mode flags */
  48. unsigned short c_oflag; /* output mode flags */
  49. unsigned short c_cflag; /* control mode flags */
  50. unsigned short c_lflag; /* local mode flags */
  51. unsigned char c_line; /* line discipline */
  52. unsigned char c_cc[NCC]; /* control characters */
  53. };
  54. /* c_cc characters */
  55. #define _VINTR 0
  56. #define _VQUIT 1
  57. #define _VERASE 2
  58. #define _VKILL 3
  59. #define _VEOF 4
  60. #define _VMIN 5
  61. #define _VEOL 6
  62. #define _VTIME 7
  63. #define _VEOL2 8
  64. #define _VSWTC 9
  65. /* line disciplines */
  66. #define N_TTY 0
  67. #define N_SLIP 1
  68. #define N_MOUSE 2
  69. #define N_PPP 3
  70. #define N_STRIP 4
  71. #define N_AX25 5
  72. #define N_X25 6 /* X.25 async */
  73. #define N_6PACK 7
  74. #define N_MASC 8 /* Reserved for Mobitex module <kaz@cafe.net> */
  75. #define N_R3964 9 /* Reserved for Simatic R3964 module */
  76. #define N_PROFIBUS_FDL 10 /* Reserved for Profibus <Dave@mvhi.com> */
  77. #define N_IRDA 11 /* Linux IrDa - http://www.cs.uit.no/~dagb/irda/irda.html */
  78. #define N_SMSBLOCK 12 /* SMS block mode - for talking to GSM data cards about SMS messages */
  79. #define N_HDLC 13 /* synchronous HDLC */
  80. #define N_SYNC_PPP 14
  81. #define N_HCI 15 /* Bluetooth HCI UART */
  82. #ifdef __KERNEL__
  83. /* ^C ^\ del ^U ^D 1 0 0 0 0 ^W ^R ^Z ^Q ^S ^V ^U */
  84. #define INIT_C_CC "\003\034\177\025\004\001\000\000\000\000\027\022\032\021\023\026\025"
  85. #endif
  86. #ifdef __KERNEL__
  87. /*
  88. * Translate a "termio" structure into a "termios". Ugh.
  89. */
  90. #define SET_LOW_TERMIOS_BITS(termios, termio, x) { \
  91. unsigned short __tmp; \
  92. get_user(__tmp,&(termio)->x); \
  93. (termios)->x = (0xffff0000 & (termios)->x) | __tmp; \
  94. }
  95. #define user_termio_to_kernel_termios(termios, termio) \
  96. ({ \
  97. SET_LOW_TERMIOS_BITS(termios, termio, c_iflag); \
  98. SET_LOW_TERMIOS_BITS(termios, termio, c_oflag); \
  99. SET_LOW_TERMIOS_BITS(termios, termio, c_cflag); \
  100. SET_LOW_TERMIOS_BITS(termios, termio, c_lflag); \
  101. copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \
  102. })
  103. /*
  104. * Translate a "termios" structure into a "termio". Ugh.
  105. */
  106. #define kernel_termios_to_user_termio(termio, termios) \
  107. ({ \
  108. put_user((termios)->c_iflag, &(termio)->c_iflag); \
  109. put_user((termios)->c_oflag, &(termio)->c_oflag); \
  110. put_user((termios)->c_cflag, &(termio)->c_cflag); \
  111. put_user((termios)->c_lflag, &(termio)->c_lflag); \
  112. put_user((termios)->c_line, &(termio)->c_line); \
  113. copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \
  114. })
  115. #define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios))
  116. #define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios))
  117. #endif /* __KERNEL__ */
  118. #endif /* _ASM_POWERPC_TERMIOS_H */