From patchwork Mon May 2 12:33:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 8992231 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 64049BF440 for ; Mon, 2 May 2016 12:54:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BC584201FA for ; Mon, 2 May 2016 12:54:36 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5F23C201FE for ; Mon, 2 May 2016 12:54:35 +0000 (UTC) Received: from localhost ([::1]:36528 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axDMt-0004UW-L6 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 02 May 2016 08:54:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35675) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axD44-0006z8-AM for qemu-devel@nongnu.org; Mon, 02 May 2016 08:35:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1axD3s-00006g-5D for qemu-devel@nongnu.org; Mon, 02 May 2016 08:34:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52000) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axD3r-0008Uc-VE for qemu-devel@nongnu.org; Mon, 02 May 2016 08:34:52 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D92132196 for ; Mon, 2 May 2016 12:34:40 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u42CXqcE000450; Mon, 2 May 2016 08:34:39 -0400 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 2 May 2016 14:33:36 +0200 Message-Id: <1462192431-146342-28-git-send-email-imammedo@redhat.com> In-Reply-To: <1462192431-146342-1-git-send-email-imammedo@redhat.com> References: <1462192431-146342-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC 27/42] acpi: add CPU devices AML to DSDT X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: drjones@redhat.com, ehabkost@redhat.com, mst@redhat.com, armbru@redhat.com, marcel@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Igor Mammedov --- hw/acpi/cpu.c | 38 ++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 2 ++ include/hw/acpi/cpu.h | 3 +++ 3 files changed, 43 insertions(+) diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c index 2b4feb0..6dab4d6 100644 --- a/hw/acpi/cpu.c +++ b/hw/acpi/cpu.c @@ -216,3 +216,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 f8c9a7c..466eebd 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1948,6 +1948,8 @@ build_dsdt(GArray *table_data, GArray *linker, 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 c746292..da087bf 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 { @@ -45,6 +46,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, \