[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 09/27] dimm: map DimmDevice into DimBus provided add
From: |
Igor Mammedov |
Subject: |
[Qemu-devel] [PATCH 09/27] dimm: map DimmDevice into DimBus provided address space |
Date: |
Thu, 21 Nov 2013 03:38:30 +0100 |
Signed-off-by: Igor Mammedov <address@hidden>
---
hw/mem/dimm.c | 13 +++++++++++++
include/hw/mem/dimm.h | 15 +++++++++++++++
2 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/hw/mem/dimm.c b/hw/mem/dimm.c
index fe81226..b3d6fda 100644
--- a/hw/mem/dimm.c
+++ b/hw/mem/dimm.c
@@ -28,12 +28,21 @@ static void dimm_bus_initfn(Object *obj)
b->allow_hotplug = true;
}
+static void dimm_bus_register_memory(DimmBus *bus, DimmDevice *dimm,
+ Error **errp)
+{
+ memory_region_add_subregion(&bus->as, dimm->start - bus->base, dimm->mr);
+ vmstate_register_ram(dimm->mr, DEVICE(dimm));
+}
+
static void dimm_bus_class_init(ObjectClass *oc, void *data)
{
BusClass *bc = BUS_CLASS(oc);
+ DimmBusClass *dbc = DIMM_BUS_CLASS(oc);
QemuOpts *opts = qemu_opts_find(qemu_find_opts("memory-opts"), NULL);
bc->max_dev = qemu_opt_get_number(opts, "slots", 0);
+ dbc->register_memory = dimm_bus_register_memory;
}
static const TypeInfo dimm_bus_info = {
@@ -42,6 +51,7 @@ static const TypeInfo dimm_bus_info = {
.instance_init = dimm_bus_initfn,
.instance_size = sizeof(DimmBus),
.class_init = dimm_bus_class_init,
+ .class_size = sizeof(DimmBusClass),
};
static Property dimm_properties[] = {
@@ -121,6 +131,7 @@ static void dimm_realize(DeviceState *dev, Error **errp)
DimmDevice *dimm = DIMM(dev);
DimmBus *bus = DIMM_BUS(qdev_get_parent_bus(dev));
BusClass *bc = BUS_GET_CLASS(bus);
+ DimmBusClass *dbc = DIMM_BUS_GET_CLASS(bus);
if (!dimm->mr) {
error_setg(errp, "'memdev' property is not set");
@@ -137,6 +148,8 @@ static void dimm_realize(DeviceState *dev, Error **errp)
return;
}
+ g_assert(dbc->register_memory);
+ dbc->register_memory(bus, dimm, errp);
}
static void dimm_finalize(Object *obj)
diff --git a/include/hw/mem/dimm.h b/include/hw/mem/dimm.h
index 0d9c28e..ae9ad2e 100644
--- a/include/hw/mem/dimm.h
+++ b/include/hw/mem/dimm.h
@@ -63,9 +63,24 @@ typedef struct DimmDeviceClass {
/**
* DimmBus:
* @parent_obj: opaque parent object container
+ * @base: address from which to start mapping @DimmDevice
+ * @as: hot-plugabble memory area where @DimmDevice-s are attached
*/
typedef struct DimmBus {
BusState parent_obj;
+ hwaddr base;
+ MemoryRegion as;
} DimmBus;
+/**
+ * DimmBusClass:
+ * @parent_class: opaque parent class container
+ * @register_memory: map @DimmDevice into hot-plugable address space
+ */
+typedef struct DimmBusClass {
+ BusClass parent_class;
+
+ void (*register_memory)(DimmBus *bus, DimmDevice *dimm, Error **errp);
+} DimmBusClass;
+
#endif
--
1.7.1
- Re: [Qemu-devel] [PATCH 02/27] rename pci_hotplug_fn to hotplug_fn and make it available for other devices, (continued)
- [Qemu-devel] [PATCH 09/27] dimm: map DimmDevice into DimBus provided address space,
Igor Mammedov <=
- [Qemu-devel] [PATCH 10/27] dimm: add busy slot check and slot auto-allocation, Igor Mammedov, 2013/11/20
- [Qemu-devel] [PATCH 11/27] dimm: add busy address check and address auto-allocation, Igor Mammedov, 2013/11/20
- [Qemu-devel] [PATCH 13/27] acpi: memory hotplug ACPI hardware implementation, Igor Mammedov, 2013/11/20
- Re: [Qemu-devel] [PATCH 13/27] acpi: memory hotplug ACPI hardware implementation, Michael S. Tsirkin, 2013/11/21
- Re: [Qemu-devel] [PATCH 13/27] acpi: memory hotplug ACPI hardware implementation, Igor Mammedov, 2013/11/21
- Re: [Qemu-devel] [PATCH 13/27] acpi: memory hotplug ACPI hardware implementation, Michael S. Tsirkin, 2013/11/21
- Re: [Qemu-devel] [PATCH 13/27] acpi: memory hotplug ACPI hardware implementation, Igor Mammedov, 2013/11/22
- Re: [Qemu-devel] [PATCH 13/27] acpi: memory hotplug ACPI hardware implementation, Michael S. Tsirkin, 2013/11/24
- Re: [Qemu-devel] [PATCH 13/27] acpi: memory hotplug ACPI hardware implementation, Markus Armbruster, 2013/11/25
- Re: [Qemu-devel] [PATCH 13/27] acpi: memory hotplug ACPI hardware implementation, Paolo Bonzini, 2013/11/25