qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 06/20] apci: switch cnt to memory api
Date: Fri, 23 Nov 2012 16:48:17 +0100	[thread overview]
Message-ID: <1353685711-24573-7-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1353685711-24573-1-git-send-email-kraxel@redhat.com>

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/acpi.c       |   38 ++++++++++++++++++++++++++++++--------
 hw/acpi.h       |    5 +++--
 hw/acpi_piix4.c |    8 +-------
 hw/vt82c686.c   |    8 +-------
 4 files changed, 35 insertions(+), 24 deletions(-)

diff --git a/hw/acpi.c b/hw/acpi.c
index ba25c23..956db95 100644
--- a/hw/acpi.c
+++ b/hw/acpi.c
@@ -372,13 +372,7 @@ void acpi_pm_tmr_reset(ACPIREGS *ar)
 }
 
 /* ACPI PM1aCNT */
-void acpi_pm1_cnt_init(ACPIREGS *ar)
-{
-    ar->wakeup.notify = acpi_notify_wakeup;
-    qemu_register_wakeup_notifier(&ar->wakeup);
-}
-
-void acpi_pm1_cnt_write(ACPIREGS *ar, uint16_t val, char s4)
+static void acpi_pm1_cnt_write(ACPIREGS *ar, uint16_t val)
 {
     ar->pm1.cnt.cnt = val & ~(ACPI_BITMASK_SLEEP_ENABLE);
 
@@ -393,7 +387,7 @@ void acpi_pm1_cnt_write(ACPIREGS *ar, uint16_t val, char s4)
             qemu_system_suspend_request();
             break;
         default:
-            if (sus_typ == s4) { /* S4 request */
+            if (sus_typ == ar->pm1.cnt.s4_val) { /* S4 request */
                 monitor_protocol_event(QEVENT_SUSPEND_DISK, NULL);
                 qemu_system_shutdown_request();
             }
@@ -413,6 +407,34 @@ void acpi_pm1_cnt_update(ACPIREGS *ar,
     }
 }
 
+static uint64_t acpi_pm_cnt_read(void *opaque, hwaddr addr, unsigned width)
+{
+    ACPIREGS *ar = opaque;
+    return ar->pm1.cnt.cnt;
+}
+
+static void acpi_pm_cnt_write(void *opaque, hwaddr addr, uint64_t val,
+                              unsigned width)
+{
+    acpi_pm1_cnt_write(opaque, val);
+}
+
+static const MemoryRegionOps acpi_pm_cnt_ops = {
+    .read = acpi_pm_cnt_read,
+    .write = acpi_pm_cnt_write,
+    .valid.min_access_size = 2,
+    .valid.max_access_size = 2,
+    .endianness = DEVICE_LITTLE_ENDIAN,
+};
+
+void acpi_pm1_cnt_init(ACPIREGS *ar, MemoryRegion *parent)
+{
+    ar->wakeup.notify = acpi_notify_wakeup;
+    qemu_register_wakeup_notifier(&ar->wakeup);
+    memory_region_init_io(&ar->pm1.cnt.io, &acpi_pm_cnt_ops, ar, "acpi-cnt", 2);
+    memory_region_add_subregion(parent, 4, &ar->pm1.cnt.io);
+}
+
 void acpi_pm1_cnt_reset(ACPIREGS *ar)
 {
     ar->pm1.cnt.cnt = 0;
diff --git a/hw/acpi.h b/hw/acpi.h
index 91f42c3..97aaab8 100644
--- a/hw/acpi.h
+++ b/hw/acpi.h
@@ -96,7 +96,9 @@ struct ACPIPM1EVT {
 };
 
 struct ACPIPM1CNT {
+    MemoryRegion io;
     uint16_t cnt;
+    uint8_t s4_val;
 };
 
 struct ACPIGPE {
@@ -139,8 +141,7 @@ void acpi_pm1_evt_power_down(ACPIREGS *ar);
 void acpi_pm1_evt_reset(ACPIREGS *ar);
 
 /* PM1a_CNT: piix and ich9 don't implement PM1b CNT. */
-void acpi_pm1_cnt_init(ACPIREGS *ar);
-void acpi_pm1_cnt_write(ACPIREGS *ar, uint16_t val, char s4);
+void acpi_pm1_cnt_init(ACPIREGS *ar, MemoryRegion *parent);
 void acpi_pm1_cnt_update(ACPIREGS *ar,
                          bool sci_enable, bool sci_disable);
 void acpi_pm1_cnt_reset(ACPIREGS *ar);
diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c
index 9301dbf..c68a0e7 100644
--- a/hw/acpi_piix4.c
+++ b/hw/acpi_piix4.c
@@ -129,9 +129,6 @@ static void pm_ioport_write(void *opaque, hwaddr addr, uint64_t val,
         acpi_pm1_evt_write_en(&s->ar, val);
         pm_update_sci(s);
         break;
-    case 0x04:
-        acpi_pm1_cnt_write(&s->ar, val, s->s4_val);
-        break;
     default:
         break;
     }
@@ -151,9 +148,6 @@ static uint64_t pm_ioport_read(void *opaque, hwaddr addr, unsigned width)
     case 0x02:
         val = s->ar.pm1.evt.en;
         break;
-    case 0x04:
-        val = s->ar.pm1.cnt.cnt;
-        break;
     default:
         val = 0;
         break;
@@ -462,6 +456,7 @@ static int piix4_pm_initfn(PCIDevice *dev)
 
     memory_region_init_io(&s->io, &pm_io_ops, s, "piix4-pm", 64);
     acpi_pm_tmr_init(&s->ar, pm_tmr_timer, &s->io);
+    acpi_pm1_cnt_init(&s->ar, &s->io);
     acpi_gpe_init(&s->ar, GPE_LEN);
 
     s->powerdown_notifier.notify = piix4_pm_powerdown_req;
@@ -488,7 +483,6 @@ i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
 
     s = DO_UPCAST(PIIX4PMState, dev, dev);
     s->irq = sci_irq;
-    acpi_pm1_cnt_init(&s->ar);
     s->smi_irq = smi_irq;
     s->kvm_enabled = kvm_enabled;
 
diff --git a/hw/vt82c686.c b/hw/vt82c686.c
index 33155eb..b8f9c19 100644
--- a/hw/vt82c686.c
+++ b/hw/vt82c686.c
@@ -211,9 +211,6 @@ static void pm_ioport_writew(void *opaque, uint32_t addr, uint32_t val)
         acpi_pm1_evt_write_en(&s->ar, val);
         pm_update_sci(s);
         break;
-    case 0x04:
-        acpi_pm1_cnt_write(&s->ar, val, 0);
-        break;
     default:
         break;
     }
@@ -233,9 +230,6 @@ static uint32_t pm_ioport_readw(void *opaque, uint32_t addr)
     case 0x02:
         val = s->ar.pm1.evt.en;
         break;
-    case 0x04:
-        val = s->ar.pm1.cnt.cnt;
-        break;
     default:
         val = 0;
         break;
@@ -444,7 +438,7 @@ static int vt82c686b_pm_initfn(PCIDevice *dev)
 
     memory_region_init_io(&s->io, &pm_io_ops, s, "vt82c686-pm", 64);
     acpi_pm_tmr_init(&s->ar, pm_tmr_timer, &s->io);
-    acpi_pm1_cnt_init(&s->ar);
+    acpi_pm1_cnt_init(&s->ar, &s->io);
 
     pm_smbus_init(&s->dev.qdev, &s->smb);
 
-- 
1.7.1

  parent reply	other threads:[~2012-11-23 15:48 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-23 15:48 [Qemu-devel] [PATCH 00/20] acpi: switch to memory api Gerd Hoffmann
2012-11-23 15:48 ` [Qemu-devel] [PATCH 01/20] apci: switch piix4 " Gerd Hoffmann
2012-11-23 15:48 ` [Qemu-devel] [PATCH 02/20] apci: switch ich9 " Gerd Hoffmann
2012-11-23 15:48 ` [Qemu-devel] [PATCH 03/20] apci: switch vt82c686 " Gerd Hoffmann
2012-11-23 15:48 ` [Qemu-devel] [PATCH 04/20] apci: switch timer " Gerd Hoffmann
2012-11-23 15:48 ` [Qemu-devel] [PATCH 05/20] apci: switch timer to memory api [ich9] Gerd Hoffmann
2012-11-23 15:48 ` Gerd Hoffmann [this message]
2012-11-23 15:48 ` [Qemu-devel] [PATCH 07/20] apci: switch cnt " Gerd Hoffmann
2012-11-23 15:48 ` [Qemu-devel] [PATCH 08/20] apci: switch evt to memory api Gerd Hoffmann
2012-11-23 15:48 ` [Qemu-devel] [PATCH 09/20] apci: switch evt to memory api [ich9] Gerd Hoffmann
2012-11-23 15:48 ` [Qemu-devel] [PATCH 10/20] acpi: cleanup piix4 memory region Gerd Hoffmann
2012-11-23 15:48 ` [Qemu-devel] [PATCH 11/20] acpi: cleanup vt82c686 " Gerd Hoffmann
2012-11-23 15:48 ` [Qemu-devel] [PATCH 12/20] apci: switch ich9 gpe to memory api Gerd Hoffmann
2012-11-23 15:48 ` [Qemu-devel] [PATCH 13/20] apci: switch ich9 smi " Gerd Hoffmann
2012-11-23 15:48 ` [Qemu-devel] [PATCH 14/20] acpi: cleanup ich9 memory region Gerd Hoffmann
2012-11-23 15:48 ` [Qemu-devel] [PATCH 15/20] acpi: switch smbus to memory api Gerd Hoffmann
2012-11-26 15:18   ` Andreas Färber
2012-11-27  8:47     ` Gerd Hoffmann
2012-11-23 15:48 ` [Qemu-devel] [PATCH 16/20] acpi: fix piix4 smbus mapping Gerd Hoffmann
2012-11-23 15:48 ` [Qemu-devel] [PATCH 17/20] apci: switch piix4 gpe to memory api Gerd Hoffmann
2012-11-23 15:48 ` [Qemu-devel] [PATCH 18/20] acpi: remove acpi_gpe_blk Gerd Hoffmann
2012-11-23 15:48 ` [Qemu-devel] [PATCH 19/20] apci: switch piix4 pci hotplug to memory api Gerd Hoffmann
2012-11-23 15:48 ` [Qemu-devel] [PATCH 20/20] q35: update lpc pci config space according to configured devices Gerd Hoffmann

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=1353685711-24573-7-git-send-email-kraxel@redhat.com \
    --to=kraxel@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).