* [PATCH for-8.0 0/2] hw/misc: Convert MOS6522 devices to 3-phase reset
@ 2022-11-10 14:34 Peter Maydell
2022-11-10 14:34 ` [PATCH for-8.0 1/2] hw/misc/mos6522: Convert TYPE_MOS6522 " Peter Maydell
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Peter Maydell @ 2022-11-10 14:34 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-ppc, Laurent Vivier, Mark Cave-Ayland
This patchset converts the TYPE_MOS6522 class and its subclasses to
use 3-phase reset. This is part of the work I'm doing to clean up some
of the reset-related code by getting rid of the
device_class_set_parent_reset() function, which is used by
legacy-reset subclasses which want to chain to their parent's reset
function. There aren't very many of these devices in total, and if we
convert them all to 3-phase reset they can use the 3-phase-reset
equivalent (resettable_class_set_parent_phases()). Eventually this
will then let us simplify the transitional code for handling old-style
device reset.
This is 8.0 material. Tested with 'make check' and 'make check-avocado'
for ppc and m68k builds.
thanks
--PMM
Peter Maydell (2):
hw/misc/mos6522: Convert TYPE_MOS6522 to 3-phase reset
hw/misc: Convert TYPE_MOS6522 subclasses to 3-phase reset
include/hw/misc/mos6522.h | 2 +-
hw/misc/mac_via.c | 26 ++++++++++++++++----------
hw/misc/macio/cuda.c | 14 ++++++++------
hw/misc/macio/pmu.c | 14 ++++++++------
hw/misc/mos6522.c | 7 ++++---
5 files changed, 37 insertions(+), 26 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH for-8.0 1/2] hw/misc/mos6522: Convert TYPE_MOS6522 to 3-phase reset
2022-11-10 14:34 [PATCH for-8.0 0/2] hw/misc: Convert MOS6522 devices to 3-phase reset Peter Maydell
@ 2022-11-10 14:34 ` Peter Maydell
2022-11-10 19:49 ` Philippe Mathieu-Daudé
2022-11-10 21:52 ` Richard Henderson
2022-11-10 14:34 ` [PATCH for-8.0 2/2] hw/misc: Convert TYPE_MOS6522 subclasses " Peter Maydell
` (2 subsequent siblings)
3 siblings, 2 replies; 9+ messages in thread
From: Peter Maydell @ 2022-11-10 14:34 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-ppc, Laurent Vivier, Mark Cave-Ayland
Convert the TYPE_MOS6522 parent class to use 3-phase reset. This is
a prerequisite for converting its subclasses.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/misc/mos6522.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/hw/misc/mos6522.c b/hw/misc/mos6522.c
index fe38c44426b..0ed631186c3 100644
--- a/hw/misc/mos6522.c
+++ b/hw/misc/mos6522.c
@@ -643,9 +643,9 @@ const VMStateDescription vmstate_mos6522 = {
}
};
-static void mos6522_reset(DeviceState *dev)
+static void mos6522_reset_hold(Object *obj)
{
- MOS6522State *s = MOS6522(dev);
+ MOS6522State *s = MOS6522(obj);
s->b = 0;
s->a = 0;
@@ -705,9 +705,10 @@ static Property mos6522_properties[] = {
static void mos6522_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
+ ResettableClass *rc = RESETTABLE_CLASS(oc);
MOS6522DeviceClass *mdc = MOS6522_CLASS(oc);
- dc->reset = mos6522_reset;
+ rc->phases.hold = mos6522_reset_hold;
dc->vmsd = &vmstate_mos6522;
device_class_set_props(dc, mos6522_properties);
mdc->portB_write = mos6522_portB_write;
--
2.25.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH for-8.0 2/2] hw/misc: Convert TYPE_MOS6522 subclasses to 3-phase reset
2022-11-10 14:34 [PATCH for-8.0 0/2] hw/misc: Convert MOS6522 devices to 3-phase reset Peter Maydell
2022-11-10 14:34 ` [PATCH for-8.0 1/2] hw/misc/mos6522: Convert TYPE_MOS6522 " Peter Maydell
@ 2022-11-10 14:34 ` Peter Maydell
2022-11-10 21:53 ` Richard Henderson
2022-11-30 10:16 ` Philippe Mathieu-Daudé
2022-11-12 0:58 ` [PATCH for-8.0 0/2] hw/misc: Convert MOS6522 devices " Mark Cave-Ayland
2022-12-16 16:03 ` Peter Maydell
3 siblings, 2 replies; 9+ messages in thread
From: Peter Maydell @ 2022-11-10 14:34 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-ppc, Laurent Vivier, Mark Cave-Ayland
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>
---
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
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH for-8.0 1/2] hw/misc/mos6522: Convert TYPE_MOS6522 to 3-phase reset
2022-11-10 14:34 ` [PATCH for-8.0 1/2] hw/misc/mos6522: Convert TYPE_MOS6522 " Peter Maydell
@ 2022-11-10 19:49 ` Philippe Mathieu-Daudé
2022-11-10 21:52 ` Richard Henderson
1 sibling, 0 replies; 9+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-11-10 19:49 UTC (permalink / raw)
To: Peter Maydell, qemu-devel; +Cc: qemu-ppc, Laurent Vivier, Mark Cave-Ayland
On 10/11/22 15:34, Peter Maydell wrote:
> Convert the TYPE_MOS6522 parent class to use 3-phase reset. This is
> a prerequisite for converting its subclasses.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> hw/misc/mos6522.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH for-8.0 1/2] hw/misc/mos6522: Convert TYPE_MOS6522 to 3-phase reset
2022-11-10 14:34 ` [PATCH for-8.0 1/2] hw/misc/mos6522: Convert TYPE_MOS6522 " Peter Maydell
2022-11-10 19:49 ` Philippe Mathieu-Daudé
@ 2022-11-10 21:52 ` Richard Henderson
1 sibling, 0 replies; 9+ messages in thread
From: Richard Henderson @ 2022-11-10 21:52 UTC (permalink / raw)
To: Peter Maydell, qemu-devel; +Cc: qemu-ppc, Laurent Vivier, Mark Cave-Ayland
On 11/11/22 00:34, Peter Maydell wrote:
> Convert the TYPE_MOS6522 parent class to use 3-phase reset. This is
> a prerequisite for converting its subclasses.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> hw/misc/mos6522.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH for-8.0 2/2] hw/misc: Convert TYPE_MOS6522 subclasses to 3-phase reset
2022-11-10 14:34 ` [PATCH for-8.0 2/2] hw/misc: Convert TYPE_MOS6522 subclasses " Peter Maydell
@ 2022-11-10 21:53 ` Richard Henderson
2022-11-30 10:16 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 9+ messages in thread
From: Richard Henderson @ 2022-11-10 21:53 UTC (permalink / raw)
To: Peter Maydell, qemu-devel; +Cc: qemu-ppc, Laurent Vivier, Mark Cave-Ayland
On 11/11/22 00:34, Peter Maydell wrote:
> 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>
> ---
> 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(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH for-8.0 0/2] hw/misc: Convert MOS6522 devices to 3-phase reset
2022-11-10 14:34 [PATCH for-8.0 0/2] hw/misc: Convert MOS6522 devices to 3-phase reset Peter Maydell
2022-11-10 14:34 ` [PATCH for-8.0 1/2] hw/misc/mos6522: Convert TYPE_MOS6522 " Peter Maydell
2022-11-10 14:34 ` [PATCH for-8.0 2/2] hw/misc: Convert TYPE_MOS6522 subclasses " Peter Maydell
@ 2022-11-12 0:58 ` Mark Cave-Ayland
2022-12-16 16:03 ` Peter Maydell
3 siblings, 0 replies; 9+ messages in thread
From: Mark Cave-Ayland @ 2022-11-12 0:58 UTC (permalink / raw)
To: Peter Maydell, qemu-devel; +Cc: qemu-ppc, Laurent Vivier
On 10/11/2022 14:34, Peter Maydell wrote:
> This patchset converts the TYPE_MOS6522 class and its subclasses to
> use 3-phase reset. This is part of the work I'm doing to clean up some
> of the reset-related code by getting rid of the
> device_class_set_parent_reset() function, which is used by
> legacy-reset subclasses which want to chain to their parent's reset
> function. There aren't very many of these devices in total, and if we
> convert them all to 3-phase reset they can use the 3-phase-reset
> equivalent (resettable_class_set_parent_phases()). Eventually this
> will then let us simplify the transitional code for handling old-style
> device reset.
>
> This is 8.0 material. Tested with 'make check' and 'make check-avocado'
> for ppc and m68k builds.
>
> thanks
> --PMM
>
> Peter Maydell (2):
> hw/misc/mos6522: Convert TYPE_MOS6522 to 3-phase reset
> hw/misc: Convert TYPE_MOS6522 subclasses to 3-phase reset
>
> include/hw/misc/mos6522.h | 2 +-
> hw/misc/mac_via.c | 26 ++++++++++++++++----------
> hw/misc/macio/cuda.c | 14 ++++++++------
> hw/misc/macio/pmu.c | 14 ++++++++------
> hw/misc/mos6522.c | 7 ++++---
> 5 files changed, 37 insertions(+), 26 deletions(-)
Again, not having played with the new reset code myself I'm not quite confident
enough to give a Reviewed-by tag, but it appears to do the right thing and passes the
avocado tests so:
Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
ATB,
Mark.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH for-8.0 2/2] hw/misc: Convert TYPE_MOS6522 subclasses to 3-phase reset
2022-11-10 14:34 ` [PATCH for-8.0 2/2] hw/misc: Convert TYPE_MOS6522 subclasses " Peter Maydell
2022-11-10 21:53 ` Richard Henderson
@ 2022-11-30 10:16 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 9+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-11-30 10:16 UTC (permalink / raw)
To: Peter Maydell, qemu-devel; +Cc: qemu-ppc, Laurent Vivier, Mark Cave-Ayland
On 10/11/22 15:34, Peter Maydell wrote:
> 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>
> ---
> 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(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH for-8.0 0/2] hw/misc: Convert MOS6522 devices to 3-phase reset
2022-11-10 14:34 [PATCH for-8.0 0/2] hw/misc: Convert MOS6522 devices to 3-phase reset Peter Maydell
` (2 preceding siblings ...)
2022-11-12 0:58 ` [PATCH for-8.0 0/2] hw/misc: Convert MOS6522 devices " Mark Cave-Ayland
@ 2022-12-16 16:03 ` Peter Maydell
3 siblings, 0 replies; 9+ messages in thread
From: Peter Maydell @ 2022-12-16 16:03 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-ppc, Laurent Vivier, Mark Cave-Ayland
On Thu, 10 Nov 2022 at 14:35, Peter Maydell <peter.maydell@linaro.org> wrote:
>
> This patchset converts the TYPE_MOS6522 class and its subclasses to
> use 3-phase reset. This is part of the work I'm doing to clean up some
> of the reset-related code by getting rid of the
> device_class_set_parent_reset() function, which is used by
> legacy-reset subclasses which want to chain to their parent's reset
> function. There aren't very many of these devices in total, and if we
> convert them all to 3-phase reset they can use the 3-phase-reset
> equivalent (resettable_class_set_parent_phases()). Eventually this
> will then let us simplify the transitional code for handling old-style
> device reset.
I plan to pick these up and send them in a pullreq together
with various other reset-related patches of mine, unless
you'd prefer them to go in some other way.
thanks
-- PMM
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-12-16 16:04 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-10 14:34 [PATCH for-8.0 0/2] hw/misc: Convert MOS6522 devices to 3-phase reset Peter Maydell
2022-11-10 14:34 ` [PATCH for-8.0 1/2] hw/misc/mos6522: Convert TYPE_MOS6522 " Peter Maydell
2022-11-10 19:49 ` Philippe Mathieu-Daudé
2022-11-10 21:52 ` Richard Henderson
2022-11-10 14:34 ` [PATCH for-8.0 2/2] hw/misc: Convert TYPE_MOS6522 subclasses " Peter Maydell
2022-11-10 21:53 ` Richard Henderson
2022-11-30 10:16 ` Philippe Mathieu-Daudé
2022-11-12 0:58 ` [PATCH for-8.0 0/2] hw/misc: Convert MOS6522 devices " Mark Cave-Ayland
2022-12-16 16:03 ` Peter Maydell
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.