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 "sysemu/hostmem.h" 21 #include "hw/qdev.h" 22 23 #define DEFAULT_PC_DIMMSIZE (1024*1024*1024) 24 25 #define TYPE_PC_DIMM "pc-dimm" 26 #define PC_DIMM(obj) \ 27 OBJECT_CHECK(PCDIMMDevice, (obj), TYPE_PC_DIMM) 28 #define PC_DIMM_CLASS(oc) \ 29 OBJECT_CLASS_CHECK(PCDIMMDeviceClass, (oc), TYPE_PC_DIMM) 30 #define PC_DIMM_GET_CLASS(obj) \ 31 OBJECT_GET_CLASS(PCDIMMDeviceClass, (obj), TYPE_PC_DIMM) 32 33 #define PC_DIMM_ADDR_PROP "addr" 34 #define PC_DIMM_SLOT_PROP "slot" 35 #define PC_DIMM_NODE_PROP "node" 36 #define PC_DIMM_SIZE_PROP "size" 37 #define PC_DIMM_MEMDEV_PROP "memdev" 38 39 #define PC_DIMM_UNASSIGNED_SLOT -1 40 41 /** 42 * PCDIMMDevice: 43 * @addr: starting guest physical address, where @PCDIMMDevice is mapped. 44 * Default value: 0, means that address is auto-allocated. 45 * @node: numa node to which @PCDIMMDevice is attached. 46 * @slot: slot number into which @PCDIMMDevice is plugged in. 47 * Default value: -1, means that slot is auto-allocated. 48 * @hostmem: host memory backend providing memory for @PCDIMMDevice 49 */ 50 typedef struct PCDIMMDevice { 51 /* private */ 52 DeviceState parent_obj; 53 54 /* public */ 55 uint64_t addr; 56 uint32_t node; 57 int32_t slot; 58 HostMemoryBackend *hostmem; 59 } PCDIMMDevice; 60 61 /** 62 * PCDIMMDeviceClass: 63 * @get_memory_region: returns #MemoryRegion associated with @dimm 64 */ 65 typedef struct PCDIMMDeviceClass { 66 /* private */ 67 DeviceClass parent_class; 68 69 /* public */ 70 MemoryRegion *(*get_memory_region)(PCDIMMDevice *dimm); 71 } PCDIMMDeviceClass; 72 73 uint64_t pc_dimm_get_free_addr(uint64_t address_space_start, 74 uint64_t address_space_size, 75 uint64_t *hint, uint64_t size, 76 Error **errp); 77 78 int pc_dimm_get_free_slot(const int *hint, int max_slots, Error **errp); 79 80 int qmp_pc_dimm_device_list(Object *obj, void *opaque); 81 #endif 82