diff mbox

[RFC,1/4] target-ppc: introduce PPCMachineClass and PPCMachineState

Message ID 1460042594-8056-2-git-send-email-mark.cave-ayland@ilande.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Mark Cave-Ayland April 7, 2016, 3:23 p.m. UTC
Introduce PPCMachineClass in anticipation of making it the superclass for
all PPC machines.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/ppc/ppc.c            |   16 ++++++++++++++++
 include/hw/ppc/ppc.h    |   16 ++++++++++++++++
 include/qemu/typedefs.h |    2 ++
 3 files changed, 34 insertions(+)

Comments

David Gibson April 15, 2016, 5:13 a.m. UTC | #1
On Thu, Apr 07, 2016 at 04:23:11PM +0100, Mark Cave-Ayland wrote:
> Introduce PPCMachineClass in anticipation of making it the superclass for
> all PPC machines.
> 
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> ---
>  hw/ppc/ppc.c            |   16 ++++++++++++++++
>  include/hw/ppc/ppc.h    |   16 ++++++++++++++++
>  include/qemu/typedefs.h |    2 ++
>  3 files changed, 34 insertions(+)
> 
> diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c
> index 38ff2e1..ccdca5d 100644
> --- a/hw/ppc/ppc.c
> +++ b/hw/ppc/ppc.c
> @@ -1343,3 +1343,19 @@ PowerPCCPU *ppc_get_vcpu_by_dt_id(int cpu_dt_id)
>  
>      return NULL;
>  }
> +
> +/* Generic PPC machine */
> +static const TypeInfo ppc_machine_info = {
> +    .name = TYPE_PPC_MACHINE,
> +    .parent = TYPE_MACHINE,
> +    .abstract = true,
> +    .instance_size = sizeof(PPCMachineState),
> +    .class_size = sizeof(PPCMachineClass)
> +};
> +
> +static void ppc_machine_register_types(void)
> +{
> +    type_register_static(&ppc_machine_info);
> +}
> +
> +type_init(ppc_machine_register_types)
> diff --git a/include/hw/ppc/ppc.h b/include/hw/ppc/ppc.h
> index 14efd0c..f1be147 100644
> --- a/include/hw/ppc/ppc.h
> +++ b/include/hw/ppc/ppc.h
> @@ -1,6 +1,22 @@
>  #ifndef HW_PPC_H
>  #define HW_PPC_H 1
>  
> +#include "hw/boards.h"
> +
> +struct PPCMachineState {
> +    /*< private >*/
> +    MachineState parent_obj;
> +};
> +
> +struct PPCMachineClass {
> +    /*< private >*/
> +    MachineClass parent_class;
> +};

It's normal QOM practice not to create actual typedefs if there's
nothing in them except the parent object.  I believe you're adding
something to one of these in subsequent patches, in which case it's ok
to create it here, but I don't think that's true for both of them.

> +#define TYPE_PPC_MACHINE "generic-ppc-machine"
> +#define PPC_MACHINE(obj) \
> +    OBJECT_CHECK(PPCMachineState, (obj), TYPE_PPC_MACHINE)
> +
>  void ppc_set_irq(PowerPCCPU *cpu, int n_IRQ, int level);
>  
>  /* PowerPC hardware exceptions management helpers */
> diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
> index 1dcf6f5..73fbad5 100644
> --- a/include/qemu/typedefs.h
> +++ b/include/qemu/typedefs.h
> @@ -73,6 +73,8 @@ typedef struct PCMachineState PCMachineState;
>  typedef struct PCMCIACardState PCMCIACardState;
>  typedef struct PixelFormat PixelFormat;
>  typedef struct PostcopyDiscardState PostcopyDiscardState;
> +typedef struct PPCMachineClass PPCMachineClass;
> +typedef struct PPCMachineState PPCMachineState;
>  typedef struct Property Property;
>  typedef struct PropertyInfo PropertyInfo;
>  typedef struct QEMUBH QEMUBH;
diff mbox

Patch

diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c
index 38ff2e1..ccdca5d 100644
--- a/hw/ppc/ppc.c
+++ b/hw/ppc/ppc.c
@@ -1343,3 +1343,19 @@  PowerPCCPU *ppc_get_vcpu_by_dt_id(int cpu_dt_id)
 
     return NULL;
 }
+
+/* Generic PPC machine */
+static const TypeInfo ppc_machine_info = {
+    .name = TYPE_PPC_MACHINE,
+    .parent = TYPE_MACHINE,
+    .abstract = true,
+    .instance_size = sizeof(PPCMachineState),
+    .class_size = sizeof(PPCMachineClass)
+};
+
+static void ppc_machine_register_types(void)
+{
+    type_register_static(&ppc_machine_info);
+}
+
+type_init(ppc_machine_register_types)
diff --git a/include/hw/ppc/ppc.h b/include/hw/ppc/ppc.h
index 14efd0c..f1be147 100644
--- a/include/hw/ppc/ppc.h
+++ b/include/hw/ppc/ppc.h
@@ -1,6 +1,22 @@ 
 #ifndef HW_PPC_H
 #define HW_PPC_H 1
 
+#include "hw/boards.h"
+
+struct PPCMachineState {
+    /*< private >*/
+    MachineState parent_obj;
+};
+
+struct PPCMachineClass {
+    /*< private >*/
+    MachineClass parent_class;
+};
+
+#define TYPE_PPC_MACHINE "generic-ppc-machine"
+#define PPC_MACHINE(obj) \
+    OBJECT_CHECK(PPCMachineState, (obj), TYPE_PPC_MACHINE)
+
 void ppc_set_irq(PowerPCCPU *cpu, int n_IRQ, int level);
 
 /* PowerPC hardware exceptions management helpers */
diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
index 1dcf6f5..73fbad5 100644
--- a/include/qemu/typedefs.h
+++ b/include/qemu/typedefs.h
@@ -73,6 +73,8 @@  typedef struct PCMachineState PCMachineState;
 typedef struct PCMCIACardState PCMCIACardState;
 typedef struct PixelFormat PixelFormat;
 typedef struct PostcopyDiscardState PostcopyDiscardState;
+typedef struct PPCMachineClass PPCMachineClass;
+typedef struct PPCMachineState PPCMachineState;
 typedef struct Property Property;
 typedef struct PropertyInfo PropertyInfo;
 typedef struct QEMUBH QEMUBH;