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
10 * Copyright Linaro Limited, 2017
11 * Written by Peter Maydell
14 #include "qemu/osdep.h"
16 #include "hw/sysbus.h"
17 #include "hw/misc/unimp.h"
19 #include "qapi/error.h"
21 #define UNIMPLEMENTED_DEVICE(obj) \
22 OBJECT_CHECK(UnimplementedDeviceState, (obj), TYPE_UNIMPLEMENTED_DEVICE)
25 SysBusDevice parent_obj
;
29 } UnimplementedDeviceState
;
31 static uint64_t unimp_read(void *opaque
, hwaddr offset
, unsigned size
)
33 UnimplementedDeviceState
*s
= UNIMPLEMENTED_DEVICE(opaque
);
35 qemu_log_mask(LOG_UNIMP
, "%s: unimplemented device read "
36 "(size %d, offset 0x%" HWADDR_PRIx
")\n",
37 s
->name
, size
, offset
);
41 static void unimp_write(void *opaque
, hwaddr offset
,
42 uint64_t value
, unsigned size
)
44 UnimplementedDeviceState
*s
= UNIMPLEMENTED_DEVICE(opaque
);
46 qemu_log_mask(LOG_UNIMP
, "%s: unimplemented device write "
47 "(size %d, value 0x%" PRIx64
48 ", offset 0x%" HWADDR_PRIx
")\n",
49 s
->name
, size
, value
, offset
);
52 static const MemoryRegionOps unimp_ops
= {
55 .impl
.min_access_size
= 1,
56 .impl
.max_access_size
= 8,
57 .valid
.min_access_size
= 1,
58 .valid
.max_access_size
= 8,
59 .endianness
= DEVICE_NATIVE_ENDIAN
,
62 static void unimp_realize(DeviceState
*dev
, Error
**errp
)
64 UnimplementedDeviceState
*s
= UNIMPLEMENTED_DEVICE(dev
);
67 error_setg(errp
, "property 'size' not specified or zero");
71 if (s
->name
== NULL
) {
72 error_setg(errp
, "property 'name' not specified");
76 memory_region_init_io(&s
->iomem
, OBJECT(s
), &unimp_ops
, s
,
78 sysbus_init_mmio(SYS_BUS_DEVICE(s
), &s
->iomem
);
81 static Property unimp_properties
[] = {
82 DEFINE_PROP_UINT64("size", UnimplementedDeviceState
, size
, 0),
83 DEFINE_PROP_STRING("name", UnimplementedDeviceState
, name
),
84 DEFINE_PROP_END_OF_LIST(),
87 static void unimp_class_init(ObjectClass
*klass
, void *data
)
89 DeviceClass
*dc
= DEVICE_CLASS(klass
);
91 dc
->realize
= unimp_realize
;
92 dc
->props
= unimp_properties
;
95 static const TypeInfo unimp_info
= {
96 .name
= TYPE_UNIMPLEMENTED_DEVICE
,
97 .parent
= TYPE_SYS_BUS_DEVICE
,
98 .instance_size
= sizeof(UnimplementedDeviceState
),
99 .class_init
= unimp_class_init
,
102 static void unimp_register_types(void)
104 type_register_static(&unimp_info
);
107 type_init(unimp_register_types
)