[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 06/22] semihosting/arm-compat-semi: unify GET/SET_ARG helpers
From: |
Alex Bennée |
Subject: |
[PULL 06/22] semihosting/arm-compat-semi: unify GET/SET_ARG helpers |
Date: |
Wed, 24 Mar 2021 14:30:05 +0000 |
>>>From the semihosting point of view what we want to know is the current
mode of the processor. Unify this into a single helper and allow us to
use the same GET/SET_ARG helpers for the rest of the code. Having the
helper will also be useful later.
Note: we aren't currently testing riscv32 due to missing toolchain for
check-tcg tests.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Keith Packard <keithp@keithp.com>
Message-Id: <20210323165308.15244-7-alex.bennee@linaro.org>
diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c
index 94950b6c56..0f0e129a7c 100644
--- a/semihosting/arm-compat-semi.c
+++ b/semihosting/arm-compat-semi.c
@@ -767,15 +767,28 @@ static const GuestFDFunctions guestfd_fns[] = {
},
};
-/* Read the input value from the argument block; fail the semihosting
- * call if the memory read fails.
+/*
+ * Read the input value from the argument block; fail the semihosting
+ * call if the memory read fails. Eventually we could use a generic
+ * CPUState helper function here.
*/
-#ifdef TARGET_ARM
+static inline bool is_64bit_semihosting(CPUArchState *env)
+{
+#if defined(TARGET_ARM)
+ return is_a64(env);
+#elif defined(TARGET_RISCV)
+ return !riscv_cpu_is_32bit(env);
+#else
+#error un-handled architecture
+#endif
+}
+
+
#define GET_ARG(n) do { \
- if (is_a64(env)) { \
+ if (is_64bit_semihosting(env)) { \
if (get_user_u64(arg ## n, args + (n) * 8)) { \
errno = EFAULT; \
- return set_swi_errno(cs, -1); \
+ return set_swi_errno(cs, -1); \
} \
} else { \
if (get_user_u32(arg ## n, args + (n) * 4)) { \
@@ -786,41 +799,10 @@ static const GuestFDFunctions guestfd_fns[] = {
} while (0)
#define SET_ARG(n, val) \
- (is_a64(env) ? \
+ (is_64bit_semihosting(env) ? \
put_user_u64(val, args + (n) * 8) : \
put_user_u32(val, args + (n) * 4))
-#endif
-#ifdef TARGET_RISCV
-
-/*
- * get_user_ual is defined as get_user_u32 in softmmu-semi.h,
- * we need a macro that fetches a target_ulong
- */
-#define get_user_utl(arg, p) \
- ((sizeof(target_ulong) == 8) ? \
- get_user_u64(arg, p) : \
- get_user_u32(arg, p))
-
-/*
- * put_user_ual is defined as put_user_u32 in softmmu-semi.h,
- * we need a macro that stores a target_ulong
- */
-#define put_user_utl(arg, p) \
- ((sizeof(target_ulong) == 8) ? \
- put_user_u64(arg, p) : \
- put_user_u32(arg, p))
-
-#define GET_ARG(n) do { \
- if (get_user_utl(arg ## n, args + (n) * sizeof(target_ulong))) { \
- errno = EFAULT; \
- return set_swi_errno(cs, -1); \
- } \
- } while (0)
-
-#define SET_ARG(n, val) \
- put_user_utl(val, args + (n) * sizeof(target_ulong))
-#endif
/*
* Do a semihosting call.
--
2.20.1
- [PULL for 6.0 00/22] various fixes (kernel-doc, semihosting, testing), Alex Bennée, 2021/03/24
- [PULL 01/22] scripts/kernel-doc: strip QEMU_ from function definitions, Alex Bennée, 2021/03/24
- [PULL 02/22] docs/devel: include the plugin API information from the headers, Alex Bennée, 2021/03/24
- [PULL 03/22] docs/devel: expand style section of memory management, Alex Bennée, 2021/03/24
- [PULL 04/22] tools/virtiofsd: include --socket-group in help, Alex Bennée, 2021/03/24
- [PULL 07/22] semihosting/arm-compat-semi: don't use SET_ARG to report SYS_HEAPINFO, Alex Bennée, 2021/03/24
- [PULL 05/22] semihosting: move semihosting tests to multiarch, Alex Bennée, 2021/03/24
- [PULL 06/22] semihosting/arm-compat-semi: unify GET/SET_ARG helpers,
Alex Bennée <=
- [PULL 11/22] configure: Don't use the __atomic_*_16 functions for testing 128-bit support, Alex Bennée, 2021/03/24
- [PULL 13/22] utils: Tighter tests for qemu_strtosz, Alex Bennée, 2021/03/24
- [PULL 10/22] gitlab-ci.yml: Merge the trace-backend testing into other jobs, Alex Bennée, 2021/03/24
- [PULL 08/22] linux-user/riscv: initialise the TaskState heap/stack info, Alex Bennée, 2021/03/24
- [PULL 14/22] utils: Work around mingw strto*l bug with 0x, Alex Bennée, 2021/03/24
- [PULL 12/22] cirrus.yml: Update the FreeBSD task to version 12.2, Alex Bennée, 2021/03/24
- [PULL 09/22] tests/tcg: add HeapInfo checking to semihosting test, Alex Bennée, 2021/03/24
- [PULL 18/22] blockdev: with -drive if=virtio, use generic virtio-blk, Alex Bennée, 2021/03/24
- [PULL 20/22] iotests: test m68k with the virt machine, Alex Bennée, 2021/03/24
- [PULL 16/22] qdev: define list of archs with virtio-pci or virtio-ccw, Alex Bennée, 2021/03/24