On 13:45 Tue 07 Jun , Richard Henderson wrote: > Split out the non-ARM specific portions of SYS_READ to a > reusable function. This handles all GuestFD. Isolate the > curious ARM-specific return value processing to a new > callback, common_semi_rw_cb. > > Note that gdb_do_syscall %x reads target_ulong, not int. > > Signed-off-by: Richard Henderson <richard.hender...@linaro.org> > --- > include/semihosting/syscalls.h | 8 ++++ > semihosting/arm-compat-semi.c | 85 ++++++++-------------------------- > semihosting/syscalls.c | 85 ++++++++++++++++++++++++++++++++++ > 3 files changed, 113 insertions(+), 65 deletions(-) >
[...] > +/* > + * SYS_READ and SYS_WRITE always return the number of bytes not read/written. > + * There is no error condition, other than returning the original length. > + */ > +static void common_semi_rw_cb(CPUState *cs, target_ulong ret, target_ulong > err) > +{ > + /* Recover the original length from the third argument. */ > + CPUArchState *env G_GNUC_UNUSED = cs->env_ptr; > + target_ulong args = common_semi_arg(cs, 1); > + target_ulong arg2; > + GET_ARG(2); > + > + if (err) { > + do_fault: Leftover label? otherwise: Reviewed-by: Luc Michel <lmic...@kalray.eu> > + ret = 0; /* error: no bytes transmitted */ > + } > + common_semi_set_ret(cs, arg2 - ret); > +} > +