qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Subject: [PULL 10/36] hw/misc: Convert TYPE_MOS6522 subclasses to 3-phase reset
Date: Fri, 16 Dec 2022 21:42:18 +0000	[thread overview]
Message-ID: <20221216214244.1391647-11-peter.maydell@linaro.org> (raw)
In-Reply-To: <20221216214244.1391647-1-peter.maydell@linaro.org>

Convert the various subclasses of TYPE_MOS6522 to 3-phase reset.
This removes some uses of device_class_set_parent_reset(), which we
would eventually like to be able to get rid of.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-id: 20221110143459.3833425-3-peter.maydell@linaro.org
---
 include/hw/misc/mos6522.h |  2 +-
 hw/misc/mac_via.c         | 26 ++++++++++++++++----------
 hw/misc/macio/cuda.c      | 14 ++++++++------
 hw/misc/macio/pmu.c       | 14 ++++++++------
 4 files changed, 33 insertions(+), 23 deletions(-)

diff --git a/include/hw/misc/mos6522.h b/include/hw/misc/mos6522.h
index 0bc22a83957..05872fffc92 100644
--- a/include/hw/misc/mos6522.h
+++ b/include/hw/misc/mos6522.h
@@ -157,7 +157,7 @@ OBJECT_DECLARE_TYPE(MOS6522State, MOS6522DeviceClass, MOS6522)
 struct MOS6522DeviceClass {
     DeviceClass parent_class;
 
-    DeviceReset parent_reset;
+    ResettablePhases parent_phases;
     void (*portB_write)(MOS6522State *dev);
     void (*portA_write)(MOS6522State *dev);
     /* These are used to influence the CUDA MacOS timebase calibration */
diff --git a/hw/misc/mac_via.c b/hw/misc/mac_via.c
index f42c12755a9..076d18e5fd9 100644
--- a/hw/misc/mac_via.c
+++ b/hw/misc/mac_via.c
@@ -975,14 +975,16 @@ static int via1_post_load(void *opaque, int version_id)
 }
 
 /* VIA 1 */
-static void mos6522_q800_via1_reset(DeviceState *dev)
+static void mos6522_q800_via1_reset_hold(Object *obj)
 {
-    MOS6522Q800VIA1State *v1s = MOS6522_Q800_VIA1(dev);
+    MOS6522Q800VIA1State *v1s = MOS6522_Q800_VIA1(obj);
     MOS6522State *ms = MOS6522(v1s);
     MOS6522DeviceClass *mdc = MOS6522_GET_CLASS(ms);
     ADBBusState *adb_bus = &v1s->adb_bus;
 
-    mdc->parent_reset(dev);
+    if (mdc->parent_phases.hold) {
+        mdc->parent_phases.hold(obj);
+    }
 
     ms->timers[0].frequency = VIA_TIMER_FREQ;
     ms->timers[1].frequency = VIA_TIMER_FREQ;
@@ -1097,11 +1099,12 @@ static Property mos6522_q800_via1_properties[] = {
 static void mos6522_q800_via1_class_init(ObjectClass *oc, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(oc);
+    ResettableClass *rc = RESETTABLE_CLASS(oc);
     MOS6522DeviceClass *mdc = MOS6522_CLASS(oc);
 
     dc->realize = mos6522_q800_via1_realize;
-    device_class_set_parent_reset(dc, mos6522_q800_via1_reset,
-                                  &mdc->parent_reset);
+    resettable_class_set_parent_phases(rc, NULL, mos6522_q800_via1_reset_hold,
+                                       NULL, &mdc->parent_phases);
     dc->vmsd = &vmstate_q800_via1;
     device_class_set_props(dc, mos6522_q800_via1_properties);
 }
@@ -1123,12 +1126,14 @@ static void mos6522_q800_via2_portB_write(MOS6522State *s)
     }
 }
 
