[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v1 5/9] hw/loongarch: Add hotplug handler for machine
From: |
Xiaojuan Yang |
Subject: |
[PATCH v1 5/9] hw/loongarch: Add hotplug handler for machine |
Date: |
Thu, 8 Sep 2022 17:46:19 +0800 |
Add hotplug handler for LoongArch virt machine and now only support
the dynamic sysbus device.
Signed-off-by: Xiaojuan Yang <yangxiaojuan@loongson.cn>
---
hw/loongarch/virt.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c
index 3976e8a058..a3dd35d579 100644
--- a/hw/loongarch/virt.c
+++ b/hw/loongarch/virt.c
@@ -804,9 +804,35 @@ static void loongarch_machine_initfn(Object *obj)
lams->oem_table_id = g_strndup(ACPI_BUILD_APPNAME8, 8);
}
+static void loongarch_machine_device_plug_cb(HotplugHandler *hotplug_dev,
+ DeviceState *dev, Error **errp)
+{
+ LoongArchMachineState *lams = LOONGARCH_MACHINE(hotplug_dev);
+ MachineClass *mc = MACHINE_GET_CLASS(lams);
+
+ if (device_is_dynamic_sysbus(mc, dev)) {
+ if (lams->platform_bus_dev) {
+
platform_bus_link_device(PLATFORM_BUS_DEVICE(lams->platform_bus_dev),
+ SYS_BUS_DEVICE(dev));
+ }
+ }
+}
+
+static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine,
+ DeviceState *dev)
+{
+ MachineClass *mc = MACHINE_GET_CLASS(machine);
+
+ if (device_is_dynamic_sysbus(mc, dev)) {
+ return HOTPLUG_HANDLER(machine);
+ }
+ return NULL;
+}
+
static void loongarch_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
+ HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc);
mc->desc = "Loongson-3A5000 LS7A1000 machine";
mc->init = loongarch_init;
@@ -819,6 +845,8 @@ static void loongarch_class_init(ObjectClass *oc, void
*data)
mc->block_default_type = IF_VIRTIO;
mc->default_boot_order = "c";
mc->no_cdrom = 1;
+ mc->get_hotplug_handler = virt_machine_get_hotplug_handler;
+ hc->plug = loongarch_machine_device_plug_cb;
object_class_property_add(oc, "acpi", "OnOffAuto",
loongarch_get_acpi, loongarch_set_acpi,
@@ -834,6 +862,10 @@ static const TypeInfo loongarch_machine_types[] = {
.instance_size = sizeof(LoongArchMachineState),
.class_init = loongarch_class_init,
.instance_init = loongarch_machine_initfn,
+ .interfaces = (InterfaceInfo[]) {
+ { TYPE_HOTPLUG_HANDLER },
+ { }
+ },
}
};
--
2.31.1
- [PATCH v1 0/9] Fix bugs and improve functions for LoongArch, Xiaojuan Yang, 2022/09/08
- [PATCH v1 4/9] hw/loongarch: Add platform bus support, Xiaojuan Yang, 2022/09/08
- [PATCH v1 2/9] hw/loongarch: Support fw_cfg dma function, Xiaojuan Yang, 2022/09/08
- [PATCH v1 5/9] hw/loongarch: Add hotplug handler for machine,
Xiaojuan Yang <=
- [PATCH v1 1/9] hw/loongarch: Remove vga device when loongarch init, Xiaojuan Yang, 2022/09/08
- [PATCH v1 3/9] hw/loongarch: Add interrupt information to FDT table, Xiaojuan Yang, 2022/09/08
- [PATCH v1 6/9] hw/loongarch: Add RAMFB to dynamic_sysbus_devices list, Xiaojuan Yang, 2022/09/08
- [PATCH v1 7/9] hw/loongarch: Fix acpi ged irq number in dsdt table, Xiaojuan Yang, 2022/09/08
- [PATCH v1 8/9] hw/loongarch: Support memory hotplug, Xiaojuan Yang, 2022/09/08
- [PATCH v1 9/9] hw/loongarch: Improve acpi dsdt table, Xiaojuan Yang, 2022/09/08
- Re: [PATCH v1 0/9] Fix bugs and improve functions for LoongArch, gaosong, 2022/09/13