From patchwork Sun Jan 29 13:25:28 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 138438 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 78718B6F9B for ; Mon, 30 Jan 2012 00:28:21 +1100 (EST) Received: from localhost ([::1]:49877 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RrUnl-0006nC-Rk for incoming@patchwork.ozlabs.org; Sun, 29 Jan 2012 08:28:13 -0500 Received: from eggs.gnu.org ([140.186.70.92]:40621) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RrUnU-0006Le-AM for qemu-devel@nongnu.org; Sun, 29 Jan 2012 08:27:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RrUnP-0000Vk-Gy for qemu-devel@nongnu.org; Sun, 29 Jan 2012 08:27:56 -0500 Received: from cantor2.suse.de ([195.135.220.15]:50581 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RrUnO-0000VB-MR for qemu-devel@nongnu.org; Sun, 29 Jan 2012 08:27:51 -0500 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 3302790182; Sun, 29 Jan 2012 14:27:50 +0100 (CET) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Sun, 29 Jan 2012 14:25:28 +0100 Message-Id: <1327843531-32403-5-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.7.7 In-Reply-To: <1327843531-32403-1-git-send-email-afaerber@suse.de> References: <1327843531-32403-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 195.135.220.15 Cc: Anthony Liguori , =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [Qemu-devel] [PATCH RFC 4/7] qom: Introduce CPU class X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org It's abstract, derived directly from TYPE_OBJECT (to avoid dependency on MODULE_INIT_DEVICE) and for now is empty. Place it in hw/. Have user emulators pick it up via VPATH, building it per target since they didn't use any qdev/QOM devices so far. Introduce processor_init() for registering, and call module init as needed. Signed-off-by: Andreas Färber Cc: Anthony Liguori --- Makefile.objs | 1 + Makefile.target | 9 ++++++--- arch_init.c | 1 + bsd-user/main.c | 1 + darwin-user/main.c | 1 + hw/cpu.c | 27 +++++++++++++++++++++++++++ include/qemu/cpu.h | 27 +++++++++++++++++++++++++++ linux-user/main.c | 1 + module.h | 2 ++ 9 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 hw/cpu.c create mode 100644 include/qemu/cpu.h diff --git a/Makefile.objs b/Makefile.objs index b942625..a4b20fa 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -189,6 +189,7 @@ user-obj-y += $(trace-obj-y) hw-obj-y = hw-obj-y += vl.o loader.o +hw-obj-y += cpu.o hw-obj-$(CONFIG_VIRTIO) += virtio-console.o hw-obj-y += usb-libhw.o hw-obj-$(CONFIG_VIRTIO_PCI) += virtio-pci.o diff --git a/Makefile.target b/Makefile.target index d1b7867..5d3470e 100644 --- a/Makefile.target +++ b/Makefile.target @@ -107,7 +107,7 @@ signal.o: QEMU_CFLAGS += $(HELPER_CFLAGS) ifdef CONFIG_LINUX_USER -$(call set-vpath, $(SRC_PATH)/linux-user:$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR)) +$(call set-vpath, $(SRC_PATH)/linux-user:$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR):$(SRC_PATH)/hw) QEMU_CFLAGS+=-I$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR) -I$(SRC_PATH)/linux-user obj-y = main.o syscall.o strace.o mmap.o signal.o thunk.o \ @@ -130,6 +130,7 @@ obj-m68k-y += m68k-sim.o m68k-semi.o $(obj-y) $(obj-$(TARGET_BASE_ARCH)-y): $(GENERATED_HEADERS) obj-y += module.o +obj-y += cpu.o obj-y += $(addprefix ../qom/, $(qom-y)) obj-y += $(addprefix ../libuser/, $(user-obj-y)) obj-y += $(addprefix ../libdis-user/, $(libdis-y)) @@ -142,7 +143,7 @@ endif #CONFIG_LINUX_USER ifdef CONFIG_DARWIN_USER -$(call set-vpath, $(SRC_PATH)/darwin-user) +$(call set-vpath, $(SRC_PATH)/darwin-user:$(SRC_PATH)/hw) QEMU_CFLAGS+=-I$(SRC_PATH)/darwin-user -I$(SRC_PATH)/darwin-user/$(TARGET_ARCH) @@ -159,6 +160,7 @@ obj-i386-y += ioport-user.o $(obj-y) $(obj-$(TARGET_BASE_ARCH)-y): $(GENERATED_HEADERS) obj-y += module.o +obj-y += cpu.o obj-y += $(addprefix ../qom/, $(qom-y)) obj-y += $(addprefix ../libuser/, $(user-obj-y)) obj-y += $(addprefix ../libdis-user/, $(libdis-y)) @@ -171,7 +173,7 @@ endif #CONFIG_DARWIN_USER ifdef CONFIG_BSD_USER -$(call set-vpath, $(SRC_PATH)/bsd-user) +$(call set-vpath, $(SRC_PATH)/bsd-user:$(SRC_PATH)/hw) QEMU_CFLAGS+=-I$(SRC_PATH)/bsd-user -I$(SRC_PATH)/bsd-user/$(TARGET_ARCH) @@ -183,6 +185,7 @@ obj-i386-y += ioport-user.o $(obj-y) $(obj-$(TARGET_BASE_ARCH)-y): $(GENERATED_HEADERS) obj-y += module.o +obj-y += cpu.o obj-y += $(addprefix ../qom/, $(qom-y)) obj-y += $(addprefix ../libuser/, $(user-obj-y)) obj-y += $(addprefix ../libdis-user/, $(libdis-y)) diff --git a/arch_init.c b/arch_init.c index 2366511..c0d5f4f 100644 --- a/arch_init.c +++ b/arch_init.c @@ -692,6 +692,7 @@ void do_smbios_option(const char *optarg) void cpudef_init(void) { + module_call_init(MODULE_INIT_CPU); #if defined(cpudef_setup) cpudef_setup(); /* parse cpu definitions in target config file */ #endif diff --git a/bsd-user/main.c b/bsd-user/main.c index 2ff0361..70e1146 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -761,6 +761,7 @@ int main(int argc, char **argv) } cpu_model = NULL; + module_call_init(MODULE_INIT_CPU); #if defined(cpudef_setup) cpudef_setup(); /* parse cpu definitions in target config file (TBD) */ #endif diff --git a/darwin-user/main.c b/darwin-user/main.c index a4c630d..d065f00 100644 --- a/darwin-user/main.c +++ b/darwin-user/main.c @@ -751,6 +751,7 @@ int main(int argc, char **argv) usage(); module_call_init(MODULE_INIT_EARLY); + module_call_init(MODULE_INIT_CPU); optind = 1; for(;;) { diff --git a/hw/cpu.c b/hw/cpu.c new file mode 100644 index 0000000..c0e9cfa --- /dev/null +++ b/hw/cpu.c @@ -0,0 +1,27 @@ +/* + * QEMU CPU model + * + * Copyright (c) 2012 SUSE LINUX Products GmbH + * + * Licensed under the terms of the GNU GPL version 2 + * or (at your option) any later version. + */ + +#include "qemu/object.h" +#include "qemu/cpu.h" +#include "qemu-common.h" + +static TypeInfo cpu_type_info = { + .name = TYPE_CPU, + .parent = TYPE_OBJECT, + .instance_size = sizeof(CPU), + .abstract = true, + .class_size = sizeof(CPUClass), +}; + +static void cpu_register_types(void) +{ + type_register_static(&cpu_type_info); +} + +processor_init(cpu_register_types) diff --git a/include/qemu/cpu.h b/include/qemu/cpu.h new file mode 100644 index 0000000..4b81f3b --- /dev/null +++ b/include/qemu/cpu.h @@ -0,0 +1,27 @@ +/* + * QEMU CPU model + * + * Copyright (c) 2012 SUSE LINUX Products GmbH + * + * Licensed under the terms of the GNU GPL version 2 + * or (at your option) any later version. + */ +#ifndef QEMU_CPU_H +#define QEMU_CPU_H + +#include "qemu/object.h" + +#define TYPE_CPU "cpu" + +typedef struct CPUClass { + ObjectClass parent_class; +} CPUClass; + +typedef struct CPU { + Object parent_obj; + + /* TODO Move common CPUState here */ +} CPU; + + +#endif diff --git a/linux-user/main.c b/linux-user/main.c index d4368b6..e727e8d 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -3304,6 +3304,7 @@ int main(int argc, char **argv, char **envp) } cpu_model = NULL; + module_call_init(MODULE_INIT_CPU); #if defined(cpudef_setup) cpudef_setup(); /* parse cpu definitions in target config file (TBD) */ #endif diff --git a/module.h b/module.h index 567ff3a..512ba6c 100644 --- a/module.h +++ b/module.h @@ -26,6 +26,7 @@ typedef enum { MODULE_INIT_DEVICE, MODULE_INIT_MACHINE, MODULE_INIT_QAPI, + MODULE_INIT_CPU, MODULE_INIT_MAX } module_init_type; @@ -34,6 +35,7 @@ typedef enum { #define device_init(function) module_init(function, MODULE_INIT_DEVICE) #define machine_init(function) module_init(function, MODULE_INIT_MACHINE) #define qapi_init(function) module_init(function, MODULE_INIT_QAPI) +#define processor_init(function) module_init(function, MODULE_INIT_CPU) void register_module_init(void (*fn)(void), module_init_type type);