From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 04/18] apci: switch timer to memory api
Date: Tue, 4 Dec 2012 14:05:01 +0100 [thread overview]
Message-ID: <1354626315-31186-5-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1354626315-31186-1-git-send-email-kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/acpi.c | 19 +++++++++++++++++--
hw/acpi.h | 5 +++--
hw/acpi_ich9.c | 5 +----
hw/acpi_piix4.c | 5 +----
hw/vt82c686.c | 6 +-----
5 files changed, 23 insertions(+), 17 deletions(-)
diff --git a/hw/acpi.c b/hw/acpi.c
index f4aca49..ba25c23 100644
--- a/hw/acpi.c
+++ b/hw/acpi.c
@@ -331,7 +331,7 @@ void acpi_pm_tmr_calc_overflow_time(ACPIREGS *ar)
ar->tmr.overflow_time = (d + 0x800000LL) & ~0x7fffffLL;
}
-uint32_t acpi_pm_tmr_get(ACPIREGS *ar)
+static uint32_t acpi_pm_tmr_get(ACPIREGS *ar)
{
uint32_t d = acpi_pm_tmr_get_clock();
return d & 0xffffff;
@@ -344,10 +344,25 @@ static void acpi_pm_tmr_timer(void *opaque)
ar->tmr.update_sci(ar);
}
-void acpi_pm_tmr_init(ACPIREGS *ar, acpi_update_sci_fn update_sci)
+static uint64_t acpi_pm_tmr_read(void *opaque, hwaddr addr, unsigned width)
+{
+ return acpi_pm_tmr_get(opaque);
+}
+
+static const MemoryRegionOps acpi_pm_tmr_ops = {
+ .read = acpi_pm_tmr_read,
+ .valid.min_access_size = 4,
+ .valid.max_access_size = 4,
+ .endianness = DEVICE_LITTLE_ENDIAN,
+};
+
+void acpi_pm_tmr_init(ACPIREGS *ar, acpi_update_sci_fn update_sci,
+ MemoryRegion *parent)
{
ar->tmr.update_sci = update_sci;
ar->tmr.timer = qemu_new_timer_ns(vm_clock, acpi_pm_tmr_timer, ar);
+ memory_region_init_io(&ar->tmr.io, &acpi_pm_tmr_ops, ar, "acpi-tmr", 4);
+ memory_region_add_subregion(parent, 8, &ar->tmr.io);
}
void acpi_pm_tmr_reset(ACPIREGS *ar)
diff --git a/hw/acpi.h b/hw/acpi.h
index 7337f41..91f42c3 100644
--- a/hw/acpi.h
+++ b/hw/acpi.h
@@ -84,6 +84,7 @@ typedef void (*acpi_update_sci_fn)(ACPIREGS *ar);
struct ACPIPMTimer {
QEMUTimer *timer;
+ MemoryRegion io;
int64_t overflow_time;
acpi_update_sci_fn update_sci;
@@ -119,8 +120,8 @@ struct ACPIREGS {
/* PM_TMR */
void acpi_pm_tmr_update(ACPIREGS *ar, bool enable);
void acpi_pm_tmr_calc_overflow_time(ACPIREGS *ar);
-uint32_t acpi_pm_tmr_get(ACPIREGS *ar);
-void acpi_pm_tmr_init(ACPIREGS *ar, acpi_update_sci_fn update_sci);
+void acpi_pm_tmr_init(ACPIREGS *ar, acpi_update_sci_fn update_sci,
+ MemoryRegion *parent);
void acpi_pm_tmr_reset(ACPIREGS *ar);
#include "qemu-timer.h"
diff --git a/hw/acpi_ich9.c b/hw/acpi_ich9.c
index bf361ec..ec6d5f2 100644
--- a/hw/acpi_ich9.c
+++ b/hw/acpi_ich9.c
@@ -170,9 +170,6 @@ static uint32_t pm_ioport_readl(void *opaque, uint32_t addr)
uint32_t val;
switch (addr & ICH9_PMIO_MASK) {
- case ICH9_PMIO_PM1_TMR:
- val = acpi_pm_tmr_get(&pm->acpi_regs);
- break;
case ICH9_PMIO_SMI_EN:
val = pm->smi_en;
break;
@@ -320,7 +317,7 @@ void ich9_pm_init(ICH9LPCPMRegs *pm, qemu_irq sci_irq, qemu_irq cmos_s3)
memory_region_set_enabled(&pm->io, false);
memory_region_add_subregion(get_system_io(), 0, &pm->io);
- acpi_pm_tmr_init(&pm->acpi_regs, ich9_pm_update_sci_fn);
+ acpi_pm_tmr_init(&pm->acpi_regs, ich9_pm_update_sci_fn, &pm->io);
acpi_pm1_cnt_init(&pm->acpi_regs);
acpi_gpe_init(&pm->acpi_regs, ICH9_PMIO_GPE0_LEN);
acpi_gpe_blk(&pm->acpi_regs, ICH9_PMIO_GPE0_STS);
diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c
index 320e045..75761a0 100644
--- a/hw/acpi_piix4.c
+++ b/hw/acpi_piix4.c
@@ -154,9 +154,6 @@ static uint64_t pm_ioport_read(void *opaque, hwaddr addr, unsigned width)
case 0x04:
val = s->ar.pm1.cnt.cnt;
break;
- case 0x08:
- val = acpi_pm_tmr_get(&s->ar);
- break;
default:
val = 0;
break;
@@ -463,7 +460,7 @@ static int piix4_pm_initfn(PCIDevice *dev)
memory_region_set_enabled(&s->io, false);
memory_region_add_subregion(get_system_io(), 0, &s->io);
- acpi_pm_tmr_init(&s->ar, pm_tmr_timer);
+ acpi_pm_tmr_init(&s->ar, pm_tmr_timer, &s->io);
acpi_gpe_init(&s->ar, GPE_LEN);
s->powerdown_notifier.notify = piix4_pm_powerdown_req;
diff --git a/hw/vt82c686.c b/hw/vt82c686.c
index 3fc6063..219cfae 100644
--- a/hw/vt82c686.c
+++ b/hw/vt82c686.c
@@ -252,14 +252,10 @@ static void pm_ioport_writel(void *opaque, uint32_t addr, uint32_t val)
static uint32_t pm_ioport_readl(void *opaque, uint32_t addr)
{
- VT686PMState *s = opaque;
uint32_t val;
addr &= 0x0f;
switch (addr) {
- case 0x08:
- val = acpi_pm_tmr_get(&s->ar);
- break;
default:
val = 0;
break;
@@ -446,7 +442,7 @@ static int vt82c686b_pm_initfn(PCIDevice *dev)
memory_region_set_enabled(&s->io, false);
memory_region_add_subregion(get_system_io(), 0, &s->io);
- acpi_pm_tmr_init(&s->ar, pm_tmr_timer);
+ acpi_pm_tmr_init(&s->ar, pm_tmr_timer, &s->io);
acpi_pm1_cnt_init(&s->ar);
pm_smbus_init(&s->dev.qdev, &s->smb);
--
1.7.1
next prev parent reply other threads:[~2012-12-04 13:06 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-04 13:04 [Qemu-devel] [PULL 00/18] acpi: switch to memory api Gerd Hoffmann
2012-12-04 13:04 ` [Qemu-devel] [PATCH 01/18] apci: switch piix4 " Gerd Hoffmann
2012-12-04 13:04 ` [Qemu-devel] [PATCH 02/18] apci: switch ich9 " Gerd Hoffmann
2012-12-04 13:05 ` [Qemu-devel] [PATCH 03/18] apci: switch vt82c686 " Gerd Hoffmann
2012-12-04 13:05 ` Gerd Hoffmann [this message]
2012-12-04 13:05 ` [Qemu-devel] [PATCH 05/18] apci: switch cnt " Gerd Hoffmann
2012-12-04 13:05 ` [Qemu-devel] [PATCH 06/18] apci: switch evt " Gerd Hoffmann
2012-12-04 13:05 ` [Qemu-devel] [PATCH 07/18] acpi: cleanup piix4 memory region Gerd Hoffmann
2012-12-04 13:05 ` [Qemu-devel] [PATCH 08/18] acpi: cleanup vt82c686 " Gerd Hoffmann
2012-12-04 13:05 ` [Qemu-devel] [PATCH 09/18] apci: switch ich9 gpe to memory api Gerd Hoffmann
2012-12-04 13:05 ` [Qemu-devel] [PATCH 10/18] apci: switch ich9 smi " Gerd Hoffmann
2012-12-04 13:05 ` [Qemu-devel] [PATCH 11/18] acpi: cleanup ich9 memory region Gerd Hoffmann
2012-12-04 13:05 ` [Qemu-devel] [PATCH 12/18] acpi: switch smbus to memory api Gerd Hoffmann
2012-12-04 13:05 ` [Qemu-devel] [PATCH 13/18] acpi: fix piix4 smbus mapping Gerd Hoffmann
2012-12-04 13:05 ` [Qemu-devel] [PATCH 14/18] apci: switch piix4 gpe to memory api Gerd Hoffmann
2012-12-04 13:05 ` [Qemu-devel] [PATCH 15/18] acpi: remove acpi_gpe_blk Gerd Hoffmann
2012-12-04 13:05 ` [Qemu-devel] [PATCH 16/18] apci: switch piix4 pci hotplug to memory api Gerd Hoffmann
2012-12-04 13:05 ` [Qemu-devel] [PATCH 17/18] q35: update lpc pci config space according to configured devices Gerd Hoffmann
2012-12-04 13:05 ` [Qemu-devel] [PATCH 18/18] acpi: drop debug port Gerd Hoffmann
2012-12-04 15:57 ` [Qemu-devel] [PULL 00/18] acpi: switch to memory api Andreas Färber
2012-12-04 16:05 ` Gerd Hoffmann
2012-12-05 16:49 ` Andreas Färber
2012-12-10 16:58 ` Anthony Liguori
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=1354626315-31186-5-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).