target/arm/arm-semi: Factor out implementation of SYS_CLOSE
commit263eb621de9dc5295c64879edf46dafe928c8b72
authorPeter Maydell <peter.maydell@linaro.org>
Mon, 16 Sep 2019 14:15:36 +0000 (16 15:15 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Tue, 15 Oct 2019 17:09:03 +0000 (15 18:09 +0100)
tree259ca7c19b66ebbaf58852c20c93dfa35b02bb08
parent939f5b4331b159b51c85cae1b8f0c9d82aa0dffd
target/arm/arm-semi: Factor out implementation of SYS_CLOSE

Currently for the semihosting calls which take a file descriptor
(SYS_CLOSE, SYS_WRITE, SYS_READ, SYS_ISTTY, SYS_SEEK, SYS_FLEN)
we have effectively two implementations, one for real host files
and one for when we indirect via the gdbstub. We want to add a
third one to deal with the magic :semihosting-features file.

Instead of having a three-way if statement in each of these
cases, factor out the implementation of the calls to separate
functions which we dispatch to via function pointers selected
via the GuestFDType for the guest fd.

In this commit, we set up the framework for the dispatch,
and convert the SYS_CLOSE call to use it.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20190916141544.17540-8-peter.maydell@linaro.org
target/arm/arm-semi.c