[PATCH 17/30] q800: add easc bool machine class property to switch between ASC and EASC

Mark Cave-Ayland posted 30 patches 1 year, 1 month ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Gerd Hoffmann <kraxel@redhat.com>, Laurent Vivier <laurent@vivier.eu>, Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>
[PATCH 17/30] q800: add easc bool machine class property to switch between ASC and EASC
Posted by Mark Cave-Ayland 1 year, 1 month ago
This determines whether the Apple Sound Chip (ASC) is set to enhanced mode
(default) or to original mode. The real Q800 hardware used an EASC chip however
a lot of older software only works with the older ASC chip.

Adding this as a machine parameter allows QEMU to be used as an developer aid
for testing and migrating code from ASC to EASC.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/m68k/q800.c         | 30 +++++++++++++++++++++++++++++-
 include/hw/m68k/q800.h |  1 +
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c
index ed862f9e9d..1af1a06f64 100644
--- a/hw/m68k/q800.c
+++ b/hw/m68k/q800.c
@@ -710,7 +710,8 @@ static void q800_machine_init(MachineState *machine)
     /* Apple Sound Chip */
 
     dev = qdev_new(TYPE_ASC);
-    qdev_prop_set_uint8(dev, "asctype", ASC_TYPE_EASC);
+    qdev_prop_set_uint8(dev, "asctype", m->easc ? ASC_TYPE_EASC
+                                                : ASC_TYPE_ASC);
     sysbus = SYS_BUS_DEVICE(dev);
     sysbus_realize_and_unref(sysbus, &error_fatal);
     memory_region_add_subregion(&m->macio, ASC_BASE - IO_BASE,
@@ -886,6 +887,28 @@ static void q800_machine_init(MachineState *machine)
     }
 }
 
+static bool q800_get_easc(Object *obj, Error **errp)
+{
+    Q800MachineState *ms = Q800_MACHINE(obj);
+
+    return ms->easc;
+}
+
+static void q800_set_easc(Object *obj, bool value, Error **errp)
+{
+    Q800MachineState *ms = Q800_MACHINE(obj);
+
+    ms->easc = value;
+}
+
+static void q800_init(Object *obj)
+{
+    Q800MachineState *ms = Q800_MACHINE(obj);
+
+    /* Default to EASC */
+    ms->easc = true;
+}
+
 static GlobalProperty hw_compat_q800[] = {
     { "scsi-hd", "quirk_mode_page_vendor_specific_apple", "on" },
     { "scsi-hd", "vendor", " SEAGATE" },
@@ -912,11 +935,16 @@ static void q800_machine_class_init(ObjectClass *oc, void *data)
     mc->block_default_type = IF_SCSI;
     mc->default_ram_id = "m68k_mac.ram";
     compat_props_add(mc->compat_props, hw_compat_q800, hw_compat_q800_len);
+
+    object_class_property_add_bool(oc, "easc", q800_get_easc, q800_set_easc);
+    object_class_property_set_description(oc, "easc",
+        "Set to off to use ASC rather than EASC");
 }
 
 static const TypeInfo q800_machine_typeinfo = {
     .name       = MACHINE_TYPE_NAME("q800"),
     .parent     = TYPE_MACHINE,
+    .instance_init = q800_init,
     .instance_size = sizeof(Q800MachineState),
     .class_init = q800_machine_class_init,
 };
