1 | /* |
2 | * PC DIMM device |
3 | * |
4 | * Copyright ProfitBricks GmbH 2012 |
5 | * Copyright (C) 2013-2014 Red Hat Inc |
6 | * |
7 | * Authors: |
8 | * Vasilis Liaskovitis <vasilis.liaskovitis@profitbricks.com> |
9 | * Igor Mammedov <imammedo@redhat.com> |
10 | * |
11 | * This work is licensed under the terms of the GNU GPL, version 2 or later. |
12 | * See the COPYING file in the top-level directory. |
13 | * |
14 | */ |
15 | |
16 | #ifndef QEMU_PC_DIMM_H |
17 | #define QEMU_PC_DIMM_H |
18 | |
19 | #include "exec/memory.h" |
20 | #include "hw/qdev-core.h" |
21 | |
22 | #define TYPE_PC_DIMM "pc-dimm" |
23 | #define PC_DIMM(obj) \ |
24 | OBJECT_CHECK(PCDIMMDevice, (obj), TYPE_PC_DIMM) |
25 | #define PC_DIMM_CLASS(oc) \ |
26 | OBJECT_CLASS_CHECK(PCDIMMDeviceClass, (oc), TYPE_PC_DIMM) |
27 | #define PC_DIMM_GET_CLASS(obj) \ |
28 | OBJECT_GET_CLASS(PCDIMMDeviceClass, (obj), TYPE_PC_DIMM) |
29 | |
30 | #define PC_DIMM_ADDR_PROP "addr" |
31 | #define PC_DIMM_SLOT_PROP "slot" |
32 | #define PC_DIMM_NODE_PROP "node" |
33 | #define PC_DIMM_SIZE_PROP "size" |
34 | #define PC_DIMM_MEMDEV_PROP "memdev" |
35 | |
36 | #define PC_DIMM_UNASSIGNED_SLOT -1 |
37 | |
38 | /** |
39 | * PCDIMMDevice: |
40 | * @addr: starting guest physical address, where @PCDIMMDevice is mapped. |
41 | * Default value: 0, means that address is auto-allocated. |
42 | * @node: numa node to which @PCDIMMDevice is attached. |
43 | * @slot: slot number into which @PCDIMMDevice is plugged in. |
44 | * Default value: -1, means that slot is auto-allocated. |
45 | * @hostmem: host memory backend providing memory for @PCDIMMDevice |
46 | */ |
47 | typedef struct PCDIMMDevice { |
48 | /* private */ |
49 | DeviceState parent_obj; |
50 | |
51 | /* public */ |
52 | uint64_t addr; |
53 | uint32_t node; |
54 | int32_t slot; |
55 | HostMemoryBackend *hostmem; |
56 | } PCDIMMDevice; |
57 | |
58 | /** |
59 | * PCDIMMDeviceClass: |
60 | * @realize: called after common dimm is realized so that the dimm based |
61 | * devices get the chance to do specified operations. |
62 | * @get_vmstate_memory_region: returns #MemoryRegion which indicates the |
63 | * memory of @dimm should be kept during live migration. Will not fail |
64 | * after the device was realized. |
65 | */ |
66 | typedef struct PCDIMMDeviceClass { |
67 | /* private */ |
68 | DeviceClass parent_class; |
69 | |
70 | /* public */ |
71 | void (*realize)(PCDIMMDevice *dimm, Error **errp); |
72 | MemoryRegion *(*get_vmstate_memory_region)(PCDIMMDevice *dimm, |
73 | Error **errp); |
74 | } PCDIMMDeviceClass; |
75 | |
76 | void pc_dimm_pre_plug(PCDIMMDevice *dimm, MachineState *machine, |
77 | const uint64_t *legacy_align, Error **errp); |
78 | void pc_dimm_plug(PCDIMMDevice *dimm, MachineState *machine, Error **errp); |
79 | void pc_dimm_unplug(PCDIMMDevice *dimm, MachineState *machine); |
80 | #endif |
81 | |