From patchwork Thu Jan 22 14:50:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 431871 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id AE0011400B6 for ; Fri, 23 Jan 2015 02:11:50 +1100 (AEDT) Received: from localhost ([::1]:53945 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEJQC-0004nF-JN for incoming@patchwork.ozlabs.org; Thu, 22 Jan 2015 10:11:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48572) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEJ6b-0003Z0-43 for qemu-devel@nongnu.org; Thu, 22 Jan 2015 09:51:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YEJ6W-0003gH-CB for qemu-devel@nongnu.org; Thu, 22 Jan 2015 09:51:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39208) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEJ6W-0003g6-4r for qemu-devel@nongnu.org; Thu, 22 Jan 2015 09:51:28 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0MEpJl6019473 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Jan 2015 09:51:20 -0500 Received: from dell-pet610-01.lab.eng.brq.redhat.com (dell-pet610-01.lab.eng.brq.redhat.com [10.34.42.20]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t0MEoYdr030524; Thu, 22 Jan 2015 09:51:18 -0500 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 22 Jan 2015 14:50:12 +0000 Message-Id: <1421938231-25698-29-git-send-email-imammedo@redhat.com> In-Reply-To: <1421938231-25698-1-git-send-email-imammedo@redhat.com> References: <1421938231-25698-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: pbonzini@redhat.com, drjones@redhat.com, marcel.a@redhat.com, claudio.fontana@huawei.com, mst@redhat.com Subject: [Qemu-devel] [PATCH v2 28/47] pc: acpi-build: generate pvpanic device description dynamically X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Drops AML template patching and allows to save some space in SSDT if pvpanic device doesn't exist by not including disabled device description into SSDT. It also makes device description smaller by replacing _STA method with named value and dropping _INI method. Signed-off-by: Igor Mammedov --- hw/i386/acpi-build.c | 36 ++++++++++++++++++++++++++++++++---- hw/i386/ssdt-misc.dsl | 47 ----------------------------------------------- 2 files changed, 32 insertions(+), 51 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 4e5858a..6ae0c81 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -760,7 +760,7 @@ build_ssdt(GArray *table_data, GArray *linker, int ssdt_start = table_data->len; AcpiAml table_aml = { .buf = table_data }; uint8_t *ssdt_ptr; - AcpiAml pkg, scope; + AcpiAml pkg, scope, dev, method, crs, field; int i; /* The current AML generator can cover the APIC ID range [0..255], @@ -775,9 +775,6 @@ build_ssdt(GArray *table_data, GArray *linker, patch_pci_windows(pci, ssdt_ptr, sizeof(ssdp_misc_aml)); ACPI_BUILD_SET_LE(ssdt_ptr, sizeof(ssdp_misc_aml), - ssdt_isa_pest[0], 16, misc->pvpanic_port); - - ACPI_BUILD_SET_LE(ssdt_ptr, sizeof(ssdp_misc_aml), ssdt_mctrl_nr_slots[0], 32, nr_mem); /* create S3_ / S4_ / S5_ packages if necessary */ @@ -808,6 +805,37 @@ build_ssdt(GArray *table_data, GArray *linker, aml_append(&scope, acpi_name_decl("_S5", pkg)); aml_append(&table_aml, scope); + if (misc->pvpanic_port) { + scope = acpi_scope("\\_SB.PCI0.ISA"); + + dev = acpi_device("PEVR"); + aml_append(&dev, acpi_name_decl("_HID", acpi_string("QEMU0002"))); + + crs = acpi_resource_template(); + aml_append(&crs, + acpi_io(acpi_decode16, misc->pvpanic_port, misc->pvpanic_port, 1, 1) + ); + aml_append(&dev, acpi_name_decl("_CRS", crs)); + + aml_append(&dev, acpi_operation_region("PEOR", acpi_system_io, + misc->pvpanic_port, 1)); + field = acpi_field("PEOR", acpi_byte_acc); + aml_append(&field, acpi_named_field("PEPT", 8)); + aml_append(&dev, field); + + method = acpi_method("RDPT", 0); + aml_append(&method, acpi_store(acpi_name("PEPT"), acpi_local0())); + aml_append(&method, acpi_return(acpi_local0())); + aml_append(&dev, method); + + method = acpi_method("WRPT", 1); + aml_append(&method, acpi_store(acpi_arg0(), acpi_name("PEPT"))); + aml_append(&dev, method); + + aml_append(&scope, dev); + aml_append(&table_aml, scope); + } + { AcpiAml sb_scope = acpi_scope("_SB"); diff --git a/hw/i386/ssdt-misc.dsl b/hw/i386/ssdt-misc.dsl index 26b9241..81be858 100644 --- a/hw/i386/ssdt-misc.dsl +++ b/hw/i386/ssdt-misc.dsl @@ -39,51 +39,4 @@ DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1) ACPI_EXTRACT_NAME_DWORD_CONST ssdt_mctrl_nr_slots Name(MEMORY_SLOTS_NUMBER, 0x12345678) } - - - External(\_SB.PCI0, DeviceObj) - External(\_SB.PCI0.ISA, DeviceObj) - - Scope(\_SB.PCI0.ISA) { - Device(PEVT) { - Name(_HID, "QEMU0001") - /* PEST will be patched to be Zero if no such device */ - ACPI_EXTRACT_NAME_WORD_CONST ssdt_isa_pest - Name(PEST, 0xFFFF) - OperationRegion(PEOR, SystemIO, PEST, 0x01) - Field(PEOR, ByteAcc, NoLock, Preserve) { - PEPT, 8, - } - - Method(_STA, 0, NotSerialized) { - Store(PEST, Local0) - If (LEqual(Local0, Zero)) { - Return (0x00) - } Else { - Return (0x0F) - } - } - - Method(RDPT, 0, NotSerialized) { - Store(PEPT, Local0) - Return (Local0) - } - - Method(WRPT, 1, NotSerialized) { - Store(Arg0, PEPT) - } - - Name(_CRS, ResourceTemplate() { - IO(Decode16, 0x00, 0x00, 0x01, 0x01, IO) - }) - - CreateWordField(_CRS, IO._MIN, IOMN) - CreateWordField(_CRS, IO._MAX, IOMX) - - Method(_INI, 0, NotSerialized) { - Store(PEST, IOMN) - Store(PEST, IOMX) - } - } - } }