From patchwork Fri Nov 18 10:36:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 82859 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp2619qge; Fri, 18 Nov 2016 02:42:07 -0800 (PST) X-Received: by 10.28.39.5 with SMTP id n5mr21130110wmn.54.1479465727464; Fri, 18 Nov 2016 02:42:07 -0800 (PST) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 79si1957803wmy.132.2016.11.18.02.42.07 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 18 Nov 2016 02:42:07 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:35689 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c7gcQ-0007O5-7t for patch@linaro.org; Fri, 18 Nov 2016 05:42:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45261) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c7gXe-0004IG-0M for qemu-devel@nongnu.org; Fri, 18 Nov 2016 05:37:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c7gXc-0004TL-SP for qemu-devel@nongnu.org; Fri, 18 Nov 2016 05:37:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51944) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c7gXc-0004T5-IN for qemu-devel@nongnu.org; Fri, 18 Nov 2016 05:37:08 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7A5BCC05490F; Fri, 18 Nov 2016 10:37:07 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-70.phx2.redhat.com [10.3.116.70]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uAIAb3PQ008728; Fri, 18 Nov 2016 05:37:05 -0500 From: Laszlo Ersek To: qemu devel list Date: Fri, 18 Nov 2016 11:36:57 +0100 Message-Id: <20161118103659.10448-2-lersek@redhat.com> In-Reply-To: <20161118103659.10448-1-lersek@redhat.com> References: <20161118103659.10448-1-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 18 Nov 2016 10:37:07 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 for-2.9 1/3] hw/isa/apm: introduce callback for APM_STS_IOPORT writes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Kevin O'Connor , Gerd Hoffmann , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" In the following patches we'll add custom handling for when APM_STS_IOPORT is written. Introduce a dedicated callback similar to the one that is now called for APM_CNT_IOPORT writes. Cc: "Kevin O'Connor" Cc: "Michael S. Tsirkin" Cc: Gerd Hoffmann Cc: Paolo Bonzini Signed-off-by: Laszlo Ersek --- Notes: v3: - feature negotiation is new in v3 [Paolo, Michael] include/hw/isa/apm.h | 9 +++++---- hw/acpi/piix4.c | 2 +- hw/isa/apm.c | 15 ++++++++++----- hw/isa/lpc_ich9.c | 2 +- hw/isa/vt82c686.c | 2 +- 5 files changed, 18 insertions(+), 12 deletions(-) -- 2.9.2 diff --git a/include/hw/isa/apm.h b/include/hw/isa/apm.h index 4839ff1df252..8fc83addde4e 100644 --- a/include/hw/isa/apm.h +++ b/include/hw/isa/apm.h @@ -5,19 +5,20 @@ #include "hw/hw.h" #include "exec/memory.h" -typedef void (*apm_ctrl_changed_t)(uint32_t val, void *arg); +typedef void (*apm_reg_changed_t)(uint32_t val, void *arg); typedef struct APMState { uint8_t apmc; uint8_t apms; - apm_ctrl_changed_t callback; + apm_reg_changed_t cnt_callback; + apm_reg_changed_t sts_callback; void *arg; MemoryRegion io; } APMState; -void apm_init(PCIDevice *dev, APMState *s, apm_ctrl_changed_t callback, - void *arg); +void apm_init(PCIDevice *dev, APMState *s, apm_reg_changed_t cnt_callback, + apm_reg_changed_t sts_callback, void *arg); extern const VMStateDescription vmstate_apm; diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index 2adc246b0044..bc4087f5f6ef 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -493,7 +493,7 @@ static void piix4_pm_realize(PCIDevice *dev, Error **errp) pci_conf[0x3d] = 0x01; // interrupt pin 1 /* APM */ - apm_init(dev, &s->apm, apm_ctrl_changed, s); + apm_init(dev, &s->apm, apm_ctrl_changed, NULL, s); if (!s->smm_enabled) { /* Mark SMM as already inited to prevent SMM from running. KVM does not diff --git a/hw/isa/apm.c b/hw/isa/apm.c index e232b0da033a..67e05b9932d6 100644 --- a/hw/isa/apm.c +++ b/hw/isa/apm.c @@ -47,11 +47,15 @@ static void apm_ioport_writeb(void *opaque, hwaddr addr, uint64_t val, if (addr == 0) { apm->apmc = val; - if (apm->callback) { - (apm->callback)(val, apm->arg); + if (apm->cnt_callback) { + apm->cnt_callback(val, apm->arg); } } else { apm->apms = val; + + if (apm->sts_callback) { + apm->sts_callback(val, apm->arg); + } } } @@ -90,10 +94,11 @@ static const MemoryRegionOps apm_ops = { }, }; -void apm_init(PCIDevice *dev, APMState *apm, apm_ctrl_changed_t callback, - void *arg) +void apm_init(PCIDevice *dev, APMState *apm, apm_reg_changed_t cnt_callback, + apm_reg_changed_t sts_callback, void *arg) { - apm->callback = callback; + apm->cnt_callback = cnt_callback; + apm->sts_callback = sts_callback; apm->arg = arg; /* ioport 0xb2, 0xb3 */ diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c index 10d1ee8b9310..e3556c9f9eae 100644 --- a/hw/isa/lpc_ich9.c +++ b/hw/isa/lpc_ich9.c @@ -634,7 +634,7 @@ static void ich9_lpc_realize(PCIDevice *d, Error **errp) lpc->isa_bus = isa_bus; ich9_cc_init(lpc); - apm_init(d, &lpc->apm, ich9_apm_ctrl_changed, lpc); + apm_init(d, &lpc->apm, ich9_apm_ctrl_changed, NULL, lpc); lpc->machine_ready.notify = ich9_lpc_machine_ready; qemu_add_machine_init_done_notifier(&lpc->machine_ready); diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index 41d5254f8e55..eb5258597b1d 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -365,7 +365,7 @@ static void vt82c686b_pm_realize(PCIDevice *dev, Error **errp) pm_smbus_init(&s->dev.qdev, &s->smb); memory_region_add_subregion(get_system_io(), s->smb_io_base, &s->smb.io); - apm_init(dev, &s->apm, NULL, s); + apm_init(dev, &s->apm, NULL, NULL, s); memory_region_init(&s->io, OBJECT(dev), "vt82c686-pm", 64); memory_region_set_enabled(&s->io, false);