xref: /openbmc/qemu/include/hw/mem/pc-dimm.h (revision f6476697)
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 #include "qom/object.h"
22 
23 #define TYPE_PC_DIMM "pc-dimm"
24 OBJECT_DECLARE_TYPE(PCDIMMDevice, PCDIMMDeviceClass,
25                     PC_DIMM)
26 
27 #define PC_DIMM_ADDR_PROP "addr"
28 #define PC_DIMM_SLOT_PROP "slot"
29 #define PC_DIMM_NODE_PROP "node"
30 #define PC_DIMM_SIZE_PROP "size"
31 #define PC_DIMM_MEMDEV_PROP "memdev"
32 
33 #define PC_DIMM_UNASSIGNED_SLOT -1
34 
35 /**
36  * PCDIMMDevice:
37  * @addr: starting guest physical address, where @PCDIMMDevice is mapped.
38  *         Default value: 0, means that address is auto-allocated.
39  * @node: numa node to which @PCDIMMDevice is attached.
40  * @slot: slot number into which @PCDIMMDevice is plugged in.
41  *        Default value: -1, means that slot is auto-allocated.
42  * @hostmem: host memory backend providing memory for @PCDIMMDevice
43  */
44 struct PCDIMMDevice {
45     /* private */
46     DeviceState parent_obj;
47 
48     /* public */
49     uint64_t addr;
50     uint32_t node;
51     int32_t slot;
52     HostMemoryBackend *hostmem;
53 };
54 
55 /**
56  * PCDIMMDeviceClass:
57  * @realize: called after common dimm is realized so that the dimm based
58  * devices get the chance to do specified operations.
59  */
60 struct PCDIMMDeviceClass {
61     /* private */
62     DeviceClass parent_class;
63 
64     /* public */
65     void (*realize)(PCDIMMDevice *dimm, Error **errp);
66 };
67 
68 void pc_dimm_pre_plug(PCDIMMDevice *dimm, MachineState *machine,
69                       const uint64_t *legacy_align, Error **errp);
70 void pc_dimm_plug(PCDIMMDevice *dimm, MachineState *machine);
71 void pc_dimm_unplug(PCDIMMDevice *dimm, MachineState *machine);
72 #endif
73