qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v3 2/7] acpi/cpu: add cpu hot unplug request callbac


From: Zhu Guihua
Subject: [Qemu-devel] [PATCH v3 2/7] acpi/cpu: add cpu hot unplug request callback function
Date: Fri, 13 Feb 2015 18:40:17 +0800

From: Gu Zheng <address@hidden>

Signed-off-by: Chen Fan <address@hidden>
Signed-off-by: Gu Zheng <address@hidden>
Signed-off-by: Zhu Guihua <address@hidden>
---
 hw/acpi/cpu_hotplug.c         | 37 ++++++++++++++++++++++++++++++++-----
 include/hw/acpi/cpu_hotplug.h |  4 ++++
 2 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/hw/acpi/cpu_hotplug.c b/hw/acpi/cpu_hotplug.c
index 8e4ed6e..42109cd 100644
--- a/hw/acpi/cpu_hotplug.c
+++ b/hw/acpi/cpu_hotplug.c
@@ -12,6 +12,11 @@
 #include "hw/hw.h"
 #include "hw/acpi/cpu_hotplug.h"
 
+typedef enum STS_OPT {
+    SET,
+    CLEAR,
+} STS_OPT;
+
 static uint64_t cpu_status_read(void *opaque, hwaddr addr, unsigned int size)
 {
     AcpiCpuHotplug *cpus = opaque;
@@ -36,8 +41,8 @@ static const MemoryRegionOps AcpiCpuHotplug_ops = {
     },
 };
 
-static void acpi_set_cpu_present_bit(AcpiCpuHotplug *g, CPUState *cpu,
-                                     Error **errp)
+static void acpi_update_cpu_present_bit(AcpiCpuHotplug *g, CPUState *cpu,
+                                        STS_OPT opt, Error **errp)
 {
     CPUClass *k = CPU_GET_CLASS(cpu);
     int64_t cpu_id;
@@ -48,13 +53,23 @@ static void acpi_set_cpu_present_bit(AcpiCpuHotplug *g, 
CPUState *cpu,
         return;
     }
 
-    g->sts[cpu_id / 8] |= (1 << (cpu_id % 8));
+    switch (opt) {
+    case SET:
+        g->sts[cpu_id / 8] |= (1 << (cpu_id % 8));
+        break;
+    case CLEAR:
+        g->sts[cpu_id / 8] &= ~(1 << (cpu_id % 8));
+        break;
+    default:
+        g_assert(0);
+        break;
+    }
 }
 
 void acpi_cpu_plug_cb(ACPIREGS *ar, qemu_irq irq,
                       AcpiCpuHotplug *g, DeviceState *dev, Error **errp)
 {
-    acpi_set_cpu_present_bit(g, CPU(dev), errp);
+    acpi_update_cpu_present_bit(g, CPU(dev), SET, errp);
     if (*errp != NULL) {
         return;
     }
@@ -65,13 +80,25 @@ void acpi_cpu_plug_cb(ACPIREGS *ar, qemu_irq irq,
     }
 }
 
+void acpi_cpu_unplug_request_cb(ACPIREGS *ar, qemu_irq irq,
+                                AcpiCpuHotplug *g, DeviceState *dev,
+                                Error **errp)
+{
+    acpi_update_cpu_present_bit(g, CPU(dev), CLEAR, errp);
+    if (*errp != NULL) {
+        return;
+    }
+
+    acpi_send_gpe_event(ar, irq, ACPI_CPU_HOTPLUG_STATUS);
+}
+
 void acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner,
                            AcpiCpuHotplug *gpe_cpu, uint16_t base)
 {
     CPUState *cpu;
 
     CPU_FOREACH(cpu) {
-        acpi_set_cpu_present_bit(gpe_cpu, cpu, &error_abort);
+        acpi_update_cpu_present_bit(gpe_cpu, cpu, SET, &error_abort);
     }
     memory_region_init_io(&gpe_cpu->io, owner, &AcpiCpuHotplug_ops,
                           gpe_cpu, "acpi-cpu-hotplug", ACPI_GPE_PROC_LEN);
diff --git a/include/hw/acpi/cpu_hotplug.h b/include/hw/acpi/cpu_hotplug.h
index f6d358d..8b15a3d 100644
--- a/include/hw/acpi/cpu_hotplug.h
+++ b/include/hw/acpi/cpu_hotplug.h
@@ -23,6 +23,10 @@ typedef struct AcpiCpuHotplug {
 void acpi_cpu_plug_cb(ACPIREGS *ar, qemu_irq irq,
                       AcpiCpuHotplug *g, DeviceState *dev, Error **errp);
 
+void acpi_cpu_unplug_request_cb(ACPIREGS *ar, qemu_irq irq,
+                                AcpiCpuHotplug *g, DeviceState *dev,
+                                Error **errp);
+
 void acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner,
                            AcpiCpuHotplug *gpe_cpu, uint16_t base);
 #endif
-- 
1.9.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]