tty_config.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * Copyright (c) 2006-2023, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2023-11-13 Shell init ver.
  9. */
  10. #ifndef __TTY_CONFIG_H__
  11. #define __TTY_CONFIG_H__
  12. /* default buffer size of tty siginfo */
  13. #define LWP_TTY_PRBUF_SIZE 256
  14. /*
  15. * System wide defaults for terminal state.
  16. */
  17. /*-
  18. * SPDX-License-Identifier: BSD-3-Clause
  19. *
  20. * Copyright (c) 1982, 1986, 1993
  21. * The Regents of the University of California. All rights reserved.
  22. * (c) UNIX System Laboratories, Inc.
  23. * All or some portions of this file are derived from material licensed
  24. * to the University of California by American Telephone and Telegraph
  25. * Co. or Unix System Laboratories, Inc. and are reproduced herein with
  26. * the permission of UNIX System Laboratories, Inc.
  27. *
  28. * Redistribution and use in source and binary forms, with or without
  29. * modification, are permitted provided that the following conditions
  30. * are met:
  31. * 1. Redistributions of source code must retain the above copyright
  32. * notice, this list of conditions and the following disclaimer.
  33. * 2. Redistributions in binary form must reproduce the above copyright
  34. * notice, this list of conditions and the following disclaimer in the
  35. * documentation and/or other materials provided with the distribution.
  36. * 3. Neither the name of the University nor the names of its contributors
  37. * may be used to endorse or promote products derived from this software
  38. * without specific prior written permission.
  39. *
  40. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  41. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  42. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  43. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  44. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  45. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  46. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  47. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  48. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  49. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  50. * SUCH DAMAGE.
  51. *
  52. * @(#)ttydefaults.h 8.4 (Berkeley) 1/21/94
  53. */
  54. /*
  55. * Defaults on "first" open.
  56. */
  57. #define TTYDEF_IFLAG (BRKINT | ICRNL | IMAXBEL | IXON | IXANY | IUTF8)
  58. #define TTYDEF_OFLAG (OPOST | ONLCR)
  59. #define TTYDEF_LFLAG_NOECHO (ICANON | ISIG | IEXTEN)
  60. #define TTYDEF_LFLAG_ECHO \
  61. (TTYDEF_LFLAG_NOECHO | ECHO | ECHOE | ECHOKE | ECHOCTL)
  62. #define TTYDEF_LFLAG TTYDEF_LFLAG_ECHO
  63. #define TTYDEF_CFLAG (CREAD | CS8 | HUPCL)
  64. #define TTYDEF_SPEED (B9600)
  65. /*
  66. * Control Character Defaults
  67. */
  68. /*
  69. * XXX: A lot of code uses lowercase characters, but control-character
  70. * conversion is actually only valid when applied to uppercase
  71. * characters. We just treat lowercase characters as if they were
  72. * inserted as uppercase.
  73. */
  74. #define _CONTROL(c) \
  75. ((c) >= 'a' && (c) <= 'z' ? ((c) - 'a' + 1) : (((c) - 'A' + 1) & 0x7f))
  76. #define CEOF _CONTROL('D')
  77. #define CEOL 0xff /* XXX avoid _POSIX_VDISABLE */
  78. #define CERASE 0x7f
  79. #define CERASE2 _CONTROL('H')
  80. #define CINTR _CONTROL('C')
  81. #define CSTATUS _CONTROL('T')
  82. #define CKILL _CONTROL('U')
  83. #define CMIN 1
  84. #define CQUIT _CONTROL('\\')
  85. #define CSUSP _CONTROL('Z')
  86. #define CTIME 0
  87. #define CDSUSP _CONTROL('Y')
  88. #define CSTART _CONTROL('Q')
  89. #define CSTOP _CONTROL('S')
  90. #define CLNEXT _CONTROL('V')
  91. #define CDISCARD _CONTROL('O')
  92. #define CWERASE _CONTROL('W')
  93. #define CREPRINT _CONTROL('R')
  94. #define CEOT CEOF
  95. /* compat */
  96. #define CBRK CEOL
  97. #define CRPRNT CREPRINT
  98. #define CFLUSH CDISCARD
  99. /* PROTECTED INCLUSION ENDS HERE */
  100. #endif /* !__TTY_CONFIG_H__ */
  101. /*
  102. * #define TTY_CONF_INCLUDE_CCHARS to include an array of default control
  103. * characters.
  104. */
  105. #ifdef TTY_CONF_INCLUDE_CCHARS
  106. #include <rtdef.h>
  107. #include <termios.h>
  108. #include <unistd.h>
  109. static const cc_t tty_ctrl_charset[NCCS] = {
  110. [VINTR] = CINTR,
  111. [VQUIT] = CQUIT,
  112. [VERASE] = CERASE,
  113. [VKILL] = CKILL,
  114. [VEOF] = CEOF,
  115. [VSTART] = CSTART,
  116. [VSTOP] = CSTOP,
  117. [VSUSP] = CSUSP,
  118. [VREPRINT] = CREPRINT,
  119. [VDISCARD] = CDISCARD,
  120. [VWERASE] = CWERASE,
  121. [VLNEXT] = CLNEXT,
  122. [VMIN] = CMIN
  123. #undef _CONTROL
  124. };
  125. #undef TTY_CONF_INCLUDE_CCHARS
  126. #endif /* __TTY_CONFIG_H__ */