xref: /openbmc/qemu/hw/nubus/mac-nubus-bridge.c (revision ba0fa56bc06e563de68d2a2bf3ddb0cfea1be4f9)
1fa2ba3b8SLaurent Vivier /*
2f48d6134SMark Cave-Ayland  * QEMU Macintosh Nubus
3f48d6134SMark Cave-Ayland  *
4fa2ba3b8SLaurent Vivier  * Copyright (c) 2013-2018 Laurent Vivier <laurent@vivier.eu>
5fa2ba3b8SLaurent Vivier  *
6fa2ba3b8SLaurent Vivier  * This work is licensed under the terms of the GNU GPL, version 2 or later.
7fa2ba3b8SLaurent Vivier  * See the COPYING file in the top-level directory.
8fa2ba3b8SLaurent Vivier  *
9fa2ba3b8SLaurent Vivier  */
10fa2ba3b8SLaurent Vivier 
11fa2ba3b8SLaurent Vivier #include "qemu/osdep.h"
12fa2ba3b8SLaurent Vivier #include "hw/sysbus.h"
13fa2ba3b8SLaurent Vivier #include "hw/nubus/mac-nubus-bridge.h"
14fa2ba3b8SLaurent Vivier 
15fa2ba3b8SLaurent Vivier 
mac_nubus_bridge_init(Object * obj)16fa2ba3b8SLaurent Vivier static void mac_nubus_bridge_init(Object *obj)
17fa2ba3b8SLaurent Vivier {
18f48d6134SMark Cave-Ayland     MacNubusBridge *s = MAC_NUBUS_BRIDGE(obj);
191fa04232SMark Cave-Ayland     NubusBridge *nb = NUBUS_BRIDGE(obj);
20fa2ba3b8SLaurent Vivier     SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
21*d585d89dSMark Cave-Ayland     NubusBus *bus = &nb->bus;
22fa2ba3b8SLaurent Vivier 
2303deab99SMark Cave-Ayland     /* Macintosh only has slots 0x9 to 0xe available */
24*d585d89dSMark Cave-Ayland     bus->slot_available_mask = MAKE_64BIT_MASK(MAC_NUBUS_FIRST_SLOT,
2503deab99SMark Cave-Ayland                                                MAC_NUBUS_SLOT_NB);
2603deab99SMark Cave-Ayland 
2762437f90SMark Cave-Ayland     /* Aliases for slots 0x9 to 0xe */
2862437f90SMark Cave-Ayland     memory_region_init_alias(&s->super_slot_alias, obj, "super-slot-alias",
29*d585d89dSMark Cave-Ayland                              &bus->nubus_mr,
3062437f90SMark Cave-Ayland                              MAC_NUBUS_FIRST_SLOT * NUBUS_SUPER_SLOT_SIZE,
3162437f90SMark Cave-Ayland                              MAC_NUBUS_SLOT_NB * NUBUS_SUPER_SLOT_SIZE);
3262437f90SMark Cave-Ayland 
3362437f90SMark Cave-Ayland     memory_region_init_alias(&s->slot_alias, obj, "slot-alias",
34*d585d89dSMark Cave-Ayland                              &bus->nubus_mr,
3562437f90SMark Cave-Ayland                              NUBUS_SLOT_BASE +
3662437f90SMark Cave-Ayland                              MAC_NUBUS_FIRST_SLOT * NUBUS_SLOT_SIZE,
3762437f90SMark Cave-Ayland                              MAC_NUBUS_SLOT_NB * NUBUS_SLOT_SIZE);
3862437f90SMark Cave-Ayland 
3962437f90SMark Cave-Ayland     sysbus_init_mmio(sbd, &s->super_slot_alias);
4062437f90SMark Cave-Ayland     sysbus_init_mmio(sbd, &s->slot_alias);
41fa2ba3b8SLaurent Vivier }
42fa2ba3b8SLaurent Vivier 
mac_nubus_bridge_class_init(ObjectClass * klass,void * data)43fa2ba3b8SLaurent Vivier static void mac_nubus_bridge_class_init(ObjectClass *klass, void *data)
44fa2ba3b8SLaurent Vivier {
45fa2ba3b8SLaurent Vivier     DeviceClass *dc = DEVICE_CLASS(klass);
46fa2ba3b8SLaurent Vivier 
47fa2ba3b8SLaurent Vivier     dc->desc = "Nubus bridge";
48fa2ba3b8SLaurent Vivier }
49fa2ba3b8SLaurent Vivier 
50fa2ba3b8SLaurent Vivier static const TypeInfo mac_nubus_bridge_info = {
51fa2ba3b8SLaurent Vivier     .name          = TYPE_MAC_NUBUS_BRIDGE,
52fa2ba3b8SLaurent Vivier     .parent        = TYPE_NUBUS_BRIDGE,
53fa2ba3b8SLaurent Vivier     .instance_init = mac_nubus_bridge_init,
54f48d6134SMark Cave-Ayland     .instance_size = sizeof(MacNubusBridge),
55fa2ba3b8SLaurent Vivier     .class_init    = mac_nubus_bridge_class_init,
56fa2ba3b8SLaurent Vivier };
57fa2ba3b8SLaurent Vivier 
mac_nubus_bridge_register_types(void)58fa2ba3b8SLaurent Vivier static void mac_nubus_bridge_register_types(void)
59fa2ba3b8SLaurent Vivier {
60fa2ba3b8SLaurent Vivier     type_register_static(&mac_nubus_bridge_info);
61fa2ba3b8SLaurent Vivier }
62fa2ba3b8SLaurent Vivier 
63fa2ba3b8SLaurent Vivier type_init(mac_nubus_bridge_register_types)
64