tests/acpi: virt: update golden masters for DSDT
[qemu/ar7.git] / hw / nubus / nubus-bus.c
blob942a6d5342d325ab0a8f746579c7c57d7c6ea6e6
1 /*
2 * QEMU Macintosh Nubus
4 * Copyright (c) 2013-2018 Laurent Vivier <laurent@vivier.eu>
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.
9 */
11 #include "qemu/osdep.h"
12 #include "hw/nubus/nubus.h"
13 #include "hw/sysbus.h"
14 #include "qapi/error.h"
17 static NubusBus *nubus_find(void)
19 /* Returns NULL unless there is exactly one nubus device */
20 return NUBUS_BUS(object_resolve_path_type("", TYPE_NUBUS_BUS, NULL));
23 static void nubus_slot_write(void *opaque, hwaddr addr, uint64_t val,
24 unsigned int size)
26 /* read only */
30 static uint64_t nubus_slot_read(void *opaque, hwaddr addr,
31 unsigned int size)
33 return 0;
36 static const MemoryRegionOps nubus_slot_ops = {
37 .read = nubus_slot_read,
38 .write = nubus_slot_write,
39 .endianness = DEVICE_BIG_ENDIAN,
40 .valid = {
41 .min_access_size = 1,
42 .max_access_size = 1,
46 static void nubus_super_slot_write(void *opaque, hwaddr addr, uint64_t val,
47 unsigned int size)
49 /* read only */
52 static uint64_t nubus_super_slot_read(void *opaque, hwaddr addr,
53 unsigned int size)
55 return 0;
58 static const MemoryRegionOps nubus_super_slot_ops = {
59 .read = nubus_super_slot_read,
60 .write = nubus_super_slot_write,
61 .endianness = DEVICE_BIG_ENDIAN,
62 .valid = {
63 .min_access_size = 1,
64 .max_access_size = 1,
68 static void nubus_realize(BusState *bus, Error **errp)
70 if (!nubus_find()) {
71 error_setg(errp, "at most one %s device is permitted", TYPE_NUBUS_BUS);
72 return;
76 static void nubus_init(Object *obj)
78 NubusBus *nubus = NUBUS_BUS(obj);
80 memory_region_init_io(&nubus->super_slot_io, obj, &nubus_super_slot_ops,
81 nubus, "nubus-super-slots",
82 NUBUS_SUPER_SLOT_NB * NUBUS_SUPER_SLOT_SIZE);
84 memory_region_init_io(&nubus->slot_io, obj, &nubus_slot_ops,
85 nubus, "nubus-slots",
86 NUBUS_SLOT_NB * NUBUS_SLOT_SIZE);
88 nubus->current_slot = NUBUS_FIRST_SLOT;
91 static void nubus_class_init(ObjectClass *oc, void *data)
93 BusClass *bc = BUS_CLASS(oc);
95 bc->realize = nubus_realize;
98 static const TypeInfo nubus_bus_info = {
99 .name = TYPE_NUBUS_BUS,
100 .parent = TYPE_BUS,
101 .instance_size = sizeof(NubusBus),
102 .instance_init = nubus_init,
103 .class_init = nubus_class_init,
106 static void nubus_register_types(void)
108 type_register_static(&nubus_bus_info);
111 type_init(nubus_register_types)