termios.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. /*
  2. * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <Kernel/API/POSIX/sys/types.h>
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. #define NCCS 32
  12. typedef uint32_t tcflag_t;
  13. typedef uint8_t cc_t;
  14. typedef uint32_t speed_t;
  15. struct termios {
  16. tcflag_t c_iflag;
  17. tcflag_t c_oflag;
  18. tcflag_t c_cflag;
  19. tcflag_t c_lflag;
  20. cc_t c_cc[NCCS];
  21. speed_t c_ispeed;
  22. speed_t c_ospeed;
  23. };
  24. /* c_cc characters */
  25. #define VINTR 0
  26. #define VQUIT 1
  27. #define VERASE 2
  28. #define VKILL 3
  29. #define VEOF 4
  30. #define VTIME 5
  31. #define VMIN 6
  32. #define VSWTC 7
  33. #define VSTART 8
  34. #define VSTOP 9
  35. #define VSUSP 10
  36. #define VEOL 11
  37. #define VREPRINT 12
  38. #define VDISCARD 13
  39. #define VWERASE 14
  40. #define VLNEXT 15
  41. #define VEOL2 16
  42. #define VINFO 17
  43. /* c_iflag bits */
  44. #define IGNBRK 0000001
  45. #define BRKINT 0000002
  46. #define IGNPAR 0000004
  47. #define PARMRK 0000010
  48. #define INPCK 0000020
  49. #define ISTRIP 0000040
  50. #define INLCR 0000100
  51. #define IGNCR 0000200
  52. #define ICRNL 0000400
  53. #define IUCLC 0001000
  54. #define IXON 0002000
  55. #define IXANY 0004000
  56. #define IXOFF 0010000
  57. #define IMAXBEL 0020000
  58. #define IUTF8 0040000
  59. /* c_oflag bits */
  60. #define OPOST 0000001
  61. #define OLCUC 0000002
  62. #define ONLCR 0000004
  63. #define OCRNL 0000010
  64. #define ONOCR 0000020
  65. #define ONLRET 0000040
  66. #define OFILL 0000100
  67. #define OFDEL 0000200
  68. #if defined __USE_MISC || defined __USE_XOPEN
  69. # define NLDLY 0000400
  70. # define NL0 0000000
  71. # define NL1 0000400
  72. # define CRDLY 0003000
  73. # define CR0 0000000
  74. # define CR1 0001000
  75. # define CR2 0002000
  76. # define CR3 0003000
  77. # define TABDLY 0014000
  78. # define TAB0 0000000
  79. # define TAB1 0004000
  80. # define TAB2 0010000
  81. # define TAB3 0014000
  82. # define BSDLY 0020000
  83. # define BS0 0000000
  84. # define BS1 0020000
  85. # define FFDLY 0100000
  86. # define FF0 0000000
  87. # define FF1 0100000
  88. #endif
  89. #define VTDLY 0040000
  90. #define VT0 0000000
  91. #define VT1 0040000
  92. #ifdef __USE_MISC
  93. # define XTABS 0014000
  94. #endif
  95. /* c_cflag bit meaning */
  96. #ifdef __USE_MISC
  97. # define CBAUD 0010017
  98. #endif
  99. #define B0 0000000 /* hang up */
  100. #define B50 0000001
  101. #define B75 0000002
  102. #define B110 0000003
  103. #define B134 0000004
  104. #define B150 0000005
  105. #define B200 0000006
  106. #define B300 0000007
  107. #define B600 0000010
  108. #define B1200 0000011
  109. #define B1800 0000012
  110. #define B2400 0000013
  111. #define B4800 0000014
  112. #define B9600 0000015
  113. #define B19200 0000016
  114. #define B38400 0000017
  115. #ifdef __USE_MISC
  116. # define EXTA B19200
  117. # define EXTB B38400
  118. #endif
  119. #define CSIZE 0000060
  120. #define CS5 0000000
  121. #define CS6 0000020
  122. #define CS7 0000040
  123. #define CS8 0000060
  124. #define CSTOPB 0000100
  125. #define CREAD 0000200
  126. #define PARENB 0000400
  127. #define PARODD 0001000
  128. #define HUPCL 0002000
  129. #define CLOCAL 0004000
  130. #ifdef __USE_MISC
  131. # define CBAUDEX 0010000
  132. #endif
  133. #define B57600 0010001
  134. #define B115200 0010002
  135. #define B230400 0010003
  136. #define B460800 0010004
  137. #define B500000 0010005
  138. #define B576000 0010006
  139. #define B921600 0010007
  140. #define B1000000 0010010
  141. #define B1152000 0010011
  142. #define B1500000 0010012
  143. #define B2000000 0010013
  144. #define B2500000 0010014
  145. #define B3000000 0010015
  146. #define B3500000 0010016
  147. #define B4000000 0010017
  148. #define __MAX_BAUD B4000000
  149. #ifdef __USE_MISC
  150. # define CIBAUD 002003600000 /* input baud rate (not used) */
  151. # define CMSPAR 010000000000 /* mark or space (stick) parity */
  152. # define CRTSCTS 020000000000 /* flow control */
  153. #endif
  154. /* c_lflag bits */
  155. #define ISIG 0000001
  156. #define ICANON 0000002
  157. #if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
  158. # define XCASE 0000004
  159. #endif
  160. #define ECHO 0000010
  161. #define ECHOE 0000020
  162. #define ECHOK 0000040
  163. #define ECHONL 0000100
  164. #define NOFLSH 0000200
  165. #define TOSTOP 0000400
  166. #ifdef __USE_MISC
  167. # define ECHOCTL 0001000
  168. # define ECHOPRT 0002000
  169. # define ECHOKE 0004000
  170. # define FLUSHO 0010000
  171. # define PENDIN 0040000
  172. #endif
  173. #define IEXTEN 0100000
  174. #ifdef __USE_MISC
  175. # define EXTPROC 0200000
  176. #endif
  177. /* tcflow() and TCXONC use these */
  178. #define TCOOFF 0
  179. #define TCOON 1
  180. #define TCIOFF 2
  181. #define TCION 3
  182. /* tcflush() and TCFLSH use these */
  183. #define TCIFLUSH 0
  184. #define TCOFLUSH 1
  185. #define TCIOFLUSH 2
  186. /* tcsetattr uses these */
  187. #define TCSANOW 0
  188. #define TCSADRAIN 1
  189. #define TCSAFLUSH 2
  190. #ifdef __cplusplus
  191. }
  192. #endif