1
2
3
4
5
6
7
8
9
10
11#include "qemu/osdep.h"
12#include "hw/nubus/nubus.h"
13#include "hw/sysbus.h"
14#include "qapi/error.h"
15
16
17static NubusBus *nubus_find(void)
18{
19
20 return NUBUS_BUS(object_resolve_path_type("", TYPE_NUBUS_BUS, NULL));
21}
22
23static void nubus_slot_write(void *opaque, hwaddr addr, uint64_t val,
24 unsigned int size)
25{
26
27}
28
29
30static uint64_t nubus_slot_read(void *opaque, hwaddr addr,
31 unsigned int size)
32{
33 return 0;
34}
35
36static 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,
43 },
44};
45
46static void nubus_super_slot_write(void *opaque, hwaddr addr, uint64_t val,
47 unsigned int size)
48{
49
50}
51
52static uint64_t nubus_super_slot_read(void *opaque, hwaddr addr,
53 unsigned int size)
54{
55 return 0;
56}
57
58static 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,
65 },
66};
67
68static void nubus_realize(BusState *bus, Error **errp)
69{
70 if (!nubus_find()) {
71 error_setg(errp, "at most one %s device is permitted", TYPE_NUBUS_BUS);
72 return;
73 }
74}
75
76static void nubus_init(Object *obj)
77{
78 NubusBus *nubus = NUBUS_BUS(obj);
79
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);
83
84 memory_region_init_io(&nubus->slot_io, obj, &nubus_slot_ops,
85 nubus, "nubus-slots",
86 NUBUS_SLOT_NB * NUBUS_SLOT_SIZE);
87
88 nubus->current_slot = NUBUS_FIRST_SLOT;
89}
90
91static void nubus_class_init(ObjectClass *oc, void *data)
92{
93 BusClass *bc = BUS_CLASS(oc);
94
95 bc->realize = nubus_realize;
96}
97
98static 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,
104};
105
106static void nubus_register_types(void)
107{
108 type_register_static(&nubus_bus_info);
109}
110
111type_init(nubus_register_types)
112