From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44814) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6uXG-0002dx-RE for qemu-devel@nongnu.org; Thu, 10 Dec 2015 01:17:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a6uXD-00037G-G8 for qemu-devel@nongnu.org; Thu, 10 Dec 2015 01:17:02 -0500 Received: from e23smtp03.au.ibm.com ([202.81.31.145]:34216) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6uXC-00036x-Vj for qemu-devel@nongnu.org; Thu, 10 Dec 2015 01:16:59 -0500 Received: from localhost by e23smtp03.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 10 Dec 2015 16:16:56 +1000 Received: from d23relay10.au.ibm.com (d23relay10.au.ibm.com [9.190.26.77]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id 0A0A93578047 for ; Thu, 10 Dec 2015 17:16:54 +1100 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay10.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id tBA6Gjqk37748888 for ; Thu, 10 Dec 2015 17:16:54 +1100 Received: from d23av03.au.ibm.com (localhost [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id tBA6GKkd030038 for ; Thu, 10 Dec 2015 17:16:21 +1100 From: Bharata B Rao Date: Thu, 10 Dec 2015 11:45:39 +0530 Message-Id: <1449728144-6223-5-git-send-email-bharata@linux.vnet.ibm.com> In-Reply-To: <1449728144-6223-1-git-send-email-bharata@linux.vnet.ibm.com> References: <1449728144-6223-1-git-send-email-bharata@linux.vnet.ibm.com> Subject: [Qemu-devel] [RFC PATCH v0 4/9] cpu: CPU socket backend List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, ehabkost@redhat.com, Bharata B Rao , agraf@suse.de, borntraeger@de.ibm.com, imammedo@redhat.com, pbonzini@redhat.com, afaerber@suse.de, david@gibson.dropbear.id.au Backend object for CPU socket. TODO: Prevent creation of socket objects beyond what is needed by max_cpus so that all the required socket objects are pre-created and user can't ever add a socket slot. Signed-off-by: Bharata B Rao --- hw/cpu/Makefile.objs | 1 + hw/cpu/socket.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ include/hw/cpu/socket.h | 26 ++++++++++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 hw/cpu/socket.c create mode 100644 include/hw/cpu/socket.h diff --git a/hw/cpu/Makefile.objs b/hw/cpu/Makefile.objs index 0954a18..93d1226 100644 --- a/hw/cpu/Makefile.objs +++ b/hw/cpu/Makefile.objs @@ -2,4 +2,5 @@ obj-$(CONFIG_ARM11MPCORE) += arm11mpcore.o obj-$(CONFIG_REALVIEW) += realview_mpcore.o obj-$(CONFIG_A9MPCORE) += a9mpcore.o obj-$(CONFIG_A15MPCORE) += a15mpcore.o +obj-y += socket.o diff --git a/hw/cpu/socket.c b/hw/cpu/socket.c new file mode 100644 index 0000000..e0a2af9 --- /dev/null +++ b/hw/cpu/socket.c @@ -0,0 +1,48 @@ +/* + * CPU socket backend + * + * Copyright (C) 2015 Bharata B Rao + * + * 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/cpu/socket.h" +#include "qom/object_interfaces.h" + +static bool cpu_socket_can_be_deleted(UserCreatable *uc, Error **errp) +{ + return false; +} + +static void cpu_socket_class_init(ObjectClass *oc, void *data) +{ + UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc); + + ucc->can_be_deleted = cpu_socket_can_be_deleted; +} + +static void cpu_socket_instance_init(Object *obj) +{ + CPUSocket *socket = CPU_SOCKET(obj); + + socket->nr_cores = 0; +} + +static const TypeInfo cpu_socket_info = { + .name = TYPE_CPU_SOCKET, + .parent = TYPE_OBJECT, + .instance_init = cpu_socket_instance_init, + .instance_size = sizeof(CPUSocket), + .class_init = cpu_socket_class_init, + .interfaces = (InterfaceInfo[]) { + { TYPE_USER_CREATABLE }, + { } + } +}; + +static void cpu_socket_register_types(void) +{ + type_register_static(&cpu_socket_info); +} + +type_init(cpu_socket_register_types) diff --git a/include/hw/cpu/socket.h b/include/hw/cpu/socket.h new file mode 100644 index 0000000..ff29367 --- /dev/null +++ b/include/hw/cpu/socket.h @@ -0,0 +1,26 @@ +/* + * CPU socket backend + * + * Copyright (C) 2015 Bharata B Rao + * + * 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_CPU_SOCKET_H +#define HW_CPU_SOCKET_H + +#include "hw/qdev.h" + +#define TYPE_CPU_SOCKET "cpu-socket" +#define CPU_SOCKET(obj) \ + OBJECT_CHECK(CPUSocket, (obj), TYPE_CPU_SOCKET) + +typedef struct CPUSocket { + /* private */ + Object parent; + + /* public */ + int nr_cores; +} CPUSocket; + +#endif -- 2.1.0