mac_via: move VIA1 portB write logic into mos6522_q800_via1_write()

Currently the logic is split between the mos6522 portB_write() callback and
the memory region used to capture the VIA1 MMIO accesses. Move everything
into the latter mos6522_q800_via1_write() function to keep all the logic in
one place to make it easier to follow.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Finn Thain <fthain@telegraphics.com.au>
Acked-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200623204936.24064-19-mark.cave-ayland@ilande.co.uk>
This commit is contained in:
Mark Cave-Ayland 2020-06-23 21:49:32 +01:00
parent cf093b0772
commit 378a503479

View File

@ -801,11 +801,21 @@ static void mos6522_q800_via1_write(void *opaque, hwaddr addr, uint64_t val,
unsigned size) unsigned size)
{ {
MOS6522Q800VIA1State *v1s = MOS6522_Q800_VIA1(opaque); MOS6522Q800VIA1State *v1s = MOS6522_Q800_VIA1(opaque);
MacVIAState *m = container_of(v1s, MacVIAState, mos6522_via1);
MOS6522State *ms = MOS6522(v1s); MOS6522State *ms = MOS6522(v1s);
addr = (addr >> 9) & 0xf; addr = (addr >> 9) & 0xf;
mos6522_write(ms, addr, val, size); mos6522_write(ms, addr, val, size);
switch (addr) {
case VIA_REG_B:
via1_rtc_update(m);
via1_adb_update(m);
v1s->last_b = ms->b;
break;
}
via1_one_second_update(v1s); via1_one_second_update(v1s);
via1_VBL_update(v1s); via1_VBL_update(v1s);
} }
@ -1037,18 +1047,6 @@ static TypeInfo mac_via_info = {
}; };
/* VIA 1 */ /* VIA 1 */
static void mos6522_q800_via1_portB_write(MOS6522State *s)
{
MOS6522Q800VIA1State *v1s = container_of(s, MOS6522Q800VIA1State,
parent_obj);
MacVIAState *m = container_of(v1s, MacVIAState, mos6522_via1);
via1_rtc_update(m);
via1_adb_update(m);
v1s->last_b = s->b;
}
static void mos6522_q800_via1_reset(DeviceState *dev) static void mos6522_q800_via1_reset(DeviceState *dev)
{ {
MOS6522State *ms = MOS6522(dev); MOS6522State *ms = MOS6522(dev);
@ -1071,10 +1069,8 @@ static void mos6522_q800_via1_init(Object *obj)
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);
MOS6522DeviceClass *mdc = MOS6522_DEVICE_CLASS(oc);
dc->reset = mos6522_q800_via1_reset; dc->reset = mos6522_q800_via1_reset;
mdc->portB_write = mos6522_q800_via1_portB_write;
} }
static const TypeInfo mos6522_q800_via1_type_info = { static const TypeInfo mos6522_q800_via1_type_info = {