1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef SYSEMU_HOSTMEM_H
14#define SYSEMU_HOSTMEM_H
15
16#include "sysemu/sysemu.h"
17#include "qapi/qapi-types-machine.h"
18#include "qom/object.h"
19#include "exec/memory.h"
20#include "qemu/bitmap.h"
21
22#define TYPE_MEMORY_BACKEND "memory-backend"
23#define MEMORY_BACKEND(obj) \
24 OBJECT_CHECK(HostMemoryBackend, (obj), TYPE_MEMORY_BACKEND)
25#define MEMORY_BACKEND_GET_CLASS(obj) \
26 OBJECT_GET_CLASS(HostMemoryBackendClass, (obj), TYPE_MEMORY_BACKEND)
27#define MEMORY_BACKEND_CLASS(klass) \
28 OBJECT_CLASS_CHECK(HostMemoryBackendClass, (klass), TYPE_MEMORY_BACKEND)
29
30typedef struct HostMemoryBackend HostMemoryBackend;
31typedef struct HostMemoryBackendClass HostMemoryBackendClass;
32
33
34
35
36
37struct HostMemoryBackendClass {
38 ObjectClass parent_class;
39
40 void (*alloc)(HostMemoryBackend *backend, Error **errp);
41};
42
43
44
45
46
47
48
49
50struct HostMemoryBackend {
51
52 Object parent;
53
54
55 uint64_t size;
56 bool merge, dump, use_canonical_path;
57 bool prealloc, force_prealloc, is_mapped, share;
58 DECLARE_BITMAP(host_nodes, MAX_NODES + 1);
59 HostMemPolicy policy;
60
61 MemoryRegion mr;
62};
63
64bool host_memory_backend_mr_inited(HostMemoryBackend *backend);
65MemoryRegion *host_memory_backend_get_memory(HostMemoryBackend *backend);
66
67void host_memory_backend_set_mapped(HostMemoryBackend *backend, bool mapped);
68bool host_memory_backend_is_mapped(HostMemoryBackend *backend);
69size_t host_memory_backend_pagesize(HostMemoryBackend *memdev);
70char *host_memory_backend_get_name(HostMemoryBackend *backend);
71
72#endif
73