mirror of https://github.com/proxmox/mirror_qemu
hw/misc: Convert TYPE_MOS6522 subclasses to 3-phase reset
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.orgmaster
parent
8bdaed0f30
commit
ed053e8997
|
@ -975,14 +975,16 @@ static int via1_post_load(void *opaque, int version_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* VIA 1 */
|
/* 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);
|
MOS6522State *ms = MOS6522(v1s);
|
||||||
MOS6522DeviceClass *mdc = MOS6522_GET_CLASS(ms);
|
MOS6522DeviceClass *mdc = MOS6522_GET_CLASS(ms);
|
||||||
ADBBusState *adb_bus = &v1s->adb_bus;
|
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[0].frequency = VIA_TIMER_FREQ;
|
||||||
ms->timers[1].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)
|
static void mos6522_q800_via1_class_init(ObjectClass *oc, void *data)
|
||||||
{
|
{
|
||||||
DeviceClass *dc = DEVICE_CLASS(oc);
|
DeviceClass *dc = DEVICE_CLASS(oc);
|
||||||
|
ResettableClass *rc = RESETTABLE_CLASS(oc);
|
||||||
MOS6522DeviceClass *mdc = MOS6522_CLASS(oc);
|
MOS6522DeviceClass *mdc = MOS6522_CLASS(oc);
|
||||||
|
|
||||||
dc->realize = mos6522_q800_via1_realize;
|
dc->realize = mos6522_q800_via1_realize;
|
||||||
device_class_set_parent_reset(dc, mos6522_q800_via1_reset,
|
resettable_class_set_parent_phases(rc, NULL, mos6522_q800_via1_reset_hold,
|
||||||
&mdc->parent_reset);
|
NULL, &mdc->parent_phases);
|
||||||
dc->vmsd = &vmstate_q800_via1;
|
dc->vmsd = &vmstate_q800_via1;
|
||||||
device_class_set_props(dc, mos6522_q800_via1_properties);
|
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);
|
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[0].frequency = VIA_TIMER_FREQ;
|
||||||
ms->timers[1].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)
|
static void mos6522_q800_via2_class_init(ObjectClass *oc, void *data)
|
||||||
{
|
{
|
||||||
DeviceClass *dc = DEVICE_CLASS(oc);
|
DeviceClass *dc = DEVICE_CLASS(oc);
|
||||||
|
ResettableClass *rc = RESETTABLE_CLASS(oc);
|
||||||
MOS6522DeviceClass *mdc = MOS6522_CLASS(oc);
|
MOS6522DeviceClass *mdc = MOS6522_CLASS(oc);
|
||||||
|
|
||||||
device_class_set_parent_reset(dc, mos6522_q800_via2_reset,
|
resettable_class_set_parent_phases(rc, NULL, mos6522_q800_via2_reset_hold,
|
||||||
&mdc->parent_reset);
|
NULL, &mdc->parent_phases);
|
||||||
dc->vmsd = &vmstate_q800_via2;
|
dc->vmsd = &vmstate_q800_via2;
|
||||||
mdc->portB_write = mos6522_q800_via2_portB_write;
|
mdc->portB_write = mos6522_q800_via2_portB_write;
|
||||||
}
|
}
|
||||||
|
|
|
@ -589,12 +589,14 @@ static void mos6522_cuda_portB_write(MOS6522State *s)
|
||||||
cuda_update(cs);
|
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);
|
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[0].frequency = CUDA_TIMER_FREQ;
|
||||||
ms->timers[1].frequency = (SCALE_US * 6000) / 4700;
|
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)
|
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);
|
MOS6522DeviceClass *mdc = MOS6522_CLASS(oc);
|
||||||
|
|
||||||
device_class_set_parent_reset(dc, mos6522_cuda_reset,
|
resettable_class_set_parent_phases(rc, NULL, mos6522_cuda_reset_hold,
|
||||||
&mdc->parent_reset);
|
NULL, &mdc->parent_phases);
|
||||||
mdc->portB_write = mos6522_cuda_portB_write;
|
mdc->portB_write = mos6522_cuda_portB_write;
|
||||||
mdc->get_timer1_counter_value = cuda_get_counter_value;
|
mdc->get_timer1_counter_value = cuda_get_counter_value;
|
||||||
mdc->get_timer2_counter_value = cuda_get_counter_value;
|
mdc->get_timer2_counter_value = cuda_get_counter_value;
|
||||||
|
|
|
@ -797,14 +797,16 @@ static void mos6522_pmu_portB_write(MOS6522State *s)
|
||||||
pmu_update(ps);
|
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);
|
MOS6522PMUState *mps = container_of(ms, MOS6522PMUState, parent_obj);
|
||||||
PMUState *s = container_of(mps, PMUState, mos6522_pmu);
|
PMUState *s = container_of(mps, PMUState, mos6522_pmu);
|
||||||
MOS6522DeviceClass *mdc = MOS6522_GET_CLASS(ms);
|
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[0].frequency = VIA_TIMER_FREQ;
|
||||||
ms->timers[1].frequency = (SCALE_US * 6000) / 4700;
|
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)
|
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);
|
MOS6522DeviceClass *mdc = MOS6522_CLASS(oc);
|
||||||
|
|
||||||
device_class_set_parent_reset(dc, mos6522_pmu_reset,
|
resettable_class_set_parent_phases(rc, NULL, mos6522_pmu_reset_hold,
|
||||||
&mdc->parent_reset);
|
NULL, &mdc->parent_phases);
|
||||||
mdc->portB_write = mos6522_pmu_portB_write;
|
mdc->portB_write = mos6522_pmu_portB_write;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -157,7 +157,7 @@ OBJECT_DECLARE_TYPE(MOS6522State, MOS6522DeviceClass, MOS6522)
|
||||||
struct MOS6522DeviceClass {
|
struct MOS6522DeviceClass {
|
||||||
DeviceClass parent_class;
|
DeviceClass parent_class;
|
||||||
|
|
||||||
DeviceReset parent_reset;
|
ResettablePhases parent_phases;
|
||||||
void (*portB_write)(MOS6522State *dev);
|
void (*portB_write)(MOS6522State *dev);
|
||||||
void (*portA_write)(MOS6522State *dev);
|
void (*portA_write)(MOS6522State *dev);
|
||||||
/* These are used to influence the CUDA MacOS timebase calibration */
|
/* These are used to influence the CUDA MacOS timebase calibration */
|
||||||
|
|
Loading…
Reference in New Issue