cpu_sh4_is_cached() is the single user-emulation helper:
move the function to its own file and simplify the #ifdef'ry.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
Based-on: <20211006172307.780893-1-richard.henderson@linaro.org>
---
target/sh4/{helper.c => helper_system.c} | 15 +------------
target/sh4/helper_user.c | 28 ++++++++++++++++++++++++
target/sh4/meson.build | 10 +++++++--
3 files changed, 37 insertions(+), 16 deletions(-)
rename target/sh4/{helper.c => helper_system.c} (98%)
create mode 100644 target/sh4/helper_user.c
diff --git a/target/sh4/helper.c b/target/sh4/helper_system.c
similarity index 98%
rename from target/sh4/helper.c
rename to target/sh4/helper_system.c
index 6a620e36fc3..077b3dd8de5 100644
--- a/target/sh4/helper.c
+++ b/target/sh4/helper_system.c
@@ -1,5 +1,5 @@
/*
- * SH4 emulation
+ * SH4 system emulation helpers
*
* Copyright (c) 2005 Samuel Tardieu
*
@@ -23,10 +23,8 @@
#include "exec/exec-all.h"
#include "exec/log.h"
-#if !defined(CONFIG_USER_ONLY)
#include "hw/sh4/sh_intc.h"
#include "sysemu/runstate.h"
-#endif
#define MMU_OK 0
#define MMU_ITLB_MISS (-1)
@@ -43,16 +41,6 @@
#define MMU_DADDR_ERROR_READ (-12)
#define MMU_DADDR_ERROR_WRITE (-13)
-#if defined(CONFIG_USER_ONLY)
-
-int cpu_sh4_is_cached(CPUSH4State *env, target_ulong addr)
-{
- /* For user mode, only U0 area is cacheable. */
- return !(addr & 0x80000000);
-}
-
-#else /* !CONFIG_USER_ONLY */
-
void superh_cpu_do_interrupt(CPUState *cs)
{
SuperHCPU *cpu = SUPERH_CPU(cs);
@@ -860,4 +848,3 @@ bool superh_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
}
cpu_loop_exit_restore(cs, retaddr);
}
-#endif /* !CONFIG_USER_ONLY */
diff --git a/target/sh4/helper_user.c b/target/sh4/helper_user.c
new file mode 100644
index 00000000000..b6eba9d085c
--- /dev/null
+++ b/target/sh4/helper_user.c
@@ -0,0 +1,28 @@
+/*
+ * SH4 user emulation helpers
+ *
+ * Copyright (c) 2005 Samuel Tardieu
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "qemu/osdep.h"
+
+#include "cpu.h"
+
+int cpu_sh4_is_cached(CPUSH4State *env, target_ulong addr)
+{
+ /* For user mode, only U0 area is cacheable. */
+ return !(addr & 0x80000000);
+}
diff --git a/target/sh4/meson.build b/target/sh4/meson.build
index 56a57576da7..bbf2bb8aa03 100644
--- a/target/sh4/meson.build
+++ b/target/sh4/meson.build
@@ -2,13 +2,19 @@
sh4_ss.add(files(
'cpu.c',
'gdbstub.c',
- 'helper.c',
'op_helper.c',
'translate.c',
))
+sh4_user_ss = ss.source_set()
+sh4_user_ss.add(files('helper_user.c'))
+
sh4_softmmu_ss = ss.source_set()
-sh4_softmmu_ss.add(files('monitor.c'))
+sh4_softmmu_ss.add(files(
+ 'monitor.c',
+ 'helper_system.c',
+))
target_arch += {'sh4': sh4_ss}
target_softmmu_arch += {'sh4': sh4_softmmu_ss}
+target_user_arch += {'sh4': sh4_user_ss}
--
2.31.1