1 | /* |
2 | * "Unimplemented" device |
3 | * |
4 | * Copyright Linaro Limited, 2017 |
5 | * Written by Peter Maydell |
6 | */ |
7 | |
8 | #ifndef HW_MISC_UNIMP_H |
9 | #define HW_MISC_UNIMP_H |
10 | |
11 | #include "hw/qdev-properties.h" |
12 | #include "hw/sysbus.h" |
13 | |
14 | #define TYPE_UNIMPLEMENTED_DEVICE "unimplemented-device" |
15 | |
16 | #define UNIMPLEMENTED_DEVICE(obj) \ |
17 | OBJECT_CHECK(UnimplementedDeviceState, (obj), TYPE_UNIMPLEMENTED_DEVICE) |
18 | |
19 | typedef struct { |
20 | SysBusDevice parent_obj; |
21 | MemoryRegion iomem; |
22 | char *name; |
23 | uint64_t size; |
24 | } UnimplementedDeviceState; |
25 | |
26 | /** |
27 | * create_unimplemented_device: create and map a dummy device |
28 | * @name: name of the device for debug logging |
29 | * @base: base address of the device's MMIO region |
30 | * @size: size of the device's MMIO region |
31 | * |
32 | * This utility function creates and maps an instance of unimplemented-device, |
33 | * which is a dummy device which simply logs all guest accesses to |
34 | * it via the qemu_log LOG_UNIMP debug log. |
35 | * The device is mapped at priority -1000, which means that you can |
36 | * use it to cover a large region and then map other devices on top of it |
37 | * if necessary. |
38 | */ |
39 | static inline void create_unimplemented_device(const char *name, |
40 | hwaddr base, |
41 | hwaddr size) |
42 | { |
43 | DeviceState *dev = qdev_create(NULL, TYPE_UNIMPLEMENTED_DEVICE); |
44 | |
45 | qdev_prop_set_string(dev, "name" , name); |
46 | qdev_prop_set_uint64(dev, "size" , size); |
47 | qdev_init_nofail(dev); |
48 | |
49 | sysbus_mmio_map_overlap(SYS_BUS_DEVICE(dev), 0, base, -1000); |
50 | } |
51 | |
52 | #endif |
53 | |