hw/riscv: Move sifive_u_otp model to hw/misc
[qemu/ar7.git] / include / hw / virtio / virtio-mem.h
blob0778224964df6f155145cefcbc03f76edb67d408
1 /*
2 * Virtio MEM device
4 * Copyright (C) 2020 Red Hat, Inc.
6 * Authors:
7 * David Hildenbrand <david@redhat.com>
9 * This work is licensed under the terms of the GNU GPL, version 2.
10 * See the COPYING file in the top-level directory.
13 #ifndef HW_VIRTIO_MEM_H
14 #define HW_VIRTIO_MEM_H
16 #include "standard-headers/linux/virtio_mem.h"
17 #include "hw/virtio/virtio.h"
18 #include "qapi/qapi-types-misc.h"
19 #include "sysemu/hostmem.h"
21 #define TYPE_VIRTIO_MEM "virtio-mem"
23 #define VIRTIO_MEM(obj) \
24 OBJECT_CHECK(VirtIOMEM, (obj), TYPE_VIRTIO_MEM)
25 #define VIRTIO_MEM_CLASS(oc) \
26 OBJECT_CLASS_CHECK(VirtIOMEMClass, (oc), TYPE_VIRTIO_MEM)
27 #define VIRTIO_MEM_GET_CLASS(obj) \
28 OBJECT_GET_CLASS(VirtIOMEMClass, (obj), TYPE_VIRTIO_MEM)
30 #define VIRTIO_MEM_MEMDEV_PROP "memdev"
31 #define VIRTIO_MEM_NODE_PROP "node"
32 #define VIRTIO_MEM_SIZE_PROP "size"
33 #define VIRTIO_MEM_REQUESTED_SIZE_PROP "requested-size"
34 #define VIRTIO_MEM_BLOCK_SIZE_PROP "block-size"
35 #define VIRTIO_MEM_ADDR_PROP "memaddr"
37 typedef struct VirtIOMEM {
38 VirtIODevice parent_obj;
40 /* guest -> host request queue */
41 VirtQueue *vq;
43 /* bitmap used to track unplugged memory */
44 int32_t bitmap_size;
45 unsigned long *bitmap;
47 /* assigned memory backend and memory region */
48 HostMemoryBackend *memdev;
50 /* NUMA node */
51 uint32_t node;
53 /* assigned address of the region in guest physical memory */
54 uint64_t addr;
56 /* usable region size (<= region_size) */
57 uint64_t usable_region_size;
59 /* actual size (how much the guest plugged) */
60 uint64_t size;
62 /* requested size */
63 uint64_t requested_size;
65 /* block size and alignment */
66 uint64_t block_size;
68 /* notifiers to notify when "size" changes */
69 NotifierList size_change_notifiers;
71 /* don't migrate unplugged memory */
72 NotifierWithReturn precopy_notifier;
73 } VirtIOMEM;
75 typedef struct VirtIOMEMClass {
76 /* private */
77 VirtIODevice parent;
79 /* public */
80 void (*fill_device_info)(const VirtIOMEM *vmen, VirtioMEMDeviceInfo *vi);
81 MemoryRegion *(*get_memory_region)(VirtIOMEM *vmem, Error **errp);
82 void (*add_size_change_notifier)(VirtIOMEM *vmem, Notifier *notifier);
83 void (*remove_size_change_notifier)(VirtIOMEM *vmem, Notifier *notifier);
84 } VirtIOMEMClass;
86 #endif