From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43532) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6oO1-0000rP-0p for qemu-devel@nongnu.org; Wed, 09 Dec 2015 18:43:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a6oNz-00051i-Ob for qemu-devel@nongnu.org; Wed, 09 Dec 2015 18:43:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60958) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6oNz-00051b-GM for qemu-devel@nongnu.org; Wed, 09 Dec 2015 18:43:03 -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 241DF37EE2 for ; Wed, 9 Dec 2015 23:43:03 +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 tB9Ng8W0005315 for ; Wed, 9 Dec 2015 18:43:02 -0500 From: Igor Mammedov Date: Thu, 10 Dec 2015 00:41:52 +0100 Message-Id: <1449704528-289297-59-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 58/74] pc: acpi: piix4: move PCI0._PRT() 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/i386/acpi-build.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-dsdt.dsl | 60 ------------------------------------- 2 files changed, 83 insertions(+), 60 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index cf98037..f0966b8 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1339,6 +1339,17 @@ static Aml *build_link_dev(const char *name, uint8_t uid, Aml *reg) return dev; } +static Aml *build_prt_entry(const char *dev) +{ + Aml *a_zero = aml_int(0); + Aml *pkg = aml_package(4); + aml_append(pkg, a_zero); + aml_append(pkg, a_zero); + aml_append(pkg, aml_name("%s", dev)); + aml_append(pkg, a_zero); + return pkg; +} + static void build_piix4_pci0_int(Aml *table) { Aml *dev; @@ -1348,6 +1359,78 @@ static void build_piix4_pci0_int(Aml *table) Aml *method; uint32_t irqs; Aml *sb_scope = aml_scope("_SB"); + Aml *pci0_scope = aml_scope("PCI0"); + + method = aml_method("_PRT", 0, AML_NOTSERIALIZED); + { + Aml *w_ctx; + Aml *if_ctx2; + Aml *else_ctx2; + Aml *a_zero = aml_int(0); + Aml *a_prt = aml_local(0); + Aml *a_pin = aml_local(1); + Aml *a_lnk = aml_local(3); + Aml *a_slot = aml_local(2); + Aml *a_prt_ent = aml_local(4); + + aml_append(method, aml_store(aml_package(128), a_prt)); + aml_append(method, aml_store(a_zero, a_pin)); + w_ctx = aml_while(aml_lless(a_pin, aml_int(128))); + + /* slot = pin >> 2 */ + aml_append(w_ctx, + aml_store(aml_shiftright(a_pin, aml_int(2), NULL), a_slot)); + + /* lnk = (slot + pin) & 3 */ + aml_append(w_ctx, + aml_store(aml_and(aml_add(a_pin, a_slot, NULL), aml_int(3), NULL), + a_lnk)); + + if_ctx = aml_if(aml_equal(a_lnk, a_zero)); + aml_append(if_ctx, aml_store(build_prt_entry("LNKD"), a_prt_ent)); + aml_append(w_ctx, if_ctx); + + if_ctx = aml_if(aml_equal(a_lnk, aml_int(1))); + /* device 1 is the power-management device, needs SCI */ + if_ctx2 = aml_if(aml_equal(a_pin, aml_int(4))); + aml_append(if_ctx2, aml_store(build_prt_entry("LNKS"), a_prt_ent)); + aml_append(if_ctx, if_ctx2); + else_ctx2 = aml_else(); + aml_append(else_ctx2, aml_store(build_prt_entry("LNKA"), a_prt_ent)); + aml_append(if_ctx, else_ctx2); + aml_append(w_ctx, if_ctx); + + if_ctx = aml_if(aml_equal(a_lnk, aml_int(2))); + aml_append(if_ctx, aml_store(build_prt_entry("LNKB"), a_prt_ent)); + aml_append(w_ctx, if_ctx); + + if_ctx = aml_if(aml_equal(a_lnk, aml_int(3))); + aml_append(if_ctx, aml_store(build_prt_entry("LNKC"), a_prt_ent)); + aml_append(w_ctx, if_ctx); + + /* + * Complete the interrupt routing entry: + * Package(4) { 0x[slot]FFFF, [pin], [link], 0) } + */ + aml_append(w_ctx, + aml_store( + aml_or(aml_shiftleft(a_slot, aml_int(16)), + aml_int(0xFFFF), NULL), + aml_index(a_prt_ent, a_zero) + ) + ); + aml_append(w_ctx, + aml_store(aml_and(a_pin, aml_int(3), NULL), + aml_index(a_prt_ent, aml_int(1)))); + aml_append(w_ctx, aml_store(a_prt_ent, aml_index(a_prt, a_pin))); + + aml_append(w_ctx, aml_increment(a_pin)); + aml_append(method, w_ctx); + + aml_append(method, aml_return(aml_local(0))); + } + aml_append(pci0_scope, method); + aml_append(sb_scope, pci0_scope); field = aml_field("PCI0.ISA.P40C", AML_BYTE_ACC, AML_NOLOCK, AML_PRESERVE); aml_append(field, aml_named_field("PRQ0", 8)); diff --git a/hw/i386/acpi-dsdt.dsl b/hw/i386/acpi-dsdt.dsl index bc6bd45..5d741dd 100644 --- a/hw/i386/acpi-dsdt.dsl +++ b/hw/i386/acpi-dsdt.dsl @@ -78,64 +78,4 @@ DefinitionBlock ( /* Hotplug notification method supplied by SSDT */ External(\_SB.PCI0.PCNT, MethodObj) } - - -/**************************************************************** - * PCI IRQs - ****************************************************************/ - - Scope(\_SB) { - Scope(PCI0) { - Method (_PRT, 0) { - Store(Package(128) {}, Local0) - Store(Zero, Local1) - While(LLess(Local1, 128)) { - // slot = pin >> 2 - Store(ShiftRight(Local1, 2), Local2) - - // lnk = (slot + pin) & 3 - Store(And(Add(Local1, Local2), 3), Local3) - If (LEqual(Local3, 0)) { - Store(Package(4) { Zero, Zero, LNKD, Zero }, Local4) - } - If (LEqual(Local3, 1)) { - // device 1 is the power-management device, needs SCI - If (LEqual(Local1, 4)) { - Store(Package(4) { Zero, Zero, LNKS, Zero }, Local4) - } Else { - Store(Package(4) { Zero, Zero, LNKA, Zero }, Local4) - } - } - If (LEqual(Local3, 2)) { - Store(Package(4) { Zero, Zero, LNKB, Zero }, Local4) - } - If (LEqual(Local3, 3)) { - Store(Package(4) { Zero, Zero, LNKC, Zero }, Local4) - } - - // Complete the interrupt routing entry: - // Package(4) { 0x[slot]FFFF, [pin], [link], 0) } - - Store(Or(ShiftLeft(Local2, 16), 0xFFFF), Index(Local4, 0)) - Store(And(Local1, 3), Index(Local4, 1)) - Store(Local4, Index(Local0, Local1)) - - Increment(Local1) - } - - Return(Local0) - } - } - - - External(PRQ0, FieldUnitObj) - External(PRQ1, FieldUnitObj) - External(PRQ2, FieldUnitObj) - External(PRQ3, FieldUnitObj) - External(LNKA, DeviceObj) - External(LNKB, DeviceObj) - External(LNKC, DeviceObj) - External(LNKD, DeviceObj) - External(LNKS, DeviceObj) - } } -- 1.8.3.1