Skip to content

Commit 378a503

Browse files
committed
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 <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Tested-by: Finn Thain <[email protected]> Acked-by: Laurent Vivier <[email protected]> Message-Id: <[email protected]>
1 parent cf093b0 commit 378a503

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

hw/misc/mac_via.c

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -801,11 +801,21 @@ static void mos6522_q800_via1_write(void *opaque, hwaddr addr, uint64_t val,
801801
unsigned size)
802802
{
803803
MOS6522Q800VIA1State *v1s = MOS6522_Q800_VIA1(opaque);
804+
MacVIAState *m = container_of(v1s, MacVIAState, mos6522_via1);
804805
MOS6522State *ms = MOS6522(v1s);
805806

806807
addr = (addr >> 9) & 0xf;
807808
mos6522_write(ms, addr, val, size);
808809

810+
switch (addr) {
811+
case VIA_REG_B:
812+
via1_rtc_update(m);
813+
via1_adb_update(m);
814+
815+
v1s->last_b = ms->b;
816+
break;
817+
}
818+
809819
via1_one_second_update(v1s);
810820
via1_VBL_update(v1s);
811821
}
@@ -1037,18 +1047,6 @@ static TypeInfo mac_via_info = {
10371047
};
10381048

10391049
/* VIA 1 */
1040-
static void mos6522_q800_via1_portB_write(MOS6522State *s)
1041-
{
1042-
MOS6522Q800VIA1State *v1s = container_of(s, MOS6522Q800VIA1State,
1043-
parent_obj);
1044-
MacVIAState *m = container_of(v1s, MacVIAState, mos6522_via1);
1045-
1046-
via1_rtc_update(m);
1047-
via1_adb_update(m);
1048-
1049-
v1s->last_b = s->b;
1050-
}
1051-
10521050
static void mos6522_q800_via1_reset(DeviceState *dev)
10531051
{
10541052
MOS6522State *ms = MOS6522(dev);
@@ -1071,10 +1069,8 @@ static void mos6522_q800_via1_init(Object *obj)
10711069
static void mos6522_q800_via1_class_init(ObjectClass *oc, void *data)
10721070
{
10731071
DeviceClass *dc = DEVICE_CLASS(oc);
1074-
MOS6522DeviceClass *mdc = MOS6522_DEVICE_CLASS(oc);
10751072

10761073
dc->reset = mos6522_q800_via1_reset;
1077-
mdc->portB_write = mos6522_q800_via1_portB_write;
10781074
}
10791075

10801076
static const TypeInfo mos6522_q800_via1_type_info = {

0 commit comments

Comments
 (0)