console.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Semihosting Console
  3. *
  4. * Copyright (c) 2019 Linaro Ltd
  5. *
  6. * SPDX-License-Identifier: GPL-2.0-or-later
  7. */
  8. #ifndef SEMIHOST_CONSOLE_H
  9. #define SEMIHOST_CONSOLE_H
  10. /**
  11. * qemu_semihosting_console_read:
  12. * @cs: CPUState
  13. * @buf: host buffer
  14. * @len: buffer size
  15. *
  16. * Receive at least one character from debug console. As this call may
  17. * block if no data is available we suspend the CPU and will re-execute the
  18. * instruction when data is there. Therefore two conditions must be met:
  19. *
  20. * - CPUState is synchronized before calling this function
  21. * - pc is only updated once the character is successfully returned
  22. *
  23. * Returns: number of characters read, OR cpu_loop_exit!
  24. */
  25. int qemu_semihosting_console_read(CPUState *cs, void *buf, int len);
  26. /**
  27. * qemu_semihosting_console_write:
  28. * @buf: host buffer
  29. * @len: buffer size
  30. *
  31. * Write len bytes from buf to the debug console.
  32. *
  33. * Returns: number of bytes written -- this should only ever be short
  34. * on some sort of i/o error.
  35. */
  36. int qemu_semihosting_console_write(void *buf, int len);
  37. /*
  38. * qemu_semihosting_console_block_until_ready:
  39. * @cs: CPUState
  40. *
  41. * If no data is available we suspend the CPU and will re-execute the
  42. * instruction when data is available.
  43. */
  44. void qemu_semihosting_console_block_until_ready(CPUState *cs);
  45. /**
  46. * qemu_semihosting_console_ready:
  47. *
  48. * Return true if characters are available for read; does not block.
  49. */
  50. bool qemu_semihosting_console_ready(void);
  51. #endif /* SEMIHOST_CONSOLE_H */