]>
Commit | Line | Data |
---|---|---|
f5095aa3 PM |
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 | ||
a27bd6c7 | 11 | #include "hw/qdev-properties.h" |
8f7b1bd6 | 12 | #include "hw/sysbus.h" |
3e80f690 | 13 | #include "qapi/error.h" |
8f7b1bd6 | 14 | |
f5095aa3 PM |
15 | #define TYPE_UNIMPLEMENTED_DEVICE "unimplemented-device" |
16 | ||
a7bc4ee5 PM |
17 | #define UNIMPLEMENTED_DEVICE(obj) \ |
18 | OBJECT_CHECK(UnimplementedDeviceState, (obj), TYPE_UNIMPLEMENTED_DEVICE) | |
19 | ||
20 | typedef struct { | |
21 | SysBusDevice parent_obj; | |
22 | MemoryRegion iomem; | |
23 | char *name; | |
24 | uint64_t size; | |
25 | } UnimplementedDeviceState; | |
26 | ||
f5095aa3 PM |
27 | /** |
28 | * create_unimplemented_device: create and map a dummy device | |
29 | * @name: name of the device for debug logging | |
30 | * @base: base address of the device's MMIO region | |
31 | * @size: size of the device's MMIO region | |
32 | * | |
33 | * This utility function creates and maps an instance of unimplemented-device, | |
34 | * which is a dummy device which simply logs all guest accesses to | |
35 | * it via the qemu_log LOG_UNIMP debug log. | |
36 | * The device is mapped at priority -1000, which means that you can | |
37 | * use it to cover a large region and then map other devices on top of it | |
38 | * if necessary. | |
39 | */ | |
40 | static inline void create_unimplemented_device(const char *name, | |
41 | hwaddr base, | |
42 | hwaddr size) | |
43 | { | |
3e80f690 | 44 | DeviceState *dev = qdev_new(TYPE_UNIMPLEMENTED_DEVICE); |
f5095aa3 PM |
45 | |
46 | qdev_prop_set_string(dev, "name", name); | |
47 | qdev_prop_set_uint64(dev, "size", size); | |
3e80f690 | 48 | qdev_realize_and_unref(dev, NULL, &error_fatal); |
f5095aa3 PM |
49 | |
50 | sysbus_mmio_map_overlap(SYS_BUS_DEVICE(dev), 0, base, -1000); | |
51 | } | |
52 | ||
53 | #endif |