diff mbox

[01/13] target-arm: Add vexpress class and machine types

Message ID 1417637167-20640-2-git-send-email-greg.bellows@linaro.org
State New
Headers show

Commit Message

Greg Bellows Dec. 3, 2014, 8:05 p.m. UTC
Adds base Vexpress class and machine objects and infrastructure.  This is in
preparation for switching to the full QEMU object model.  The base vexpress
infrastructure is intended to handle common vexpress details.

Signed-off-by: Greg Bellows <greg.bellows@linaro.org>
---
 hw/arm/vexpress.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

Comments

Peter Maydell Dec. 5, 2014, 3:16 p.m. UTC | #1
On 3 December 2014 at 20:05, Greg Bellows <greg.bellows@linaro.org> wrote:
> Adds base Vexpress class and machine objects and infrastructure.  This is in
> preparation for switching to the full QEMU object model.  The base vexpress
> infrastructure is intended to handle common vexpress details.
>
> Signed-off-by: Greg Bellows <greg.bellows@linaro.org>

This patch results in an incorrect extra line appearing in
the "-M help output":
vexpress             ARM Versatile Express
and if you try to use it we dump core:

e104462:trusty:qemu$ ./build/x86/arm-softmmu/qemu-system-arm -M vexpress
Segmentation fault (core dumped)

We need to either figure out a way for indicating that
a subclass of MACHINE is actually an abstract subclass,
or just have the a15 and a9 directly inherit from MACHINE.

thanks
-- PMM
Greg Bellows Dec. 5, 2014, 8:04 p.m. UTC | #2
Thanks Marcel that appears to have done the trick.

On 5 December 2014 at 13:02, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
wrote:

> On Fri, 2014-12-05 at 15:16 +0000, Peter Maydell wrote:
> > On 3 December 2014 at 20:05, Greg Bellows <greg.bellows@linaro.org>
> wrote:
> > > Adds base Vexpress class and machine objects and infrastructure.  This
> is in
> > > preparation for switching to the full QEMU object model.  The base
> vexpress
> > > infrastructure is intended to handle common vexpress details.
> > >
> > > Signed-off-by: Greg Bellows <greg.bellows@linaro.org>
> >
> > This patch results in an incorrect extra line appearing in
> > the "-M help output":
> > vexpress             ARM Versatile Express
> > and if you try to use it we dump core:
> >
> > e104462:trusty:qemu$ ./build/x86/arm-softmmu/qemu-system-arm -M vexpress
> > Segmentation fault (core dumped)
> >
> > We need to either figure out a way for indicating that
> > a subclass of MACHINE is actually an abstract subclass,
> > or just have the a15 and a9 directly inherit from MACHINE.
>
> We can just add ".abstract = true:  to vexpress_info that should be
> enough.
>
> Thanks,
> Marcel
>
> >
> > thanks
> > -- PMM
> >
>
>
>
>
diff mbox

Patch

diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
index 7cbd13f..8bec04a 100644
--- a/hw/arm/vexpress.c
+++ b/hw/arm/vexpress.c
@@ -157,6 +157,23 @@  static hwaddr motherboard_aseries_map[] = {
 
 typedef struct VEDBoardInfo VEDBoardInfo;
 
+typedef struct {
+    MachineClass parent;
+    VEDBoardInfo *daughterboard;
+} VexpressMachineClass;
+
+typedef struct {
+    MachineState parent;
+} VexpressMachineState;
+
+#define TYPE_VEXPRESS_MACHINE   "vexpress"
+#define VEXPRESS_MACHINE(obj) \
+    OBJECT_CHECK(VexpressMachineState, (obj), TYPE_VEXPRESS_MACHINE)
+#define VEXPRESS_MACHINE_GET_CLASS(obj) \
+    OBJECT_GET_CLASS(VexpressMachineClass, obj, TYPE_VEXPRESS_MACHINE)
+#define VEXPRESS_MACHINE_CLASS(klass) \
+    OBJECT_CLASS_CHECK(VexpressMachineClass, klass, TYPE_VEXPRESS_MACHINE)
+
 typedef void DBoardInitFn(const VEDBoardInfo *daughterboard,
                           ram_addr_t ram_size,
                           const char *cpu_model,
@@ -681,6 +698,13 @@  static void vexpress_common_init(VEDBoardInfo *daughterboard,
     arm_load_kernel(ARM_CPU(first_cpu), &daughterboard->bootinfo);
 }
 
+static void vexpress_init(MachineState *machine)
+{
+    VexpressMachineClass *vmc = VEXPRESS_MACHINE_GET_CLASS(machine);
+
+    vexpress_common_init(vmc->daughterboard, machine);
+}
+
 static void vexpress_a9_init(MachineState *machine)
 {
     vexpress_common_init(&a9_daughterboard, machine);
@@ -691,6 +715,25 @@  static void vexpress_a15_init(MachineState *machine)
     vexpress_common_init(&a15_daughterboard, machine);
 }
 
+static void vexpress_class_init(ObjectClass *oc, void *data)
+{
+    MachineClass *mc = MACHINE_CLASS(oc);
+
+    mc->name = TYPE_VEXPRESS_MACHINE;
+    mc->desc = "ARM Versatile Express";
+    mc->init = vexpress_init;
+    mc->block_default_type = IF_SCSI;
+    mc->max_cpus = 4;
+}
+
+static const TypeInfo vexpress_info = {
+    .name = TYPE_VEXPRESS_MACHINE,
+    .parent = TYPE_MACHINE,
+    .instance_size = sizeof(VexpressMachineState),
+    .class_size = sizeof(VexpressMachineClass),
+    .class_init = vexpress_class_init,
+};
+
 static QEMUMachine vexpress_a9_machine = {
     .name = "vexpress-a9",
     .desc = "ARM Versatile Express for Cortex-A9",
@@ -709,6 +752,7 @@  static QEMUMachine vexpress_a15_machine = {
 
 static void vexpress_machine_init(void)
 {
+    type_register_static(&vexpress_info);
     qemu_register_machine(&vexpress_a9_machine);
     qemu_register_machine(&vexpress_a15_machine);
 }