tty_internal.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 __LWP_TTY_INTERNAL_H__
  11. #define __LWP_TTY_INTERNAL_H__
  12. #include "lwp.h"
  13. #include "terminal.h"
  14. extern struct cdevsw bsd_ttydev_methods;
  15. extern struct bsd_fileops bsd_ptsdev_methods;
  16. /* bsd devsw porting */
  17. void bsd_devsw_init(struct lwp_ttydevsw *tsw);
  18. /**
  19. * Do not assert RTS or DTR automatically. If CNO_RTSDTR is set then the RTS and
  20. * DTR lines will not be asserted when the device is opened. As a result, this
  21. * flag is only useful on initial-state devices.
  22. *
  23. * Note: this feature is not using on smart system, so this flag is always 0.
  24. */
  25. #define CNO_RTSDTR 0
  26. /* Waking up readers/writers. */
  27. int tty_wait(struct lwp_tty *tp, struct rt_condvar *cv);
  28. int tty_wait_background(struct lwp_tty *tp, struct rt_thread *td, int sig);
  29. int tty_timedwait(struct lwp_tty *tp, struct rt_condvar *cv, rt_tick_t timeout);
  30. void tty_wakeup(struct lwp_tty *tp, int flags);
  31. void tty_info(struct lwp_tty *tp);
  32. void pts_set_lock(lwp_tty_t pts, rt_bool_t is_lock);
  33. rt_bool_t pts_is_locked(lwp_tty_t pts);
  34. int pts_get_pktmode(lwp_tty_t pts);
  35. int pts_alloc(int fflags, struct rt_thread *td, struct dfs_file *ptm_file);
  36. int lwp_tty_ioctl_adapter(lwp_tty_t tp, int cmd, int oflags, void *args, rt_thread_t td);
  37. int lwp_tty_set_ctrl_proc(lwp_tty_t tp, rt_thread_t td);
  38. int lwp_tty_assign_foreground(lwp_tty_t tp, rt_thread_t td, int pgid);
  39. int lwp_tty_bg_stop(struct lwp_tty *tp, struct rt_condvar *cv);
  40. rt_inline rt_bool_t is_sess_leader(rt_lwp_t p)
  41. {
  42. /**
  43. * Note: a pgrp leader is never lose its group, so once it's
  44. * true then it's always true
  45. */
  46. return p->pid == p->sid;
  47. }
  48. rt_inline int tty_is_ctty(struct lwp_tty *tp, struct rt_lwp *p)
  49. {
  50. tty_assert_locked(tp);
  51. return p->pgrp->session == tp->t_session && p->term_ctrlterm;
  52. }
  53. #endif /* __LWP_TTY_INTERNAL_H__ */