aboutsummaryrefslogtreecommitdiff
path: root/semihosting
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2022-04-28 11:40:14 -0700
committerRichard Henderson <richard.henderson@linaro.org>2022-06-28 04:35:27 +0530
commit3753b00e5747068882c7f0302dcf9b87402993ab (patch)
tree7f6128b2c3a00f5c93df85782fbbbde09b96a322 /semihosting
parent189878ae237d443571250f76655161d91c018889 (diff)
semihosting: Move GET_ARG/SET_ARG earlier in the file
Moving this to be useful for another function besides do_common_semihosting. Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'semihosting')
-rw-r--r--semihosting/arm-compat-semi.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c
index adb4e5b581..72a1350512 100644
--- a/semihosting/arm-compat-semi.c
+++ b/semihosting/arm-compat-semi.c
@@ -182,6 +182,30 @@ static LayoutInfo common_semi_find_bases(CPUState *cs)
#include "common-semi-target.h"
/*
+ * 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.
+ */
+
+#define GET_ARG(n) do { \
+ if (is_64bit_semihosting(env)) { \
+ if (get_user_u64(arg ## n, args + (n) * 8)) { \
+ goto do_fault; \
+ } \
+ } else { \
+ if (get_user_u32(arg ## n, args + (n) * 4)) { \
+ goto do_fault; \
+ } \
+ } \
+} while (0)
+
+#define SET_ARG(n, val) \
+ (is_64bit_semihosting(env) ? \
+ put_user_u64(val, args + (n) * 8) : \
+ put_user_u32(val, args + (n) * 4))
+
+
+/*
* The semihosting API has no concept of its errno being thread-safe,
* as the API design predates SMP CPUs and was intended as a simple
* real-hardware set of debug functionality. For QEMU, we make the
@@ -508,30 +532,6 @@ static const GuestFDFunctions guestfd_fns[] = {
};
/*
- * 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.
- */
-
-#define GET_ARG(n) do { \
- if (is_64bit_semihosting(env)) { \
- if (get_user_u64(arg ## n, args + (n) * 8)) { \
- goto do_fault; \
- } \
- } else { \
- if (get_user_u32(arg ## n, args + (n) * 4)) { \
- goto do_fault; \
- } \
- } \
-} while (0)
-
-#define SET_ARG(n, val) \
- (is_64bit_semihosting(env) ? \
- put_user_u64(val, args + (n) * 8) : \
- put_user_u32(val, args + (n) * 4))
-
-
-/*
* Do a semihosting call.
*
* The specification always says that the "return register" either