Signed-off-by: Igor Mammedov <imamm...@redhat.com> --- hw/i386/pc.c | 11 +++++++++++ hw/mem/dimm.c | 4 ++++ include/hw/i386/pc.h | 6 ++++++ include/hw/mem/dimm.h | 4 ++++ 4 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c index ba82c67..85d0862 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1225,6 +1225,17 @@ FWCfgState *pc_memory_init(MemoryRegion *system_memory, return fw_cfg; } +void pc_acpi_dev_memory_hotplug_init(DimmBus *hotplug_mem_bus, + hotplug_fn hotplug, + Object *acpi_dev) +{ + g_assert(acpi_dev); + if (memory_region_size(&hotplug_mem_bus->as)) { + hotplug_mem_bus->hotplug_dev = DEVICE(acpi_dev); + hotplug_mem_bus->hotplug = hotplug; + } +} + qemu_irq *pc_allocate_cpu_irq(void) { return qemu_allocate_irqs(pic_irq_request, NULL, 1); diff --git a/hw/mem/dimm.c b/hw/mem/dimm.c index b3c27cc..7029675 100644 --- a/hw/mem/dimm.c +++ b/hw/mem/dimm.c @@ -278,6 +278,10 @@ static void dimm_realize(DeviceState *dev, Error **errp) g_assert(dbc->register_memory); dbc->register_memory(bus, dimm, errp); + + if (bus->hotplug) { + bus->hotplug(bus->hotplug_dev, dev, HOTPLUG_ENABLED); + } } static void dimm_finalize(Object *obj) diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index c4e8048..0c86ee5 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -12,6 +12,7 @@ #include "qemu/bitmap.h" #include "sysemu/sysemu.h" #include "hw/pci/pci.h" +#include "hw/mem/dimm.h" /* PC-style peripherals (also used by other machines). */ @@ -148,6 +149,11 @@ FWCfgState *pc_memory_init(MemoryRegion *system_memory, MemoryRegion *rom_memory, MemoryRegion **ram_memory, PcGuestInfo *guest_info); + +void pc_acpi_dev_memory_hotplug_init(DimmBus *hotplug_mem_bus, + hotplug_fn hotplug, + Object *acpi_dev); + qemu_irq *pc_allocate_cpu_irq(void); DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus); void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi, diff --git a/include/hw/mem/dimm.h b/include/hw/mem/dimm.h index abedae2..b655006 100644 --- a/include/hw/mem/dimm.h +++ b/include/hw/mem/dimm.h @@ -65,11 +65,15 @@ typedef struct DimmDeviceClass { * @parent_obj: opaque parent object container * @base: address from which to start mapping @DimmDevice * @as: hot-plugabble memory area where @DimmDevice-s are attached + * @hotplug_dev: device that hotplugs realized DimmDevice + * @hotplug: hotplug callback set by the board */ typedef struct DimmBus { BusState parent_obj; hwaddr base; MemoryRegion as; + DeviceState *hotplug_dev; + hotplug_fn hotplug; } DimmBus; /** -- 1.7.1