qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: qemu-devel@nongnu.org
Cc: marcel@redhat.com, mst@redhat.com
Subject: [Qemu-devel] [PATCH v5 08/16] pc: acpi-build: drop template patching and create Device(SMC) dynamically
Date: Fri, 20 Feb 2015 18:22:12 +0000	[thread overview]
Message-ID: <1424456540-27854-9-git-send-email-imammedo@redhat.com> (raw)
In-Reply-To: <1424456540-27854-1-git-send-email-imammedo@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.

Also it fixes wrong IO range in CRS if "iobase"
property is set to a non default value.

PS:
Testing with XP shows that current default "iobase"
used SMC device conflicts with floppy controller IO,
but it's topic for another patch and I'd leave it
to SMC device author for resolving conflict.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
CC: agraf@suse.de
---
 hw/i386/acpi-build.c      | 29 ++++++++++++++++++++++-------
 hw/i386/acpi-dsdt-isa.dsl | 11 -----------
 hw/i386/acpi-dsdt.dsl     |  1 -
 hw/i386/q35-acpi-dsdt.dsl |  1 -
 4 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index badfa73..05eb80a 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -116,6 +116,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 {
@@ -127,7 +128,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);
@@ -135,17 +135,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
@@ -248,6 +242,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)
@@ -955,6 +950,26 @@ build_ssdt(GArray *table_data, GArray *linker,
     aml_append(scope, aml_name_decl("_S5", pkg));
     aml_append(ssdt, scope);
 
+    if (misc->applesmc_io_base) {
+        scope = aml_scope("\\_SB.PCI0.ISA");
+        dev = aml_device("SMC");
+
+        aml_append(dev, aml_name_decl("_HID", aml_eisaid("APP0001")));
+        /* device present, functioning, decoding, not shown in UI */
+        aml_append(dev, aml_name_decl("_STA", aml_int(0xB)));
+
+        crs = aml_resource_template();
+        aml_append(crs,
+            aml_io(aml_decode16, misc->applesmc_io_base, misc->applesmc_io_base,
+                   0x01, APPLESMC_MAX_DATA_LENGTH)
+        );
+        aml_append(crs, aml_irq_no_flags(6));
+        aml_append(dev, aml_name_decl("_CRS", crs));
+
+        aml_append(scope, dev);
+        aml_append(ssdt, scope);
+    }
+
     if (misc->pvpanic_port) {
         scope = aml_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() {
diff --git a/hw/i386/acpi-dsdt.dsl b/hw/i386/acpi-dsdt.dsl
index 09b68f0..a2d84ec 100644
--- a/hw/i386/acpi-dsdt.dsl
+++ b/hw/i386/acpi-dsdt.dsl
@@ -85,7 +85,6 @@ DefinitionBlock (
         }
     }
 
-#define DSDT_APPLESMC_STA piix_dsdt_applesmc_sta
 #include "acpi-dsdt-isa.dsl"
 
 
diff --git a/hw/i386/q35-acpi-dsdt.dsl b/hw/i386/q35-acpi-dsdt.dsl
index 3fb4b2f..16eaca3 100644
--- a/hw/i386/q35-acpi-dsdt.dsl
+++ b/hw/i386/q35-acpi-dsdt.dsl
@@ -150,7 +150,6 @@ DefinitionBlock (
         }
     }
 
-#define DSDT_APPLESMC_STA q35_dsdt_applesmc_sta
 #include "acpi-dsdt-isa.dsl"
 
 
-- 
1.8.3.1

  parent reply	other threads:[~2015-02-20 18:22 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-20 18:22 [Qemu-devel] [PATCH v5 00/16] ACPI refactoring: replace template patching with C AML API Igor Mammedov
2015-02-20 18:22 ` [Qemu-devel] [PATCH v5 01/16] pc: acpi-build: create PCI0._CRS dynamically Igor Mammedov
2015-02-20 18:22 ` [Qemu-devel] [PATCH v5 02/16] pc: acpi: drop manual hole punching for PCI hotplug resources Igor Mammedov
2015-02-20 18:22 ` [Qemu-devel] [PATCH v5 03/16] pc: acpi: drop manual hole punching for CPU " Igor Mammedov
2015-02-20 18:22 ` [Qemu-devel] [PATCH v5 04/16] pc: acpi: drop manual hole punching for GPE0 resources Igor Mammedov
2015-02-20 18:22 ` [Qemu-devel] [PATCH v5 05/16] pc: acpi-build: drop remaining ssdt_misc template Igor Mammedov
2015-02-20 18:22 ` [Qemu-devel] [PATCH v5 06/16] acpi: add acpi_irq_no_flags() term Igor Mammedov
2015-02-20 18:22 ` [Qemu-devel] [PATCH v5 07/16] pc: export applesmc IO port/len Igor Mammedov
2015-02-20 18:22 ` Igor Mammedov [this message]
2015-02-26 16:33   ` [Qemu-devel] [PATCH v5 08/16] pc: acpi-build: drop template patching and create Device(SMC) dynamically Igor Mammedov
2015-02-20 18:22 ` [Qemu-devel] [PATCH v5 09/16] tests: ACPI test blobs update due to PCI0._CRS changes Igor Mammedov
2015-02-20 18:22 ` [Qemu-devel] [PATCH v5 10/16] tests: bios-tables-test: add support for testing bridges Igor Mammedov
2015-02-20 18:22 ` [Qemu-devel] [PATCH v5 11/16] tests: add ACPI blobs for qemu with bridge cases Igor Mammedov
2015-02-20 18:22 ` [Qemu-devel] [PATCH v5 12/16] pc: acpi-build: simplify PCI bus tree generation Igor Mammedov
2015-02-20 18:22 ` [Qemu-devel] [PATCH v5 13/16] tests: ACPI: update pc/SSDT.bridge due to new alg of PCI tree creation Igor Mammedov
2015-02-20 18:22 ` [Qemu-devel] [PATCH v5 14/16] pc: acpi-build: drop template patching and create PCI bus tree dynamically Igor Mammedov
2015-02-20 18:22 ` [Qemu-devel] [PATCH v5 15/16] pc: acpi: remove not used anymore ssdt-[misc|pcihp].hex.generated blobs Igor Mammedov
2015-02-20 18:22 ` [Qemu-devel] [PATCH v5 16/16] acpi: make build_*() routines static to aml-build.c Igor Mammedov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1424456540-27854-9-git-send-email-imammedo@redhat.com \
    --to=imammedo@redhat.com \
    --cc=marcel@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).