From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54760) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VjKCb-0006j5-Ey for qemu-devel@nongnu.org; Wed, 20 Nov 2013 21:41:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VjKCV-00043c-As for qemu-devel@nongnu.org; Wed, 20 Nov 2013 21:41:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:16856) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VjKCV-00043U-2O for qemu-devel@nongnu.org; Wed, 20 Nov 2013 21:41:03 -0500 From: Igor Mammedov Date: Thu, 21 Nov 2013 03:38:33 +0100 Message-Id: <1385001528-12003-13-git-send-email-imammedo@redhat.com> In-Reply-To: <1385001528-12003-1-git-send-email-imammedo@redhat.com> References: <1385001528-12003-1-git-send-email-imammedo@redhat.com> Subject: [Qemu-devel] [PATCH 12/27] dimm: add hotplug callback to DimmBus List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, stefanha@redhat.com, mst@redhat.com, chegu_vinod@hp.com, stefanb@linux.vnet.ibm.com, mjt@tls.msk.ru, mdroth@linux.vnet.ibm.com, armbru@redhat.com, vasilis.liaskovitis@profitbricks.com, quintela@redhat.com, kraxel@redhat.com, aliguori@amazon.com, hutao@cn.fujitsu.com, pbonzini@redhat.com, marcel.a@redhat.com, lcapitulino@redhat.com, afaerber@suse.de Signed-off-by: Igor Mammedov --- 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