@@ -11,6 +11,11 @@ QEMU_CFLAGS += -I../linux-headers
endif
QEMU_CFLAGS += -I.. -I$(SRC_PATH)/target-$(TARGET_BASE_ARCH) -DNEED_CPU_H
+ARCH_DIRS = $(TARGET_BASE_ARCH)
+ifeq ($(TARGET_BASE_ARCH), multi)
+ARCH_DIRS +=
+endif
+
QEMU_CFLAGS+=-I$(SRC_PATH)/include
ifdef CONFIG_USER_ONLY
@@ -87,7 +92,8 @@ obj-y += tcg/tcg.o tcg/tcg-op.o tcg/optimize.o
obj-$(CONFIG_TCG_INTERPRETER) += tci.o
obj-$(CONFIG_TCG_INTERPRETER) += disas/tci.o
obj-y += fpu/softfloat.o
-obj-y += target-$(TARGET_BASE_ARCH)/
+obj-y += $(foreach a, $(ARCH_DIRS), target-$(a)/)
+obj-$(CONFIG_ARCH_MULTI) += target-multi/
obj-y += disas.o
obj-$(call notempty,$(TARGET_XML_FILES)) += gdbstub-xml.o
obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
@@ -146,7 +152,7 @@ obj-$(call lnot,$(CONFIG_XEN_I386)) += xen-hvm-stub.o
ifeq ($(TARGET_NAME), sparc64)
obj-y += hw/sparc64/
else
-obj-y += hw/$(TARGET_BASE_ARCH)/
+obj-y += $(foreach a, $(ARCH_DIRS), hw/$(a)/)
endif
GENERATED_HEADERS += hmp-commands.h qmp-commands-old.h
@@ -73,7 +73,9 @@ int graphic_depth = 32;
#endif
-#if defined(TARGET_ALPHA)
+#if defined(TARGET_MULTI)
+#define QEMU_ARCH QEMU_ARCH_MULTI
+#elif defined(TARGET_ALPHA)
#define QEMU_ARCH QEMU_ARCH_ALPHA
#elif defined(TARGET_ARM)
#define QEMU_ARCH QEMU_ARCH_ARM
@@ -5195,6 +5195,9 @@ case "$target_name" in
;;
moxie)
;;
+ multi)
+ bflt="yes"
+ ;;
or32)
TARGET_ARCH=openrisc
TARGET_BASE_ARCH=openrisc
@@ -5277,6 +5280,10 @@ if [ "$HOST_VARIANT_DIR" != "" ]; then
echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
fi
case "$target_name" in
+ multi)
+ MULTI_TARGETS=""
+esac
+case "$target_name" in
i386|x86_64)
if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
echo "CONFIG_XEN=y" >> $config_target_mak
@@ -5343,7 +5350,12 @@ fi
cflags=""
ldflags=""
-for i in $ARCH $TARGET_BASE_ARCH ; do
+for i in $MULTI_TARGETS; do
+ i_upper="`upper $i`"
+ echo "TARGET_$i_upper=y" >> $config_target_mak
+done;
+
+for i in $ARCH $TARGET_BASE_ARCH $MULTI_TARGETS; do
case "$i" in
alpha)
echo "CONFIG_ALPHA_DIS=y" >> $config_target_mak
new file mode 100644
@@ -0,0 +1,3 @@
+
+include microblazeel-softmmu.mak
+include aarch64-softmmu.mak
@@ -23,6 +23,7 @@ enum {
QEMU_ARCH_UNICORE32 = (1 << 14),
QEMU_ARCH_MOXIE = (1 << 15),
QEMU_ARCH_TRICORE = (1 << 16),
+ QEMU_ARCH_MULTI = (1 << 17),
};
extern const uint32_t arch_type;
new file mode 100644
@@ -0,0 +1 @@
+obj-y += translate.o
new file mode 100644
@@ -0,0 +1,24 @@
+#ifndef MULTI_CPU_HEAD_H
+#define MULTI_CPU_HEAD_H
+
+#define TARGET_LONG_BITS 64
+
+/* This should be the max of whatever the most demanding architecture
+ * is. Currently, that is ARM with 7 MMU modes.
+ */
+#define NB_MMU_MODES 7
+
+#define TARGET_IS_BIENDIAN 1
+
+#define TARGET_PAGE_BITS 12
+
+#define TARGET_PHYS_ADDR_SPACE_BITS 48
+#define TARGET_VIRT_ADDR_SPACE_BITS 64
+
+#define cpu_get_tb_cpu_state(env, pc, cs_base, flags) \
+ (ENV_GET_CPU(env)->cpu_get_tb_cpu_state(ENV_GET_CPU(env), (pc), \
+ (cs_base), (flags)))
+
+#define cpu_mmu_index(env) (ENV_GET_CPU(env)->cpu_mmu_index(ENV_GET_CPU(env)))
+
+#endif /* MULTI_CPU_HEAD_H */
new file mode 100644
@@ -0,0 +1,40 @@
+#ifndef MULTI_CPU_H
+#define MULTI_CPU_H
+
+#include "config.h"
+#include "qemu-common.h"
+
+#include "cpu-head.h"
+
+#include "exec/cpu-defs.h"
+
+#include "qom/cpu.h"
+
+typedef struct CPUMultiState
+{
+ CPU_COMMON
+} CPUMultiState;
+
+typedef struct MultiCPU
+{
+ /*< private >*/
+ CPUState parent_obj;
+ /*< Public >*/
+ CPUMultiState env;
+} MultiCPU;
+
+#define CPUArchState CPUMultiState
+
+#include "exec/cpu-all.h"
+#include "exec/exec-all.h"
+
+static inline MultiCPU *multi_env_get_cpu(void *env)
+{
+ CPUMultiState *envm = (CPUMultiState *)env;
+
+ return container_of(envm, MultiCPU, env);
+}
+
+#define ENV_GET_CPU(e) CPU(multi_env_get_cpu(e))
+
+#endif
new file mode 100644
new file mode 100644
@@ -0,0 +1,15 @@
+#include "translate.h"
+
+TCGv_ptr cpu_env;
+
+void multi_translate_init(void)
+{
+ static bool inited;
+
+ if (inited) {
+ return;
+ }
+ inited = true;
+
+ cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env");
+}
new file mode 100644
@@ -0,0 +1,10 @@
+#ifndef TARGET_MULTI_TRANSLATE_H
+#define TARGET_MULTI_TRANSLATE_H
+
+#include "tcg/tcg.h"
+
+extern TCGv_ptr cpu_env;
+
+void multi_translate_init(void);
+
+#endif
Create the multi-arch target architecture. The arch can create system mode emulations with multiple target- cpu types. The page size and target long size are fixed based on AArch64 but this forms a superset of the immediately supportable multi-arch CPU targets anyway. All supported arches have their target-foo and hw/foo code compiled. The auto-included cpu.h comes from target-multi/cpu.h which defines the minimal defs needed only by core code only. Each supported arch will also always compile-in target-multi, as supported arches can rely of target-multi code even for single-arch functionality. Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com> --- Makefile.target | 10 ++++++++-- arch_init.c | 4 +++- configure | 14 +++++++++++++- default-configs/multi-softmmu.mak | 3 +++ include/sysemu/arch_init.h | 1 + target-multi/Makefile.objs | 1 + target-multi/cpu-head.h | 24 +++++++++++++++++++++++ target-multi/cpu.h | 40 +++++++++++++++++++++++++++++++++++++++ target-multi/helper.h | 0 target-multi/translate.c | 15 +++++++++++++++ target-multi/translate.h | 10 ++++++++++ 11 files changed, 118 insertions(+), 4 deletions(-) create mode 100644 default-configs/multi-softmmu.mak create mode 100644 target-multi/Makefile.objs create mode 100644 target-multi/cpu-head.h create mode 100644 target-multi/cpu.h create mode 100644 target-multi/helper.h create mode 100644 target-multi/translate.c create mode 100644 target-multi/translate.h