All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: "Andreas Färber" <afaerber@suse.de>
Cc: Anthony Liguori <aliguori@us.ibm.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH RFC 4/7] qom: Introduce CPU class
Date: Sun, 29 Jan 2012 20:14:11 -0600	[thread overview]
Message-ID: <4F25FCF3.2000702@codemonkey.ws> (raw)
In-Reply-To: <1327843531-32403-5-git-send-email-afaerber@suse.de>

On 01/29/2012 07:25 AM, Andreas Färber wrote:
> 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<afaerber@suse.de>
> Cc: Anthony Liguori<aliguori@us.ibm.com>
> ---
>   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),


Probably want to do CPUState or something of that nature so that you can use 
CPU() as a dynamic_cast macro.

BTW, if the class_size == parent.class_size you don't need to define or specific 
the class.

Regards,

Anthony Liguori

> +    .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);
>

  reply	other threads:[~2012-01-30  2:14 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-29 13:25 [Qemu-devel] [PATCH RFC 0/7] Introduce QOM CPU and use for target-arm Andreas Färber
2012-01-29 13:25 ` [Qemu-devel] [PATCH 1/7][RESEND] qom: Introduce object_class_is_abstract() Andreas Färber
2012-01-29 13:25 ` [Qemu-devel] [PATCH RFC 2/7] qom: Register QOM infrastructure early Andreas Färber
2012-01-29 13:25 ` [Qemu-devel] [PATCH RFC 3/7] qom: Add QOM support to user emulators Andreas Färber
2012-01-29 13:25 ` [Qemu-devel] [PATCH RFC 4/7] qom: Introduce CPU class Andreas Färber
2012-01-30  2:14   ` Anthony Liguori [this message]
2012-01-30 11:58     ` Andreas Färber
2012-01-31 10:36     ` Andreas Färber
2012-01-29 13:25 ` [Qemu-devel] [PATCH RFC 5/7] cpu: Introduce cpu_class_foreach() Andreas Färber
2012-01-30  2:16   ` Anthony Liguori
2012-01-30 12:02     ` Andreas Färber
2012-01-29 13:25 ` [Qemu-devel] [PATCH RFC 6/7] target-arm: Introduce QOM CPU and use for it CPUID lookup Andreas Färber
2012-01-30  2:19   ` Anthony Liguori
2012-01-30 12:11     ` Andreas Färber
2012-01-29 13:25 ` [Qemu-devel] [PATCH RFC 7/7] target-arm: Embed CPUARMState in QOM ARMCPU Andreas Färber
2012-01-30  2:22   ` Anthony Liguori
2012-01-30 12:52     ` Andreas Färber
2012-01-30 16:01     ` Andreas Färber
2012-01-29 23:50 ` [Qemu-devel] [PATCH RFC 8/7] target-arm: Use IoC for CPU init Andreas Färber
2012-01-30  2:23   ` Anthony Liguori
2012-01-29 23:50 ` [Qemu-devel] [PATCH RFC 9/7] target-arm: Move CPU feature flags to class Andreas Färber
2012-01-30 19:27   ` 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=4F25FCF3.2000702@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=afaerber@suse.de \
    --cc=aliguori@us.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.