migration/doc: We broke backwards compatibility
[qemu/kevin.git] / hw / misc / empty_slot.c
blob37b0ddfb02a90740d03cc75e86218d8f3549d8b6
1 /*
2 * QEMU Empty Slot
4 * The empty_slot device emulates known to a bus but not connected devices.
6 * Copyright (c) 2010 Artyom Tarasenko
8 * This code is licensed under the GNU GPL v2 or (at your option) any later
9 * version.
12 #include "qemu/osdep.h"
13 #include "hw/sysbus.h"
14 #include "hw/qdev-properties.h"
15 #include "hw/misc/empty_slot.h"
16 #include "qapi/error.h"
17 #include "trace.h"
18 #include "qom/object.h"
20 #define TYPE_EMPTY_SLOT "empty_slot"
21 OBJECT_DECLARE_SIMPLE_TYPE(EmptySlot, EMPTY_SLOT)
23 struct EmptySlot {
24 SysBusDevice parent_obj;
26 MemoryRegion iomem;
27 char *name;
28 uint64_t size;
31 static uint64_t empty_slot_read(void *opaque, hwaddr addr,
32 unsigned size)
34 EmptySlot *s = EMPTY_SLOT(opaque);
36 trace_empty_slot_write(addr, size << 1, 0, size, s->name);
38 return 0;
41 static void empty_slot_write(void *opaque, hwaddr addr,
42 uint64_t val, unsigned size)
44 EmptySlot *s = EMPTY_SLOT(opaque);
46 trace_empty_slot_write(addr, size << 1, val, size, s->name);
49 static const MemoryRegionOps empty_slot_ops = {
50 .read = empty_slot_read,
51 .write = empty_slot_write,
52 .endianness = DEVICE_NATIVE_ENDIAN,
55 void empty_slot_init(const char *name, hwaddr addr, uint64_t slot_size)
57 if (slot_size > 0) {
58 /* Only empty slots larger than 0 byte need handling. */
59 DeviceState *dev;
61 dev = qdev_new(TYPE_EMPTY_SLOT);
63 qdev_prop_set_uint64(dev, "size", slot_size);
64 sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
66 sysbus_mmio_map_overlap(SYS_BUS_DEVICE(dev), 0, addr, -10000);
70 static void empty_slot_realize(DeviceState *dev, Error **errp)
72 EmptySlot *s = EMPTY_SLOT(dev);
74 if (s->name == NULL) {
75 s->name = g_strdup("empty-slot");
77 memory_region_init_io(&s->iomem, OBJECT(s), &empty_slot_ops, s,
78 s->name, s->size);
79 sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
82 static Property empty_slot_properties[] = {
83 DEFINE_PROP_UINT64("size", EmptySlot, size, 0),
84 DEFINE_PROP_STRING("name", EmptySlot, name),
85 DEFINE_PROP_END_OF_LIST(),
88 static void empty_slot_class_init(ObjectClass *klass, void *data)
90 DeviceClass *dc = DEVICE_CLASS(klass);
92 dc->realize = empty_slot_realize;
93 device_class_set_props(dc, empty_slot_properties);
94 set_bit(DEVICE_CATEGORY_MISC, dc->categories);
97 static const TypeInfo empty_slot_info = {
98 .name = TYPE_EMPTY_SLOT,
99 .parent = TYPE_SYS_BUS_DEVICE,
100 .instance_size = sizeof(EmptySlot),
101 .class_init = empty_slot_class_init,
104 static void empty_slot_register_types(void)
106 type_register_static(&empty_slot_info);
109 type_init(empty_slot_register_types)