g364fb: switch to using DirtyBitmapSnapshot
[qemu/ar7.git] / hw / core / empty_slot.c
blobc1b9c2b10416bb3e5036ba70a432082c6a76e45a
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/hw.h"
14 #include "hw/sysbus.h"
15 #include "hw/empty_slot.h"
17 //#define DEBUG_EMPTY_SLOT
19 #ifdef DEBUG_EMPTY_SLOT
20 #define DPRINTF(fmt, ...) \
21 do { printf("empty_slot: " fmt , ## __VA_ARGS__); } while (0)
22 #else
23 #define DPRINTF(fmt, ...) do {} while (0)
24 #endif
26 #define TYPE_EMPTY_SLOT "empty_slot"
27 #define EMPTY_SLOT(obj) OBJECT_CHECK(EmptySlot, (obj), TYPE_EMPTY_SLOT)
29 typedef struct EmptySlot {
30 SysBusDevice parent_obj;
32 MemoryRegion iomem;
33 uint64_t size;
34 } EmptySlot;
36 static uint64_t empty_slot_read(void *opaque, hwaddr addr,
37 unsigned size)
39 DPRINTF("read from " TARGET_FMT_plx "\n", addr);
40 return 0;
43 static void empty_slot_write(void *opaque, hwaddr addr,
44 uint64_t val, unsigned size)
46 DPRINTF("write 0x%x to " TARGET_FMT_plx "\n", (unsigned)val, addr);
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(hwaddr addr, uint64_t slot_size)
57 if (slot_size > 0) {
58 /* Only empty slots larger than 0 byte need handling. */
59 DeviceState *dev;
60 SysBusDevice *s;
61 EmptySlot *e;
63 dev = qdev_create(NULL, TYPE_EMPTY_SLOT);
64 s = SYS_BUS_DEVICE(dev);
65 e = EMPTY_SLOT(dev);
66 e->size = slot_size;
68 qdev_init_nofail(dev);
70 sysbus_mmio_map(s, 0, addr);
74 static int empty_slot_init1(SysBusDevice *dev)
76 EmptySlot *s = EMPTY_SLOT(dev);
78 memory_region_init_io(&s->iomem, OBJECT(s), &empty_slot_ops, s,
79 "empty-slot", s->size);
80 sysbus_init_mmio(dev, &s->iomem);
81 return 0;
84 static void empty_slot_class_init(ObjectClass *klass, void *data)
86 SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
88 k->init = empty_slot_init1;
91 static const TypeInfo empty_slot_info = {
92 .name = TYPE_EMPTY_SLOT,
93 .parent = TYPE_SYS_BUS_DEVICE,
94 .instance_size = sizeof(EmptySlot),
95 .class_init = empty_slot_class_init,
98 static void empty_slot_register_types(void)
100 type_register_static(&empty_slot_info);
103 type_init(empty_slot_register_types)