tty.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* Copyright (C) 2021 Rain */
  2. /* This file is part of XNIX. */
  3. /*
  4. XNIX is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) and later version.
  8. */
  9. /*
  10. XNIX is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. */
  15. /*
  16. You should have received a copy of the GNU General Public License
  17. along with XNIX. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. #ifndef _TTY_H
  20. #define _TTY_H
  21. #include <kernel/init.h>
  22. #include <kernel/types.h>
  23. int tty_read(struct tty *, char *, size_t);
  24. int tty_write(struct tty *, char *, size_t);
  25. struct tty {
  26. struct fifo *input_fifo;
  27. /* unreadable (wr-only) */
  28. #define T_NORD 0x01
  29. /* tty_read returns character / line */
  30. #define T_COOKED 0x02
  31. /* put the input character to screen (in tty_read) */
  32. #define T_INPUT_BACK 0x04
  33. __uint8_t mode;
  34. /* the controller process id */
  35. __uint32_t ctl;
  36. __uint8_t vx, vy;
  37. int (* putc) (struct tty *, char c);
  38. struct tty *next;
  39. };
  40. /* tty0: system console (0xb8000) tty1: serial port 0 (if exists) */
  41. extern struct tty tty0, tty1;
  42. #endif