tty_ldisc.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2021.12.07 linzhenxing first version
  9. */
  10. #ifndef __TTY_LDISC_
  11. #define __TTY_LDISC_
  12. #include <rtthread.h>
  13. #include <dfs.h>
  14. #include <dfs_fs.h>
  15. #include <tty.h>
  16. #if defined(RT_USING_POSIX_TERMIOS)
  17. #include <termios.h>
  18. #endif
  19. struct tty_struct;
  20. struct tty_ldisc_ops
  21. {
  22. char *name;
  23. int num;
  24. int (*open) (struct dfs_fd *fd);
  25. int (*close) (struct tty_struct *tty);
  26. int (*ioctl) (struct dfs_fd *fd, int cmd, void *args);
  27. int (*read) (struct dfs_fd *fd, void *buf, size_t count);
  28. int (*write) (struct dfs_fd *fd, const void *buf, size_t count);
  29. int (*flush) (struct dfs_fd *fd);
  30. int (*lseek) (struct dfs_fd *fd, off_t offset);
  31. int (*getdents) (struct dfs_fd *fd, struct dirent *dirp, uint32_t count);
  32. int (*poll) (struct dfs_fd *fd, struct rt_pollreq *req);
  33. void (*set_termios) (struct tty_struct *tty, struct termios *old);
  34. int (*receive_buf) (struct tty_struct *tty,char *cp, int count);
  35. int refcount;
  36. };
  37. struct tty_ldisc
  38. {
  39. struct tty_ldisc_ops *ops;
  40. struct tty_struct *tty;
  41. };
  42. #define TTY_LDISC_MAGIC 0x5403
  43. int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
  44. void tty_ldisc_kill(struct tty_struct *tty);
  45. void tty_ldisc_init(struct tty_struct *tty);
  46. void tty_ldisc_release(struct tty_struct *tty);
  47. void n_tty_init(void);
  48. #endif // __TTY_LDISC_