[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 07/74] semihosting: Split out guestfd.c
From: |
Peter Maydell |
Subject: |
Re: [PATCH v2 07/74] semihosting: Split out guestfd.c |
Date: |
Mon, 16 May 2022 16:14:58 +0100 |
On Tue, 3 May 2022 at 21:02, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> In arm-compat-semi.c, we have more advanced treatment of
> guest file descriptors than we do in other implementations.
> Split out GuestFD and related functions to a new file so
> that they can be shared.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> configs/targets/aarch64-linux-user.mak | 1 +
> configs/targets/aarch64_be-linux-user.mak | 1 +
> configs/targets/arm-linux-user.mak | 1 +
> configs/targets/armeb-linux-user.mak | 1 +
> configs/targets/riscv32-linux-user.mak | 1 +
> configs/targets/riscv64-linux-user.mak | 1 +
> include/semihosting/guestfd.h | 40 +++++++
> semihosting/arm-compat-semi.c | 125 +---------------------
> semihosting/guestfd.c | 116 ++++++++++++++++++++
> semihosting/meson.build | 4 +
> 10 files changed, 168 insertions(+), 123 deletions(-)
> create mode 100644 include/semihosting/guestfd.h
> create mode 100644 semihosting/guestfd.c
>
> diff --git a/configs/targets/aarch64-linux-user.mak
> b/configs/targets/aarch64-linux-user.mak
> index d0c603c54e..db552f1839 100644
> --- a/configs/targets/aarch64-linux-user.mak
> +++ b/configs/targets/aarch64-linux-user.mak
> @@ -2,4 +2,5 @@ TARGET_ARCH=aarch64
> TARGET_BASE_ARCH=arm
> TARGET_XML_FILES= gdb-xml/aarch64-core.xml gdb-xml/aarch64-fpu.xml
> TARGET_HAS_BFLT=y
> +CONFIG_SEMIHOSTING=y
> CONFIG_ARM_COMPATIBLE_SEMIHOSTING=y
Is it not possible to make CONFIG_ARM_COMPATIBLE_SEMIHOSTING=y
imply CONFIG_SEMIHOSTING=y somehow?
> --- /dev/null
> +++ b/include/semihosting/guestfd.h
> @@ -0,0 +1,40 @@
> +/*
> + * Hosted file support for semihosting syscalls.
> + *
> + * Copyright (c) 2005, 2007 CodeSourcery.
> + * Copyright (c) 2019 Linaro
> + * Copyright © 2020 by Keith Packard <keithp@keithp.com>
> + *
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + */
> +
> +#ifndef SEMIHOSTING_GUESTFD_H
> +#define SEMIHOSTING_GUESTFD_H
> +
> +typedef enum GuestFDType {
> + GuestFDUnused = 0,
> + GuestFDHost = 1,
> + GuestFDGDB = 2,
> + GuestFDFeatureFile = 3,
> +} GuestFDType;
> +
> +/*
> + * Guest file descriptors are integer indexes into an array of
> + * these structures (we will dynamically resize as necessary).
> + */
> +typedef struct GuestFD {
> + GuestFDType type;
> + union {
> + int hostfd;
> + unsigned featurefile_offset;
> + };
> +} GuestFD;
> +
> +int alloc_guestfd(void);
> +void dealloc_guestfd(int guestfd);
> +GuestFD *get_guestfd(int guestfd);
> +
> +void associate_guestfd(int guestfd, int hostfd);
> +void init_featurefile_guestfd(int guestfd);
If these are moving from being static functions local to a file
to being global, they should get kerneldoc style doc-comments here in
the header file.
thanks
-- PMM
- [PATCH v2 04/74] semihosting: Move softmmu-uaccess.h functions out of line, (continued)
- [PATCH v2 04/74] semihosting: Move softmmu-uaccess.h functions out of line, Richard Henderson, 2022/05/03
- [PATCH v2 03/74] semihosting: Improve condition for config.c and console.c, Richard Henderson, 2022/05/03
- [PATCH v2 05/74] semihosting: Add target_strlen for softmmu-uaccess.h, Richard Henderson, 2022/05/03
- [PATCH v2 06/74] semihosting: Simplify softmmu_lock_user_string, Richard Henderson, 2022/05/03
- [PATCH v2 07/74] semihosting: Split out guestfd.c, Richard Henderson, 2022/05/03
- Re: [PATCH v2 07/74] semihosting: Split out guestfd.c,
Peter Maydell <=
- [PATCH v2 08/74] semihosting: Generalize GuestFDFeatureFile, Richard Henderson, 2022/05/03
- [PATCH v2 09/74] semihosting: Return void from do_common_semihosting, Richard Henderson, 2022/05/03
- [PATCH v2 13/74] include/exec: Move gdb_stat and gdb_timeval to gdbstub.h, Richard Henderson, 2022/05/03
- [PATCH v2 10/74] semihosting: Adjust error checking in common_semi_cb, Richard Henderson, 2022/05/03
- [PATCH v2 12/74] include/exec: Move gdb open flags to gdbstub.h, Richard Henderson, 2022/05/03
- [PATCH v2 14/74] include/exec: Define errno values in gdbstub.h, Richard Henderson, 2022/05/03
- [PATCH v2 15/74] semihosting: Use struct gdb_stat in common_semi_flen_cb, Richard Henderson, 2022/05/03