]> git.ipfire.org Git - thirdparty/qemu.git/blame - include/hw/misc/unimp.h
Use OBJECT_DECLARE_SIMPLE_TYPE when possible
[thirdparty/qemu.git] / include / hw / misc / unimp.h
CommitLineData
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"
db1015e9 14#include "qom/object.h"
8f7b1bd6 15
f5095aa3
PM
16#define TYPE_UNIMPLEMENTED_DEVICE "unimplemented-device"
17
8063396b 18OBJECT_DECLARE_SIMPLE_TYPE(UnimplementedDeviceState, UNIMPLEMENTED_DEVICE)
a7bc4ee5 19
db1015e9 20struct UnimplementedDeviceState {
a7bc4ee5
PM
21 SysBusDevice parent_obj;
22 MemoryRegion iomem;
55d35c88 23 unsigned offset_fmt_width;
a7bc4ee5
PM
24 char *name;
25 uint64_t size;
db1015e9 26};
a7bc4ee5 27
f5095aa3
PM
28/**
29 * create_unimplemented_device: create and map a dummy device
30 * @name: name of the device for debug logging
31 * @base: base address of the device's MMIO region
32 * @size: size of the device's MMIO region
33 *
34 * This utility function creates and maps an instance of unimplemented-device,
35 * which is a dummy device which simply logs all guest accesses to
36 * it via the qemu_log LOG_UNIMP debug log.
37 * The device is mapped at priority -1000, which means that you can
38 * use it to cover a large region and then map other devices on top of it
39 * if necessary.
40 */
41static inline void create_unimplemented_device(const char *name,
42 hwaddr base,
43 hwaddr size)
44{
3e80f690 45 DeviceState *dev = qdev_new(TYPE_UNIMPLEMENTED_DEVICE);
f5095aa3
PM
46
47 qdev_prop_set_string(dev, "name", name);
48 qdev_prop_set_uint64(dev, "size", size);
3c6ef471 49 sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
f5095aa3
PM
50
51 sysbus_mmio_map_overlap(SYS_BUS_DEVICE(dev), 0, base, -1000);
52}
53
54#endif