Richard Henderson | 5b3f39c | 2022-04-28 01:44:28 -0700 | [diff] [blame] | 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 | /* |
| 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 | |
Richard Henderson | af0484b | 2022-04-28 11:40:41 -0700 | [diff] [blame] | 21 | typedef struct GuestFD GuestFD; |
| 22 | |
Richard Henderson | 5b3f39c | 2022-04-28 01:44:28 -0700 | [diff] [blame] | 23 | void semihost_sys_open(CPUState *cs, gdb_syscall_complete_cb complete, |
| 24 | target_ulong fname, target_ulong fname_len, |
| 25 | int gdb_flags, int mode); |
| 26 | |
Richard Henderson | 5eadbbf | 2022-04-28 09:22:18 -0700 | [diff] [blame] | 27 | void semihost_sys_close(CPUState *cs, gdb_syscall_complete_cb complete, |
| 28 | int fd); |
| 29 | |
Richard Henderson | af0484b | 2022-04-28 11:40:41 -0700 | [diff] [blame] | 30 | void semihost_sys_read(CPUState *cs, gdb_syscall_complete_cb complete, |
| 31 | int fd, target_ulong buf, target_ulong len); |
| 32 | |
| 33 | void semihost_sys_read_gf(CPUState *cs, gdb_syscall_complete_cb complete, |
| 34 | GuestFD *gf, target_ulong buf, target_ulong len); |
| 35 | |
Richard Henderson | aa915bd | 2022-04-28 11:49:47 -0700 | [diff] [blame] | 36 | void semihost_sys_write(CPUState *cs, gdb_syscall_complete_cb complete, |
| 37 | int fd, target_ulong buf, target_ulong len); |
| 38 | |
| 39 | void semihost_sys_write_gf(CPUState *cs, gdb_syscall_complete_cb complete, |
| 40 | GuestFD *gf, target_ulong buf, target_ulong len); |
| 41 | |
Richard Henderson | 9a89470 | 2022-04-28 12:04:44 -0700 | [diff] [blame] | 42 | void semihost_sys_lseek(CPUState *cs, gdb_syscall_complete_cb complete, |
| 43 | int fd, int64_t off, int gdb_whence); |
| 44 | |
Richard Henderson | a221247 | 2022-04-28 12:31:25 -0700 | [diff] [blame] | 45 | void semihost_sys_isatty(CPUState *cs, gdb_syscall_complete_cb complete, |
| 46 | int fd); |
| 47 | |
Richard Henderson | a6300ed | 2022-04-29 09:05:36 -0700 | [diff] [blame] | 48 | void semihost_sys_flen(CPUState *cs, gdb_syscall_complete_cb fstat_cb, |
| 49 | gdb_syscall_complete_cb flen_cb, |
| 50 | int fd, target_ulong fstat_addr); |
| 51 | |
Richard Henderson | dffeb77 | 2022-04-29 15:45:25 -0700 | [diff] [blame] | 52 | void semihost_sys_fstat(CPUState *cs, gdb_syscall_complete_cb complete, |
| 53 | int fd, target_ulong addr); |
| 54 | |
| 55 | void semihost_sys_stat(CPUState *cs, gdb_syscall_complete_cb complete, |
| 56 | target_ulong fname, target_ulong fname_len, |
| 57 | target_ulong addr); |
| 58 | |
Richard Henderson | d49e79b | 2022-04-29 09:29:27 -0700 | [diff] [blame] | 59 | void semihost_sys_remove(CPUState *cs, gdb_syscall_complete_cb complete, |
| 60 | target_ulong fname, target_ulong fname_len); |
| 61 | |
Richard Henderson | 25a95da | 2022-04-29 10:11:31 -0700 | [diff] [blame] | 62 | void semihost_sys_rename(CPUState *cs, gdb_syscall_complete_cb complete, |
| 63 | target_ulong oname, target_ulong oname_len, |
| 64 | target_ulong nname, target_ulong nname_len); |
| 65 | |
Richard Henderson | 90d8e0b | 2022-04-29 13:57:19 -0700 | [diff] [blame] | 66 | void semihost_sys_system(CPUState *cs, gdb_syscall_complete_cb complete, |
| 67 | target_ulong cmd, target_ulong cmd_len); |
| 68 | |
Richard Henderson | 1875dab | 2022-04-29 16:05:49 -0700 | [diff] [blame] | 69 | void semihost_sys_gettimeofday(CPUState *cs, gdb_syscall_complete_cb complete, |
| 70 | target_ulong tv_addr, target_ulong tz_addr); |
| 71 | |
Richard Henderson | 1b9177f | 2022-05-02 11:15:40 -0700 | [diff] [blame] | 72 | void semihost_sys_poll_one(CPUState *cs, gdb_syscall_complete_cb complete, |
| 73 | int fd, GIOCondition cond, int timeout); |
| 74 | |
Richard Henderson | 5b3f39c | 2022-04-28 01:44:28 -0700 | [diff] [blame] | 75 | #endif /* SEMIHOSTING_SYSCALLS_H */ |