diff --git a/include/hw/m68k/q800.h b/include/hw/m68k/q800.h
index 0602d07d3d..0144be5e6e 100644
--- a/include/hw/m68k/q800.h
+++ b/include/hw/m68k/q800.h
@@ -30,6 +30,7 @@
 struct Q800MachineState {
     MachineState parent_obj;
 
+    bool easc;
     M68kCPU *cpu;
     MemoryRegion rom;
     DeviceState *glue;
-- 
2.30.2
Re: [PATCH 17/30] q800: add easc bool machine class property to switch between ASC and EASC
Posted by Laurent Vivier 1 year, 1 month ago
Le 24/05/2023 à 23:10, Mark Cave-Ayland a écrit :
> This determines whether the Apple Sound Chip (ASC) is set to enhanced mode
> (default) or to original mode. The real Q800 hardware used an EASC chip however
> a lot of older software only works with the older ASC chip.
> 
> Adding this as a machine parameter allows QEMU to be used as an developer aid
> for testing and migrating code from ASC to EASC.
> 
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> ---
>   hw/m68k/q800.c         | 30 +++++++++++++++++++++++++++++-
>   include/hw/m68k/q800.h |  1 +
>   2 files changed, 30 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c
> index ed862f9e9d..1af1a06f64 100644
> --- a/hw/m68k/q800.c
> +++ b/hw/m68k/q800.c
> @@ -710,7 +710,8 @@ static void q800_machine_init(MachineState *machine)
>       /* Apple Sound Chip */
>   
>       dev = qdev_new(TYPE_ASC);
> -    qdev_prop_set_uint8(dev, "asctype", ASC_TYPE_EASC);
> +    qdev_prop_set_uint8(dev, "asctype", m->easc ? ASC_TYPE_EASC
> +                                                : ASC_TYPE_ASC);
>       sysbus = SYS_BUS_DEVICE(dev);
>       sysbus_realize_and_unref(sysbus, &error_fatal);
>       memory_region_add_subregion(&m->macio, ASC_BASE - IO_BASE,
> @@ -886,6 +887,28 @@ static void q800_machine_init(MachineState *machine)
>       }
>   }
>   
> +static bool q800_get_easc(Object *obj, Error **errp)
> +{
> +    Q800MachineState *ms = Q800_MACHINE(obj);
> +
> +    return ms->easc;
> +}
> +
> +static void q800_set_easc(Object *obj, bool value, Error **errp)
> +{
> +    Q800MachineState *ms = Q800_MACHINE(obj);
> +
> +    ms->easc = value;
> +}
> +
> +static void q800_init(Object *obj)
> +{
> +    Q800MachineState *ms = Q800_MACHINE(obj);
> +
> +    /* Default to EASC */
> +    ms->easc = true;
> +}
> +
>   static GlobalProperty hw_compat_q800[] = {
>       { "scsi-hd", "quirk_mode_page_vendor_specific_apple", "on" },
>       { "scsi-hd", "vendor", " SEAGATE" },
> @@ -912,11 +935,16 @@ static void q800_machine_class_init(ObjectClass *oc, void *data)
>       mc->block_default_type = IF_SCSI;
>       mc->default_ram_id = "m68k_mac.ram";
>       compat_props_add(mc->compat_props, hw_compat_q800, hw_compat_q800_len);
> +
> +    object_class_property_add_bool(oc, "easc", q800_get_easc, q800_set_easc);
> +    object_class_property_set_description(oc, "easc",
> +        "Set to off to use ASC rather than EASC");
>   }
>   
>   static const TypeInfo q800_machine_typeinfo = {
>       .name       = MACHINE_TYPE_NAME("q800"),
>       .parent     = TYPE_MACHINE,
> +    .instance_init = q800_init,
>       .instance_size = sizeof(Q800MachineState),
>       .class_init = q800_machine_class_init,
>   };
> diff --git a/include/hw/m68k/q800.h b/include/hw/m68k/q800.h
> index 0602d07d3d..0144be5e6e 100644
> --- a/include/hw/m68k/q800.h
> +++ b/include/hw/m68k/q800.h
> @@ -30,6 +30,7 @@
>   struct Q800MachineState {
>       MachineState parent_obj;
>   
> +    bool easc;
>       M68kCPU *cpu;
>       MemoryRegion rom;
>       DeviceState *glue;

Reviewed-by: Laurent Vivier <laurent@vivier.eu>