xref: /openbmc/qemu/include/hw/mem/nvdimm.h (revision 35658f6e)
1 /*
2  * Non-Volatile Dual In-line Memory Module Virtualization Implementation
3  *
4  * Copyright(C) 2015 Intel Corporation.
5  *
6  * Author:
7  *  Xiao Guangrong <guangrong.xiao@linux.intel.com>
8  *
9  * NVDIMM specifications and some documents can be found at:
10  * NVDIMM ACPI device and NFIT are introduced in ACPI 6:
11  *      http://www.uefi.org/sites/default/files/resources/ACPI_6.0.pdf
12  * NVDIMM Namespace specification:
13  *      http://pmem.io/documents/NVDIMM_Namespace_Spec.pdf
14  * DSM Interface Example:
15  *      http://pmem.io/documents/NVDIMM_DSM_Interface_Example.pdf
16  * Driver Writer's Guide:
17  *      http://pmem.io/documents/NVDIMM_Driver_Writers_Guide.pdf
18  *
19  * This work is licensed under the terms of the GNU GPL, version 2 or later.
20  * See the COPYING file in the top-level directory.
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 #define TYPE_NVDIMM             "nvdimm"
38 
39 #define NVDIMM_DSM_MEM_FILE     "etc/acpi/nvdimm-mem"
40 
41 /*
42  * 32 bits IO port starting from 0x0a18 in guest is reserved for
43  * NVDIMM ACPI emulation.
44  */
45 #define NVDIMM_ACPI_IO_BASE     0x0a18
46 #define NVDIMM_ACPI_IO_LEN      4
47 
48 struct AcpiNVDIMMState {
49     /* detect if NVDIMM support is enabled. */
50     bool is_enabled;
51 
52     /* the data of the fw_cfg file NVDIMM_DSM_MEM_FILE. */
53     GArray *dsm_mem;
54     /* the IO region used by OSPM to transfer control to QEMU. */
55     MemoryRegion io_mr;
56 };
57 typedef struct AcpiNVDIMMState AcpiNVDIMMState;
58 
59 void nvdimm_init_acpi_state(AcpiNVDIMMState *state, MemoryRegion *io,
60                             FWCfgState *fw_cfg, Object *owner);
61 void nvdimm_build_acpi(GArray *table_offsets, GArray *table_data,
62                        BIOSLinker *linker, GArray *dsm_dma_arrea);
63 #endif
64