From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43340) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6oNs-0000YY-A3 for qemu-devel@nongnu.org; Wed, 09 Dec 2015 18:42:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a6oNm-0004xD-Km for qemu-devel@nongnu.org; Wed, 09 Dec 2015 18:42:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55714) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6oNm-0004x5-BR for qemu-devel@nongnu.org; Wed, 09 Dec 2015 18:42:50 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id F2D5C537A for ; Wed, 9 Dec 2015 23:42:49 +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 tB9Ng8Vi005315 for ; Wed, 9 Dec 2015 18:42:49 -0500 From: Igor Mammedov Date: Thu, 10 Dec 2015 00:41:36 +0100 Message-Id: <1449704528-289297-43-git-send-email-imammedo@redhat.com> In-Reply-To: <1449704528-289297-1-git-send-email-imammedo@redhat.com> References: <1449704528-289297-1-git-send-email-imammedo@redhat.com> Subject: [Qemu-devel] [PATCH 42/74] pc: acpi: cpuhp: move PRSC() method into SSDT List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Signed-off-by: Igor Mammedov --- hw/acpi/cpu_hotplug_acpi_table.c | 55 +++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 2 +- hw/i386/acpi-dsdt-cpu-hotplug.dsl | 39 +-------------------------- hw/i386/acpi-dsdt.dsl | 2 +- hw/i386/q35-acpi-dsdt.dsl | 2 +- include/hw/acpi/aml-build.h | 2 ++ include/hw/acpi/cpu_hotplug.h | 1 + include/hw/acpi/pc-hotplug.h | 1 + 8 files changed, 63 insertions(+), 41 deletions(-) diff --git a/hw/acpi/cpu_hotplug_acpi_table.c b/hw/acpi/cpu_hotplug_acpi_table.c index 8255937..4ff444d 100644 --- a/hw/acpi/cpu_hotplug_acpi_table.c +++ b/hw/acpi/cpu_hotplug_acpi_table.c @@ -26,6 +26,8 @@ void build_cpu_hotplug_aml(Aml *ctx) Aml *a_cpu_on = aml_local(0); Aml *a_madt = aml_local(1); Aml *a_cpus_map = aml_name(CPU_CPU_ON_BITMAP); + Aml *a_zero = aml_int(0); + Aml *a_one = aml_int(1); /* * _MAT method - creates an madt apic buffer @@ -65,5 +67,58 @@ void build_cpu_hotplug_aml(Aml *ctx) aml_append(method, aml_sleep(200)); aml_append(sb_scope, method); + method = aml_method(stringify(CPU_SCAN_METHOD), 0, AML_NOTSERIALIZED); + { + Aml *while_ctx, *if_ctx2; + Aml *a_bus_check_evt = aml_int(1); + Aml *a_remove_evt = aml_int(3); + Aml *a_status_map = aml_local(5); /* Local5 = active cpu bitmap */ + Aml *a_byte = aml_local(2); /* Local2 = last read byte from bitmap */ + Aml *a_idx = aml_local(0); /* Processor ID / APIC ID iterator */ + Aml *a_is_cpu_on = aml_local(1); /* Local1 = CPON flag for cpu */ + Aml *a_status = aml_local(3); /* Local3 = active state for cpu */ + + aml_append(method, aml_store(aml_name(CPU_STATUS_MAP), a_status_map)); + aml_append(method, aml_store(a_zero, a_byte)); + aml_append(method, aml_store(a_zero, a_idx)); + + /* While (a_idx < SizeOf(CPON)) */ + while_ctx = aml_while(aml_lless(a_idx, aml_sizeof(a_cpus_map))); + aml_append(while_ctx, aml_store( + aml_derefof(aml_index(a_cpus_map, a_idx)), a_is_cpu_on)); + + if_ctx = aml_if(aml_and(a_idx, aml_int(0x07), NULL)); + /* Shift down previously read bitmap byte */ + aml_append(if_ctx, aml_shiftright(a_byte, a_one, a_byte)); + aml_append(while_ctx, if_ctx); + + else_ctx = aml_else(); + /* Read next byte from cpu bitmap */ + aml_append(else_ctx, aml_store(aml_derefof( + aml_index(a_status_map, aml_shiftright(a_idx, aml_int(3), NULL))), + a_byte)); + aml_append(while_ctx, else_ctx); + + aml_append(while_ctx, + aml_store(aml_and(a_byte, a_one, NULL), a_status)); + if_ctx = aml_if(aml_lnot(aml_equal(a_is_cpu_on, a_status))); + + /* State change - update CPON with new state */ + aml_append(if_ctx, aml_store(a_status, aml_index(a_cpus_map, a_idx))); + if_ctx2 = aml_if(aml_equal(a_status, a_one)); + aml_append(if_ctx2, + aml_call2(AML_NOTIFY_METHOD, a_idx, a_bus_check_evt)); + aml_append(if_ctx, if_ctx2); + else_ctx = aml_else(); + aml_append(else_ctx, + aml_call2(AML_NOTIFY_METHOD, a_idx, a_remove_evt)); + aml_append(if_ctx, else_ctx); + aml_append(while_ctx, if_ctx); + + aml_append(while_ctx, aml_increment(a_idx)); /* go to next cpu */ + aml_append(method, while_ctx); + } + aml_append(sb_scope, method); + aml_append(ctx, sb_scope); } diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 3675928..39e7434 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1313,7 +1313,7 @@ build_ssdt(GArray *table_data, GArray *linker, * Method(NTFY, 2) {If (LEqual(Arg0, 0x00)) {Notify(CP00, Arg1)} ...} */ /* Arg0 = Processor ID = APIC ID */ - method = aml_method("NTFY", 2, AML_NOTSERIALIZED); + method = aml_method(AML_NOTIFY_METHOD, 2, AML_NOTSERIALIZED); for (i = 0; i < acpi_cpus; i++) { ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i))); aml_append(ifctx, diff --git a/hw/i386/acpi-dsdt-cpu-hotplug.dsl b/hw/i386/acpi-dsdt-cpu-hotplug.dsl index fb75eda..88c472b 100644 --- a/hw/i386/acpi-dsdt-cpu-hotplug.dsl +++ b/hw/i386/acpi-dsdt-cpu-hotplug.dsl @@ -19,42 +19,5 @@ Scope(\_SB) { /* Objects filled in by run-time generated SSDT */ - External(NTFY, MethodObj) - External(CPON, PkgObj) - External(PRS, FieldUnitObj) - - /* Methods called by run-time generated SSDT Processor objects */ - Method(PRSC, 0) { - // Local5 = active cpu bitmap - Store(PRS, Local5) - // Local2 = last read byte from bitmap - Store(Zero, Local2) - // Local0 = Processor ID / APIC ID iterator - Store(Zero, Local0) - While (LLess(Local0, SizeOf(CPON))) { - // Local1 = CPON flag for this cpu - Store(DerefOf(Index(CPON, Local0)), Local1) - If (And(Local0, 0x07)) { - // Shift down previously read bitmap byte - ShiftRight(Local2, 1, Local2) - } Else { - // Read next byte from cpu bitmap - Store(DerefOf(Index(Local5, ShiftRight(Local0, 3))), Local2) - } - // Local3 = active state for this cpu - Store(And(Local2, 1), Local3) - - If (LNotEqual(Local1, Local3)) { - // State change - update CPON with new state - Store(Local3, Index(CPON, Local0)) - // Do CPU notify - If (LEqual(Local3, 1)) { - NTFY(Local0, 1) - } Else { - NTFY(Local0, 3) - } - } - Increment(Local0) - } - } + External(CPU_SCAN_METHOD, MethodObj) } diff --git a/hw/i386/acpi-dsdt.dsl b/hw/i386/acpi-dsdt.dsl index 9cf1b88..6a0c656 100644 --- a/hw/i386/acpi-dsdt.dsl +++ b/hw/i386/acpi-dsdt.dsl @@ -268,7 +268,7 @@ DefinitionBlock ( } Method(_E02) { // CPU hotplug event - \_SB.PRSC() + \_SB.CPU_SCAN_METHOD() } Method(_L04) { } diff --git a/hw/i386/q35-acpi-dsdt.dsl b/hw/i386/q35-acpi-dsdt.dsl index f950f39..7211665 100644 --- a/hw/i386/q35-acpi-dsdt.dsl +++ b/hw/i386/q35-acpi-dsdt.dsl @@ -401,7 +401,7 @@ DefinitionBlock ( } Method(_E02) { // CPU hotplug event - \_SB.PRSC() + \_SB.CPU_SCAN_METHOD() } Method(_L04) { } diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index a3a058f..a23b8da 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -16,6 +16,8 @@ #define ACPI_BUILD_RSDP_FILE "etc/acpi/rsdp" #define ACPI_BUILD_TPMLOG_FILE "etc/tpm/log" +#define AML_NOTIFY_METHOD "NTFY" + typedef enum { AML_NO_OPCODE = 0,/* has only data */ AML_OPCODE, /* has opcode optionally followed by data */ diff --git a/include/hw/acpi/cpu_hotplug.h b/include/hw/acpi/cpu_hotplug.h index 1ae3b29..1c5f630 100644 --- a/include/hw/acpi/cpu_hotplug.h +++ b/include/hw/acpi/cpu_hotplug.h @@ -31,6 +31,7 @@ void acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner, #define CPU_MAT_METHOD "CPMA" #define CPU_CPU_ON_BITMAP "CPON" #define CPU_STATUS_METHOD "CPST" +#define CPU_STATUS_MAP "PRS" void build_cpu_hotplug_aml(Aml *ctx); #endif diff --git a/include/hw/acpi/pc-hotplug.h b/include/hw/acpi/pc-hotplug.h index 6a8d268..6522745 100644 --- a/include/hw/acpi/pc-hotplug.h +++ b/include/hw/acpi/pc-hotplug.h @@ -28,6 +28,7 @@ #define ICH9_CPU_HOTPLUG_IO_BASE 0x0CD8 #define PIIX4_CPU_HOTPLUG_IO_BASE 0xaf00 #define CPU_HOTPLUG_RESOURCE_DEVICE PRES +#define CPU_SCAN_METHOD PRSC #define ACPI_MEMORY_HOTPLUG_IO_LEN 24 #define ACPI_MEMORY_HOTPLUG_BASE 0x0a00 -- 1.8.3.1