Skip to contentSkip to conversation

QOM'ify SPARC CPU

PATCH New Andreas Färber 1 participant 3 messages Apr 4, 2012 Kbuild

v2 of 3 New Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover QOM'ify SPARC CPU

Hello Blue,

This series strips down my SPARC QOM'ification patch from the qom-cpu-others.v1 RFC series to the bare minimum needed and splits off the file rename.

Subclasses and properties can follow up later, specific to target-sparc then.

I've picked up your idea of using different type names for 32-bit and 64-bit targets respectively.

Please apply if you're satisfied, there's no dependency on the x86 series.

Available from:
git://github.com/afaerber/qemu-cpu.git qom-cpu-sparc.v2
https://github.com/afaerber/qemu-cpu/commits/qom-cpu-sparc.v2

Regards,
Andreas

Cc Blue Swirl <[email protected]>

v1 -> v2:
* Split off from qom-cpu-others series.
* Rebased onto qemu.git, no longer depends on other targets wrt Makefile.target.
* Split out file rename into its own patch (and enforce git rename detection).
* Update argument/variable naming to avoid "klass" and to use ..._type_info.
* Drop subclasses for now, thus leave TYPE_SPARC_CPU non-abstract and add finalizer.
* Rename TYPE_SPARC_CPU to "sparc64-cpu" for TARGET_SPARC64, suggested by Blue.

Andreas Färber (2):
target-sparc: Rename cpu_init.c
target-sparc: QOM'ify CPU

 Makefile.target                    |    2 +-
 target-sparc/cpu-qom.h             |   75 ++++++++++++++++++++++++++++++++++++
 target-sparc/{cpu_init.c => cpu.c} |   68 ++++++++++++++++++++++++++++----
 target-sparc/cpu.h                 |    1 +
 4 files changed, 136 insertions(+), 10 deletions(-)
 create mode 100644 target-sparc/cpu-qom.h
 rename target-sparc/{cpu_init.c => cpu.c} (95%)
Signature · 1 line
1.7.7
#1 lore raw

PATCH v2 1/2 target-sparc: Rename cpu_init.c

Align QOM'ified targets, with a view to simplify Makefile.target.

---
 Makefile.target                    |    2 +-
 target-sparc/{cpu_init.c => cpu.c} |    0
 2 files changed, 1 insertions(+), 1 deletions(-)
 rename target-sparc/{cpu_init.c => cpu.c} (100%)
Makefile.target +1 -1
index 6c4a77a..1110796 100644
@@ -96,7 +96,7 @@ libobj-$(TARGET_ARM) += cpu.o
 libobj-$(TARGET_S390X) += cpu.o
 ifeq ($(TARGET_BASE_ARCH), sparc)
 libobj-y += fop_helper.o cc_helper.o win_helper.o mmu_helper.o ldst_helper.o
-libobj-y += cpu_init.o
+libobj-y += cpu.o
 endif
 libobj-$(TARGET_SPARC) += int32_helper.o
 libobj-$(TARGET_SPARC64) += int64_helper.o
target-sparc/cpu.c renamed from target-sparc/cpu_init.c +0 -0
similarity index 100%
rename from target-sparc/cpu_init.c
rename to target-sparc/cpu.c
Signature · 1 line
1.7.7
#2 lore raw

PATCH v2 2/2 target-sparc: QOM'ify CPU

In reply to Andreas Färber

Embed CPUSPARCState as first member of SPARCCPU.
Drop cpu_sparc_close() in favor of object_delete() and a finalizer. Let cpu_state_reset() call cpu_reset().

Make TYPE_SPARC_CPU non-abstract for now. Distinguish between "sparc-cpu" and "sparc64-cpu".

---
 target-sparc/cpu-qom.h |   75 ++++++++++++++++++++++++++++++++++++++++++++++++
 target-sparc/cpu.c     |   68 +++++++++++++++++++++++++++++++++++++------
 target-sparc/cpu.h     |    1 +
 3 files changed, 135 insertions(+), 9 deletions(-)
 create mode 100644 target-sparc/cpu-qom.h
target-sparc/cpu-qom.h new file +75 -0
new file mode 100644
index 0000000..3d3ac0f
@@ -0,0 +1,75 @@
+/*
+ * QEMU SPARC CPU
+ *
+ * Copyright (c) 2012 SUSE LINUX Products GmbH
+ *
+ * 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_SPARC_CPU_QOM_H
+#define QEMU_SPARC_CPU_QOM_H
+
+#include "qemu/cpu.h"
+#include "cpu.h"
+
+#ifdef TARGET_SPARC64
+#define TYPE_SPARC_CPU "sparc64-cpu"
+#else
+#define TYPE_SPARC_CPU "sparc-cpu"
+#endif
+
+#define SPARC_CPU_CLASS(klass) \
+    OBJECT_CLASS_CHECK(SPARCCPUClass, (klass), TYPE_SPARC_CPU)
+#define SPARC_CPU(obj) \
+    OBJECT_CHECK(SPARCCPU, (obj), TYPE_SPARC_CPU)
+#define SPARC_CPU_GET_CLASS(obj) \
+    OBJECT_GET_CLASS(SPARCCPUClass, (obj), TYPE_SPARC_CPU)
+
+/**
+ * SPARCCPUClass:
+ * @parent_reset: The parent class' reset handler.
+ *
+ * A SPARC CPU model.
+ */
+typedef struct SPARCCPUClass {
+    /*< private >*/
+    CPUClass parent_class;
+    /*< public >*/
+
+    void (*parent_reset)(CPUState *cpu);
+} SPARCCPUClass;
+
+/**
+ * SPARCCPU:
+ * @env: #CPUSPARCState
+ *
+ * A SPARC CPU.
+ */
+typedef struct SPARCCPU {
+    /*< private >*/
+    CPUState parent_obj;
+    /*< public >*/
+
+    CPUSPARCState env;
+} SPARCCPU;
+
+static inline SPARCCPU *sparc_env_get_cpu(CPUSPARCState *env)
+{
+    return SPARC_CPU(container_of(env, SPARCCPU, env));
+}
+
+#define ENV_GET_CPU(e) CPU(sparc_env_get_cpu(e))
+
+
+#endif
target-sparc/cpu.c +59 -9

96 lines not on this page · raw message

target-sparc/cpu.h +1 -0
index 885ad45..865288c 100644
@@ -691,6 +691,7 @@ static inline void cpu_clone_regs(CPUSPARCState *env, target_ulong newsp)
 #endif
 
 #include "cpu-all.h"
+#include "cpu-qom.h"
 
 #ifdef TARGET_SPARC64
 /* sun4u.c */
Signature · 1 line
1.7.7