[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PATCH v7 08/13] target-ppc: Introduce PowerPC specific CPU c
From: |
Bharata B Rao |
Subject: |
[Qemu-ppc] [PATCH v7 08/13] target-ppc: Introduce PowerPC specific CPU core device |
Date: |
Thu, 28 Jan 2016 11:19:50 +0530 |
CPU core device is a container of CPU thread devices. CPU hotplug is
performed at the granularity of CPU core device. When hotplugged, CPU core
creates CPU thread devices.
Signed-off-by: Bharata B Rao <address@hidden>
---
hw/ppc/Makefile.objs | 1 +
hw/ppc/cpu-core.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++
include/hw/ppc/cpu-core.h | 33 +++++++++++++++++++++
3 files changed, 109 insertions(+)
create mode 100644 hw/ppc/cpu-core.c
create mode 100644 include/hw/ppc/cpu-core.h
diff --git a/hw/ppc/Makefile.objs b/hw/ppc/Makefile.objs
index c1ffc77..a6b7cfb 100644
--- a/hw/ppc/Makefile.objs
+++ b/hw/ppc/Makefile.objs
@@ -21,3 +21,4 @@ obj-$(CONFIG_E500) += e500.o mpc8544ds.o e500plat.o
obj-$(CONFIG_E500) += mpc8544_guts.o ppce500_spin.o
# PowerPC 440 Xilinx ML507 reference board.
obj-$(CONFIG_XILINX) += virtex_ml507.o
+obj-y += cpu-core.o
diff --git a/hw/ppc/cpu-core.c b/hw/ppc/cpu-core.c
new file mode 100644
index 0000000..aa96e79
--- /dev/null
+++ b/hw/ppc/cpu-core.c
@@ -0,0 +1,75 @@
+/*
+ * PowerPC CPU core device, acts as container of CPU thread devices.
+ *
+ * Copyright (C) 2016 Bharata B Rao <address@hidden>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#include "hw/ppc/cpu-core.h"
+#include "hw/boards.h"
+#include <sysemu/cpus.h>
+#include "qemu/error-report.h"
+
+static int ppc_cpu_core_realize_child(Object *child, void *opaque)
+{
+ Error **errp = opaque;
+
+ object_property_set_bool(child, true, "realized", errp);
+ if (*errp) {
+ return 1;
+ }
+
+ return 0;
+}
+
+static void ppc_cpu_core_realize(DeviceState *dev, Error **errp)
+{
+ object_child_foreach(OBJECT(dev), ppc_cpu_core_realize_child, errp);
+}
+
+static void ppc_cpu_core_class_init(ObjectClass *oc, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(oc);
+
+ dc->realize = ppc_cpu_core_realize;
+ dc->desc = "PowerPC CPU core";
+}
+
+static void ppc_cpu_core_instance_init(Object *obj)
+{
+ int i;
+ CPUState *cpu;
+ MachineState *machine = MACHINE(qdev_get_machine());
+ PowerPCCPUCore *core = POWERPC_CPU_CORE(obj);
+
+ /* Create as many CPU threads as specified in the topology */
+ for (i = 0; i < smp_threads; i++) {
+ cpu = cpu_generic_init(TYPE_POWERPC_CPU, machine->cpu_model);
+ if (!cpu) {
+ error_report("Unable to find CPU definition: %s",
+ machine->cpu_model);
+ exit(EXIT_FAILURE);
+ }
+ object_property_add_child(obj, "thread[*]", OBJECT(cpu), &error_abort);
+ object_unref(OBJECT(cpu));
+ if (!i) {
+ core->thread0 = POWERPC_CPU(cpu);
+ }
+ }
+}
+
+static const TypeInfo ppc_cpu_core_type_info = {
+ .name = TYPE_POWERPC_CPU_CORE,
+ .parent = TYPE_DEVICE,
+ .class_init = ppc_cpu_core_class_init,
+ .instance_init = ppc_cpu_core_instance_init,
+ .instance_size = sizeof(PowerPCCPUCore),
+};
+
+static void cpu_core_register_types(void)
+{
+ type_register_static(&ppc_cpu_core_type_info);
+}
+
+type_init(cpu_core_register_types)
diff --git a/include/hw/ppc/cpu-core.h b/include/hw/ppc/cpu-core.h
new file mode 100644
index 0000000..ff2ebc2
--- /dev/null
+++ b/include/hw/ppc/cpu-core.h
@@ -0,0 +1,33 @@
+/*
+ * CPU core device.
+ *
+ * Copyright (C) 2016 Bharata B Rao <address@hidden>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#ifndef HW_PPC_CPU_CORE_H
+#define HW_PPC_CPU_CORE_H
+
+#include "hw/qdev.h"
+
+#ifdef TARGET_PPC64
+#define TYPE_POWERPC_CPU_CORE "powerpc64-cpu-core"
+#elif defined(TARGET_PPCEMB)
+#define TYPE_POWERPC_CPU_CORE "embedded-powerpc-cpu-core"
+#else
+#define TYPE_POWERPC_CPU_CORE "powerpc-cpu-core"
+#endif
+
+#define POWERPC_CPU_CORE(obj) \
+ OBJECT_CHECK(PowerPCCPUCore, (obj), TYPE_POWERPC_CPU_CORE)
+
+typedef struct PowerPCCPUCore {
+ /*< private >*/
+ DeviceState parent_obj;
+ /*< public >*/
+
+ PowerPCCPU *thread0;
+} PowerPCCPUCore;
+
+#endif
--
2.1.0
- Re: [Qemu-ppc] [PATCH v7 01/13] machine: Don't allow CPU toplogies with partially filled cores, (continued)
[Qemu-ppc] [PATCH v7 02/13] exec: Remove cpu from cpus list during cpu_exec_exit(), Bharata B Rao, 2016/01/28
[Qemu-ppc] [PATCH v7 04/13] cpu: Don't realize CPU from cpu_generic_init(), Bharata B Rao, 2016/01/28
[Qemu-ppc] [PATCH v7 06/13] cpu: Add a sync version of cpu_remove(), Bharata B Rao, 2016/01/28
[Qemu-ppc] [PATCH v7 05/13] cpu: Reclaim vCPU objects, Bharata B Rao, 2016/01/28
[Qemu-ppc] [PATCH v7 07/13] xics, xics_kvm: Handle CPU unplug correctly, Bharata B Rao, 2016/01/28
[Qemu-ppc] [PATCH v7 08/13] target-ppc: Introduce PowerPC specific CPU core device,
Bharata B Rao <=
[Qemu-ppc] [PATCH v7 10/13] spapr: CPU hotplug support, Bharata B Rao, 2016/01/28
[Qemu-ppc] [PATCH v7 09/13] spapr: Enable CPU hotplug for pseries-2.6 and add CPU DRC DT entries, Bharata B Rao, 2016/01/28
[Qemu-ppc] [PATCH v7 11/13] spapr: CPU hot unplug support, Bharata B Rao, 2016/01/28
[Qemu-ppc] [PATCH v7 12/13] qmp: Add query-ppc-cpu-cores command, Bharata B Rao, 2016/01/28