From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60044) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YrhIT-0008F2-KO for qemu-devel@nongnu.org; Mon, 11 May 2015 02:34:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YrhDq-0002xa-SD for qemu-devel@nongnu.org; Mon, 11 May 2015 02:29:52 -0400 Received: from mail-pd0-x229.google.com ([2607:f8b0:400e:c02::229]:33063) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YrhDq-0002xQ-Gr for qemu-devel@nongnu.org; Mon, 11 May 2015 02:29:50 -0400 Received: by pdbnk13 with SMTP id nk13so138828011pdb.0 for ; Sun, 10 May 2015 23:29:49 -0700 (PDT) From: Peter Crosthwaite Date: Sun, 10 May 2015 23:29:06 -0700 Message-Id: In-Reply-To: References: In-Reply-To: References: Subject: [Qemu-devel] [RFC PATCH 03/34] target-multi: Add List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, edgari@xilinx.com, sorenb@xilinx.com, afaerber@suse.de, rth@twiddle.net 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 --- 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 diff --git a/Makefile.target b/Makefile.target index 1083377..3e5a4f9 100644 --- a/Makefile.target +++ b/Makefile.target @@ -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 diff --git a/arch_init.c b/arch_init.c index 4c8fcee..7479eae 100644 --- a/arch_init.c +++ b/arch_init.c @@ -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 diff --git a/configure b/configure index 255d85b..270a87c 100755 --- a/configure +++ b/configure @@ -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 diff --git a/default-configs/multi-softmmu.mak b/default-configs/multi-softmmu.mak new file mode 100644 index 0000000..f76eb8f --- /dev/null +++ b/default-configs/multi-softmmu.mak @@ -0,0 +1,3 @@ + +include microblazeel-softmmu.mak +include aarch64-softmmu.mak diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h index 54b36c1..c539dec 100644 --- a/include/sysemu/arch_init.h +++ b/include/sysemu/arch_init.h @@ -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; diff --git a/target-multi/Makefile.objs b/target-multi/Makefile.objs new file mode 100644 index 0000000..4406ab9 --- /dev/null +++ b/target-multi/Makefile.objs @@ -0,0 +1 @@ +obj-y += translate.o diff --git a/target-multi/cpu-head.h b/target-multi/cpu-head.h new file mode 100644 index 0000000..fb6628e --- /dev/null +++ b/target-multi/cpu-head.h @@ -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 */ diff --git a/target-multi/cpu.h b/target-multi/cpu.h new file mode 100644 index 0000000..b4d439a --- /dev/null +++ b/target-multi/cpu.h @@ -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 diff --git a/target-multi/helper.h b/target-multi/helper.h new file mode 100644 index 0000000..e69de29 diff --git a/target-multi/translate.c b/target-multi/translate.c new file mode 100644 index 0000000..58a6e4d --- /dev/null +++ b/target-multi/translate.c @@ -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"); +} diff --git a/target-multi/translate.h b/target-multi/translate.h new file mode 100644 index 0000000..d86c9eb --- /dev/null +++ b/target-multi/translate.h @@ -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 -- 1.9.1