I had whipped up an rx-elf cross toolchain to test something
recently, and since I had built it, thought it would be easy
to use libgloss to run the multiarch hello and memory tests.
But we haven't implemented libgloss-style semihosting for rx.
I had forgotten how much boilerplate there is currently for
implementing semihosting for an architecture. And we have 3
implementations that really could share much more code.
So: split out semihosting syscalls to individual functions,
and allow them to be wired up with a minimum of fuss. Fix a
few bugs and to-do items on the way.
Still to do:
* Merge semihosting console.c into GuestFD.
The ARM semihosting spec has separate syscalls for console output,
and expects the read/write syscalls to only apply to files.
But the other semihosting implementations assume stdin/stdout,
and we should be able to wire those up via the same mechanism.
* Errno. The ARM spec punts this entirely. But we aren't even
self-consistant, some paths returning host <errno.h> values,
and anything going through gdbstub using the gdb remote
file-io errno values. The arm and nios2 specs explicitly
call for the gdb values, which we are not doing.
* tests/tcg/m68k semihosting implementation.
* target/rx semihosting implementation.
r~
Richard Henderson (43):
semihosting: Move exec/softmmu-semi.h to semihosting/softmmu-uaccess.h
semihosting: Return failure from softmmu-uaccess.h functions
semihosting: Improve condition for config.c and console.c
semihosting: Move softmmu-uaccess functions out of line
semihosting: Add target_strlen for softmmu-uaccess.h
semihosting: Simplify softmmu_lock_user_string
semihosting: Split out guestfd.c
semihosting: Generalize GuestFDFeatureFile
semihosting: Return void from do_common_semihosting
semihosting: Adjust error checking in common_semi_cb
semihosting: Move common-semi.h to include/semihosting/
include/exec: Move gdb open flags to gdbstub.h
include/exec: Move gdb_stat and gdb_timeval to gdbstub.h
semihosting: Use struct gdb_stat in common_semi_flen_cb
semihosting: Split is_64bit_semihosting per target
semihosting: Split common_semi_flen_buf per target
semihosting: Split out common_semi_has_synccache
semihosting: Use env more often in do_common_semihosting
semihosting: Move GET_ARG/SET_ARG earlier in the file
semihosting: Split out semihost_sys_open
semihosting: Split out semihost_sys_close
semihosting: Split out semihost_sys_read
semihosting: Split out semihost_sys_write
semihosting: Bound length for semihost_sys_{read,write}
semihosting: Split out semihost_sys_lseek
semihosting: Split out semihost_sys_isatty
semihosting: Split out semihost_sys_flen
semihosting: Split out semihost_sys_remove
semihosting: Split out semihost_sys_rename
semihosting: Split out semihost_sys_system
semihosting: Create semihost_sys_{stat,fstat}
semihosting: Create semihost_sys_gettimeofday
gdbstub: Widen gdb_syscall_complete_cb return value
target/m68k: Eliminate m68k_semi_is_fseek
target/m68k: Make semihosting system only
target/m68k: Use guestfd.h to implement syscalls.
target/m68k: Do semihosting call as a normal helper
target/m68k: Enable semihosting for non-coldfire
target/m68k: Remove EXCP_HALT_INSN
target/nios2: Eliminate nios2_semi_is_lseek
target/nios2: Move nios2-semi.c to nios2_softmmu_ss
target/nios2: Use guestfd.h to implement syscalls.
target/nios2: Do semihosting call as a normal helper
configs/targets/aarch64-linux-user.mak | 1 +
configs/targets/aarch64_be-linux-user.mak | 1 +
configs/targets/arm-linux-user.mak | 1 +
configs/targets/armeb-linux-user.mak | 1 +
configs/targets/riscv32-linux-user.mak | 1 +
configs/targets/riscv64-linux-user.mak | 1 +
include/exec/gdbstub.h | 43 +-
include/exec/softmmu-semi.h | 101 --
.../semihosting}/common-semi.h | 2 +-
include/semihosting/guestfd.h | 95 ++
include/semihosting/softmmu-uaccess.h | 59 ++
target/arm/common-semi-target.h | 62 ++
target/m68k/cpu.h | 3 -
target/m68k/helper.h | 1 +
target/nios2/cpu.h | 3 -
target/nios2/helper.h | 1 +
target/riscv/common-semi-target.h | 50 +
gdbstub.c | 7 +-
linux-user/aarch64/cpu_loop.c | 2 +-
linux-user/arm/cpu_loop.c | 2 +-
linux-user/m68k/cpu_loop.c | 5 -
linux-user/riscv/cpu_loop.c | 2 +-
semihosting/arm-compat-semi.c | 955 ++++--------------
semihosting/console.c | 7 +-
semihosting/guestfd.c | 935 +++++++++++++++++
semihosting/uaccess.c | 71 ++
target/arm/helper.c | 4 +-
target/arm/m_helper.c | 2 +-
target/m68k/m68k-semi.c | 374 +------
target/m68k/op_helper.c | 15 -
target/m68k/translate.c | 38 +-
target/mips/tcg/sysemu/mips-semi.c | 2 +-
target/nios2/helper.c | 7 -
target/nios2/nios2-semi.c | 357 +------
target/nios2/translate.c | 2 +-
target/riscv/cpu_helper.c | 2 +-
semihosting/meson.build | 5 +
target/m68k/meson.build | 6 +-
target/nios2/meson.build | 4 +-
39 files changed, 1686 insertions(+), 1544 deletions(-)
delete mode 100644 include/exec/softmmu-semi.h
rename {semihosting => include/semihosting}/common-semi.h (96%)
create mode 100644 include/semihosting/guestfd.h
create mode 100644 include/semihosting/softmmu-uaccess.h
create mode 100644 target/arm/common-semi-target.h
create mode 100644 target/riscv/common-semi-target.h
create mode 100644 semihosting/guestfd.c
create mode 100644 semihosting/uaccess.c
--
2.34.1