1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23#ifndef QEMU_NVDIMM_H
24#define QEMU_NVDIMM_H
25
26#include "hw/mem/pc-dimm.h"
27#include "hw/acpi/bios-linker-loader.h"
28
29#define NVDIMM_DEBUG 0
30#define nvdimm_debug(fmt, ...) \
31 do { \
32 if (NVDIMM_DEBUG) { \
33 fprintf(stderr, "nvdimm: " fmt, ## __VA_ARGS__); \
34 } \
35 } while (0)
36
37
38
39
40
41
42
43#define MIN_NAMESPACE_LABEL_SIZE (128UL << 10)
44
45#define TYPE_NVDIMM "nvdimm"
46#define NVDIMM(obj) OBJECT_CHECK(NVDIMMDevice, (obj), TYPE_NVDIMM)
47#define NVDIMM_CLASS(oc) OBJECT_CLASS_CHECK(NVDIMMClass, (oc), TYPE_NVDIMM)
48#define NVDIMM_GET_CLASS(obj) OBJECT_GET_CLASS(NVDIMMClass, (obj), \
49 TYPE_NVDIMM)
50struct NVDIMMDevice {
51
52 PCDIMMDevice parent_obj;
53
54
55
56
57
58
59
60 uint64_t label_size;
61
62
63
64
65
66
67 void *label_data;
68
69
70
71
72
73 MemoryRegion nvdimm_mr;
74};
75typedef struct NVDIMMDevice NVDIMMDevice;
76
77struct NVDIMMClass {
78
79 PCDIMMDeviceClass parent_class;
80
81
82
83
84 void (*read_label_data)(NVDIMMDevice *nvdimm, void *buf,
85 uint64_t size, uint64_t offset);
86
87 void (*write_label_data)(NVDIMMDevice *nvdimm, const void *buf,
88 uint64_t size, uint64_t offset);
89};
90typedef struct NVDIMMClass NVDIMMClass;
91
92#define NVDIMM_DSM_MEM_FILE "etc/acpi/nvdimm-mem"
93
94
95
96
97
98#define NVDIMM_ACPI_IO_BASE 0x0a18
99#define NVDIMM_ACPI_IO_LEN 4
100
101
102
103
104
105
106
107
108struct NvdimmFitBuffer {
109 GArray *fit;
110 bool dirty;
111};
112typedef struct NvdimmFitBuffer NvdimmFitBuffer;
113
114struct AcpiNVDIMMState {
115
116 bool is_enabled;
117
118
119 GArray *dsm_mem;
120
121 NvdimmFitBuffer fit_buf;
122
123
124 MemoryRegion io_mr;
125};
126typedef struct AcpiNVDIMMState AcpiNVDIMMState;
127
128void nvdimm_init_acpi_state(AcpiNVDIMMState *state, MemoryRegion *io,
129 FWCfgState *fw_cfg, Object *owner);
130void nvdimm_build_acpi(GArray *table_offsets, GArray *table_data,
131 BIOSLinker *linker, AcpiNVDIMMState *state,
132 uint32_t ram_slots);
133void nvdimm_plug(AcpiNVDIMMState *state);
134void nvdimm_acpi_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev);
135#endif
136