From mboxrd@z Thu Jan 1 00:00:00 1970 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 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Sun, 29 Jan 2012 14:25:28 +0100 Message-Id: <1327843531-32403-5-git-send-email-afaerber@suse.de> 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH RFC 4/7] qom: Introduce CPU class List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Anthony Liguori , =?UTF-8?q?Andreas=20F=C3=A4rber?= 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=C3=A4rber 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 +=3D $(trace-obj-y) =20 hw-obj-y =3D hw-obj-y +=3D vl.o loader.o +hw-obj-y +=3D cpu.o hw-obj-$(CONFIG_VIRTIO) +=3D virtio-console.o hw-obj-y +=3D usb-libhw.o hw-obj-$(CONFIG_VIRTIO_PCI) +=3D 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 +=3D $(HELPER_CFLAGS) =20 ifdef CONFIG_LINUX_USER =20 -$(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) =20 QEMU_CFLAGS+=3D-I$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR) -I$(SRC_PATH)/= linux-user obj-y =3D main.o syscall.o strace.o mmap.o signal.o thunk.o \ @@ -130,6 +130,7 @@ obj-m68k-y +=3D m68k-sim.o m68k-semi.o $(obj-y) $(obj-$(TARGET_BASE_ARCH)-y): $(GENERATED_HEADERS) =20 obj-y +=3D module.o +obj-y +=3D cpu.o obj-y +=3D $(addprefix ../qom/, $(qom-y)) obj-y +=3D $(addprefix ../libuser/, $(user-obj-y)) obj-y +=3D $(addprefix ../libdis-user/, $(libdis-y)) @@ -142,7 +143,7 @@ endif #CONFIG_LINUX_USER =20 ifdef CONFIG_DARWIN_USER =20 -$(call set-vpath, $(SRC_PATH)/darwin-user) +$(call set-vpath, $(SRC_PATH)/darwin-user:$(SRC_PATH)/hw) =20 QEMU_CFLAGS+=3D-I$(SRC_PATH)/darwin-user -I$(SRC_PATH)/darwin-user/$(TAR= GET_ARCH) =20 @@ -159,6 +160,7 @@ obj-i386-y +=3D ioport-user.o $(obj-y) $(obj-$(TARGET_BASE_ARCH)-y): $(GENERATED_HEADERS) =20 obj-y +=3D module.o +obj-y +=3D cpu.o obj-y +=3D $(addprefix ../qom/, $(qom-y)) obj-y +=3D $(addprefix ../libuser/, $(user-obj-y)) obj-y +=3D $(addprefix ../libdis-user/, $(libdis-y)) @@ -171,7 +173,7 @@ endif #CONFIG_DARWIN_USER =20 ifdef CONFIG_BSD_USER =20 -$(call set-vpath, $(SRC_PATH)/bsd-user) +$(call set-vpath, $(SRC_PATH)/bsd-user:$(SRC_PATH)/hw) =20 QEMU_CFLAGS+=3D-I$(SRC_PATH)/bsd-user -I$(SRC_PATH)/bsd-user/$(TARGET_AR= CH) =20 @@ -183,6 +185,7 @@ obj-i386-y +=3D ioport-user.o $(obj-y) $(obj-$(TARGET_BASE_ARCH)-y): $(GENERATED_HEADERS) =20 obj-y +=3D module.o +obj-y +=3D cpu.o obj-y +=3D $(addprefix ../qom/, $(qom-y)) obj-y +=3D $(addprefix ../libuser/, $(user-obj-y)) obj-y +=3D $(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) =20 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) } =20 cpu_model =3D 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(); =20 module_call_init(MODULE_INIT_EARLY); + module_call_init(MODULE_INIT_CPU); =20 optind =3D 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 =3D { + .name =3D TYPE_CPU, + .parent =3D TYPE_OBJECT, + .instance_size =3D sizeof(CPU), + .abstract =3D true, + .class_size =3D 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) } =20 cpu_model =3D 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; =20 @@ -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) =20 void register_module_init(void (*fn)(void), module_init_type type); =20 --=20 1.7.7