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