tty.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* Copyright 2018 SiFive, Inc */
  2. /* SPDX-License-Identifier: Apache-2.0 */
  3. #ifndef METAL__TTY_H
  4. #define METAL__TTY_H
  5. /*!
  6. * @file tty.h
  7. * @brief API for emulated serial teriminals
  8. */
  9. /*!
  10. * @brief Write a character to the default output device
  11. *
  12. * Write a character to the default output device, which for most
  13. * targets is the UART serial port.
  14. *
  15. * putc() does CR/LF mapping.
  16. * putc_raw() does not.
  17. *
  18. * @param c The character to write to the terminal
  19. * @return 0 on success, or -1 on failure.
  20. */
  21. int metal_tty_putc(int c);
  22. /*!
  23. * @brief Write a raw character to the default output device
  24. *
  25. * Write a character to the default output device, which for most
  26. * targets is the UART serial port.
  27. *
  28. * putc() does CR/LF mapping.
  29. * putc_raw() does not.
  30. *
  31. * @param c The character to write to the terminal
  32. * @return 0 on success, or -1 on failure.
  33. */
  34. int metal_tty_putc_raw(int c);
  35. /*!
  36. * @brief Get a byte from the default output device
  37. *
  38. * The default output device, is typically the UART serial port.
  39. *
  40. * This call is non-blocking, if nothing is ready c==-1
  41. * if something is ready, then c=[0x00 to 0xff] byte value.
  42. *
  43. * @return 0 on success, or -1 on failure.
  44. */
  45. int metal_tty_getc(int *c);
  46. #endif