4 * Copyright ProfitBricks GmbH 2012
5 * Copyright (C) 2013-2014 Red Hat Inc
8 * Vasilis Liaskovitis <vasilis.liaskovitis@profitbricks.com>
9 * Igor Mammedov <imammedo@redhat.com>
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.
16 #ifndef QEMU_PC_DIMM_H
17 #define QEMU_PC_DIMM_H
19 #include "exec/memory.h"
20 #include "hw/qdev-core.h"
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)
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"
36 #define PC_DIMM_UNASSIGNED_SLOT -1
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
47 typedef struct PCDIMMDevice
{
49 DeviceState parent_obj
;
55 HostMemoryBackend
*hostmem
;
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.
66 typedef struct PCDIMMDeviceClass
{
68 DeviceClass parent_class
;
71 void (*realize
)(PCDIMMDevice
*dimm
, Error
**errp
);
72 MemoryRegion
*(*get_vmstate_memory_region
)(PCDIMMDevice
*dimm
,
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
);