[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 29/30] semihosting: Implement SYS_TMPNAM
From: |
Alex Bennée |
Subject: |
[PULL 29/30] semihosting: Implement SYS_TMPNAM |
Date: |
Fri, 15 Jan 2021 13:08:27 +0000 |
From: Keith Packard <keithp@keithp.com>
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>
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);
--
2.20.1
- [PULL 02/30] Makefile: add GNU global tags support, (continued)
- [PULL 02/30] Makefile: add GNU global tags support, Alex Bennée, 2021/01/15
- [PULL 06/30] Makefile: wrap etags in quiet-command calls, Alex Bennée, 2021/01/15
- [PULL 04/30] Add newline when generating Dockerfile, Alex Bennée, 2021/01/15
- [PULL 05/30] Makefile: wrap ctags in quiet-command calls, Alex Bennée, 2021/01/15
- [PULL 17/30] gdbstub: add support to Xfer:auxv:read: packet, Alex Bennée, 2021/01/15
- [PULL 25/30] semihosting: Support SYS_HEAPINFO when env->boot_info is not set, Alex Bennée, 2021/01/15
- [PULL 13/30] test/guest-debug: echo QEMU command as well, Alex Bennée, 2021/01/15
- [PULL 14/30] configure: gate our use of GDB to 8.3.1 or above, Alex Bennée, 2021/01/15
- [PULL 21/30] target/arm: use official org.gnu.gdb.aarch64.sve layout for registers, Alex Bennée, 2021/01/15
- [PULL 30/30] semihosting: Implement SYS_ISERROR, Alex Bennée, 2021/01/15
- [PULL 29/30] semihosting: Implement SYS_TMPNAM,
Alex Bennée <=
- [PULL 07/30] Makefile: wrap cscope in quiet-command calls, Alex Bennée, 2021/01/15
- [PULL 28/30] semihosting: Implement SYS_ELAPSED and SYS_TICKFREQ, Alex Bennée, 2021/01/15
- [PULL 16/30] gdbstub: implement a softmmu based test, Alex Bennée, 2021/01/15
- [PULL 18/30] gdbstub: drop CPUEnv from gdb_exit(), Alex Bennée, 2021/01/15
- [PULL 19/30] gdbstub: drop gdbserver_cleanup in favour of gdb_exit, Alex Bennée, 2021/01/15
- [PULL 23/30] semihosting: Change common-semi API to be architecture-independent, Alex Bennée, 2021/01/15
- [PULL 08/30] docker: expand debian-amd64 image to include tag tools, Alex Bennée, 2021/01/15
- [PULL 27/30] riscv: Add semihosting support for user mode, Alex Bennée, 2021/01/15
- [PULL 20/30] gdbstub: ensure we clean-up when terminated, Alex Bennée, 2021/01/15
- [PULL 22/30] semihosting: Move ARM semihosting code to shared directories, Alex Bennée, 2021/01/15