Commit 378a5034 authored by Mark Cave-Ayland's avatar Mark Cave-Ayland
Browse files

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: default avatarMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: default avatarFinn Thain <fthain@telegraphics.com.au>
Acked-by: default avatarLaurent Vivier <laurent@vivier.eu>
Message-Id: <20200623204936.24064-19-mark.cave-ayland@ilande.co.uk>
parent cf093b07
Loading
Loading
Loading
Loading
+10 −14
Original line number Diff line number Diff line
@@ -801,11 +801,21 @@ static void mos6522_q800_via1_write(void *opaque, hwaddr addr, uint64_t val,
                                    unsigned size)
{
    MOS6522Q800VIA1State *v1s = MOS6522_Q800_VIA1(opaque);
    MacVIAState *m = container_of(v1s, MacVIAState, mos6522_via1);
    MOS6522State *ms = MOS6522(v1s);

    addr = (addr >> 9) & 0xf;
    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_VBL_update(v1s);
}
@@ -1037,18 +1047,6 @@ static TypeInfo mac_via_info = {
};

/* 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)
{
    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)
{
    DeviceClass *dc = DEVICE_CLASS(oc);
    MOS6522DeviceClass *mdc = MOS6522_DEVICE_CLASS(oc);

    dc->reset = mos6522_q800_via1_reset;
    mdc->portB_write = mos6522_q800_via1_portB_write;
}

static const TypeInfo mos6522_q800_via1_type_info = {