[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-arm] [PATCH 10/13] target/arm/arm-semi: Factor out implementat
From: |
Alex Bennée |
Subject: |
Re: [Qemu-arm] [PATCH 10/13] target/arm/arm-semi: Factor out implementation of SYS_FLEN |
Date: |
Thu, 12 Sep 2019 12:43:44 +0100 |
User-agent: |
mu4e 1.3.4; emacs 27.0.50 |
Peter Maydell <address@hidden> writes:
> Factor out the implementation of SYS_FLEN via the new
> function tables.
>
> Signed-off-by: Peter Maydell <address@hidden>
Reviewed-by: Alex Bennée <address@hidden>
> ---
> target/arm/arm-semi.c | 31 +++++++++++++++++++++----------
> 1 file changed, 21 insertions(+), 10 deletions(-)
>
> diff --git a/target/arm/arm-semi.c b/target/arm/arm-semi.c
> index c548ce849e7..f9019b00b8d 100644
> --- a/target/arm/arm-semi.c
> +++ b/target/arm/arm-semi.c
> @@ -352,6 +352,7 @@ typedef uint32_t sys_readfn(TaskState *ts, ARMCPU *cpu,
> GuestFD *gf,
> typedef uint32_t sys_isattyfn(TaskState *ts, ARMCPU *cpu, GuestFD *gf);
> typedef uint32_t sys_seekfn(TaskState *ts, ARMCPU *cpu, GuestFD *gf,
> target_ulong offset);
> +typedef uint32_t sys_flenfn(TaskState *ts, ARMCPU *cpu, GuestFD *gf);
>
> static uint32_t host_closefn(TaskState *ts, ARMCPU *cpu, GuestFD *gf)
> {
> @@ -417,6 +418,16 @@ static uint32_t host_seekfn(TaskState *ts, ARMCPU *cpu,
> GuestFD *gf,
> return 0;
> }
>
> +static uint32_t host_flenfn(TaskState *ts, ARMCPU *cpu, GuestFD *gf)
> +{
> + struct stat buf;
> + uint32_t ret = set_swi_errno(ts, fstat(gf->hostfd, &buf));
> + if (ret == (uint32_t)-1) {
> + return -1;
> + }
> + return buf.st_size;
> +}
> +
> static uint32_t gdb_closefn(TaskState *ts, ARMCPU *cpu, GuestFD *gf)
> {
> return arm_gdb_syscall(cpu, arm_semi_cb, "close,%x", gf->hostfd);
> @@ -450,12 +461,19 @@ static uint32_t gdb_seekfn(TaskState *ts, ARMCPU *cpu,
> GuestFD *gf,
> gf->hostfd, offset);
> }
>
> +static uint32_t gdb_flenfn(TaskState *ts, ARMCPU *cpu, GuestFD *gf)
> +{
> + return arm_gdb_syscall(cpu, arm_semi_flen_cb, "fstat,%x,%x",
> + gf->hostfd, arm_flen_buf(cpu));
> +}
> +
> typedef struct GuestFDFunctions {
> sys_closefn *closefn;
> sys_writefn *writefn;
> sys_readfn *readfn;
> sys_isattyfn *isattyfn;
> sys_seekfn *seekfn;
> + sys_flenfn *flenfn;
> } GuestFDFunctions;
>
> static const GuestFDFunctions guestfd_fns[] = {
> @@ -465,6 +483,7 @@ static const GuestFDFunctions guestfd_fns[] = {
> .readfn = host_readfn,
> .isattyfn = host_isattyfn,
> .seekfn = host_seekfn,
> + .flenfn = host_flenfn,
> },
> [GuestFDGDB] = {
> .closefn = gdb_closefn,
> @@ -472,6 +491,7 @@ static const GuestFDFunctions guestfd_fns[] = {
> .readfn = gdb_readfn,
> .isattyfn = gdb_isattyfn,
> .seekfn = gdb_seekfn,
> + .flenfn = gdb_flenfn,
> },
> };
>
> @@ -657,16 +677,7 @@ target_ulong do_arm_semihosting(CPUARMState *env)
> return set_swi_errno(ts, -1);
> }
>
> - if (use_gdb_syscalls()) {
> - return arm_gdb_syscall(cpu, arm_semi_flen_cb, "fstat,%x,%x",
> - gf->hostfd, arm_flen_buf(cpu));
> - } else {
> - struct stat buf;
> - ret = set_swi_errno(ts, fstat(gf->hostfd, &buf));
> - if (ret == (uint32_t)-1)
> - return -1;
> - return buf.st_size;
> - }
> + return guestfd_fns[gf->type].flenfn(ts, cpu, gf);
> case TARGET_SYS_TMPNAM:
> qemu_log_mask(LOG_UNIMP, "%s: SYS_TMPNAM not implemented", __func__);
> return -1;
--
Alex Bennée
- Re: [Qemu-arm] [PATCH 05/13] target/arm/arm-semi: Factor out implementation of SYS_CLOSE, (continued)
- [Qemu-arm] [PATCH 06/13] target/arm/arm-semi: Factor out implementation of SYS_WRITE, Peter Maydell, 2019/09/10
- [Qemu-arm] [PATCH 07/13] target/arm/arm-semi: Factor out implementation of SYS_READ, Peter Maydell, 2019/09/10
- [Qemu-arm] [PATCH 08/13] target/arm/arm-semi: Factor out implementation of SYS_ISTTY, Peter Maydell, 2019/09/10
- [Qemu-arm] [PATCH 09/13] target/arm/arm-semi: Factor out implementation of SYS_SEEK, Peter Maydell, 2019/09/10
- [Qemu-arm] [PATCH 10/13] target/arm/arm-semi: Factor out implementation of SYS_FLEN, Peter Maydell, 2019/09/10
- Re: [Qemu-arm] [PATCH 10/13] target/arm/arm-semi: Factor out implementation of SYS_FLEN,
Alex Bennée <=
- [Qemu-arm] [PATCH 13/13] target/arm/arm-semi: Implement SH_EXT_EXIT_EXTENDED extension, Peter Maydell, 2019/09/10
- [Qemu-arm] [PATCH 11/13] target/arm/arm-semi: Implement support for semihosting feature detection, Peter Maydell, 2019/09/10
- [Qemu-arm] [PATCH 12/13] target/arm/arm-semi: Implement SH_EXT_STDOUT_STDERR extension, Peter Maydell, 2019/09/10