diff options
author | Keith Packard | 2021-01-08 23:42:55 +0100 |
---|---|---|
committer | Alex Bennée | 2021-01-18 11:05:06 +0100 |
commit | 27e3b109d1bcf9a43888d3d3c825bda38157dfe4 (patch) | |
tree | 05aa529cbabc86720a31e8f40db0bb86ad2ee954 | |
parent | semihosting: Implement SYS_ELAPSED and SYS_TICKFREQ (diff) | |
download | qemu-27e3b109d1bcf9a43888d3d3c825bda38157dfe4.tar.gz qemu-27e3b109d1bcf9a43888d3d3c825bda38157dfe4.tar.xz qemu-27e3b109d1bcf9a43888d3d3c825bda38157dfe4.zip |
semihosting: Implement SYS_TMPNAM
Part of Semihosting for AArch32 and AArch64 Release 2.0
Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20210107170717.2098982-9-keithp@keithp.com>
Message-Id: <20210108224256.2321-20-alex.bennee@linaro.org>
-rw-r--r-- | hw/semihosting/arm-compat-semi.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/hw/semihosting/arm-compat-semi.c b/hw/semihosting/arm-compat-semi.c index 3d6604dcdd..a631904fb0 100644 --- a/hw/semihosting/arm-compat-semi.c +++ b/hw/semihosting/arm-compat-semi.c @@ -835,6 +835,7 @@ target_ulong do_common_semihosting(CPUState *cs) CPUArchState *env = cs->env_ptr; target_ulong args; target_ulong arg0, arg1, arg2, arg3; + target_ulong ul_ret; char * s; int nr; uint32_t ret; @@ -998,8 +999,24 @@ target_ulong do_common_semihosting(CPUState *cs) return guestfd_fns[gf->type].flenfn(cs, gf); case TARGET_SYS_TMPNAM: - qemu_log_mask(LOG_UNIMP, "%s: SYS_TMPNAM not implemented", __func__); - return -1; + GET_ARG(0); + GET_ARG(1); + GET_ARG(2); + if (asprintf(&s, "/tmp/qemu-%x%02x", getpid(), + (int) (arg1 & 0xff)) < 0) { + return -1; + } + ul_ret = (target_ulong) -1; + + /* Make sure there's enough space in the buffer */ + if (strlen(s) < arg2) { + char *output = lock_user(VERIFY_WRITE, arg0, arg2, 0); + strcpy(output, s); + unlock_user(output, arg0, arg2); + ul_ret = 0; + } + free(s); + return ul_ret; case TARGET_SYS_REMOVE: GET_ARG(0); GET_ARG(1); |