Laurent Vivier | fa2ba3b | 2019-10-26 18:45:42 +0200 | [diff] [blame] | 1 | /* |
Mark Cave-Ayland | f48d613 | 2021-09-24 08:38:02 +0100 | [diff] [blame] | 2 | * QEMU Macintosh Nubus |
| 3 | * |
| 4 | * Copyright (c) 2013-2018 Laurent Vivier <laurent@vivier.eu> |
Laurent Vivier | fa2ba3b | 2019-10-26 18:45:42 +0200 | [diff] [blame] | 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 | |
| 16 | static void mac_nubus_bridge_init(Object *obj) |
| 17 | { |
Mark Cave-Ayland | f48d613 | 2021-09-24 08:38:02 +0100 | [diff] [blame] | 18 | MacNubusBridge *s = MAC_NUBUS_BRIDGE(obj); |
Mark Cave-Ayland | 1fa0423 | 2021-09-24 08:38:03 +0100 | [diff] [blame] | 19 | NubusBridge *nb = NUBUS_BRIDGE(obj); |
Laurent Vivier | fa2ba3b | 2019-10-26 18:45:42 +0200 | [diff] [blame] | 20 | SysBusDevice *sbd = SYS_BUS_DEVICE(obj); |
Mark Cave-Ayland | d585d89 | 2021-09-24 08:38:04 +0100 | [diff] [blame] | 21 | NubusBus *bus = &nb->bus; |
Laurent Vivier | fa2ba3b | 2019-10-26 18:45:42 +0200 | [diff] [blame] | 22 | |
Mark Cave-Ayland | 03deab9 | 2021-09-24 08:37:52 +0100 | [diff] [blame] | 23 | /* Macintosh only has slots 0x9 to 0xe available */ |
Mark Cave-Ayland | d585d89 | 2021-09-24 08:38:04 +0100 | [diff] [blame] | 24 | bus->slot_available_mask = MAKE_64BIT_MASK(MAC_NUBUS_FIRST_SLOT, |
| 25 | MAC_NUBUS_SLOT_NB); |
Mark Cave-Ayland | 03deab9 | 2021-09-24 08:37:52 +0100 | [diff] [blame] | 26 | |
Mark Cave-Ayland | 62437f9 | 2021-09-24 08:38:00 +0100 | [diff] [blame] | 27 | /* Aliases for slots 0x9 to 0xe */ |
| 28 | memory_region_init_alias(&s->super_slot_alias, obj, "super-slot-alias", |
Mark Cave-Ayland | d585d89 | 2021-09-24 08:38:04 +0100 | [diff] [blame] | 29 | &bus->nubus_mr, |
Mark Cave-Ayland | 62437f9 | 2021-09-24 08:38:00 +0100 | [diff] [blame] | 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", |
Mark Cave-Ayland | d585d89 | 2021-09-24 08:38:04 +0100 | [diff] [blame] | 34 | &bus->nubus_mr, |
Mark Cave-Ayland | 62437f9 | 2021-09-24 08:38:00 +0100 | [diff] [blame] | 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); |
Laurent Vivier | fa2ba3b | 2019-10-26 18:45:42 +0200 | [diff] [blame] | 41 | } |
| 42 | |
| 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, |
Mark Cave-Ayland | f48d613 | 2021-09-24 08:38:02 +0100 | [diff] [blame] | 54 | .instance_size = sizeof(MacNubusBridge), |
Laurent Vivier | fa2ba3b | 2019-10-26 18:45:42 +0200 | [diff] [blame] | 55 | .class_init = mac_nubus_bridge_class_init, |
| 56 | }; |
| 57 | |
| 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) |