]>
Commit | Line | Data |
---|---|---|
1f070489 IM |
1 | /* |
2 | * QEMU Host Memory Backend | |
3 | * | |
4 | * Copyright (C) 2013-2014 Red Hat Inc | |
5 | * | |
6 | * Authors: | |
7 | * Igor Mammedov <imammedo@redhat.com> | |
8 | * | |
9 | * This work is licensed under the terms of the GNU GPL, version 2 or later. | |
10 | * See the COPYING file in the top-level directory. | |
11 | */ | |
121d0712 MA |
12 | |
13 | #ifndef SYSEMU_HOSTMEM_H | |
14 | #define SYSEMU_HOSTMEM_H | |
1f070489 | 15 | |
4cf1b76b | 16 | #include "sysemu/sysemu.h" /* for MAX_NODES */ |
1f070489 | 17 | #include "qom/object.h" |
1f070489 | 18 | #include "exec/memory.h" |
4cf1b76b | 19 | #include "qemu/bitmap.h" |
1f070489 IM |
20 | |
21 | #define TYPE_MEMORY_BACKEND "memory-backend" | |
22 | #define MEMORY_BACKEND(obj) \ | |
23 | OBJECT_CHECK(HostMemoryBackend, (obj), TYPE_MEMORY_BACKEND) | |
24 | #define MEMORY_BACKEND_GET_CLASS(obj) \ | |
25 | OBJECT_GET_CLASS(HostMemoryBackendClass, (obj), TYPE_MEMORY_BACKEND) | |
26 | #define MEMORY_BACKEND_CLASS(klass) \ | |
27 | OBJECT_CLASS_CHECK(HostMemoryBackendClass, (klass), TYPE_MEMORY_BACKEND) | |
28 | ||
29 | typedef struct HostMemoryBackend HostMemoryBackend; | |
30 | typedef struct HostMemoryBackendClass HostMemoryBackendClass; | |
31 | ||
32 | /** | |
33 | * HostMemoryBackendClass: | |
34 | * @parent_class: opaque parent class container | |
35 | */ | |
36 | struct HostMemoryBackendClass { | |
37 | ObjectClass parent_class; | |
bd9262d9 HT |
38 | |
39 | void (*alloc)(HostMemoryBackend *backend, Error **errp); | |
1f070489 IM |
40 | }; |
41 | ||
42 | /** | |
43 | * @HostMemoryBackend | |
44 | * | |
45 | * @parent: opaque parent object container | |
46 | * @size: amount of memory backend provides | |
1f070489 IM |
47 | * @mr: MemoryRegion representing host memory belonging to backend |
48 | */ | |
49 | struct HostMemoryBackend { | |
50 | /* private */ | |
51 | Object parent; | |
52 | ||
53 | /* protected */ | |
e1ff3c67 | 54 | char *id; |
1f070489 | 55 | uint64_t size; |
605d0a94 | 56 | bool merge, dump; |
2aece63c | 57 | bool prealloc, force_prealloc, is_mapped; |
4cf1b76b HT |
58 | DECLARE_BITMAP(host_nodes, MAX_NODES + 1); |
59 | HostMemPolicy policy; | |
1f070489 IM |
60 | |
61 | MemoryRegion mr; | |
62 | }; | |
63 | ||
4728b574 | 64 | bool host_memory_backend_mr_inited(HostMemoryBackend *backend); |
1f070489 IM |
65 | MemoryRegion *host_memory_backend_get_memory(HostMemoryBackend *backend, |
66 | Error **errp); | |
67 | ||
2aece63c XG |
68 | void host_memory_backend_set_mapped(HostMemoryBackend *backend, bool mapped); |
69 | bool host_memory_backend_is_mapped(HostMemoryBackend *backend); | |
1f070489 | 70 | #endif |