-static void mos6522_q800_via2_reset(DeviceState *dev)
+static void mos6522_q800_via2_reset_hold(Object *obj)
 {
-    MOS6522State *ms = MOS6522(dev);
+    MOS6522State *ms = MOS6522(obj);
     MOS6522DeviceClass *mdc = MOS6522_GET_CLASS(ms);
 
-    mdc->parent_reset(dev);
+    if (mdc->parent_phases.hold) {
+        mdc->parent_phases.hold(obj);
+    }
 
     ms->timers[0].frequency = VIA_TIMER_FREQ;
     ms->timers[1].frequency = VIA_TIMER_FREQ;
@@ -1183,10 +1188,11 @@ static const VMStateDescription vmstate_q800_via2 = {
 static void mos6522_q800_via2_class_init(ObjectClass *oc, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(oc);
+    ResettableClass *rc = RESETTABLE_CLASS(oc);
     MOS6522DeviceClass *mdc = MOS6522_CLASS(oc);
 
-    device_class_set_parent_reset(dc, mos6522_q800_via2_reset,
-                                  &mdc->parent_reset);
+    resettable_class_set_parent_phases(rc, NULL, mos6522_q800_via2_reset_hold,
+                                       NULL, &mdc->parent_phases);
     dc->vmsd = &vmstate_q800_via2;
     mdc->portB_write = mos6522_q800_via2_portB_write;
 }
diff --git a/hw/misc/macio/cuda.c b/hw/misc/macio/cuda.c
index 0d4c13319a8..853e88bfedd 100644
--- a/hw/misc/macio/cuda.c
+++ b/hw/misc/macio/cuda.c
@@ -589,12 +589,14 @@ static void mos6522_cuda_portB_write(MOS6522State *s)
     cuda_update(cs);
 }
 
-static void mos6522_cuda_reset(DeviceState *dev)
+static void mos6522_cuda_reset_hold(Object *obj)
 {
-    MOS6522State *ms = MOS6522(dev);
+    MOS6522State *ms = MOS6522(obj);
     MOS6522DeviceClass *mdc = MOS6522_GET_CLASS(ms);
 
-    mdc->parent_reset(dev);
+    if (mdc->parent_phases.hold) {
+        mdc->parent_phases.hold(obj);
+    }
 
     ms->timers[0].frequency = CUDA_TIMER_FREQ;
     ms->timers[1].frequency = (SCALE_US * 6000) / 4700;
@@ -602,11 +604,11 @@ static void mos6522_cuda_reset(DeviceState *dev)
 
 static void mos6522_cuda_class_init(ObjectClass *oc, void *data)
 {
-    DeviceClass *dc = DEVICE_CLASS(oc);
+    ResettableClass *rc = RESETTABLE_CLASS(oc);
     MOS6522DeviceClass *mdc = MOS6522_CLASS(oc);
 
-    device_class_set_parent_reset(dc, mos6522_cuda_reset,
-                                  &mdc->parent_reset);
+    resettable_class_set_parent_phases(rc, NULL, mos6522_cuda_reset_hold,
+                                       NULL, &mdc->parent_phases);
     mdc->portB_write = mos6522_cuda_portB_write;
     mdc->get_timer1_counter_value = cuda_get_counter_value;
     mdc->get_timer2_counter_value = cuda_get_counter_value;
diff --git a/hw/misc/macio/pmu.c b/hw/misc/macio/pmu.c
index 70562ed8d07..97ef8c771b6 100644
--- a/hw/misc/macio/pmu.c
+++ b/hw/misc/macio/pmu.c
@@ -797,14 +797,16 @@ static void mos6522_pmu_portB_write(MOS6522State *s)
     pmu_update(ps);
 }
 
-static void mos6522_pmu_reset(DeviceState *dev)
+static void mos6522_pmu_reset_hold(Object *obj)
 {
-    MOS6522State *ms = MOS6522(dev);
+    MOS6522State *ms = MOS6522(obj);
     MOS6522PMUState *mps = container_of(ms, MOS6522PMUState, parent_obj);
     PMUState *s = container_of(mps, PMUState, mos6522_pmu);
     MOS6522DeviceClass *mdc = MOS6522_GET_CLASS(ms);
 
-    mdc->parent_reset(dev);
+    if (mdc->parent_phases.hold) {
+        mdc->parent_phases.hold(obj);
+    }
 
     ms->timers[0].frequency = VIA_TIMER_FREQ;
     ms->timers[1].frequency = (SCALE_US * 6000) / 4700;
@@ -814,11 +816,11 @@ static void mos6522_pmu_reset(DeviceState *dev)
 
 static void mos6522_pmu_class_init(ObjectClass *oc, void *data)
 {
-    DeviceClass *dc = DEVICE_CLASS(oc);
+    ResettableClass *rc = RESETTABLE_CLASS(oc);
     MOS6522DeviceClass *mdc = MOS6522_CLASS(oc);
 
-    device_class_set_parent_reset(dc, mos6522_pmu_reset,
-                                  &mdc->parent_reset);
+    resettable_class_set_parent_phases(rc, NULL, mos6522_pmu_reset_hold,
+                                       NULL, &mdc->parent_phases);
     mdc->portB_write = mos6522_pmu_portB_write;
 }
 
-- 
2.25.1



  parent reply	other threads:[~2022-12-16 22:11 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-16 21:42 [PULL 00/36] reset refactoring patches Peter Maydell
2022-12-16 21:42 ` [PULL 01/36] hw/s390x/s390-pci-inst.c: Use device_cold_reset() to reset PCI devices Peter Maydell
2022-12-16 21:42 ` [PULL 02/36] pci: Use device_cold_reset() and bus_cold_reset() Peter Maydell
2022-12-16 21:42 ` [PULL 03/36] hw/hyperv/vmbus: " Peter Maydell
2022-12-16 21:42 ` [PULL 04/36] Replace use of qdev_reset_all() with device_cold_reset() Peter Maydell
2022-12-16 21:42 ` [PULL 05/36] qdev: Remove qdev_reset_all() and qbus_reset_all() Peter Maydell
2022-12-16 21:42 ` [PULL 06/36] hw: Remove device_legacy_reset() Peter Maydell
2022-12-16 21:42 ` [PULL 07/36] hw/input/ps2: Convert TYPE_PS2_DEVICE to 3-phase reset Peter Maydell
2022-12-16 21:42 ` [PULL 08/36] hw/input/ps2.c: Convert TYPE_PS2_{KBD, MOUSE}_DEVICE " Peter Maydell
2022-12-16 21:42 ` [PULL 09/36] hw/misc/mos6522: Convert TYPE_MOS6522 " Peter Maydell
2022-12-16 21:42 ` Peter Maydell [this message]
2022-12-16 21:42 ` [PULL 11/36] hw/core/cpu-common: Convert TYPE_CPU class " Peter Maydell
2022-12-16 21:42 ` [PULL 12/36] target/arm: Convert " Peter Maydell
2022-12-16 21:42 ` [PULL 13/36] target/avr: " Peter Maydell
2022-12-16 21:42 ` [PULL 14/36] target/cris: " Peter Maydell
2022-12-16 21:42 ` [PULL 15/36] target/hexagon: " Peter Maydell
2022-12-16 21:42 ` [PULL 16/36] target/i386: " Peter Maydell
2022-12-16 21:42 ` [PULL 17/36] target/loongarch: " Peter Maydell
2022-12-16 21:42 ` [PULL 18/36] target/m68k: " Peter Maydell
2022-12-16 21:42 ` [PULL 19/36] target/microblaze: " Peter Maydell
2022-12-16 21:42 ` [PULL 20/36] target/mips: " Peter Maydell
2022-12-16 21:42 ` [PULL 21/36] target/nios2: " Peter Maydell
2022-12-16 21:42 ` [PULL 22/36] target/openrisc: " Peter Maydell
2022-12-16 21:42 ` [PULL 23/36] target/ppc: " Peter Maydell
2022-12-16 21:42 ` [PULL 24/36] target/riscv: " Peter Maydell
2022-12-16 21:42 ` [PULL 25/36] target/rx: " Peter Maydell
2022-12-16 21:42 ` [PULL 26/36] target/sh4: " Peter Maydell
2022-12-16 21:42 ` [PULL 27/36] target/sparc: " Peter Maydell
2022-12-16 21:42 ` [PULL 28/36] target/tricore: " Peter Maydell
2022-12-16 21:42 ` [PULL 29/36] target/xtensa: " Peter Maydell
2022-12-16 21:42 ` [PULL 30/36] hw/virtio: Convert TYPE_VIRTIO_PCI " Peter Maydell
2022-12-16 21:42 ` [PULL 31/36] hw/display/virtio-vga: Convert TYPE_VIRTIO_VGA_BASE " Peter Maydell
2022-12-16 21:42 ` [PULL 32/36] pci: Convert TYPE_PCIE_ROOT_PORT " Peter Maydell
2022-12-16 21:42 ` [PULL 33/36] pci: Convert child classes of " Peter Maydell
2022-12-16 21:42 ` [PULL 34/36] hw/intc/xics: Reset TYPE_ICS objects with device_cold_reset() Peter Maydell
2022-12-16 21:42 ` [PULL 35/36] hw/intc/xics: Convert TYPE_ICS to 3-phase reset Peter Maydell
2022-12-16 21:42 ` [PULL 36/36] hw/pci-host/pnv_phb3_msi: Convert TYPE_PHB3_MSI " Peter Maydell
2022-12-17 21:18 ` [PULL 00/36] reset refactoring patches Peter Maydell

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=20221216214244.1391647-11-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).