2014-06-02 15:25:05 +02:00
|
|
|
/*
|
|
|
|
* PC DIMM device
|
|
|
|
*
|
|
|
|
* Copyright ProfitBricks GmbH 2012
|
|
|
|
* Copyright (C) 2013-2014 Red Hat Inc
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Vasilis Liaskovitis <vasilis.liaskovitis@profitbricks.com>
|
|
|
|
* Igor Mammedov <imammedo@redhat.com>
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
|
* See the COPYING file in the top-level directory.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef QEMU_PC_DIMM_H
|
|
|
|
#define QEMU_PC_DIMM_H
|
|
|
|
|
|
|
|
#include "exec/memory.h"
|
|
|
|
#include "sysemu/hostmem.h"
|
|
|
|
#include "hw/qdev.h"
|
|
|
|
|
|
|
|
#define TYPE_PC_DIMM "pc-dimm"
|
|
|
|
#define PC_DIMM(obj) \
|
|
|
|
OBJECT_CHECK(PCDIMMDevice, (obj), TYPE_PC_DIMM)
|
|
|
|
#define PC_DIMM_CLASS(oc) \
|
|
|
|
OBJECT_CLASS_CHECK(PCDIMMDeviceClass, (oc), TYPE_PC_DIMM)
|
|
|
|
#define PC_DIMM_GET_CLASS(obj) \
|
|
|
|
OBJECT_GET_CLASS(PCDIMMDeviceClass, (obj), TYPE_PC_DIMM)
|
|
|
|
|
|
|
|
#define PC_DIMM_ADDR_PROP "addr"
|
|
|
|
#define PC_DIMM_SLOT_PROP "slot"
|
|
|
|
#define PC_DIMM_NODE_PROP "node"
|
|
|
|
#define PC_DIMM_SIZE_PROP "size"
|
|
|
|
#define PC_DIMM_MEMDEV_PROP "memdev"
|
|
|
|
|
|
|
|
#define PC_DIMM_UNASSIGNED_SLOT -1
|
|
|
|
|
|
|
|
/**
|
|
|
|
* PCDIMMDevice:
|
|
|
|
* @addr: starting guest physical address, where @PCDIMMDevice is mapped.
|
|
|
|
* Default value: 0, means that address is auto-allocated.
|
|
|
|
* @node: numa node to which @PCDIMMDevice is attached.
|
|
|
|
* @slot: slot number into which @PCDIMMDevice is plugged in.
|
|
|
|
* Default value: -1, means that slot is auto-allocated.
|
|
|
|
* @hostmem: host memory backend providing memory for @PCDIMMDevice
|
|
|
|
*/
|
|
|
|
typedef struct PCDIMMDevice {
|
|
|
|
/* private */
|
|
|
|
DeviceState parent_obj;
|
|
|
|
|
|
|
|
/* public */
|
|
|
|
uint64_t addr;
|
|
|
|
uint32_t node;
|
|
|
|
int32_t slot;
|
|
|
|
HostMemoryBackend *hostmem;
|
|
|
|
} PCDIMMDevice;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* PCDIMMDeviceClass:
|
2016-05-20 10:19:59 +02:00
|
|
|
* @realize: called after common dimm is realized so that the dimm based
|
|
|
|
* devices get the chance to do specified operations.
|
2016-05-20 10:19:58 +02:00
|
|
|
* @get_memory_region: returns #MemoryRegion associated with @dimm which
|
2016-06-07 14:21:57 +02:00
|
|
|
* is directly mapped into the physical address space of guest.
|
|
|
|
* @get_vmstate_memory_region: returns #MemoryRegion which indicates the
|
|
|
|
* memory of @dimm should be kept during live migration.
|
2014-06-02 15:25:05 +02:00
|
|
|
*/
|
|
|
|
typedef struct PCDIMMDeviceClass {
|
|
|
|
/* private */
|
|
|
|
DeviceClass parent_class;
|
|
|
|
|
|
|
|
/* public */
|
2016-05-20 10:19:59 +02:00
|
|
|
void (*realize)(PCDIMMDevice *dimm, Error **errp);
|
2017-08-21 08:30:29 +02:00
|
|
|
MemoryRegion *(*get_memory_region)(PCDIMMDevice *dimm, Error **errp);
|
2016-06-07 14:21:57 +02:00
|
|
|
MemoryRegion *(*get_vmstate_memory_region)(PCDIMMDevice *dimm);
|
2014-06-02 15:25:05 +02:00
|
|
|
} PCDIMMDeviceClass;
|
|
|
|
|
2015-06-29 10:20:22 +02:00
|
|
|
/**
|
|
|
|
* MemoryHotplugState:
|
2016-03-03 10:24:12 +01:00
|
|
|
* @base: address in guest physical address space where hotplug memory
|
2015-06-29 10:20:22 +02:00
|
|
|
* address space begins.
|
|
|
|
* @mr: hotplug memory address space container
|
|
|
|
*/
|
|
|
|
typedef struct MemoryHotplugState {
|
2016-01-21 02:37:51 +01:00
|
|
|
hwaddr base;
|
2015-06-29 10:20:22 +02:00
|
|
|
MemoryRegion mr;
|
|
|
|
} MemoryHotplugState;
|
|
|
|
|
2014-06-02 15:25:13 +02:00
|
|
|
uint64_t pc_dimm_get_free_addr(uint64_t address_space_start,
|
|
|
|
uint64_t address_space_size,
|
2015-10-28 17:55:06 +01:00
|
|
|
uint64_t *hint, uint64_t align, uint64_t size,
|
|
|
|
Error **errp);
|
2014-06-02 15:25:14 +02:00
|
|
|
|
|
|
|
int pc_dimm_get_free_slot(const int *hint, int max_slots, Error **errp);
|
2014-06-16 19:12:25 +02:00
|
|
|
|
|
|
|
int qmp_pc_dimm_device_list(Object *obj, void *opaque);
|
2015-01-27 05:05:02 +01:00
|
|
|
uint64_t pc_existing_dimms_capacity(Error **errp);
|
2017-08-29 17:30:21 +02:00
|
|
|
uint64_t get_plugged_memory_size(void);
|
2015-06-29 10:20:23 +02:00
|
|
|
void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms,
|
2015-10-28 17:55:06 +01:00
|
|
|
MemoryRegion *mr, uint64_t align, Error **errp);
|
2015-06-29 10:20:23 +02:00
|
|
|
void pc_dimm_memory_unplug(DeviceState *dev, MemoryHotplugState *hpms,
|
|
|
|
MemoryRegion *mr);
|
2014-06-02 15:25:05 +02:00
|
|
|
#endif
|