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 <bhar...@linux.vnet.ibm.com> --- 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 <bhar...@linux.vnet.ibm.com> + * + * 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 <bhar...@linux.vnet.ibm.com> + * + * 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