mac_via: remove mac_via device
Remove the mac_via device and wire up both q800 VIA1 and VIA2 directly for the m68k q800 machine. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20210830102447.10806-10-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
This commit is contained in:
parent
846ae7c636
commit
02a68a3e65
@ -225,7 +225,7 @@ static void q800_init(MachineState *machine)
|
||||
hwaddr parameters_base;
|
||||
CPUState *cs;
|
||||
DeviceState *dev;
|
||||
DeviceState *via_dev, *via1_dev;
|
||||
DeviceState *via1_dev, *via2_dev;
|
||||
DeviceState *escc_orgate;
|
||||
SysBusESPState *sysbus_esp;
|
||||
ESPState *esp;
|
||||
@ -270,28 +270,30 @@ static void q800_init(MachineState *machine)
|
||||
object_property_set_link(OBJECT(glue), "cpu", OBJECT(cpu), &error_abort);
|
||||
sysbus_realize_and_unref(SYS_BUS_DEVICE(glue), &error_fatal);
|
||||
|
||||
/* VIA */
|
||||
|
||||
via_dev = qdev_new(TYPE_MAC_VIA);
|
||||
/* VIA 1 */
|
||||
via1_dev = qdev_new(TYPE_MOS6522_Q800_VIA1);
|
||||
dinfo = drive_get(IF_MTD, 0, 0);
|
||||
if (dinfo) {
|
||||
qdev_prop_set_drive(via_dev, "drive", blk_by_legacy_dinfo(dinfo));
|
||||
qdev_prop_set_drive(via1_dev, "drive", blk_by_legacy_dinfo(dinfo));
|
||||
}
|
||||
sysbus = SYS_BUS_DEVICE(via_dev);
|
||||
sysbus = SYS_BUS_DEVICE(via1_dev);
|
||||
sysbus_realize_and_unref(sysbus, &error_fatal);
|
||||
sysbus_mmio_map(sysbus, 0, VIA_BASE);
|
||||
qdev_connect_gpio_out_named(DEVICE(sysbus), "irq", 0,
|
||||
qdev_get_gpio_in(glue, 0));
|
||||
qdev_connect_gpio_out_named(DEVICE(sysbus), "irq", 1,
|
||||
qdev_get_gpio_in(glue, 1));
|
||||
sysbus_mmio_map(sysbus, 1, VIA_BASE);
|
||||
sysbus_connect_irq(sysbus, 0, qdev_get_gpio_in(glue, 0));
|
||||
|
||||
via1_dev = DEVICE(MOS6522_Q800_VIA1(&MAC_VIA(via_dev)->mos6522_via1));
|
||||
adb_bus = qdev_get_child_bus(DEVICE(via1_dev), "adb.0");
|
||||
adb_bus = qdev_get_child_bus(via1_dev, "adb.0");
|
||||
dev = qdev_new(TYPE_ADB_KEYBOARD);
|
||||
qdev_realize_and_unref(dev, adb_bus, &error_fatal);
|
||||
dev = qdev_new(TYPE_ADB_MOUSE);
|
||||
qdev_realize_and_unref(dev, adb_bus, &error_fatal);
|
||||
|
||||
/* VIA 2 */
|
||||
via2_dev = qdev_new(TYPE_MOS6522_Q800_VIA2);
|
||||
sysbus = SYS_BUS_DEVICE(via2_dev);
|
||||
sysbus_realize_and_unref(sysbus, &error_fatal);
|
||||
sysbus_mmio_map(sysbus, 1, VIA_BASE + VIA_SIZE);
|
||||
sysbus_connect_irq(sysbus, 0, qdev_get_gpio_in(glue, 1));
|
||||
|
||||
/* MACSONIC */
|
||||
|
||||
if (nb_nics > 1) {
|
||||
@ -375,11 +377,11 @@ static void q800_init(MachineState *machine)
|
||||
|
||||
sysbus = SYS_BUS_DEVICE(dev);
|
||||
sysbus_realize_and_unref(sysbus, &error_fatal);
|
||||
sysbus_connect_irq(sysbus, 0, qdev_get_gpio_in_named(via_dev,
|
||||
sysbus_connect_irq(sysbus, 0, qdev_get_gpio_in_named(via2_dev,
|
||||
"via2-irq",
|
||||
VIA2_IRQ_SCSI_BIT));
|
||||
sysbus_connect_irq(sysbus, 1,
|
||||
qdev_get_gpio_in_named(via_dev, "via2-irq",
|
||||
qdev_get_gpio_in_named(via2_dev, "via2-irq",
|
||||
VIA2_IRQ_SCSI_DATA_BIT));
|
||||
sysbus_mmio_map(sysbus, 0, ESP_BASE);
|
||||
sysbus_mmio_map(sysbus, 1, ESP_PDMA);
|
||||
|
@ -34,11 +34,9 @@
|
||||
#include "qemu/log.h"
|
||||
|
||||
/*
|
||||
* VIAs: There are two in every machine,
|
||||
* VIAs: There are two in every machine
|
||||
*/
|
||||
|
||||
#define VIA_SIZE (0x2000)
|
||||
|
||||
/*
|
||||
* Not all of these are true post MacII I think.
|
||||
* CSA: probably the ones CHRP marks as 'unused' change purposes
|
||||
@ -945,52 +943,6 @@ static const MemoryRegionOps mos6522_q800_via2_ops = {
|
||||
},
|
||||
};
|
||||
|
||||
static void mac_via_realize(DeviceState *dev, Error **errp)
|
||||
{
|
||||
MacVIAState *m = MAC_VIA(dev);
|
||||
MOS6522State *ms;
|
||||
|
||||
/* Pass through mos6522 output IRQs */
|
||||
ms = MOS6522(&m->mos6522_via1);
|
||||
object_property_add_alias(OBJECT(dev), "irq[0]", OBJECT(ms),
|
||||
SYSBUS_DEVICE_GPIO_IRQ "[0]");
|
||||
ms = MOS6522(&m->mos6522_via2);
|
||||
object_property_add_alias(OBJECT(dev), "irq[1]", OBJECT(ms),
|
||||
SYSBUS_DEVICE_GPIO_IRQ "[0]");
|
||||
|
||||
sysbus_realize(SYS_BUS_DEVICE(&m->mos6522_via1), &error_abort);
|
||||
sysbus_realize(SYS_BUS_DEVICE(&m->mos6522_via2), &error_abort);
|
||||
|
||||
/* Pass through mos6522 input IRQs */
|
||||
qdev_pass_gpios(DEVICE(&m->mos6522_via1), dev, "via1-irq");
|
||||
qdev_pass_gpios(DEVICE(&m->mos6522_via2), dev, "via2-irq");
|
||||
}
|
||||
|
||||
static void mac_via_init(Object *obj)
|
||||
{
|
||||
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
|
||||
MacVIAState *m = MAC_VIA(obj);
|
||||
|
||||
/* MMIO */
|
||||
memory_region_init(&m->mmio, obj, "mac-via", 2 * VIA_SIZE);
|
||||
sysbus_init_mmio(sbd, &m->mmio);
|
||||
|
||||
memory_region_init_io(&m->via1mem, obj, &mos6522_q800_via1_ops,
|
||||
&m->mos6522_via1, "via1", VIA_SIZE);
|
||||
memory_region_add_subregion(&m->mmio, 0x0, &m->via1mem);
|
||||
|
||||
memory_region_init_io(&m->via2mem, obj, &mos6522_q800_via2_ops,
|
||||
&m->mos6522_via2, "via2", VIA_SIZE);
|
||||
memory_region_add_subregion(&m->mmio, VIA_SIZE, &m->via2mem);
|
||||
|
||||
/* Init VIAs 1 and 2 */
|
||||
object_initialize_child(obj, "via1", &m->mos6522_via1,
|
||||
TYPE_MOS6522_Q800_VIA1);
|
||||
|
||||
object_initialize_child(obj, "via2", &m->mos6522_via2,
|
||||
TYPE_MOS6522_Q800_VIA2);
|
||||
}
|
||||
|
||||
static void via1_postload_update_cb(void *opaque, bool running, RunState state)
|
||||
{
|
||||
MOS6522Q800VIA1State *v1s = MOS6522_Q800_VIA1(opaque);
|
||||
@ -1013,21 +965,6 @@ static int via1_post_load(void *opaque, int version_id)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void mac_via_class_init(ObjectClass *oc, void *data)
|
||||
{
|
||||
DeviceClass *dc = DEVICE_CLASS(oc);
|
||||
|
||||
dc->realize = mac_via_realize;
|
||||
}
|
||||
|
||||
static TypeInfo mac_via_info = {
|
||||
.name = TYPE_MAC_VIA,
|
||||
.parent = TYPE_SYS_BUS_DEVICE,
|
||||
.instance_size = sizeof(MacVIAState),
|
||||
.instance_init = mac_via_init,
|
||||
.class_init = mac_via_class_init,
|
||||
};
|
||||
|
||||
/* VIA 1 */
|
||||
static void mos6522_q800_via1_reset(DeviceState *dev)
|
||||
{
|
||||
@ -1095,6 +1032,11 @@ static void mos6522_q800_via1_realize(DeviceState *dev, Error **errp)
|
||||
static void mos6522_q800_via1_init(Object *obj)
|
||||
{
|
||||
MOS6522Q800VIA1State *v1s = MOS6522_Q800_VIA1(obj);
|
||||
SysBusDevice *sbd = SYS_BUS_DEVICE(v1s);
|
||||
|
||||
memory_region_init_io(&v1s->via_mem, obj, &mos6522_q800_via1_ops, v1s,
|
||||
"via1", VIA_SIZE);
|
||||
sysbus_init_mmio(sbd, &v1s->via_mem);
|
||||
|
||||
/* ADB */
|
||||
qbus_create_inplace((BusState *)&v1s->adb_bus, sizeof(v1s->adb_bus),
|
||||
@ -1187,6 +1129,13 @@ static void mos6522_q800_via2_reset(DeviceState *dev)
|
||||
|
||||
static void mos6522_q800_via2_init(Object *obj)
|
||||
{
|
||||
MOS6522Q800VIA2State *v2s = MOS6522_Q800_VIA2(obj);
|
||||
SysBusDevice *sbd = SYS_BUS_DEVICE(v2s);
|
||||
|
||||
memory_region_init_io(&v2s->via_mem, obj, &mos6522_q800_via2_ops, v2s,
|
||||
"via2", VIA_SIZE);
|
||||
sysbus_init_mmio(sbd, &v2s->via_mem);
|
||||
|
||||
qdev_init_gpio_in_named(DEVICE(obj), via2_irq_request, "via2-irq",
|
||||
VIA2_IRQ_NB);
|
||||
}
|
||||
@ -1224,7 +1173,6 @@ static void mac_via_register_types(void)
|
||||
{
|
||||
type_register_static(&mos6522_q800_via1_type_info);
|
||||
type_register_static(&mos6522_q800_via2_type_info);
|
||||
type_register_static(&mac_via_info);
|
||||
}
|
||||
|
||||
type_init(mac_via_register_types);
|
||||
|
@ -15,6 +15,8 @@
|
||||
#include "qom/object.h"
|
||||
|
||||
|
||||
#define VIA_SIZE 0x2000
|
||||
|
||||
/* VIA 1 */
|
||||
#define VIA1_IRQ_ONE_SECOND_BIT 0
|
||||
#define VIA1_IRQ_60HZ_BIT 1
|
||||
@ -38,6 +40,8 @@ struct MOS6522Q800VIA1State {
|
||||
/*< private >*/
|
||||
MOS6522State parent_obj;
|
||||
|
||||
MemoryRegion via_mem;
|
||||
|
||||
qemu_irq irqs[VIA1_IRQ_NB];
|
||||
uint8_t last_b;
|
||||
|
||||
@ -95,23 +99,8 @@ OBJECT_DECLARE_SIMPLE_TYPE(MOS6522Q800VIA2State, MOS6522_Q800_VIA2)
|
||||
struct MOS6522Q800VIA2State {
|
||||
/*< private >*/
|
||||
MOS6522State parent_obj;
|
||||
};
|
||||
|
||||
|
||||
#define TYPE_MAC_VIA "mac_via"
|
||||
OBJECT_DECLARE_SIMPLE_TYPE(MacVIAState, MAC_VIA)
|
||||
|
||||
struct MacVIAState {
|
||||
SysBusDevice busdev;
|
||||
|
||||
/* MMIO */
|
||||
MemoryRegion mmio;
|
||||
MemoryRegion via1mem;
|
||||
MemoryRegion via2mem;
|
||||
|
||||
/* VIAs */
|
||||
MOS6522Q800VIA1State mos6522_via1;
|
||||
MOS6522Q800VIA2State mos6522_via2;
|
||||
MemoryRegion via_mem;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user