diff mbox

[23/33] acpi: add CPU devices AML to DSDT

Message ID 1463496205-251412-24-git-send-email-imammedo@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Igor Mammedov May 17, 2016, 2:43 p.m. UTC
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/cpu.c         | 38 ++++++++++++++++++++++++++++++++++++++
 hw/i386/acpi-build.c  | 10 +++++++++-
 include/hw/acpi/cpu.h |  3 +++
 3 files changed, 50 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c
index 73258a1..b3e1cca 100644
--- a/hw/acpi/cpu.c
+++ b/hw/acpi/cpu.c
@@ -205,3 +205,41 @@  const VMStateDescription vmstate_cpu_hotplug = {
         VMSTATE_END_OF_LIST()
     }
 };
+
+#define CPU_NAME_FMT      "C%.03X"
+
+void build_cpus_aml(Aml *table, MachineState *machine, bool acpi1_compat)
+{
+    Aml *cpus_dev;
+    Aml *sb_scope = aml_scope("_SB");
+    MachineClass *mc = MACHINE_GET_CLASS(machine);
+    CPUArchIdList *arch_ids = mc->possible_cpu_arch_ids(machine);
+    cpus_dev = aml_device("\\_SB.CPUS");
+    {
+        int i;
+
+        aml_append(cpus_dev, aml_name_decl("_HID", aml_string("ACPI0010")));
+        aml_append(cpus_dev, aml_name_decl("_CID", aml_eisaid("PNP0A05")));
+
+        /* build Processor object for each processor */
+        for (i = 0; i < arch_ids->len; i++) {
+            Aml *dev;
+            Aml *uid = aml_int(i);
+            int arch_id = arch_ids->cpus[i].arch_id;
+
+            if (acpi1_compat && arch_id < 255) {
+                dev = aml_processor(i, 0, 0, CPU_NAME_FMT, i);
+            } else {
+                dev = aml_device(CPU_NAME_FMT, arch_id);
+                aml_append(dev, aml_name_decl("_HID", aml_string("ACPI0007")));
+                aml_append(dev, aml_name_decl("_UID", uid));
+            }
+
+            aml_append(cpus_dev, dev);
+        }
+    }
+    aml_append(sb_scope, cpus_dev);
+    aml_append(table, sb_scope);
+
+    g_free(arch_ids);
+}
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index af939bc..47d4182 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -93,6 +93,7 @@  typedef struct AcpiPmInfo {
     uint32_t gpe0_blk;
     uint32_t gpe0_blk_len;
     uint32_t io_base;
+    bool legacy_cpu_hp;
     uint16_t cpu_hp_io_base;
     uint16_t mem_hp_io_base;
     uint16_t mem_hp_io_len;
@@ -141,6 +142,9 @@  static void acpi_get_pm_info(AcpiPmInfo *pm)
     }
     assert(obj);
 
+    pm->legacy_cpu_hp = object_property_get_bool(obj, "cpu-hotplug-legacy",
+                                                 NULL);
+
     pm->mem_hp_io_base = ACPI_MEMORY_HOTPLUG_BASE;
     pm->mem_hp_io_len = ACPI_MEMORY_HOTPLUG_IO_LEN;
 
@@ -1942,7 +1946,11 @@  build_dsdt(GArray *table_data, GArray *linker,
         build_q35_pci0_int(dsdt);
     }
 
-    build_legacy_cpu_hotplug_aml(dsdt, machine, pm->cpu_hp_io_base);
+    if (pm->legacy_cpu_hp) {
+        build_legacy_cpu_hotplug_aml(dsdt, machine, pm->cpu_hp_io_base);
+    } else {
+        build_cpus_aml(dsdt, machine, true);
+    }
     build_memory_hotplug_aml(dsdt, nr_mem, pm->mem_hp_io_base,
                              pm->mem_hp_io_len);
 
diff --git a/include/hw/acpi/cpu.h b/include/hw/acpi/cpu.h
index 3fdf4eb..ca32e07 100644
--- a/include/hw/acpi/cpu.h
+++ b/include/hw/acpi/cpu.h
@@ -14,6 +14,7 @@ 
 
 #include "hw/qdev-core.h"
 #include "hw/acpi/acpi.h"
+#include "hw/acpi/aml-build.h"
 #include "hw/hotplug.h"
 
 typedef struct AcpiCpuStatus {
@@ -44,6 +45,8 @@  void acpi_cpu_unplug_cb(CPUHotplugState *cpu_st,
 void cpu_hotplug_hw_init(MemoryRegion *as, Object *owner,
                          CPUHotplugState *state, hwaddr base_addr);
 
+void build_cpus_aml(Aml *table, MachineState *machine, bool apci1_compat);
+
 extern const VMStateDescription vmstate_cpu_hotplug;
 #define VMSTATE_CPU_HOTPLUG(cpuhp, state) \
     VMSTATE_STRUCT(cpuhp, state, 1, \