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 "qemu/module.h"
20 #include "qapi/error.h"
22 static uint64_t unimp_read(void *opaque
, hwaddr offset
, unsigned size
)
24 UnimplementedDeviceState
*s
= UNIMPLEMENTED_DEVICE(opaque
);
26 qemu_log_mask(LOG_UNIMP
, "%s: unimplemented device read "
27 "(size %d, offset 0x%" HWADDR_PRIx
")\n",
28 s
->name
, size
, offset
);
32 static void unimp_write(void *opaque
, hwaddr offset
,
33 uint64_t value
, unsigned size
)
35 UnimplementedDeviceState
*s
= UNIMPLEMENTED_DEVICE(opaque
);
37 qemu_log_mask(LOG_UNIMP
, "%s: unimplemented device write "
38 "(size %d, value 0x%" PRIx64
39 ", offset 0x%" HWADDR_PRIx
")\n",
40 s
->name
, size
, value
, offset
);
43 static const MemoryRegionOps unimp_ops
= {
46 .impl
.min_access_size
= 1,
47 .impl
.max_access_size
= 8,
48 .valid
.min_access_size
= 1,
49 .valid
.max_access_size
= 8,
50 .endianness
= DEVICE_NATIVE_ENDIAN
,
53 static void unimp_realize(DeviceState
*dev
, Error
**errp
)
55 UnimplementedDeviceState
*s
= UNIMPLEMENTED_DEVICE(dev
);
58 error_setg(errp
, "property 'size' not specified or zero");
62 if (s
->name
== NULL
) {
63 error_setg(errp
, "property 'name' not specified");
67 memory_region_init_io(&s
->iomem
, OBJECT(s
), &unimp_ops
, s
,
69 sysbus_init_mmio(SYS_BUS_DEVICE(s
), &s
->iomem
);
72 static Property unimp_properties
[] = {
73 DEFINE_PROP_UINT64("size", UnimplementedDeviceState
, size
, 0),
74 DEFINE_PROP_STRING("name", UnimplementedDeviceState
, name
),
75 DEFINE_PROP_END_OF_LIST(),
78 static void unimp_class_init(ObjectClass
*klass
, void *data
)
80 DeviceClass
*dc
= DEVICE_CLASS(klass
);
82 dc
->realize
= unimp_realize
;
83 dc
->props
= unimp_properties
;
86 static const TypeInfo unimp_info
= {
87 .name
= TYPE_UNIMPLEMENTED_DEVICE
,
88 .parent
= TYPE_SYS_BUS_DEVICE
,
89 .instance_size
= sizeof(UnimplementedDeviceState
),
90 .class_init
= unimp_class_init
,
93 static void unimp_register_types(void)
95 type_register_static(&unimp_info
);
98 type_init(unimp_register_types
)