On Tue, 3 May 2022 at 21:02, Richard Henderson <richard.hender...@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.hender...@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 <kei...@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