From: "Andreas Färber" <afaerber@suse.de>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Andreas Färber" <afaerber@suse.de>,
"Richard Henderson" <rth@twiddle.net>
Subject: [Qemu-devel] [PATCH RFC 2/4] target-i386: Prepare CPU socket/core abstraction
Date: Mon, 23 Mar 2015 18:32:01 +0100 [thread overview]
Message-ID: <1427131923-4670-3-git-send-email-afaerber@suse.de> (raw)
In-Reply-To: <1427131923-4670-1-git-send-email-afaerber@suse.de>
Short of generic recursive device realization, realize cores and threads
recursively.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/i386/Makefile.objs | 1 +
hw/i386/cpu-core.c | 45 ++++++++++++++++++++++++++++++++++++++++++++
hw/i386/cpu-socket.c | 45 ++++++++++++++++++++++++++++++++++++++++++++
include/hw/i386/cpu-core.h | 26 +++++++++++++++++++++++++
include/hw/i386/cpu-socket.h | 29 ++++++++++++++++++++++++++++
5 files changed, 146 insertions(+)
create mode 100644 hw/i386/cpu-core.c
create mode 100644 hw/i386/cpu-socket.c
create mode 100644 include/hw/i386/cpu-core.h
create mode 100644 include/hw/i386/cpu-socket.h
diff --git a/hw/i386/Makefile.objs b/hw/i386/Makefile.objs
index e058a39..9f76424 100644
--- a/hw/i386/Makefile.objs
+++ b/hw/i386/Makefile.objs
@@ -1,5 +1,6 @@
obj-$(CONFIG_KVM) += kvm/
obj-y += multiboot.o smbios.o
+obj-y += cpu-socket.o cpu-core.o
obj-y += pc.o pc_piix.o pc_q35.o
obj-y += pc_sysfw.o
obj-y += intel_iommu.o
diff --git a/hw/i386/cpu-core.c b/hw/i386/cpu-core.c
new file mode 100644
index 0000000..d579025
--- /dev/null
+++ b/hw/i386/cpu-core.c
@@ -0,0 +1,45 @@
+/*
+ * x86 CPU core abstraction
+ *
+ * Copyright (c) 2015 SUSE Linux GmbH
+ */
+
+#include "hw/i386/cpu-core.h"
+
+static int x86_cpu_core_realize_child(Object *child, void *opaque)
+{
+ Error **errp = opaque;
+ Error *local_err = NULL;
+
+ object_property_set_bool(child, true, "realized", &local_err);
+ error_propagate(errp, local_err);
+
+ return local_err != NULL ? 1 : 0;
+}
+
+static void x86_cpu_core_realize(DeviceState *dev, Error **errp)
+{
+ /* XXX generic */
+ object_child_foreach(OBJECT(dev), x86_cpu_core_realize_child, errp);
+}
+
+static void x86_cpu_core_class_init(ObjectClass *oc, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(oc);
+
+ dc->realize = x86_cpu_core_realize;
+}
+
+static const TypeInfo x86_cpu_core_type_info = {
+ .name = TYPE_X86_CPU_CORE,
+ .parent = TYPE_DEVICE,
+ .instance_size = sizeof(X86CPUCore),
+ .class_init = x86_cpu_core_class_init,
+};
+
+static void x86_cpu_core_register_types(void)
+{
+ type_register_static(&x86_cpu_core_type_info);
+}
+
+type_init(x86_cpu_core_register_types)
diff --git a/hw/i386/cpu-socket.c b/hw/i386/cpu-socket.c
new file mode 100644
index 0000000..dc27400
--- /dev/null
+++ b/hw/i386/cpu-socket.c
@@ -0,0 +1,45 @@
+/*
+ * x86 CPU socket abstraction
+ *
+ * Copyright (c) 2015 SUSE Linux GmbH
+ */
+
+#include "hw/i386/cpu-socket.h"
+
+static int x86_cpu_socket_realize_child(Object *child, void *opaque)
+{
+ Error **errp = opaque;
+ Error *local_err = NULL;
+
+ object_property_set_bool(child, true, "realized", &local_err);
+ error_propagate(errp, local_err);
+
+ return local_err != NULL ? 1 : 0;
+}
+
+static void x86_cpu_socket_realize(DeviceState *dev, Error **errp)
+{
+ /* XXX generic */
+ object_child_foreach(OBJECT(dev), x86_cpu_socket_realize_child, errp);
+}
+
+static void x86_cpu_socket_class_init(ObjectClass *oc, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(oc);
+
+ dc->realize = x86_cpu_socket_realize;
+}
+
+static const TypeInfo x86_cpu_socket_type_info = {
+ .name = TYPE_X86_CPU_SOCKET,
+ .parent = TYPE_CPU_SOCKET,
+ .instance_size = sizeof(X86CPUSocket),
+ .class_init = x86_cpu_socket_class_init,
+};
+
+static void x86_cpu_socket_register_types(void)
+{
+ type_register_static(&x86_cpu_socket_type_info);
+}
+
+type_init(x86_cpu_socket_register_types)
diff --git a/include/hw/i386/cpu-core.h b/include/hw/i386/cpu-core.h
new file mode 100644
index 0000000..be78f95
--- /dev/null
+++ b/include/hw/i386/cpu-core.h
@@ -0,0 +1,26 @@
+/*
+ * x86 CPU core abstraction
+ *
+ * Copyright (c) 2015 SUSE Linux GmbH
+ */
+#ifndef HW_I386_CPU_CORE_H
+#define HW_I386_CPU_CORE_H
+
+#include "hw/qdev.h"
+
+#ifdef TARGET_X86_64
+#define TYPE_X86_CPU_CORE "x86_64-cpu-core"
+#else
+#define TYPE_X86_CPU_CORE "i386-cpu-core"
+#endif
+
+#define X86_CPU_CORE(obj) \
+ OBJECT_CHECK(X86CPUCore, (obj), TYPE_X86_CPU_CORE)
+
+typedef struct X86CPUCore {
+ /*< private >*/
+ DeviceState parent_obj;
+ /*< public >*/
+} X86CPUCore;
+
+#endif
diff --git a/include/hw/i386/cpu-socket.h b/include/hw/i386/cpu-socket.h
new file mode 100644
index 0000000..9fb3ef8
--- /dev/null
+++ b/include/hw/i386/cpu-socket.h
@@ -0,0 +1,29 @@
+/*
+ * x86 CPU socket abstraction
+ *
+ * Copyright (c) 2015 SUSE Linux GmbH
+ */
+#ifndef HW_I386_CPU_SOCKET_H
+#define HW_I386_CPU_SOCKET_H
+
+#include "hw/cpu/socket.h"
+#include "cpu-core.h"
+
+#ifdef TARGET_X86_64
+#define TYPE_X86_CPU_SOCKET "x86_64-cpu-socket"
+#else
+#define TYPE_X86_CPU_SOCKET "i386-cpu-socket"
+#endif
+
+#define X86_CPU_SOCKET(obj) \
+ OBJECT_CHECK(X86CPUSocket, (obj), TYPE_X86_CPU_SOCKET)
+
+typedef struct X86CPUSocket {
+ /*< private >*/
+ DeviceState parent_obj;
+ /*< public >*/
+
+ X86CPUCore core[0];
+} X86CPUSocket;
+
+#endif
--
2.1.4
next prev parent reply other threads:[~2015-03-23 17:32 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-23 17:31 [Qemu-devel] [PATCH RFC 0/4] target-i386: PC socket/core/thread modeling, part 1 Andreas Färber
2015-03-23 17:32 ` [Qemu-devel] [PATCH RFC 1/4] cpu: Prepare Socket container type Andreas Färber
2015-03-23 17:32 ` Andreas Färber [this message]
2015-03-23 17:32 ` [Qemu-devel] [PATCH RFC 3/4] pc: Create sockets and cores for CPUs Andreas Färber
2015-03-25 16:55 ` Bharata B Rao
2015-03-25 17:13 ` Andreas Färber
2015-03-26 2:24 ` Bharata B Rao
2015-03-23 17:32 ` [Qemu-devel] [PATCH RFC 4/4] pc: Create initial CPUs in-place Andreas Färber
2015-03-24 14:33 ` [Qemu-devel] [PATCH RFC 0/4] target-i386: PC socket/core/thread modeling, part 1 Christian Borntraeger
2015-03-26 17:39 ` Igor Mammedov
2015-04-07 12:43 ` [Qemu-devel] cpu modelling and hotplug (was: [PATCH RFC 0/4] target-i386: PC socket/core/thread modeling, part 1) Christian Borntraeger
2015-04-07 15:07 ` Igor Mammedov
2015-04-08 7:07 ` [Qemu-devel] cpu modelling and hotplug Christian Borntraeger
2015-04-23 7:32 ` [Qemu-devel] cpu modelling and hotplug (was: [PATCH RFC 0/4] target-i386: PC socket/core/thread modeling, part 1) David Gibson
2015-04-23 7:37 ` David Gibson
2015-04-23 13:17 ` Eduardo Habkost
2015-04-27 10:46 ` David Gibson
2015-10-22 1:27 ` [Qemu-devel] cpu modelling and hotplug Zhu Guihua
2015-10-22 16:52 ` Andreas Färber
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1427131923-4670-3-git-send-email-afaerber@suse.de \
--to=afaerber@suse.de \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).