console.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. #include "cpu.h"
  11. /**
  12. * qemu_semihosting_console_read:
  13. * @cs: CPUState
  14. * @buf: host buffer
  15. * @len: buffer size
  16. *
  17. * Receive at least one character from debug console. As this call may
  18. * block if no data is available we suspend the CPU and will re-execute the
  19. * instruction when data is there. Therefore two conditions must be met:
  20. *
  21. * - CPUState is synchronized before calling this function
  22. * - pc is only updated once the character is successfully returned
  23. *
  24. * Returns: number of characters read, OR cpu_loop_exit!
  25. */
  26. int qemu_semihosting_console_read(CPUState *cs, void *buf, int len);
  27. /**
  28. * qemu_semihosting_console_write:
  29. * @buf: host buffer
  30. * @len: buffer size
  31. *
  32. * Write len bytes from buf to the debug console.
  33. *
  34. * Returns: number of bytes written -- this should only ever be short
  35. * on some sort of i/o error.
  36. */
  37. int qemu_semihosting_console_write(void *buf, int len);
  38. /**
  39. * qemu_semihosting_log_out:
  40. * @s: pointer to string
  41. * @len: length of string
  42. *
  43. * Send a string to the debug output. Unlike console_out these strings
  44. * can't be sent to a remote gdb instance as they don't exist in guest
  45. * memory.
  46. *
  47. * Returns: number of bytes written
  48. */
  49. int qemu_semihosting_log_out(const char *s, int len);
  50. #endif /* SEMIHOST_CONSOLE_H */