[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH RFC 4/5] xen: implement Xen PV target
From: |
Wei Liu |
Subject: |
[Qemu-devel] [PATCH RFC 4/5] xen: implement Xen PV target |
Date: |
Thu, 23 Jan 2014 22:16:05 +0000 |
Basically it's a dummy CPU that doens't do anything. This patch contains
necessary hooks to make QEMU compile.
Signed-off-by: Wei Liu <address@hidden>
---
arch_init.c | 2 ++
cpu-exec.c | 2 ++
include/sysemu/arch_init.h | 1 +
target-xenpv/Makefile.objs | 1 +
target-xenpv/cpu-qom.h | 64 ++++++++++++++++++++++++++++++++++++++++++
target-xenpv/cpu.h | 66 ++++++++++++++++++++++++++++++++++++++++++++
target-xenpv/helper.c | 32 +++++++++++++++++++++
target-xenpv/translate.c | 27 ++++++++++++++++++
8 files changed, 195 insertions(+)
create mode 100644 target-xenpv/Makefile.objs
create mode 100644 target-xenpv/cpu-qom.h
create mode 100644 target-xenpv/cpu.h
create mode 100644 target-xenpv/helper.c
create mode 100644 target-xenpv/helper.h
create mode 100644 target-xenpv/translate.c
diff --git a/arch_init.c b/arch_init.c
index 2935426..41041d5 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -101,6 +101,8 @@ int graphic_depth = 32;
#define QEMU_ARCH QEMU_ARCH_XTENSA
#elif defined(TARGET_UNICORE32)
#define QEMU_ARCH QEMU_ARCH_UNICORE32
+#elif defined(TARGET_XENPV)
+#define QEMU_ARCH QEMU_ARCH_XENPV
#endif
const uint32_t arch_type = QEMU_ARCH;
diff --git a/cpu-exec.c b/cpu-exec.c
index b744a1f..c86c383 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -255,6 +255,7 @@ int cpu_exec(CPUArchState *env)
#elif defined(TARGET_CRIS)
#elif defined(TARGET_S390X)
#elif defined(TARGET_XTENSA)
+#elif defined(TARGET_XENPV)
/* XXXXX */
#else
#error unsupported target CPU
@@ -710,6 +711,7 @@ int cpu_exec(CPUArchState *env)
#elif defined(TARGET_CRIS)
#elif defined(TARGET_S390X)
#elif defined(TARGET_XTENSA)
+#elif defined(TARGET_XENPV)
/* XXXXX */
#else
#error unsupported target CPU
diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h
index be71bca..66ea63f 100644
--- a/include/sysemu/arch_init.h
+++ b/include/sysemu/arch_init.h
@@ -22,6 +22,7 @@ enum {
QEMU_ARCH_OPENRISC = 8192,
QEMU_ARCH_UNICORE32 = 0x4000,
QEMU_ARCH_MOXIE = 0x8000,
+ QEMU_ARCH_XENPV = 0x10000,
};
extern const uint32_t arch_type;
diff --git a/target-xenpv/Makefile.objs b/target-xenpv/Makefile.objs
new file mode 100644
index 0000000..ae3cad5
--- /dev/null
+++ b/target-xenpv/Makefile.objs
@@ -0,0 +1 @@
+obj-$(CONFIG_TCG) += helper.o translate.o
diff --git a/target-xenpv/cpu-qom.h b/target-xenpv/cpu-qom.h
new file mode 100644
index 0000000..61135a6
--- /dev/null
+++ b/target-xenpv/cpu-qom.h
@@ -0,0 +1,64 @@
+/*
+ * QEMU XenPV CPU
+ *
+ * Copyright (c) 2014 Citrix Systems UK Ltd
+ *
+ * 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/lgpl-2.1.html>
+ */
+#ifndef QEMU_XENPV_CPU_QOM_H
+#define QEMU_XENPV_CPU_QOM_H
+
+#include "qom/cpu.h"
+#include "cpu.h"
+#include "qapi/error.h"
+
+#define TYPE_XENPV_CPU "xenpv-cpu"
+
+/**
+ * XenPVCPUClass:
+ * @parent_realize: The parent class' realize handler.
+ * @parent_reset: The parent class' reset handler.
+ *
+ */
+typedef struct XenPVCPUClass {
+ /*< private >*/
+ CPUClass parent_class;
+ /*< public >*/
+
+ DeviceRealize parent_realize;
+ void (*parent_reset)(CPUState *cpu);
+} XenPVCPUClass;
+
+/**
+ * XenPVCPU:
+ * @env: #CPUXenPVState
+ *
+ */
+typedef struct XenPVCPU {
+ /*< private >*/
+ CPUState parent_obj;
+ /*< public >*/
+ CPUXenPVState env;
+} XenPVCPU;
+
+static inline XenPVCPU *noarch_env_get_cpu(CPUXenPVState *env)
+{
+ return container_of(env, XenPVCPU, env);
+}
+
+#define ENV_GET_CPU(e) CPU(noarch_env_get_cpu(e))
+
+#endif
+
diff --git a/target-xenpv/cpu.h b/target-xenpv/cpu.h
new file mode 100644
index 0000000..0e65707
--- /dev/null
+++ b/target-xenpv/cpu.h
@@ -0,0 +1,66 @@
+/*
+ * XenPV virtual CPU header
+ *
+ * Copyright (c) 2014 Citrix Systems UK Ltd
+ *
+ * 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 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/>.
+ */
+#ifndef CPU_XENPV_H
+#define CPU_XENPV_H
+
+#include "config.h"
+#include "qemu-common.h"
+
+#define TARGET_LONG_BITS 64
+#define TARGET_PAGE_BITS 12
+#define TARGET_PHYS_ADDR_SPACE_BITS 52
+#define TARGET_VIRT_ADDR_SPACE_BITS 47
+#define NB_MMU_MODES 1
+
+#define CPUArchState struct CPUXenPVState
+
+#include "exec/cpu-defs.h"
+
+typedef struct CPUXenPVState {
+ CPU_COMMON
+} CPUXenPVState;
+
+#include "cpu-qom.h"
+
+static inline int cpu_mmu_index (CPUXenPVState *env)
+{
+ abort();
+}
+
+static inline void cpu_get_tb_cpu_state(CPUXenPVState *env, target_ulong *pc,
+ target_ulong *cs_base, int *flags)
+{
+ abort();
+}
+
+static inline bool cpu_has_work(CPUState *cs)
+{
+ abort();
+ return false;
+}
+
+int cpu_xenpv_exec(CPUXenPVState *s);
+#define cpu_exec cpu_xenpv_exec
+
+#include "exec/cpu-all.h"
+
+#include "exec/exec-all.h"
+
+#endif /* CPU_XENPV_H */
+
diff --git a/target-xenpv/helper.c b/target-xenpv/helper.c
new file mode 100644
index 0000000..225a063
--- /dev/null
+++ b/target-xenpv/helper.c
@@ -0,0 +1,32 @@
+#include "cpu.h"
+#include "helper.h"
+#if !defined(CONFIG_USER_ONLY)
+#include "exec/softmmu_exec.h"
+#endif
+
+#if !defined(CONFIG_USER_ONLY)
+
+#define MMUSUFFIX _mmu
+
+#define SHIFT 0
+#include "exec/softmmu_template.h"
+
+#define SHIFT 1
+#include "exec/softmmu_template.h"
+
+#define SHIFT 2
+#include "exec/softmmu_template.h"
+
+#define SHIFT 3
+#include "exec/softmmu_template.h"
+
+#endif
+
+#if !defined(CONFIG_USER_ONLY)
+void tlb_fill(CPUXenPVState *env, target_ulong addr, int is_write,
+ int mmu_idx, uintptr_t retaddr)
+{
+ abort();
+}
+#endif
+
diff --git a/target-xenpv/helper.h b/target-xenpv/helper.h
new file mode 100644
index 0000000..e69de29
diff --git a/target-xenpv/translate.c b/target-xenpv/translate.c
new file mode 100644
index 0000000..4bc84e5
--- /dev/null
+++ b/target-xenpv/translate.c
@@ -0,0 +1,27 @@
+#include <inttypes.h>
+#include "qemu/host-utils.h"
+#include "cpu.h"
+#include "disas/disas.h"
+#include "tcg-op.h"
+
+#include "helper.h"
+#define GEN_HELPER 1
+#include "helper.h"
+
+void gen_intermediate_code(CPUXenPVState *env, TranslationBlock *tb)
+{
+ abort();
+}
+
+void gen_intermediate_code_pc(CPUXenPVState *env, TranslationBlock *tb)
+{
+ abort();
+}
+
+void restore_state_to_opc(CPUXenPVState *env, TranslationBlock *tb,
+ int pc_pos)
+{
+ abort();
+}
+
+
--
1.7.10.4
- [Qemu-devel] [PATCH RFC 0/5] Xen: introduce Xen PV target, Wei Liu, 2014/01/23
- [Qemu-devel] [PATCH RFC 4/5] xen: implement Xen PV target,
Wei Liu <=
- [Qemu-devel] [PATCH RFC 2/5] xen: factor out common functions, Wei Liu, 2014/01/23
- [Qemu-devel] [PATCH RFC 1/5] xen: move Xen PV machine files to hw/xenpv, Wei Liu, 2014/01/23
- [Qemu-devel] [PATCH RFC 3/5] exec: guard Xen HVM hooks with CONFIG_XEN_I386, Wei Liu, 2014/01/23
- [Qemu-devel] [PATCH RFC 5/5] xen: introduce xenpv-softmmu.mak, Wei Liu, 2014/01/23
- Re: [Qemu-devel] [PATCH RFC 0/5] Xen: introduce Xen PV target, Peter Maydell, 2014/01/23