dma/xlnx-zdma: Remove redundant statement in zdma_write_dst()
[qemu/ar7.git] / hw / misc / unimp.c
blobbc4084d344ecdbe97ef64fb72cb18366b11eb2c1
1 /* "Unimplemented" device
3 * This is a dummy device which accepts and logs all accesses.
4 * It's useful for stubbing out regions of an SoC or board
5 * map which correspond to devices that have not yet been
6 * implemented. This is often sufficient to placate initial
7 * guest device driver probing such that the system will
8 * come up.
10 * Copyright Linaro Limited, 2017
11 * Written by Peter Maydell
14 #include "qemu/osdep.h"
15 #include "hw/sysbus.h"
16 #include "hw/misc/unimp.h"
17 #include "qemu/log.h"
18 #include "qemu/module.h"
19 #include "qapi/error.h"
21 static uint64_t unimp_read(void *opaque, hwaddr offset, unsigned size)
23 UnimplementedDeviceState *s = UNIMPLEMENTED_DEVICE(opaque);
25 qemu_log_mask(LOG_UNIMP, "%s: unimplemented device read "
26 "(size %d, offset 0x%" HWADDR_PRIx ")\n",
27 s->name, size, offset);
28 return 0;
31 static void unimp_write(void *opaque, hwaddr offset,
32 uint64_t value, unsigned size)
34 UnimplementedDeviceState *s = UNIMPLEMENTED_DEVICE(opaque);
36 qemu_log_mask(LOG_UNIMP, "%s: unimplemented device write "
37 "(size %d, value 0x%" PRIx64
38 ", offset 0x%" HWADDR_PRIx ")\n",
39 s->name, size, value, offset);
42 static const MemoryRegionOps unimp_ops = {
43 .read = unimp_read,
44 .write = unimp_write,
45 .impl.min_access_size = 1,
46 .impl.max_access_size = 8,
47 .valid.min_access_size = 1,
48 .valid.max_access_size = 8,
49 .endianness = DEVICE_NATIVE_ENDIAN,
52 static void unimp_realize(DeviceState *dev, Error **errp)
54 UnimplementedDeviceState *s = UNIMPLEMENTED_DEVICE(dev);
56 if (s->size == 0) {
57 error_setg(errp, "property 'size' not specified or zero");
58 return;
61 if (s->name == NULL) {
62 error_setg(errp, "property 'name' not specified");
63 return;
66 memory_region_init_io(&s->iomem, OBJECT(s), &unimp_ops, s,
67 s->name, s->size);
68 sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem);
71 static Property unimp_properties[] = {
72 DEFINE_PROP_UINT64("size", UnimplementedDeviceState, size, 0),
73 DEFINE_PROP_STRING("name", UnimplementedDeviceState, name),
74 DEFINE_PROP_END_OF_LIST(),
77 static void unimp_class_init(ObjectClass *klass, void *data)
79 DeviceClass *dc = DEVICE_CLASS(klass);
81 dc->realize = unimp_realize;
82 device_class_set_props(dc, unimp_properties);
85 static const TypeInfo unimp_info = {
86 .name = TYPE_UNIMPLEMENTED_DEVICE,
87 .parent = TYPE_SYS_BUS_DEVICE,
88 .instance_size = sizeof(UnimplementedDeviceState),
89 .class_init = unimp_class_init,
92 static void unimp_register_types(void)
94 type_register_static(&unimp_info);
97 type_init(unimp_register_types)