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