syscalls.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Syscall implementations for semihosting.
  3. *
  4. * Copyright (c) 2022 Linaro
  5. *
  6. * SPDX-License-Identifier: GPL-2.0-or-later
  7. */
  8. #ifndef SEMIHOSTING_SYSCALLS_H
  9. #define SEMIHOSTING_SYSCALLS_H
  10. #include "exec/cpu-defs.h"
  11. #include "gdbstub/syscalls.h"
  12. /*
  13. * Argument loading from the guest is performed by the caller;
  14. * results are returned via the 'complete' callback.
  15. *
  16. * String operands are in address/len pairs. The len argument may be 0
  17. * (when the semihosting abi does not already provide the length),
  18. * or non-zero (where it should include the terminating zero).
  19. */
  20. typedef struct GuestFD GuestFD;
  21. void semihost_sys_open(CPUState *cs, gdb_syscall_complete_cb complete,
  22. target_ulong fname, target_ulong fname_len,
  23. int gdb_flags, int mode);
  24. void semihost_sys_close(CPUState *cs, gdb_syscall_complete_cb complete,
  25. int fd);
  26. void semihost_sys_read(CPUState *cs, gdb_syscall_complete_cb complete,
  27. int fd, target_ulong buf, target_ulong len);
  28. void semihost_sys_read_gf(CPUState *cs, gdb_syscall_complete_cb complete,
  29. GuestFD *gf, target_ulong buf, target_ulong len);
  30. void semihost_sys_write(CPUState *cs, gdb_syscall_complete_cb complete,
  31. int fd, target_ulong buf, target_ulong len);
  32. void semihost_sys_write_gf(CPUState *cs, gdb_syscall_complete_cb complete,
  33. GuestFD *gf, target_ulong buf, target_ulong len);
  34. void semihost_sys_lseek(CPUState *cs, gdb_syscall_complete_cb complete,
  35. int fd, int64_t off, int gdb_whence);
  36. void semihost_sys_isatty(CPUState *cs, gdb_syscall_complete_cb complete,
  37. int fd);
  38. void semihost_sys_flen(CPUState *cs, gdb_syscall_complete_cb fstat_cb,
  39. gdb_syscall_complete_cb flen_cb,
  40. int fd, target_ulong fstat_addr);
  41. void semihost_sys_fstat(CPUState *cs, gdb_syscall_complete_cb complete,
  42. int fd, target_ulong addr);
  43. void semihost_sys_stat(CPUState *cs, gdb_syscall_complete_cb complete,
  44. target_ulong fname, target_ulong fname_len,
  45. target_ulong addr);
  46. void semihost_sys_remove(CPUState *cs, gdb_syscall_complete_cb complete,
  47. target_ulong fname, target_ulong fname_len);
  48. void semihost_sys_rename(CPUState *cs, gdb_syscall_complete_cb complete,
  49. target_ulong oname, target_ulong oname_len,
  50. target_ulong nname, target_ulong nname_len);
  51. void semihost_sys_system(CPUState *cs, gdb_syscall_complete_cb complete,
  52. target_ulong cmd, target_ulong cmd_len);
  53. void semihost_sys_gettimeofday(CPUState *cs, gdb_syscall_complete_cb complete,
  54. target_ulong tv_addr, target_ulong tz_addr);
  55. void semihost_sys_poll_one(CPUState *cs, gdb_syscall_complete_cb complete,
  56. int fd, GIOCondition cond, int timeout);
  57. #endif /* SEMIHOSTING_SYSCALLS_H */