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