[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4 39/53] semihosting: Create semihost_sys_gettimeofday
From: |
Luc Michel |
Subject: |
Re: [PATCH v4 39/53] semihosting: Create semihost_sys_gettimeofday |
Date: |
Fri, 24 Jun 2022 10:26:25 +0200 |
User-agent: |
Mutt/1.9.4 (2018-02-28) |
On 13:45 Tue 07 Jun , Richard Henderson wrote:
> This syscall will be used by m68k and nios2 semihosting.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Luc Michel <lmichel@kalray.eu>
> ---
> include/semihosting/syscalls.h | 3 +++
> semihosting/syscalls.c | 42 ++++++++++++++++++++++++++++++++++
> 2 files changed, 45 insertions(+)
>
> diff --git a/include/semihosting/syscalls.h b/include/semihosting/syscalls.h
> index ecc97751a9..347200cb9f 100644
> --- a/include/semihosting/syscalls.h
> +++ b/include/semihosting/syscalls.h
> @@ -66,4 +66,7 @@ void semihost_sys_rename(CPUState *cs,
> gdb_syscall_complete_cb complete,
> void semihost_sys_system(CPUState *cs, gdb_syscall_complete_cb complete,
> target_ulong cmd, target_ulong cmd_len);
>
> +void semihost_sys_gettimeofday(CPUState *cs, gdb_syscall_complete_cb
> complete,
> + target_ulong tv_addr, target_ulong tz_addr);
> +
> #endif /* SEMIHOSTING_SYSCALLS_H */
> diff --git a/semihosting/syscalls.c b/semihosting/syscalls.c
> index d21064716d..db1e9f6cc9 100644
> --- a/semihosting/syscalls.c
> +++ b/semihosting/syscalls.c
> @@ -236,6 +236,12 @@ static void gdb_system(CPUState *cs,
> gdb_syscall_complete_cb complete,
> gdb_do_syscall(complete, "system,%s", cmd, len);
> }
>
> +static void gdb_gettimeofday(CPUState *cs, gdb_syscall_complete_cb complete,
> + target_ulong tv_addr, target_ulong tz_addr)
> +{
> + gdb_do_syscall(complete, "gettimeofday,%x,%x", tv_addr, tz_addr);
> +}
> +
> /*
> * Host semihosting syscall implementations.
> */
> @@ -487,6 +493,32 @@ static void host_system(CPUState *cs,
> gdb_syscall_complete_cb complete,
> unlock_user(p, cmd, 0);
> }
>
> +static void host_gettimeofday(CPUState *cs, gdb_syscall_complete_cb complete,
> + target_ulong tv_addr, target_ulong tz_addr)
> +{
> + CPUArchState *env G_GNUC_UNUSED = cs->env_ptr;
> + struct gdb_timeval *p;
> + int64_t rt;
> +
> + /* GDB fails on non-null TZ, so be consistent. */
> + if (tz_addr != 0) {
> + complete(cs, -1, EINVAL);
> + return;
> + }
> +
> + p = lock_user(VERIFY_WRITE, tv_addr, sizeof(struct gdb_timeval), 0);
> + if (!p) {
> + complete(cs, -1, EFAULT);
> + return;
> + }
> +
> + /* TODO: Like stat, gdb always produces big-endian results; match it. */
> + rt = g_get_real_time();
> + p->tv_sec = cpu_to_be32(rt / G_USEC_PER_SEC);
> + p->tv_usec = cpu_to_be64(rt % G_USEC_PER_SEC);
> + unlock_user(p, tv_addr, sizeof(struct gdb_timeval));
> +}
> +
> /*
> * Static file semihosting syscall implementations.
> */
> @@ -796,3 +828,13 @@ void semihost_sys_system(CPUState *cs,
> gdb_syscall_complete_cb complete,
> host_system(cs, complete, cmd, cmd_len);
> }
> }
> +
> +void semihost_sys_gettimeofday(CPUState *cs, gdb_syscall_complete_cb
> complete,
> + target_ulong tv_addr, target_ulong tz_addr)
> +{
> + if (use_gdb_syscalls()) {
> + gdb_gettimeofday(cs, complete, tv_addr, tz_addr);
> + } else {
> + host_gettimeofday(cs, complete, tv_addr, tz_addr);
> + }
> +}
> --
> 2.34.1
>
>
>
>
> To declare a filtering error, please use the following link :
> https://www.security-mail.net/reporter.php?mid=c119.629fd54f.4e3dd.0&r=lmichel%40kalrayinc.com&s=qemu-devel-bounces%2Blmichel%3Dkalrayinc.com%40nongnu.org&o=%5BPATCH+v4+39%2F53%5D+semihosting%3A+Create+semihost_sys_gettimeofday&verdict=C&c=72ff7ee6d62e9655defaed81c32535afbc86c0b7
>
--
- Re: [PATCH v4 32/53] semihosting: Split out semihost_sys_lseek, (continued)
- [PATCH v4 30/53] semihosting: Split out semihost_sys_write, Richard Henderson, 2022/06/07
- [PATCH v4 33/53] semihosting: Split out semihost_sys_isatty, Richard Henderson, 2022/06/07
- [PATCH v4 34/53] semihosting: Split out semihost_sys_flen, Richard Henderson, 2022/06/07
- [PATCH v4 36/53] semihosting: Split out semihost_sys_rename, Richard Henderson, 2022/06/07
- [PATCH v4 39/53] semihosting: Create semihost_sys_gettimeofday, Richard Henderson, 2022/06/07
- Re: [PATCH v4 39/53] semihosting: Create semihost_sys_gettimeofday,
Luc Michel <=
- [PATCH v4 41/53] semihosting: Fix docs comment for qemu_semihosting_console_inc, Richard Henderson, 2022/06/07
- [PATCH v4 45/53] semihosting: Create qemu_semihosting_console_write, Richard Henderson, 2022/06/07
- [PATCH v4 42/53] semihosting: Pass CPUState to qemu_semihosting_console_inc, Richard Henderson, 2022/06/07
- [PATCH v4 48/53] semihosting: Use console_in_gf for SYS_READC, Richard Henderson, 2022/06/07