[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 8/9] semihosting: Implement SYS_TMPNAM
From: |
Keith Packard |
Subject: |
[PATCH 8/9] semihosting: Implement SYS_TMPNAM |
Date: |
Mon, 14 Dec 2020 12:07:12 -0800 |
Part of Semihosting for AArch32 and AArch64 Release 2.0
Signed-off-by: Keith Packard <keithp@keithp.com>
---
hw/semihosting/common-semi.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/hw/semihosting/common-semi.c b/hw/semihosting/common-semi.c
index b1368d945c..b0648c3812 100644
--- a/hw/semihosting/common-semi.c
+++ b/hw/semihosting/common-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.29.2
- Re: [PATCH 0/8] Add RISC-V semihosting 0.2. Finish ARM semihosting 2.0, Alex Bennée, 2020/12/14
- Re: [PATCH 0/8] Add RISC-V semihosting 0.2. Finish ARM semihosting 2.0, Alex Bennée, 2020/12/14
- Re: [PATCH 0/8] Add RISC-V semihosting 0.2. Finish ARM semihosting 2.0, Keith Packard, 2020/12/14
- [PATCH 0/9] Add RISC-V semihosting 0.2. Finish ARM semihosting 2.0, Keith Packard, 2020/12/14
- [PATCH 2/9] semihosting: Change common-semi API to be architecture-independent, Keith Packard, 2020/12/14
- [PATCH 4/9] semihosting: Support SYS_HEAPINFO when env->boot_info is not set, Keith Packard, 2020/12/14
- [PATCH 7/9] semihosting: Implement SYS_ELAPSED and SYS_TICKFREQ, Keith Packard, 2020/12/14
- [PATCH 8/9] semihosting: Implement SYS_TMPNAM,
Keith Packard <=
- [PATCH 3/9] semihosting: Change internal common-semi interfaces to use CPUState *, Keith Packard, 2020/12/14
- [PATCH 9/9] semihosting: Implement SYS_ISERROR, Keith Packard, 2020/12/14
- [PATCH 6/9] riscv: Add semihosting support for user mode, Keith Packard, 2020/12/14
- [PATCH 5/9] riscv: Add semihosting support, Keith Packard, 2020/12/14
- [PATCH 1/9] semihosting: Move ARM semihosting code to shared directories, Keith Packard, 2020/12/14