bsd_ttydisc.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. /*-
  11. * SPDX-License-Identifier: BSD-2-Clause
  12. *
  13. * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
  14. * All rights reserved.
  15. *
  16. * Portions of this software were developed under sponsorship from Snow
  17. * B.V., the Netherlands.
  18. *
  19. * Redistribution and use in source and binary forms, with or without
  20. * modification, are permitted provided that the following conditions
  21. * are met:
  22. * 1. Redistributions of source code must retain the above copyright
  23. * notice, this list of conditions and the following disclaimer.
  24. * 2. Redistributions in binary form must reproduce the above copyright
  25. * notice, this list of conditions and the following disclaimer in the
  26. * documentation and/or other materials provided with the distribution.
  27. *
  28. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  29. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  30. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  31. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  32. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  33. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  34. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  35. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  36. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  37. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  38. * SUCH DAMAGE.
  39. */
  40. #ifndef _SYS_TTYDISC_H_
  41. #define _SYS_TTYDISC_H_
  42. #ifndef __LWP_TERMINAL_H__
  43. #error "can only be included through <terminal.h>"
  44. #endif /* !__LWP_TERMINAL_H__ */
  45. #include <rtdef.h>
  46. struct rt_wqueue;
  47. struct rt_thread;
  48. struct lwp_tty;
  49. struct uio;
  50. /* Top half routines. */
  51. void ttydisc_open(struct lwp_tty *tp);
  52. void ttydisc_close(struct lwp_tty *tp);
  53. int ttydisc_read(struct lwp_tty *tp, struct uio *uio, int ioflag);
  54. int ttydisc_write(struct lwp_tty *tp, struct uio *uio, int ioflag);
  55. void ttydisc_optimize(struct lwp_tty *tp);
  56. /* Bottom half routines. */
  57. void ttydisc_modem(struct lwp_tty *tp, int open);
  58. #define ttydisc_can_bypass(tp) ((tp)->t_flags & TF_BYPASS)
  59. int ttydisc_rint(struct lwp_tty *tp, char c, int flags);
  60. size_t ttydisc_rint_simple(struct lwp_tty *tp, const void *buf, size_t len);
  61. size_t ttydisc_rint_bypass(struct lwp_tty *tp, const void *buf, size_t len);
  62. void ttydisc_rint_done(struct lwp_tty *tp);
  63. size_t ttydisc_rint_poll(struct lwp_tty *tp);
  64. size_t ttydisc_getc(struct lwp_tty *tp, void *buf, size_t len);
  65. int ttydisc_getc_uio(struct lwp_tty *tp, struct uio *uio);
  66. size_t ttydisc_getc_poll(struct lwp_tty *tp);
  67. /* Error codes for ttydisc_rint(). */
  68. #define TRE_FRAMING 0x01
  69. #define TRE_PARITY 0x02
  70. #define TRE_OVERRUN 0x04
  71. #define TRE_BREAK 0x08
  72. #endif /* !_SYS_TTYDISC_H_ */