From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49160) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEJ74-0004ME-4h for qemu-devel@nongnu.org; Thu, 22 Jan 2015 09:52:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YEJ6z-0003wq-DD for qemu-devel@nongnu.org; Thu, 22 Jan 2015 09:52:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:10593) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEJ6z-0003wd-5d for qemu-devel@nongnu.org; Thu, 22 Jan 2015 09:51:57 -0500 From: Igor Mammedov Date: Thu, 22 Jan 2015 14:50:31 +0000 Message-Id: <1421938231-25698-48-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> Subject: [Qemu-devel] [PATCH v2 47/47] pc: acpi-build: drop template patching and create Device(SMC) dynamically List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, drjones@redhat.com, marcel.a@redhat.com, claudio.fontana@huawei.com, mst@redhat.com patch moves SMC device into SSDT and creates it only when device is present, which makes ACPI tables smaller in default case when device is not present. PS: also it fixes wrong IO range in CRS if "iobase" property is set to a not default value. Signed-off-by: Igor Mammedov --- hw/i386/acpi-build.c | 33 ++++++++++++++++++++++++++------- hw/i386/acpi-dsdt-isa.dsl | 11 ----------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index fc9dcfa..f66da5d 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -115,6 +115,7 @@ typedef struct AcpiMiscInfo { const unsigned char *dsdt_code; unsigned dsdt_size; uint16_t pvpanic_port; + uint16_t applesmc_io_base; } AcpiMiscInfo; typedef struct AcpiBuildPciBusHotplugState { @@ -126,7 +127,6 @@ typedef struct AcpiBuildPciBusHotplugState { static void acpi_get_dsdt(AcpiMiscInfo *info) { - uint16_t *applesmc_sta; Object *piix = piix4_pm_find(); Object *lpc = ich9_lpc_find(); assert(!!piix != !!lpc); @@ -134,17 +134,11 @@ static void acpi_get_dsdt(AcpiMiscInfo *info) if (piix) { info->dsdt_code = AcpiDsdtAmlCode; info->dsdt_size = sizeof AcpiDsdtAmlCode; - applesmc_sta = piix_dsdt_applesmc_sta; } if (lpc) { info->dsdt_code = Q35AcpiDsdtAmlCode; info->dsdt_size = sizeof Q35AcpiDsdtAmlCode; - applesmc_sta = q35_dsdt_applesmc_sta; } - - /* Patch in appropriate value for AppleSMC _STA */ - *(uint8_t *)(info->dsdt_code + *applesmc_sta) = - applesmc_port() ? 0x0b : 0x00; } static @@ -241,6 +235,7 @@ static void acpi_get_misc_info(AcpiMiscInfo *info) info->has_hpet = hpet_find(); info->has_tpm = tpm_find(); info->pvpanic_port = pvpanic_port(); + info->applesmc_io_base = applesmc_port(); } static void acpi_get_pci_info(PcPciInfo *info) @@ -741,6 +736,30 @@ build_ssdt(AcpiAml *table_aml, GArray *linker, aml_append(&scope, acpi_name_decl("_S5", pkg)); aml_append(&ssdt, scope); + if (misc->applesmc_io_base) { + scope = acpi_scope("\\_SB.PCI0.ISA"); + dev = acpi_device("SMC"); + + aml_append(&dev, acpi_name_decl("_HID", acpi_eisaid("APP0001"))); + /* device present, functioning, decoding, not shown in UI */ + aml_append(&dev, acpi_name_decl("_STA", acpi_int(0xB))); + + crs = acpi_resource_template(); + aml_append(&crs, + acpi_io(acpi_decode16, + misc->applesmc_io_base, + misc->applesmc_io_base, + 0x01, + APPLESMC_MAX_DATA_LENGTH + ) + ); + aml_append(&crs, acpi_iqr_no_flags(6)); + aml_append(&dev, acpi_name_decl("_CRS", crs)); + + aml_append(&scope, dev); + aml_append(&ssdt, scope); + } + if (misc->pvpanic_port) { scope = acpi_scope("\\_SB.PCI0.ISA"); diff --git a/hw/i386/acpi-dsdt-isa.dsl b/hw/i386/acpi-dsdt-isa.dsl index deb37de..89caa16 100644 --- a/hw/i386/acpi-dsdt-isa.dsl +++ b/hw/i386/acpi-dsdt-isa.dsl @@ -16,17 +16,6 @@ /* Common legacy ISA style devices. */ Scope(\_SB.PCI0.ISA) { - Device (SMC) { - Name(_HID, EisaId("APP0001")) - /* _STA will be patched to 0x0B if AppleSMC is present */ - ACPI_EXTRACT_NAME_BYTE_CONST DSDT_APPLESMC_STA - Name(_STA, 0xF0) - Name(_CRS, ResourceTemplate () { - IO (Decode16, 0x0300, 0x0300, 0x01, 0x20) - IRQNoFlags() { 6 } - }) - } - Device(RTC) { Name(_HID, EisaId("PNP0B00")) Name(_CRS, ResourceTemplate() { -- 1.8.3.1