Skip to content

target-mips: add MDI semihosting

Nathan Froyd qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest6 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6sysemu: add section_callback argument to ELF loaderelf_ops.h loader.c sysemu.h+50 -80 replies
2/6add softmmu_target_strlensoftmmu-semi.h+16 -00 replies
3/6add implementation of MIPS semihostingMakefile.target mips-semi.c target-mips/cpu.h+219 -02 replies
4/6target-mips: add MDI semihosting support to mipssim machinehw/mips_mipssim.c target-mips/cpu.h target-mips/helper.c+103 -70 replies
5/6enable --semihosting option for TARGET_MIPSqemu-options.hx vl.c+2 -20 replies
6/6gdbstub: add qSymbol handling for TARGET_MIPSgdbstub.c+29 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [Qemu-devel] [PATCH 0/6] target-mips: add MDI semihosting

This patch series adds semihosting for bare-metal 32-bit MIPS targets that follows the MDI semihosting model used in MIPS's development product.

The semihosting protocol works as follows:

- All semihosted calls go through _mdi_syscall, which in the absence of simulator support, returns ENOSYS;

- The address of _mdi_syscall is stored in a special section, .sdeosabi;

- When an MDI semihosting-aware simulator is used, a breakpoint is placed at _mdi_syscall;

- When this breakpoint is hit, the simulator performs the requested action and returns control to the program.

Discovering the address of _mdi_syscall is straightforward when the program is passed in via -kernel. We extended the ELF loader interface slightly so that the caller could inspect the sections of the binary and act on the contents of the sections if they so chose. Things are slightly trickier when using QEMU as a GDB remote target, as the program will not be provided via -kernel, but via `load' from within GDB. This second method requires that we implement qSymbol support in the GDB stub so we can directly ask GDB where _mdi_syscall is.

The patches have been built for {mips,mips64}-softmmu targets and tested with the libstdc++ testsuite (which exercises things like read(), write(), and lseek()).

-Nathan