termios.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. #pragma once
  2. #ifndef _KERNEL_
  3. #include <sys/types.h>
  4. #else
  5. #include <kernel/types.h>
  6. #endif
  7. /* Technically part of ioctl */
  8. struct winsize {
  9. unsigned short ws_row;
  10. unsigned short ws_col;
  11. unsigned short ws_xpixel;
  12. unsigned short ws_ypixel;
  13. };
  14. typedef unsigned int tcflag_t;
  15. typedef unsigned int speed_t;
  16. typedef unsigned char cc_t;
  17. /* reserving 0 for particular reason */
  18. #define VEOF 1 /* ^D (end of file) */
  19. #define VEOL 2 /* NULL (end of line) */
  20. #define VERASE 3 /* ^H (backspace/del) */
  21. #define VINTR 4 /* ^C (interrupt) */
  22. #define VKILL 5 /* ^U (erase input buffer) */
  23. #define VMIN 6 /* minimum number of characters for non-canonical read */
  24. #define VQUIT 7 /* ^\ send SIGQUIT */
  25. #define VSTART 8 /* ^Q restart STOPped input */
  26. #define VSTOP 9 /* ^S stop input */
  27. #define VSUSP 10 /* ^Z suspend foreground applicatioan (send SIGTSTP) */
  28. #define VTIME 11 /* Timeout for non-canonical read, deciseconds */
  29. /* flags for input modes */
  30. #define BRKINT 0000001
  31. #define ICRNL 0000002
  32. #define IGNBRK 0000004
  33. #define IGNCR 0000010
  34. #define IGNPAR 0000020
  35. #define INLCR 0000040
  36. #define INPCK 0000100
  37. #define ISTRIP 0000200
  38. #define IUCLC 0000400
  39. #define IXANY 0001000
  40. #define IXOFF 0002000
  41. #define IXON 0004000
  42. #define PARMRK 0010000
  43. /* flags for output modes */
  44. #define OPOST 0000001
  45. #define OLCUC 0000002
  46. #define ONLCR 0000004
  47. #define OCRNL 0000010
  48. #define ONOCR 0000020
  49. #define ONLRET 0000040
  50. #define OFILL 0000100
  51. #define OFDEL 0000200
  52. #define NLDLY 0000400
  53. #define NL0 0000000
  54. #define NL1 0000400
  55. #define CRDLY 0003000
  56. #define CR0 0000000
  57. #define CR1 0001000
  58. #define CR2 0002000
  59. #define CR3 0003000
  60. #define TABDLY 0014000
  61. #define TAB0 0000000
  62. #define TAB1 0004000
  63. #define TAB2 0010000
  64. #define TAB3 0014000
  65. #define BSDLY 0020000
  66. #define BS0 0000000
  67. #define BS1 0020000
  68. #define FFDLY 0100000
  69. #define FF0 0000000
  70. #define FF1 0100000
  71. #define VTDLY 0040000
  72. #define VT0 0000000
  73. #define VT1 0040000
  74. /* baud rates */
  75. #define B0 0000000
  76. #define B50 0000001
  77. #define B75 0000002
  78. #define B110 0000003
  79. #define B134 0000004
  80. #define B150 0000005
  81. #define B200 0000006
  82. #define B300 0000007
  83. #define B600 0000010
  84. #define B1200 0000011
  85. #define B1800 0000012
  86. #define B2400 0000013
  87. #define B4800 0000014
  88. #define B9600 0000015
  89. #define B19200 0000016
  90. #define B38400 0000017
  91. /* control modes */
  92. #define CSIZE 0000060
  93. #define CS5 0000000
  94. #define CS6 0000020
  95. #define CS7 0000040
  96. #define CS8 0000060
  97. #define CSTOPB 0000100
  98. #define CREAD 0000200
  99. #define PARENB 0000400
  100. #define PARODD 0001000
  101. #define HUPCL 0002000
  102. #define CLOCAL 0004000
  103. /* local modes */
  104. #define ISIG 0000001
  105. #define ICANON 0000002
  106. #define XCASE 0000004
  107. #define ECHO 0000010
  108. #define ECHOE 0000020
  109. #define ECHOK 0000040
  110. #define ECHONL 0000100
  111. #define NOFLSH 0000200
  112. #define TOSTOP 0000400
  113. #define IEXTEN 0001000
  114. /* attributes */
  115. #define TCSANOW 0x0001
  116. #define TCSADRAIN 0x0002
  117. #define TCSAFLUSH 0x0004
  118. #define TCIFLUSH 0x0001
  119. #define TCIOFLUSH 0x0003
  120. #define TCOFLUSH 0x0002
  121. #define TCIOFF 0x0001
  122. #define TCION 0x0002
  123. #define TCOOFF 0x0004
  124. #define TCOON 0x0008
  125. #define NCCS 32
  126. struct termios {
  127. tcflag_t c_iflag;
  128. tcflag_t c_oflag;
  129. tcflag_t c_cflag;
  130. tcflag_t c_lflag;
  131. cc_t c_cc[NCCS];
  132. };
  133. /* ioctl commands */
  134. #define TCGETS 0x4000 /* Get termios struct */
  135. #define TCSETS 0x4001 /* Set termios struct */
  136. #define TCSETSW 0x4002 /* Set, but let drain first */
  137. #define TCSETSF 0x4003 /* Set, but let flush first */
  138. #define TCGETA TCGETS
  139. #define TCSETA TCSETS
  140. #define TCGETAW TCGETSW
  141. #define TCGETAF TCGETSF
  142. #define TCSBRK 0x4004
  143. #define TCXONC 0x4005
  144. #define TCFLSH 0x4006
  145. #define TIOCEXCL 0x4007
  146. #define TIOCNXCL 0x4008
  147. #define TIOCSCTTY 0x4009
  148. #define TIOCGPGRP 0x400A
  149. #define TIOCSPGRP 0x400B
  150. #define TIOCOUTQ 0x400C
  151. #define TIOCSTI 0x400D
  152. #define TIOCGWINSZ 0x400E
  153. #define TIOCSWINSZ 0x400F
  154. #define TIOCMGET 0x4010
  155. #define TIOCMBIS 0x4011
  156. #define TIOCMBIC 0x4012
  157. #define TIOCMSET 0x4013
  158. #define TIOCGSOFTCAR 0x4014
  159. #define TIOCSSOFTCAR 0x4015
  160. /* termios functions */
  161. #ifndef _KERNEL_
  162. speed_t cfgetispeed(const struct termios *);
  163. speed_t cfgetospeed(const struct termios *);
  164. int cfsetispeed(struct termios *, speed_t);
  165. int cfsetospeed(struct termios *, speed_t);
  166. int tcdrain(int);
  167. int tcflow(int, int);
  168. int tcflush(int, int);
  169. int tcgetattr(int, struct termios *);
  170. pid_t tcgetsid(int);
  171. int tcsendbreak(int, int);
  172. int tcsetattr(int, int, struct termios *);
  173. int ioctl(int, int, void*);
  174. #endif /* ndef _KERNEL_ */