* [Qemu-devel] [PATCH 00/20] acpi: switch to memory api
@ 2012-11-23 15:48 Gerd Hoffmann
2012-11-23 15:48 ` [Qemu-devel] [PATCH 01/20] apci: switch piix4 " Gerd Hoffmann
` (19 more replies)
0 siblings, 20 replies; 23+ messages in thread
From: Gerd Hoffmann @ 2012-11-23 15:48 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Hi,
While wading through the qemu acpi and seabios aml code I've figured the
qemu acpi codebase is *way* too messy. So this patch series switches
the apci code to the memory api. That alone cleans up quite a bit and
makes the code in hw/acpi.c more self-contained. As bonus everything
shows up nicely in "info mtree" now, so you can compare that with
/proc/ioports content of the guest for trouble-shooting.
I've fixed one or another bug along the way.
The patch series applies on top of Jason's q35 patch series. I've kept
all ich9 bits as separate patches though, so when simply dropping all
ich9 patches the resulting series should apply to master just fine.
Comments? Reviews?
cheers,
Gerd
Gerd Hoffmann (20):
apci: switch piix4 to memory api
apci: switch ich9 to memory api
apci: switch vt82c686 to memory api
apci: switch timer to memory api
apci: switch timer to memory api [ich9]
apci: switch cnt to memory api
apci: switch cnt to memory api [ich9]
apci: switch evt to memory api
apci: switch evt to memory api [ich9]
acpi: cleanup piix4 memory region
acpi: cleanup vt82c686 memory region
apci: switch ich9 gpe to memory api
apci: switch ich9 smi to memory api
acpi: cleanup ich9 memory region
acpi: switch smbus to memory api
acpi: fix piix4 smbus mapping
apci: switch piix4 gpe to memory api
acpi: remove acpi_gpe_blk
apci: switch piix4 pci hotplug to memory api
q35: update lpc pci config space according to configured devices
hw/acpi.c | 113 +++++++++++++++++++++++++++------
hw/acpi.h | 18 +++---
hw/acpi_ich9.c | 188 ++++++++++++++-----------------------------------------
hw/acpi_ich9.h | 3 +
hw/acpi_piix4.c | 166 ++++++++++++++++++++++++-------------------------
hw/ich9.h | 1 +
hw/lpc_ich9.c | 29 +++++++++
hw/pm_smbus.c | 17 ++++-
hw/pm_smbus.h | 3 +-
hw/smbus_ich9.c | 64 +++++--------------
hw/vt82c686.c | 95 ++++------------------------
11 files changed, 308 insertions(+), 389 deletions(-)
^ permalink raw reply [flat|nested] 23+ messages in thread
* [Qemu-devel] [PATCH 01/20] apci: switch piix4 to memory api
2012-11-23 15:48 [Qemu-devel] [PATCH 00/20] acpi: switch to memory api Gerd Hoffmann
@ 2012-11-23 15:48 ` Gerd Hoffmann
2012-11-23 15:48 ` [Qemu-devel] [PATCH 02/20] apci: switch ich9 " Gerd Hoffmann
` (18 subsequent siblings)
19 siblings, 0 replies; 23+ messages in thread
From: Gerd Hoffmann @ 2012-11-23 15:48 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/acpi_piix4.c | 30 +++++++++++++++++++-----------
1 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c
index 519269a..086f230 100644
--- a/hw/acpi_piix4.c
+++ b/hw/acpi_piix4.c
@@ -28,6 +28,7 @@
#include "range.h"
#include "ioport.h"
#include "fw_cfg.h"
+#include "exec-memory.h"
//#define DEBUG
@@ -55,7 +56,7 @@ struct pci_status {
typedef struct PIIX4PMState {
PCIDevice dev;
- IORange ioport;
+ MemoryRegion io;
ACPIREGS ar;
APMState apm;
@@ -109,10 +110,10 @@ static void pm_tmr_timer(ACPIREGS *ar)
pm_update_sci(s);
}
-static void pm_ioport_write(IORange *ioport, uint64_t addr, unsigned width,
- uint64_t val)
+static void pm_ioport_write(void *opaque, hwaddr addr, uint64_t val,
+ unsigned width)
{
- PIIX4PMState *s = container_of(ioport, PIIX4PMState, ioport);
+ PIIX4PMState *s = opaque;
if (width != 2) {
PIIX4_DPRINTF("PM write port=0x%04x width=%d val=0x%08x\n",
@@ -138,10 +139,9 @@ static void pm_ioport_write(IORange *ioport, uint64_t addr, unsigned width,
(unsigned int)val);
}
-static void pm_ioport_read(IORange *ioport, uint64_t addr, unsigned width,
- uint64_t *data)
+static uint64_t pm_ioport_read(void *opaque, hwaddr addr, unsigned width)
{
- PIIX4PMState *s = container_of(ioport, PIIX4PMState, ioport);
+ PIIX4PMState *s = opaque;
uint32_t val;
switch(addr) {
@@ -162,12 +162,17 @@ static void pm_ioport_read(IORange *ioport, uint64_t addr, unsigned width,
break;
}
PIIX4_DPRINTF("PM readw port=0x%04x val=0x%04x\n", (unsigned int)addr, val);
- *data = val;
+ return val;
}
-static const IORangeOps pm_iorange_ops = {
+static const MemoryRegionOps pm_io_ops = {
.read = pm_ioport_read,
.write = pm_ioport_write,
+ .valid.min_access_size = 1,
+ .valid.max_access_size = 4,
+ .impl.min_access_size = 1,
+ .impl.max_access_size = 4,
+ .endianness = DEVICE_LITTLE_ENDIAN,
};
static void apm_ctrl_changed(uint32_t val, void *arg)
@@ -193,14 +198,16 @@ static void pm_io_space_update(PIIX4PMState *s)
{
uint32_t pm_io_base;
+ if (s->io.parent) {
+ memory_region_del_subregion(get_system_io(), &s->io);
+ }
if (s->dev.config[0x80] & 1) {
pm_io_base = le32_to_cpu(*(uint32_t *)(s->dev.config + 0x40));
pm_io_base &= 0xffc0;
/* XXX: need to improve memory and ioport allocation */
PIIX4_DPRINTF("PM: mapping to 0x%x\n", pm_io_base);
- iorange_init(&s->ioport, &pm_iorange_ops, pm_io_base, 64);
- ioport_register(&s->ioport);
+ memory_region_add_subregion(get_system_io(), pm_io_base, &s->io);
}
}
@@ -456,6 +463,7 @@ static int piix4_pm_initfn(PCIDevice *dev)
register_ioport_write(s->smb_io_base, 64, 1, smb_ioport_writeb, &s->smb);
register_ioport_read(s->smb_io_base, 64, 1, smb_ioport_readb, &s->smb);
+ memory_region_init_io(&s->io, &pm_io_ops, s, "piix4-pm", 64);
acpi_pm_tmr_init(&s->ar, pm_tmr_timer);
acpi_gpe_init(&s->ar, GPE_LEN);
--
1.7.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [Qemu-devel] [PATCH 02/20] apci: switch ich9 to memory api
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 ` Gerd Hoffmann
2012-11-23 15:48 ` [Qemu-devel] [PATCH 03/20] apci: switch vt82c686 " Gerd Hoffmann
` (17 subsequent siblings)
19 siblings, 0 replies; 23+ messages in thread
From: Gerd Hoffmann @ 2012-11-23 15:48 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/acpi_ich9.c | 33 +++++++++++++++++++++++----------
hw/acpi_ich9.h | 1 +
2 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/hw/acpi_ich9.c b/hw/acpi_ich9.c
index 61034d3..e03b1a6 100644
--- a/hw/acpi_ich9.c
+++ b/hw/acpi_ich9.c
@@ -29,6 +29,7 @@
#include "sysemu.h"
#include "acpi.h"
#include "kvm.h"
+#include "exec-memory.h"
#include "ich9.h"
@@ -217,14 +218,31 @@ static uint32_t pm_ioport_read_fallback(void *opaque, uint32_t addr, int len)
return val;
}
+static const MemoryRegionOps pm_io_ops = {
+ .old_portio = (MemoryRegionPortio[]) {
+ { .offset = 0, .len = ICH9_PMIO_SIZE, .size = 1,
+ .read = pm_ioport_readb, .write = pm_ioport_writeb },
+ { .offset = 0, .len = ICH9_PMIO_SIZE, .size = 2,
+ .read = pm_ioport_readw, .write = pm_ioport_writew },
+ { .offset = 0, .len = ICH9_PMIO_SIZE, .size = 4,
+ .read = pm_ioport_readl, .write = pm_ioport_writel },
+ PORTIO_END_OF_LIST(),
+ },
+ .valid.min_access_size = 1,
+ .valid.max_access_size = 4,
+ .impl.min_access_size = 1,
+ .impl.max_access_size = 4,
+ .endianness = DEVICE_LITTLE_ENDIAN,
+};
+
void ich9_pm_iospace_update(ICH9LPCPMRegs *pm, uint32_t pm_io_base)
{
ICH9_DEBUG("to 0x%x\n", pm_io_base);
assert((pm_io_base & ICH9_PMIO_MASK) == 0);
- if (pm->pm_io_base != 0) {
- isa_unassign_ioport(pm->pm_io_base, ICH9_PMIO_SIZE);
+ if (pm->io.parent) {
+ memory_region_del_subregion(get_system_io(), &pm->io);
}
/* don't map at 0 */
@@ -232,15 +250,8 @@ void ich9_pm_iospace_update(ICH9LPCPMRegs *pm, uint32_t pm_io_base)
return;
}
- register_ioport_write(pm_io_base, ICH9_PMIO_SIZE, 1, pm_ioport_writeb, pm);
- register_ioport_read(pm_io_base, ICH9_PMIO_SIZE, 1, pm_ioport_readb, pm);
- register_ioport_write(pm_io_base, ICH9_PMIO_SIZE, 2, pm_ioport_writew, pm);
- register_ioport_read(pm_io_base, ICH9_PMIO_SIZE, 2, pm_ioport_readw, pm);
- register_ioport_write(pm_io_base, ICH9_PMIO_SIZE, 4, pm_ioport_writel, pm);
- register_ioport_read(pm_io_base, ICH9_PMIO_SIZE, 4, pm_ioport_readl, pm);
-
+ memory_region_add_subregion(get_system_io(), pm_io_base, &pm->io);
pm->pm_io_base = pm_io_base;
- acpi_gpe_blk(&pm->acpi_regs, pm_io_base + ICH9_PMIO_GPE0_STS);
}
static int ich9_pm_post_load(void *opaque, int version_id)
@@ -311,9 +322,11 @@ static void pm_powerdown_req(Notifier *n, void *opaque)
void ich9_pm_init(ICH9LPCPMRegs *pm, qemu_irq sci_irq, qemu_irq cmos_s3)
{
+ memory_region_init_io(&pm->io, &pm_io_ops, pm, "ich9-pm", ICH9_PMIO_SIZE);
acpi_pm_tmr_init(&pm->acpi_regs, ich9_pm_update_sci_fn);
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);
pm->irq = sci_irq;
qemu_register_reset(pm_reset, pm);
diff --git a/hw/acpi_ich9.h b/hw/acpi_ich9.h
index 180c406..0a2ee6c 100644
--- a/hw/acpi_ich9.h
+++ b/hw/acpi_ich9.h
@@ -30,6 +30,7 @@ typedef struct ICH9LPCPMRegs {
* PM1a_CNT_BLK = 2 in FADT so it is defined as uint16_t.
*/
ACPIREGS acpi_regs;
+ MemoryRegion io;
uint32_t smi_en;
uint32_t smi_sts;
--
1.7.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [Qemu-devel] [PATCH 03/20] apci: switch vt82c686 to memory api
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 ` Gerd Hoffmann
2012-11-23 15:48 ` [Qemu-devel] [PATCH 04/20] apci: switch timer " Gerd Hoffmann
` (16 subsequent siblings)
19 siblings, 0 replies; 23+ messages in thread
From: Gerd Hoffmann @ 2012-11-23 15:48 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/vt82c686.c | 28 +++++++++++++++++++++++-----
1 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/hw/vt82c686.c b/hw/vt82c686.c
index 5d7c00c..7f9c7a2 100644
--- a/hw/vt82c686.c
+++ b/hw/vt82c686.c
@@ -24,6 +24,7 @@
#include "pm_smbus.h"
#include "sysemu.h"
#include "qemu-timer.h"
+#include "exec-memory.h"
typedef uint32_t pci_addr_t;
#include "pci_host.h"
@@ -159,6 +160,7 @@ static void vt82c686b_write_config(PCIDevice * d, uint32_t address,
typedef struct VT686PMState {
PCIDevice dev;
+ MemoryRegion io;
ACPIREGS ar;
APMState apm;
PMSMBus smb;
@@ -266,20 +268,35 @@ static uint32_t pm_ioport_readl(void *opaque, uint32_t addr)
return val;
}
+static const MemoryRegionOps pm_io_ops = {
+ .old_portio = (MemoryRegionPortio[]) {
+ { .offset = 0, .len = 64, .size = 2,
+ .read = pm_ioport_readw, .write = pm_ioport_writew },
+ { .offset = 0, .len = 64, .size = 4,
+ .read = pm_ioport_readl, .write = pm_ioport_writel },
+ PORTIO_END_OF_LIST(),
+ },
+ .valid.min_access_size = 1,
+ .valid.max_access_size = 4,
+ .impl.min_access_size = 1,
+ .impl.max_access_size = 4,
+ .endianness = DEVICE_LITTLE_ENDIAN,
+};
+
static void pm_io_space_update(VT686PMState *s)
{
uint32_t pm_io_base;
+ if (s->io.parent) {
+ memory_region_del_subregion(get_system_io(), &s->io);
+ }
+
if (s->dev.config[0x80] & 1) {
pm_io_base = pci_get_long(s->dev.config + 0x40);
pm_io_base &= 0xffc0;
- /* XXX: need to improve memory and ioport allocation */
DPRINTF("PM: mapping to 0x%x\n", pm_io_base);
- register_ioport_write(pm_io_base, 64, 2, pm_ioport_writew, s);
- register_ioport_read(pm_io_base, 64, 2, pm_ioport_readw, s);
- register_ioport_write(pm_io_base, 64, 4, pm_ioport_writel, s);
- register_ioport_read(pm_io_base, 64, 4, pm_ioport_readl, s);
+ memory_region_add_subregion(get_system_io(), pm_io_base, &s->io);
}
}
@@ -429,6 +446,7 @@ static int vt82c686b_pm_initfn(PCIDevice *dev)
apm_init(&s->apm, NULL, s);
+ memory_region_init_io(&s->io, &pm_io_ops, s, "vt82c686-pm", 64);
acpi_pm_tmr_init(&s->ar, pm_tmr_timer);
acpi_pm1_cnt_init(&s->ar);
--
1.7.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [Qemu-devel] [PATCH 04/20] apci: switch timer to memory api
2012-11-23 15:48 [Qemu-devel] [PATCH 00/20] acpi: switch to memory api Gerd Hoffmann
` (2 preceding siblings ...)
2012-11-23 15:48 ` [Qemu-devel] [PATCH 03/20] apci: switch vt82c686 " Gerd Hoffmann
@ 2012-11-23 15:48 ` Gerd Hoffmann
2012-11-23 15:48 ` [Qemu-devel] [PATCH 05/20] apci: switch timer to memory api [ich9] Gerd Hoffmann
` (15 subsequent siblings)
19 siblings, 0 replies; 23+ messages in thread
From: Gerd Hoffmann @ 2012-11-23 15:48 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/acpi.c | 19 +++++++++++++++++--
hw/acpi.h | 5 +++--
hw/acpi_piix4.c | 5 +----
hw/vt82c686.c | 6 +-----
4 files changed, 22 insertions(+), 13 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_piix4.c b/hw/acpi_piix4.c
index 086f230..9301dbf 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;
@@ -464,7 +461,7 @@ static int piix4_pm_initfn(PCIDevice *dev)
register_ioport_read(s->smb_io_base, 64, 1, smb_ioport_readb, &s->smb);
memory_region_init_io(&s->io, &pm_io_ops, s, "piix4-pm", 64);
- 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 7f9c7a2..33155eb 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;
@@ -447,7 +443,7 @@ static int vt82c686b_pm_initfn(PCIDevice *dev)
apm_init(&s->apm, NULL, s);
memory_region_init_io(&s->io, &pm_io_ops, s, "vt82c686-pm", 64);
- 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
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [Qemu-devel] [PATCH 05/20] apci: switch timer to memory api [ich9]
2012-11-23 15:48 [Qemu-devel] [PATCH 00/20] acpi: switch to memory api Gerd Hoffmann
` (3 preceding siblings ...)
2012-11-23 15:48 ` [Qemu-devel] [PATCH 04/20] apci: switch timer " Gerd Hoffmann
@ 2012-11-23 15:48 ` Gerd Hoffmann
2012-11-23 15:48 ` [Qemu-devel] [PATCH 06/20] apci: switch cnt to memory api Gerd Hoffmann
` (14 subsequent siblings)
19 siblings, 0 replies; 23+ messages in thread
From: Gerd Hoffmann @ 2012-11-23 15:48 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/acpi_ich9.c | 5 +----
1 files changed, 1 insertions(+), 4 deletions(-)
diff --git a/hw/acpi_ich9.c b/hw/acpi_ich9.c
index e03b1a6..b3022c0 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;
@@ -323,7 +320,7 @@ static void pm_powerdown_req(Notifier *n, void *opaque)
void ich9_pm_init(ICH9LPCPMRegs *pm, qemu_irq sci_irq, qemu_irq cmos_s3)
{
memory_region_init_io(&pm->io, &pm_io_ops, pm, "ich9-pm", ICH9_PMIO_SIZE);
- 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);
--
1.7.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [Qemu-devel] [PATCH 06/20] apci: switch cnt to memory api
2012-11-23 15:48 [Qemu-devel] [PATCH 00/20] acpi: switch to memory api Gerd Hoffmann
` (4 preceding siblings ...)
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
2012-11-23 15:48 ` [Qemu-devel] [PATCH 07/20] apci: switch cnt to memory api [ich9] Gerd Hoffmann
` (13 subsequent siblings)
19 siblings, 0 replies; 23+ messages in thread
From: Gerd Hoffmann @ 2012-11-23 15:48 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
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
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [Qemu-devel] [PATCH 07/20] apci: switch cnt to memory api [ich9]
2012-11-23 15:48 [Qemu-devel] [PATCH 00/20] acpi: switch to memory api Gerd Hoffmann
` (5 preceding siblings ...)
2012-11-23 15:48 ` [Qemu-devel] [PATCH 06/20] apci: switch cnt to memory api Gerd Hoffmann
@ 2012-11-23 15:48 ` Gerd Hoffmann
2012-11-23 15:48 ` [Qemu-devel] [PATCH 08/20] apci: switch evt to memory api Gerd Hoffmann
` (12 subsequent siblings)
19 siblings, 0 replies; 23+ messages in thread
From: Gerd Hoffmann @ 2012-11-23 15:48 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/acpi_ich9.c | 8 +-------
1 files changed, 1 insertions(+), 7 deletions(-)
diff --git a/hw/acpi_ich9.c b/hw/acpi_ich9.c
index b3022c0..237b577 100644
--- a/hw/acpi_ich9.c
+++ b/hw/acpi_ich9.c
@@ -116,9 +116,6 @@ static void pm_ioport_writew(void *opaque, uint32_t addr, uint32_t val)
pm->acpi_regs.pm1.evt.en = val;
pm_update_sci(pm);
break;
- case ICH9_PMIO_PM1_CNT:
- acpi_pm1_cnt_write(&pm->acpi_regs, val, 0);
- break;
default:
pm_ioport_write_fallback(opaque, addr, 2, val);
break;
@@ -138,9 +135,6 @@ static uint32_t pm_ioport_readw(void *opaque, uint32_t addr)
case ICH9_PMIO_PM1_EN:
val = pm->acpi_regs.pm1.evt.en;
break;
- case ICH9_PMIO_PM1_CNT:
- val = pm->acpi_regs.pm1.cnt.cnt;
- break;
default:
val = pm_ioport_read_fallback(opaque, addr, 2);
break;
@@ -321,7 +315,7 @@ void ich9_pm_init(ICH9LPCPMRegs *pm, qemu_irq sci_irq, qemu_irq cmos_s3)
{
memory_region_init_io(&pm->io, &pm_io_ops, pm, "ich9-pm", ICH9_PMIO_SIZE);
acpi_pm_tmr_init(&pm->acpi_regs, ich9_pm_update_sci_fn, &pm->io);
- acpi_pm1_cnt_init(&pm->acpi_regs);
+ acpi_pm1_cnt_init(&pm->acpi_regs, &pm->io);
acpi_gpe_init(&pm->acpi_regs, ICH9_PMIO_GPE0_LEN);
acpi_gpe_blk(&pm->acpi_regs, ICH9_PMIO_GPE0_STS);
--
1.7.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [Qemu-devel] [PATCH 08/20] apci: switch evt to memory api
2012-11-23 15:48 [Qemu-devel] [PATCH 00/20] acpi: switch to memory api Gerd Hoffmann
` (6 preceding siblings ...)
2012-11-23 15:48 ` [Qemu-devel] [PATCH 07/20] apci: switch cnt to memory api [ich9] Gerd Hoffmann
@ 2012-11-23 15:48 ` Gerd Hoffmann
2012-11-23 15:48 ` [Qemu-devel] [PATCH 09/20] apci: switch evt to memory api [ich9] Gerd Hoffmann
` (11 subsequent siblings)
19 siblings, 0 replies; 23+ messages in thread
From: Gerd Hoffmann @ 2012-11-23 15:48 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/acpi.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++--
hw/acpi.h | 6 ++++--
hw/acpi_piix4.c | 18 +-----------------
hw/vt82c686.c | 18 +-----------------
4 files changed, 53 insertions(+), 38 deletions(-)
diff --git a/hw/acpi.c b/hw/acpi.c
index 956db95..e58e45f 100644
--- a/hw/acpi.c
+++ b/hw/acpi.c
@@ -275,7 +275,7 @@ uint16_t acpi_pm1_evt_get_sts(ACPIREGS *ar)
return ar->pm1.evt.sts;
}
-void acpi_pm1_evt_write_sts(ACPIREGS *ar, uint16_t val)
+static void acpi_pm1_evt_write_sts(ACPIREGS *ar, uint16_t val)
{
uint16_t pm1_sts = acpi_pm1_evt_get_sts(ar);
if (pm1_sts & val & ACPI_BITMASK_TIMER_STATUS) {
@@ -285,7 +285,7 @@ void acpi_pm1_evt_write_sts(ACPIREGS *ar, uint16_t val)
ar->pm1.evt.sts &= ~val;
}
-void acpi_pm1_evt_write_en(ACPIREGS *ar, uint16_t val)
+static void acpi_pm1_evt_write_en(ACPIREGS *ar, uint16_t val)
{
ar->pm1.evt.en = val;
qemu_system_wakeup_enable(QEMU_WAKEUP_REASON_RTC,
@@ -310,6 +310,51 @@ void acpi_pm1_evt_reset(ACPIREGS *ar)
qemu_system_wakeup_enable(QEMU_WAKEUP_REASON_PMTIMER, 0);
}
+static uint64_t acpi_pm_evt_read(void *opaque, hwaddr addr, unsigned width)
+{
+ ACPIREGS *ar = opaque;
+ switch (addr) {
+ case 0:
+ return acpi_pm1_evt_get_sts(ar);
+ case 2:
+ return ar->pm1.evt.en;
+ default:
+ return 0;
+ }
+}
+
+static void acpi_pm_evt_write(void *opaque, hwaddr addr, uint64_t val,
+ unsigned width)
+{
+ ACPIREGS *ar = opaque;
+ switch (addr) {
+ case 0:
+ acpi_pm1_evt_write_sts(ar, val);
+ ar->pm1.evt.update_sci(ar);
+ break;
+ case 2:
+ acpi_pm1_evt_write_en(ar, val);
+ ar->pm1.evt.update_sci(ar);
+ break;
+ }
+}
+
+static const MemoryRegionOps acpi_pm_evt_ops = {
+ .read = acpi_pm_evt_read,
+ .write = acpi_pm_evt_write,
+ .valid.min_access_size = 2,
+ .valid.max_access_size = 2,
+ .endianness = DEVICE_LITTLE_ENDIAN,
+};
+
+void acpi_pm1_evt_init(ACPIREGS *ar, acpi_update_sci_fn update_sci,
+ MemoryRegion *parent)
+{
+ ar->pm1.evt.update_sci = update_sci;
+ memory_region_init_io(&ar->pm1.evt.io, &acpi_pm_evt_ops, ar, "acpi-evt", 4);
+ memory_region_add_subregion(parent, 0, &ar->pm1.evt.io);
+}
+
/* ACPI PM_TMR */
void acpi_pm_tmr_update(ACPIREGS *ar, bool enable)
{
diff --git a/hw/acpi.h b/hw/acpi.h
index 97aaab8..918d7f5 100644
--- a/hw/acpi.h
+++ b/hw/acpi.h
@@ -91,8 +91,10 @@ struct ACPIPMTimer {
};
struct ACPIPM1EVT {
+ MemoryRegion io;
uint16_t sts;
uint16_t en;
+ acpi_update_sci_fn update_sci;
};
struct ACPIPM1CNT {
@@ -135,10 +137,10 @@ static inline int64_t acpi_pm_tmr_get_clock(void)
/* PM1a_EVT: piix and ich9 don't implement PM1b. */
uint16_t acpi_pm1_evt_get_sts(ACPIREGS *ar);
-void acpi_pm1_evt_write_sts(ACPIREGS *ar, uint16_t val);
-void acpi_pm1_evt_write_en(ACPIREGS *ar, uint16_t val);
void acpi_pm1_evt_power_down(ACPIREGS *ar);
void acpi_pm1_evt_reset(ACPIREGS *ar);
+void acpi_pm1_evt_init(ACPIREGS *ar, acpi_update_sci_fn update_sci,
+ MemoryRegion *parent);
/* PM1a_CNT: piix and ich9 don't implement PM1b CNT. */
void acpi_pm1_cnt_init(ACPIREGS *ar, MemoryRegion *parent);
diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c
index c68a0e7..e4fe6f1 100644
--- a/hw/acpi_piix4.c
+++ b/hw/acpi_piix4.c
@@ -113,22 +113,12 @@ static void pm_tmr_timer(ACPIREGS *ar)
static void pm_ioport_write(void *opaque, hwaddr addr, uint64_t val,
unsigned width)
{
- PIIX4PMState *s = opaque;
-
if (width != 2) {
PIIX4_DPRINTF("PM write port=0x%04x width=%d val=0x%08x\n",
(unsigned)addr, width, (unsigned)val);
}
switch(addr) {
- case 0x00:
- acpi_pm1_evt_write_sts(&s->ar, val);
- pm_update_sci(s);
- break;
- case 0x02:
- acpi_pm1_evt_write_en(&s->ar, val);
- pm_update_sci(s);
- break;
default:
break;
}
@@ -138,16 +128,9 @@ static void pm_ioport_write(void *opaque, hwaddr addr, uint64_t val,
static uint64_t pm_ioport_read(void *opaque, hwaddr addr, unsigned width)
{
- PIIX4PMState *s = opaque;
uint32_t val;
switch(addr) {
- case 0x00:
- val = acpi_pm1_evt_get_sts(&s->ar);
- break;
- case 0x02:
- val = s->ar.pm1.evt.en;
- break;
default:
val = 0;
break;
@@ -456,6 +439,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_evt_init(&s->ar, pm_tmr_timer, &s->io);
acpi_pm1_cnt_init(&s->ar, &s->io);
acpi_gpe_init(&s->ar, GPE_LEN);
diff --git a/hw/vt82c686.c b/hw/vt82c686.c
index b8f9c19..86ff7f9 100644
--- a/hw/vt82c686.c
+++ b/hw/vt82c686.c
@@ -199,18 +199,8 @@ static void pm_tmr_timer(ACPIREGS *ar)
static void pm_ioport_writew(void *opaque, uint32_t addr, uint32_t val)
{
- VT686PMState *s = opaque;
-
addr &= 0x0f;
switch (addr) {
- case 0x00:
- acpi_pm1_evt_write_sts(&s->ar, val);
- pm_update_sci(s);
- break;
- case 0x02:
- acpi_pm1_evt_write_en(&s->ar, val);
- pm_update_sci(s);
- break;
default:
break;
}
@@ -219,17 +209,10 @@ static void pm_ioport_writew(void *opaque, uint32_t addr, uint32_t val)
static uint32_t pm_ioport_readw(void *opaque, uint32_t addr)
{
- VT686PMState *s = opaque;
uint32_t val;
addr &= 0x0f;
switch (addr) {
- case 0x00:
- val = acpi_pm1_evt_get_sts(&s->ar);
- break;
- case 0x02:
- val = s->ar.pm1.evt.en;
- break;
default:
val = 0;
break;
@@ -438,6 +421,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_evt_init(&s->ar, pm_tmr_timer, &s->io);
acpi_pm1_cnt_init(&s->ar, &s->io);
pm_smbus_init(&s->dev.qdev, &s->smb);
--
1.7.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [Qemu-devel] [PATCH 09/20] apci: switch evt to memory api [ich9]
2012-11-23 15:48 [Qemu-devel] [PATCH 00/20] acpi: switch to memory api Gerd Hoffmann
` (7 preceding siblings ...)
2012-11-23 15:48 ` [Qemu-devel] [PATCH 08/20] apci: switch evt to memory api Gerd Hoffmann
@ 2012-11-23 15:48 ` Gerd Hoffmann
2012-11-23 15:48 ` [Qemu-devel] [PATCH 10/20] acpi: cleanup piix4 memory region Gerd Hoffmann
` (10 subsequent siblings)
19 siblings, 0 replies; 23+ messages in thread
From: Gerd Hoffmann @ 2012-11-23 15:48 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/acpi_ich9.c | 18 +-----------------
1 files changed, 1 insertions(+), 17 deletions(-)
diff --git a/hw/acpi_ich9.c b/hw/acpi_ich9.c
index 237b577..0f025f8 100644
--- a/hw/acpi_ich9.c
+++ b/hw/acpi_ich9.c
@@ -105,17 +105,7 @@ static uint32_t pm_ioport_readb(void *opaque, uint32_t addr)
static void pm_ioport_writew(void *opaque, uint32_t addr, uint32_t val)
{
- ICH9LPCPMRegs *pm = opaque;
-
switch (addr & ICH9_PMIO_MASK) {
- case ICH9_PMIO_PM1_STS:
- acpi_pm1_evt_write_sts(&pm->acpi_regs, val);
- pm_update_sci(pm);
- break;
- case ICH9_PMIO_PM1_EN:
- pm->acpi_regs.pm1.evt.en = val;
- pm_update_sci(pm);
- break;
default:
pm_ioport_write_fallback(opaque, addr, 2, val);
break;
@@ -125,16 +115,9 @@ static void pm_ioport_writew(void *opaque, uint32_t addr, uint32_t val)
static uint32_t pm_ioport_readw(void *opaque, uint32_t addr)
{
- ICH9LPCPMRegs *pm = opaque;
uint32_t val;
switch (addr & ICH9_PMIO_MASK) {
- case ICH9_PMIO_PM1_STS:
- val = acpi_pm1_evt_get_sts(&pm->acpi_regs);
- break;
- case ICH9_PMIO_PM1_EN:
- val = pm->acpi_regs.pm1.evt.en;
- break;
default:
val = pm_ioport_read_fallback(opaque, addr, 2);
break;
@@ -315,6 +298,7 @@ void ich9_pm_init(ICH9LPCPMRegs *pm, qemu_irq sci_irq, qemu_irq cmos_s3)
{
memory_region_init_io(&pm->io, &pm_io_ops, pm, "ich9-pm", ICH9_PMIO_SIZE);
acpi_pm_tmr_init(&pm->acpi_regs, ich9_pm_update_sci_fn, &pm->io);
+ acpi_pm1_evt_init(&pm->acpi_regs, ich9_pm_update_sci_fn, &pm->io);
acpi_pm1_cnt_init(&pm->acpi_regs, &pm->io);
acpi_gpe_init(&pm->acpi_regs, ICH9_PMIO_GPE0_LEN);
acpi_gpe_blk(&pm->acpi_regs, ICH9_PMIO_GPE0_STS);
--
1.7.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [Qemu-devel] [PATCH 10/20] acpi: cleanup piix4 memory region
2012-11-23 15:48 [Qemu-devel] [PATCH 00/20] acpi: switch to memory api Gerd Hoffmann
` (8 preceding siblings ...)
2012-11-23 15:48 ` [Qemu-devel] [PATCH 09/20] apci: switch evt to memory api [ich9] Gerd Hoffmann
@ 2012-11-23 15:48 ` Gerd Hoffmann
2012-11-23 15:48 ` [Qemu-devel] [PATCH 11/20] acpi: cleanup vt82c686 " Gerd Hoffmann
` (9 subsequent siblings)
19 siblings, 0 replies; 23+ messages in thread
From: Gerd Hoffmann @ 2012-11-23 15:48 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Nothing left to do, everything handled by subregions,
we can zap the reaw/write handlers now.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/acpi_piix4.c | 41 +----------------------------------------
1 files changed, 1 insertions(+), 40 deletions(-)
diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c
index e4fe6f1..2f1d77b 100644
--- a/hw/acpi_piix4.c
+++ b/hw/acpi_piix4.c
@@ -110,45 +110,6 @@ static void pm_tmr_timer(ACPIREGS *ar)
pm_update_sci(s);
}
-static void pm_ioport_write(void *opaque, hwaddr addr, uint64_t val,
- unsigned width)
-{
- if (width != 2) {
- PIIX4_DPRINTF("PM write port=0x%04x width=%d val=0x%08x\n",
- (unsigned)addr, width, (unsigned)val);
- }
-
- switch(addr) {
- default:
- break;
- }
- PIIX4_DPRINTF("PM writew port=0x%04x val=0x%04x\n", (unsigned int)addr,
- (unsigned int)val);
-}
-
-static uint64_t pm_ioport_read(void *opaque, hwaddr addr, unsigned width)
-{
- uint32_t val;
-
- switch(addr) {
- default:
- val = 0;
- break;
- }
- PIIX4_DPRINTF("PM readw port=0x%04x val=0x%04x\n", (unsigned int)addr, val);
- return val;
-}
-
-static const MemoryRegionOps pm_io_ops = {
- .read = pm_ioport_read,
- .write = pm_ioport_write,
- .valid.min_access_size = 1,
- .valid.max_access_size = 4,
- .impl.min_access_size = 1,
- .impl.max_access_size = 4,
- .endianness = DEVICE_LITTLE_ENDIAN,
-};
-
static void apm_ctrl_changed(uint32_t val, void *arg)
{
PIIX4PMState *s = arg;
@@ -437,7 +398,7 @@ static int piix4_pm_initfn(PCIDevice *dev)
register_ioport_write(s->smb_io_base, 64, 1, smb_ioport_writeb, &s->smb);
register_ioport_read(s->smb_io_base, 64, 1, smb_ioport_readb, &s->smb);
- memory_region_init_io(&s->io, &pm_io_ops, s, "piix4-pm", 64);
+ memory_region_init(&s->io, "piix4-pm", 64);
acpi_pm_tmr_init(&s->ar, pm_tmr_timer, &s->io);
acpi_pm1_evt_init(&s->ar, pm_tmr_timer, &s->io);
acpi_pm1_cnt_init(&s->ar, &s->io);
--
1.7.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [Qemu-devel] [PATCH 11/20] acpi: cleanup vt82c686 memory region
2012-11-23 15:48 [Qemu-devel] [PATCH 00/20] acpi: switch to memory api Gerd Hoffmann
` (9 preceding siblings ...)
2012-11-23 15:48 ` [Qemu-devel] [PATCH 10/20] acpi: cleanup piix4 memory region Gerd Hoffmann
@ 2012-11-23 15:48 ` Gerd Hoffmann
2012-11-23 15:48 ` [Qemu-devel] [PATCH 12/20] apci: switch ich9 gpe to memory api Gerd Hoffmann
` (8 subsequent siblings)
19 siblings, 0 replies; 23+ messages in thread
From: Gerd Hoffmann @ 2012-11-23 15:48 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Nothing left to do, everything handled by subregions,
we can zap the reaw/write handlers now.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/vt82c686.c | 61 +--------------------------------------------------------
1 files changed, 1 insertions(+), 60 deletions(-)
diff --git a/hw/vt82c686.c b/hw/vt82c686.c
index 86ff7f9..e1a941c 100644
--- a/hw/vt82c686.c
+++ b/hw/vt82c686.c
@@ -197,65 +197,6 @@ static void pm_tmr_timer(ACPIREGS *ar)
pm_update_sci(s);
}
-static void pm_ioport_writew(void *opaque, uint32_t addr, uint32_t val)
-{
- addr &= 0x0f;
- switch (addr) {
- default:
- break;
- }
- DPRINTF("PM writew port=0x%04x val=0x%02x\n", addr, val);
-}
-
-static uint32_t pm_ioport_readw(void *opaque, uint32_t addr)
-{
- uint32_t val;
-
- addr &= 0x0f;
- switch (addr) {
- default:
- val = 0;
- break;
- }
- DPRINTF("PM readw port=0x%04x val=0x%02x\n", addr, val);
- return val;
-}
-
-static void pm_ioport_writel(void *opaque, uint32_t addr, uint32_t val)
-{
- addr &= 0x0f;
- DPRINTF("PM writel port=0x%04x val=0x%08x\n", addr, val);
-}
-
-static uint32_t pm_ioport_readl(void *opaque, uint32_t addr)
-{
- uint32_t val;
-
- addr &= 0x0f;
- switch (addr) {
- default:
- val = 0;
- break;
- }
- DPRINTF("PM readl port=0x%04x val=0x%08x\n", addr, val);
- return val;
-}
-
-static const MemoryRegionOps pm_io_ops = {
- .old_portio = (MemoryRegionPortio[]) {
- { .offset = 0, .len = 64, .size = 2,
- .read = pm_ioport_readw, .write = pm_ioport_writew },
- { .offset = 0, .len = 64, .size = 4,
- .read = pm_ioport_readl, .write = pm_ioport_writel },
- PORTIO_END_OF_LIST(),
- },
- .valid.min_access_size = 1,
- .valid.max_access_size = 4,
- .impl.min_access_size = 1,
- .impl.max_access_size = 4,
- .endianness = DEVICE_LITTLE_ENDIAN,
-};
-
static void pm_io_space_update(VT686PMState *s)
{
uint32_t pm_io_base;
@@ -419,7 +360,7 @@ static int vt82c686b_pm_initfn(PCIDevice *dev)
apm_init(&s->apm, NULL, s);
- memory_region_init_io(&s->io, &pm_io_ops, s, "vt82c686-pm", 64);
+ memory_region_init(&s->io, "vt82c686-pm", 64);
acpi_pm_tmr_init(&s->ar, pm_tmr_timer, &s->io);
acpi_pm1_evt_init(&s->ar, pm_tmr_timer, &s->io);
acpi_pm1_cnt_init(&s->ar, &s->io);
--
1.7.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [Qemu-devel] [PATCH 12/20] apci: switch ich9 gpe to memory api
2012-11-23 15:48 [Qemu-devel] [PATCH 00/20] acpi: switch to memory api Gerd Hoffmann
` (10 preceding siblings ...)
2012-11-23 15:48 ` [Qemu-devel] [PATCH 11/20] acpi: cleanup vt82c686 " Gerd Hoffmann
@ 2012-11-23 15:48 ` Gerd Hoffmann
2012-11-23 15:48 ` [Qemu-devel] [PATCH 13/20] apci: switch ich9 smi " Gerd Hoffmann
` (7 subsequent siblings)
19 siblings, 0 replies; 23+ messages in thread
From: Gerd Hoffmann @ 2012-11-23 15:48 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/acpi_ich9.c | 38 ++++++++++++++++++++++++++++----------
hw/acpi_ich9.h | 1 +
2 files changed, 29 insertions(+), 10 deletions(-)
diff --git a/hw/acpi_ich9.c b/hw/acpi_ich9.c
index 0f025f8..aa290d6 100644
--- a/hw/acpi_ich9.c
+++ b/hw/acpi_ich9.c
@@ -73,12 +73,7 @@ static void ich9_pm_update_sci_fn(ACPIREGS *regs)
static void pm_ioport_writeb(void *opaque, uint32_t addr, uint32_t val)
{
- ICH9LPCPMRegs *pm = opaque;
-
switch (addr & ICH9_PMIO_MASK) {
- case ICH9_PMIO_GPE0_STS ... (ICH9_PMIO_GPE0_STS + ICH9_PMIO_GPE0_LEN - 1):
- acpi_gpe_ioport_writeb(&pm->acpi_regs, addr, val);
- break;
default:
break;
}
@@ -88,13 +83,9 @@ static void pm_ioport_writeb(void *opaque, uint32_t addr, uint32_t val)
static uint32_t pm_ioport_readb(void *opaque, uint32_t addr)
{
- ICH9LPCPMRegs *pm = opaque;
uint32_t val = 0;
switch (addr & ICH9_PMIO_MASK) {
- case ICH9_PMIO_GPE0_STS ... (ICH9_PMIO_GPE0_STS + ICH9_PMIO_GPE0_LEN - 1):
- val = acpi_gpe_ioport_readb(&pm->acpi_regs, addr);
- break;
default:
val = 0;
break;
@@ -209,6 +200,29 @@ static const MemoryRegionOps pm_io_ops = {
.endianness = DEVICE_LITTLE_ENDIAN,
};
+static uint64_t ich9_gpe_readb(void *opaque, hwaddr addr, unsigned width)
+{
+ ICH9LPCPMRegs *pm = opaque;
+ return acpi_gpe_ioport_readb(&pm->acpi_regs, addr);
+}
+
+static void ich9_gpe_writeb(void *opaque, hwaddr addr, uint64_t val,
+ unsigned width)
+{
+ ICH9LPCPMRegs *pm = opaque;
+ acpi_gpe_ioport_writeb(&pm->acpi_regs, addr, val);
+}
+
+static const MemoryRegionOps ich9_gpe_ops = {
+ .read = ich9_gpe_readb,
+ .write = ich9_gpe_writeb,
+ .valid.min_access_size = 1,
+ .valid.max_access_size = 4,
+ .impl.min_access_size = 1,
+ .impl.max_access_size = 1,
+ .endianness = DEVICE_LITTLE_ENDIAN,
+};
+
void ich9_pm_iospace_update(ICH9LPCPMRegs *pm, uint32_t pm_io_base)
{
ICH9_DEBUG("to 0x%x\n", pm_io_base);
@@ -300,8 +314,12 @@ void ich9_pm_init(ICH9LPCPMRegs *pm, qemu_irq sci_irq, qemu_irq cmos_s3)
acpi_pm_tmr_init(&pm->acpi_regs, ich9_pm_update_sci_fn, &pm->io);
acpi_pm1_evt_init(&pm->acpi_regs, ich9_pm_update_sci_fn, &pm->io);
acpi_pm1_cnt_init(&pm->acpi_regs, &pm->io);
+
acpi_gpe_init(&pm->acpi_regs, ICH9_PMIO_GPE0_LEN);
- acpi_gpe_blk(&pm->acpi_regs, ICH9_PMIO_GPE0_STS);
+ acpi_gpe_blk(&pm->acpi_regs, 0);
+ memory_region_init_io(&pm->io_gpe, &ich9_gpe_ops, pm, "apci-gpe0",
+ ICH9_PMIO_GPE0_LEN);
+ memory_region_add_subregion(&pm->io, ICH9_PMIO_GPE0_STS, &pm->io_gpe);
pm->irq = sci_irq;
qemu_register_reset(pm_reset, pm);
diff --git a/hw/acpi_ich9.h b/hw/acpi_ich9.h
index 0a2ee6c..f3b05d7 100644
--- a/hw/acpi_ich9.h
+++ b/hw/acpi_ich9.h
@@ -31,6 +31,7 @@ typedef struct ICH9LPCPMRegs {
*/
ACPIREGS acpi_regs;
MemoryRegion io;
+ MemoryRegion io_gpe;
uint32_t smi_en;
uint32_t smi_sts;
--
1.7.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [Qemu-devel] [PATCH 13/20] apci: switch ich9 smi to memory api
2012-11-23 15:48 [Qemu-devel] [PATCH 00/20] acpi: switch to memory api Gerd Hoffmann
` (11 preceding siblings ...)
2012-11-23 15:48 ` [Qemu-devel] [PATCH 12/20] apci: switch ich9 gpe to memory api Gerd Hoffmann
@ 2012-11-23 15:48 ` Gerd Hoffmann
2012-11-23 15:48 ` [Qemu-devel] [PATCH 14/20] acpi: cleanup ich9 memory region Gerd Hoffmann
` (6 subsequent siblings)
19 siblings, 0 replies; 23+ messages in thread
From: Gerd Hoffmann @ 2012-11-23 15:48 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/acpi_ich9.c | 46 ++++++++++++++++++++++++++++++++++++----------
hw/acpi_ich9.h | 1 +
2 files changed, 37 insertions(+), 10 deletions(-)
diff --git a/hw/acpi_ich9.c b/hw/acpi_ich9.c
index aa290d6..cdfa266 100644
--- a/hw/acpi_ich9.c
+++ b/hw/acpi_ich9.c
@@ -119,12 +119,7 @@ static uint32_t pm_ioport_readw(void *opaque, uint32_t addr)
static void pm_ioport_writel(void *opaque, uint32_t addr, uint32_t val)
{
- ICH9LPCPMRegs *pm = opaque;
-
switch (addr & ICH9_PMIO_MASK) {
- case ICH9_PMIO_SMI_EN:
- pm->smi_en = val;
- break;
default:
pm_ioport_write_fallback(opaque, addr, 4, val);
break;
@@ -134,14 +129,9 @@ static void pm_ioport_writel(void *opaque, uint32_t addr, uint32_t val)
static uint32_t pm_ioport_readl(void *opaque, uint32_t addr)
{
- ICH9LPCPMRegs *pm = opaque;
uint32_t val;
switch (addr & ICH9_PMIO_MASK) {
- case ICH9_PMIO_SMI_EN:
- val = pm->smi_en;
- break;
-
default:
val = pm_ioport_read_fallback(opaque, addr, 4);
break;
@@ -223,6 +213,38 @@ static const MemoryRegionOps ich9_gpe_ops = {
.endianness = DEVICE_LITTLE_ENDIAN,
};
+static uint64_t ich9_smi_readl(void *opaque, hwaddr addr, unsigned width)
+{
+ ICH9LPCPMRegs *pm = opaque;
+ switch (addr) {
+ case 0:
+ return pm->smi_en;
+ case 4:
+ return pm->smi_sts;
+ default:
+ return 0;
+ }
+}
+
+static void ich9_smi_writel(void *opaque, hwaddr addr, uint64_t val,
+ unsigned width)
+{
+ ICH9LPCPMRegs *pm = opaque;
+ switch (addr) {
+ case 0:
+ pm->smi_en = val;
+ break;
+ }
+}
+
+static const MemoryRegionOps ich9_smi_ops = {
+ .read = ich9_smi_readl,
+ .write = ich9_smi_writel,
+ .valid.min_access_size = 4,
+ .valid.max_access_size = 4,
+ .endianness = DEVICE_LITTLE_ENDIAN,
+};
+
void ich9_pm_iospace_update(ICH9LPCPMRegs *pm, uint32_t pm_io_base)
{
ICH9_DEBUG("to 0x%x\n", pm_io_base);
@@ -321,6 +343,10 @@ void ich9_pm_init(ICH9LPCPMRegs *pm, qemu_irq sci_irq, qemu_irq cmos_s3)
ICH9_PMIO_GPE0_LEN);
memory_region_add_subregion(&pm->io, ICH9_PMIO_GPE0_STS, &pm->io_gpe);
+ memory_region_init_io(&pm->io_smi, &ich9_smi_ops, pm, "apci-smi",
+ 8);
+ memory_region_add_subregion(&pm->io, ICH9_PMIO_SMI_EN, &pm->io_smi);
+
pm->irq = sci_irq;
qemu_register_reset(pm_reset, pm);
pm->powerdown_notifier.notify = pm_powerdown_req;
diff --git a/hw/acpi_ich9.h b/hw/acpi_ich9.h
index f3b05d7..bc221d3 100644
--- a/hw/acpi_ich9.h
+++ b/hw/acpi_ich9.h
@@ -32,6 +32,7 @@ typedef struct ICH9LPCPMRegs {
ACPIREGS acpi_regs;
MemoryRegion io;
MemoryRegion io_gpe;
+ MemoryRegion io_smi;
uint32_t smi_en;
uint32_t smi_sts;
--
1.7.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [Qemu-devel] [PATCH 14/20] acpi: cleanup ich9 memory region
2012-11-23 15:48 [Qemu-devel] [PATCH 00/20] acpi: switch to memory api Gerd Hoffmann
` (12 preceding siblings ...)
2012-11-23 15:48 ` [Qemu-devel] [PATCH 13/20] apci: switch ich9 smi " Gerd Hoffmann
@ 2012-11-23 15:48 ` Gerd Hoffmann
2012-11-23 15:48 ` [Qemu-devel] [PATCH 15/20] acpi: switch smbus to memory api Gerd Hoffmann
` (5 subsequent siblings)
19 siblings, 0 replies; 23+ messages in thread
From: Gerd Hoffmann @ 2012-11-23 15:48 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Nothing left to do, everything handled by subregions,
we can zap the reaw/write handlers now.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/acpi_ich9.c | 125 +-------------------------------------------------------
1 files changed, 1 insertions(+), 124 deletions(-)
diff --git a/hw/acpi_ich9.c b/hw/acpi_ich9.c
index cdfa266..4faa18d 100644
--- a/hw/acpi_ich9.c
+++ b/hw/acpi_ich9.c
@@ -42,10 +42,6 @@ do { printf("%s "fmt, __func__, ## __VA_ARGS__); } while (0)
#define ICH9_DEBUG(fmt, ...) do { } while (0)
#endif
-static void pm_ioport_write_fallback(void *opaque, uint32_t addr, int len,
- uint32_t val);
-static uint32_t pm_ioport_read_fallback(void *opaque, uint32_t addr, int len);
-
static void pm_update_sci(ICH9LPCPMRegs *pm)
{
int sci_level, pm1a_sts;
@@ -71,125 +67,6 @@ static void ich9_pm_update_sci_fn(ACPIREGS *regs)
pm_update_sci(pm);
}
-static void pm_ioport_writeb(void *opaque, uint32_t addr, uint32_t val)
-{
- switch (addr & ICH9_PMIO_MASK) {
- default:
- break;
- }
-
- ICH9_DEBUG("port=0x%04x val=0x%04x\n", addr, val);
-}
-
-static uint32_t pm_ioport_readb(void *opaque, uint32_t addr)
-{
- uint32_t val = 0;
-
- switch (addr & ICH9_PMIO_MASK) {
- default:
- val = 0;
- break;
- }
- ICH9_DEBUG("port=0x%04x val=0x%04x\n", addr, val);
- return val;
-}
-
-static void pm_ioport_writew(void *opaque, uint32_t addr, uint32_t val)
-{
- switch (addr & ICH9_PMIO_MASK) {
- default:
- pm_ioport_write_fallback(opaque, addr, 2, val);
- break;
- }
- ICH9_DEBUG("port=0x%04x val=0x%04x\n", addr, val);
-}
-
-static uint32_t pm_ioport_readw(void *opaque, uint32_t addr)
-{
- uint32_t val;
-
- switch (addr & ICH9_PMIO_MASK) {
- default:
- val = pm_ioport_read_fallback(opaque, addr, 2);
- break;
- }
- ICH9_DEBUG("port=0x%04x val=0x%04x\n", addr, val);
- return val;
-}
-
-static void pm_ioport_writel(void *opaque, uint32_t addr, uint32_t val)
-{
- switch (addr & ICH9_PMIO_MASK) {
- default:
- pm_ioport_write_fallback(opaque, addr, 4, val);
- break;
- }
- ICH9_DEBUG("port=0x%04x val=0x%08x\n", addr, val);
-}
-
-static uint32_t pm_ioport_readl(void *opaque, uint32_t addr)
-{
- uint32_t val;
-
- switch (addr & ICH9_PMIO_MASK) {
- default:
- val = pm_ioport_read_fallback(opaque, addr, 4);
- break;
- }
- ICH9_DEBUG("port=0x%04x val=0x%08x\n", addr, val);
- return val;
-}
-
-static void pm_ioport_write_fallback(void *opaque, uint32_t addr, int len,
- uint32_t val)
- {
- int subsize = (len == 4) ? 2 : 1;
- IOPortWriteFunc *ioport_write =
- (subsize == 2) ? pm_ioport_writew : pm_ioport_writeb;
-
- int i;
-
- for (i = 0; i < len; i += subsize) {
- ioport_write(opaque, addr, val);
- val >>= 8 * subsize;
- }
-}
-
-static uint32_t pm_ioport_read_fallback(void *opaque, uint32_t addr, int len)
-{
- int subsize = (len == 4) ? 2 : 1;
- IOPortReadFunc *ioport_read =
- (subsize == 2) ? pm_ioport_readw : pm_ioport_readb;
-
- uint32_t val;
- int i;
-
- val = 0;
- for (i = 0; i < len; i += subsize) {
- val <<= 8 * subsize;
- val |= ioport_read(opaque, addr);
- }
-
- return val;
-}
-
-static const MemoryRegionOps pm_io_ops = {
- .old_portio = (MemoryRegionPortio[]) {
- { .offset = 0, .len = ICH9_PMIO_SIZE, .size = 1,
- .read = pm_ioport_readb, .write = pm_ioport_writeb },
- { .offset = 0, .len = ICH9_PMIO_SIZE, .size = 2,
- .read = pm_ioport_readw, .write = pm_ioport_writew },
- { .offset = 0, .len = ICH9_PMIO_SIZE, .size = 4,
- .read = pm_ioport_readl, .write = pm_ioport_writel },
- PORTIO_END_OF_LIST(),
- },
- .valid.min_access_size = 1,
- .valid.max_access_size = 4,
- .impl.min_access_size = 1,
- .impl.max_access_size = 4,
- .endianness = DEVICE_LITTLE_ENDIAN,
-};
-
static uint64_t ich9_gpe_readb(void *opaque, hwaddr addr, unsigned width)
{
ICH9LPCPMRegs *pm = opaque;
@@ -332,7 +209,7 @@ static void pm_powerdown_req(Notifier *n, void *opaque)
void ich9_pm_init(ICH9LPCPMRegs *pm, qemu_irq sci_irq, qemu_irq cmos_s3)
{
- memory_region_init_io(&pm->io, &pm_io_ops, pm, "ich9-pm", ICH9_PMIO_SIZE);
+ memory_region_init(&pm->io, "ich9-pm", ICH9_PMIO_SIZE);
acpi_pm_tmr_init(&pm->acpi_regs, ich9_pm_update_sci_fn, &pm->io);
acpi_pm1_evt_init(&pm->acpi_regs, ich9_pm_update_sci_fn, &pm->io);
acpi_pm1_cnt_init(&pm->acpi_regs, &pm->io);
--
1.7.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [Qemu-devel] [PATCH 15/20] acpi: switch smbus to memory api
2012-11-23 15:48 [Qemu-devel] [PATCH 00/20] acpi: switch to memory api Gerd Hoffmann
` (13 preceding siblings ...)
2012-11-23 15:48 ` [Qemu-devel] [PATCH 14/20] acpi: cleanup ich9 memory region Gerd Hoffmann
@ 2012-11-23 15:48 ` Gerd Hoffmann
2012-11-26 15:18 ` Andreas Färber
2012-11-23 15:48 ` [Qemu-devel] [PATCH 16/20] acpi: fix piix4 smbus mapping Gerd Hoffmann
` (4 subsequent siblings)
19 siblings, 1 reply; 23+ messages in thread
From: Gerd Hoffmann @ 2012-11-23 15:48 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/acpi_piix4.c | 5 ++---
hw/pm_smbus.c | 17 +++++++++++++----
hw/pm_smbus.h | 3 +--
hw/smbus_ich9.c | 52 +++++++++++++++-------------------------------------
hw/vt82c686.c | 6 ++----
5 files changed, 33 insertions(+), 50 deletions(-)
diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c
index 2f1d77b..cd876c8 100644
--- a/hw/acpi_piix4.c
+++ b/hw/acpi_piix4.c
@@ -395,8 +395,8 @@ static int piix4_pm_initfn(PCIDevice *dev)
pci_conf[0x90] = s->smb_io_base | 1;
pci_conf[0x91] = s->smb_io_base >> 8;
pci_conf[0xd2] = 0x09;
- register_ioport_write(s->smb_io_base, 64, 1, smb_ioport_writeb, &s->smb);
- register_ioport_read(s->smb_io_base, 64, 1, smb_ioport_readb, &s->smb);
+ pm_smbus_init(&s->dev.qdev, &s->smb);
+ memory_region_add_subregion(get_system_io(), s->smb_io_base, &s->smb.io);
memory_region_init(&s->io, "piix4-pm", 64);
acpi_pm_tmr_init(&s->ar, pm_tmr_timer, &s->io);
@@ -407,7 +407,6 @@ static int piix4_pm_initfn(PCIDevice *dev)
s->powerdown_notifier.notify = piix4_pm_powerdown_req;
qemu_register_powerdown_notifier(&s->powerdown_notifier);
- pm_smbus_init(&s->dev.qdev, &s->smb);
s->machine_ready.notify = piix4_pm_machine_ready;
qemu_add_machine_init_done_notifier(&s->machine_ready);
qemu_register_reset(piix4_reset, s);
diff --git a/hw/pm_smbus.c b/hw/pm_smbus.c
index 5d6046d..ea1380c 100644
--- a/hw/pm_smbus.c
+++ b/hw/pm_smbus.c
@@ -94,10 +94,11 @@ static void smb_transaction(PMSMBus *s)
s->smb_stat |= 0x04;
}
-void smb_ioport_writeb(void *opaque, uint32_t addr, uint32_t val)
+static void smb_ioport_writeb(void *opaque, hwaddr addr, uint64_t val,
+ unsigned width)
{
PMSMBus *s = opaque;
- addr &= 0x3f;
+
SMBUS_DPRINTF("SMB writeb port=0x%04x val=0x%02x\n", addr, val);
switch(addr) {
case SMBHSTSTS:
@@ -131,12 +132,11 @@ void smb_ioport_writeb(void *opaque, uint32_t addr, uint32_t val)
}
}
-uint32_t smb_ioport_readb(void *opaque, uint32_t addr)
+static uint64_t smb_ioport_readb(void *opaque, hwaddr addr, unsigned width)
{
PMSMBus *s = opaque;
uint32_t val;
- addr &= 0x3f;
switch(addr) {
case SMBHSTSTS:
val = s->smb_stat;
@@ -170,7 +170,16 @@ uint32_t smb_ioport_readb(void *opaque, uint32_t addr)
return val;
}
+static const MemoryRegionOps pm_smbus_ops = {
+ .read = smb_ioport_readb,
+ .write = smb_ioport_writeb,
+ .valid.min_access_size = 1,
+ .valid.max_access_size = 1,
+ .endianness = DEVICE_LITTLE_ENDIAN,
+};
+
void pm_smbus_init(DeviceState *parent, PMSMBus *smb)
{
smb->smbus = i2c_init_bus(parent, "i2c");
+ memory_region_init_io(&smb->io, &pm_smbus_ops, smb, "pm-smbus", 64);
}
diff --git a/hw/pm_smbus.h b/hw/pm_smbus.h
index 4750a40..e3069bf 100644
--- a/hw/pm_smbus.h
+++ b/hw/pm_smbus.h
@@ -3,6 +3,7 @@
typedef struct PMSMBus {
i2c_bus *smbus;
+ MemoryRegion io;
uint8_t smb_stat;
uint8_t smb_ctl;
@@ -15,7 +16,5 @@ typedef struct PMSMBus {
} PMSMBus;
void pm_smbus_init(DeviceState *parent, PMSMBus *smb);
-void smb_ioport_writeb(void *opaque, uint32_t addr, uint32_t val);
-uint32_t smb_ioport_readb(void *opaque, uint32_t addr);
#endif /* !PM_SMBUS_H */
diff --git a/hw/smbus_ich9.c b/hw/smbus_ich9.c
index 6940583..54e7e12 100644
--- a/hw/smbus_ich9.c
+++ b/hw/smbus_ich9.c
@@ -40,7 +40,6 @@ typedef struct ICH9SMBState {
PCIDevice dev;
PMSMBus smb;
- MemoryRegion mem_bar;
} ICH9SMBState;
static const VMStateDescription vmstate_ich9_smbus = {
@@ -54,42 +53,23 @@ static const VMStateDescription vmstate_ich9_smbus = {
}
};
-static void ich9_smb_ioport_writeb(void *opaque, hwaddr addr,
- uint64_t val, unsigned size)
+static void ich9_smbus_write_config(PCIDevice *d, uint32_t address,
+ uint32_t val, int len)
{
- ICH9SMBState *s = opaque;
- uint8_t hostc = s->dev.config[ICH9_SMB_HOSTC];
+ ICH9SMBState *s = ICH9_SMB_DEVICE(d);
- if ((hostc & ICH9_SMB_HOSTC_HST_EN) && !(hostc & ICH9_SMB_HOSTC_I2C_EN)) {
- uint64_t offset = addr - s->dev.io_regions[ICH9_SMB_SMB_BASE_BAR].addr;
- smb_ioport_writeb(&s->smb, offset, val);
+ pci_default_write_config(d, address, val, len);
+ if (range_covers_byte(address, len, ICH9_SMB_HOSTC)) {
+ uint8_t hostc = s->dev.config[ICH9_SMB_HOSTC];
+ if ((hostc & ICH9_SMB_HOSTC_HST_EN) &&
+ !(hostc & ICH9_SMB_HOSTC_I2C_EN)) {
+ memory_region_set_enabled(&s->smb.io, true);
+ } else {
+ memory_region_set_enabled(&s->smb.io, false);
+ }
}
}
-static uint64_t ich9_smb_ioport_readb(void *opaque, hwaddr addr,
- unsigned size)
-{
- ICH9SMBState *s = opaque;
- uint8_t hostc = s->dev.config[ICH9_SMB_HOSTC];
-
- if ((hostc & ICH9_SMB_HOSTC_HST_EN) && !(hostc & ICH9_SMB_HOSTC_I2C_EN)) {
- uint64_t offset = addr - s->dev.io_regions[ICH9_SMB_SMB_BASE_BAR].addr;
- return smb_ioport_readb(&s->smb, offset);
- }
-
- return 0xff;
-}
-
-static const MemoryRegionOps lpc_smb_mmio_ops = {
- .read = ich9_smb_ioport_readb,
- .write = ich9_smb_ioport_writeb,
- .endianness = DEVICE_LITTLE_ENDIAN,
- .impl = {
- .min_access_size = 1,
- .max_access_size = 1,
- },
-};
-
static int ich9_smbus_initfn(PCIDevice *d)
{
ICH9SMBState *s = ICH9_SMB_DEVICE(d);
@@ -109,15 +89,12 @@ static int ich9_smbus_initfn(PCIDevice *d)
* Is there any OS that depends on them?
*/
- /* TODO smb_io_base */
pci_set_byte(d->config + ICH9_SMB_HOSTC, 0);
/* TODO bar0, bar1: 64bit BAR support*/
- memory_region_init_io(&s->mem_bar, &lpc_smb_mmio_ops, s, "ich9-smbus-bar",
- ICH9_SMB_SMB_BASE_SIZE);
- pci_register_bar(d, ICH9_SMB_SMB_BASE_BAR, PCI_BASE_ADDRESS_SPACE_IO,
- &s->mem_bar);
pm_smbus_init(&d->qdev, &s->smb);
+ pci_register_bar(d, ICH9_SMB_SMB_BASE_BAR, PCI_BASE_ADDRESS_SPACE_IO,
+ &s->smb.io);
return 0;
}
@@ -134,6 +111,7 @@ static void ich9_smb_class_init(ObjectClass *klass, void *data)
dc->vmsd = &vmstate_ich9_smbus;
dc->desc = "ICH9 SMBUS Bridge";
k->init = ich9_smbus_initfn;
+ k->config_write = ich9_smbus_write_config;
}
i2c_bus *ich9_smb_init(PCIBus *bus, int devfn, uint32_t smb_io_base)
diff --git a/hw/vt82c686.c b/hw/vt82c686.c
index e1a941c..dc05a83 100644
--- a/hw/vt82c686.c
+++ b/hw/vt82c686.c
@@ -355,8 +355,8 @@ static int vt82c686b_pm_initfn(PCIDevice *dev)
pci_conf[0x90] = s->smb_io_base | 1;
pci_conf[0x91] = s->smb_io_base >> 8;
pci_conf[0xd2] = 0x90;
- register_ioport_write(s->smb_io_base, 0xf, 1, smb_ioport_writeb, &s->smb);
- register_ioport_read(s->smb_io_base, 0xf, 1, smb_ioport_readb, &s->smb);
+ pm_smbus_init(&s->dev.qdev, &s->smb);
+ memory_region_add_subregion(get_system_io(), s->smb_io_base, &s->smb.io);
apm_init(&s->apm, NULL, s);
@@ -365,8 +365,6 @@ static int vt82c686b_pm_initfn(PCIDevice *dev)
acpi_pm1_evt_init(&s->ar, pm_tmr_timer, &s->io);
acpi_pm1_cnt_init(&s->ar, &s->io);
- pm_smbus_init(&s->dev.qdev, &s->smb);
-
return 0;
}
--
1.7.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [Qemu-devel] [PATCH 16/20] acpi: fix piix4 smbus mapping
2012-11-23 15:48 [Qemu-devel] [PATCH 00/20] acpi: switch to memory api Gerd Hoffmann
` (14 preceding siblings ...)
2012-11-23 15:48 ` [Qemu-devel] [PATCH 15/20] acpi: switch smbus to memory api Gerd Hoffmann
@ 2012-11-23 15:48 ` Gerd Hoffmann
2012-11-23 15:48 ` [Qemu-devel] [PATCH 17/20] apci: switch piix4 gpe to memory api Gerd Hoffmann
` (3 subsequent siblings)
19 siblings, 0 replies; 23+ messages in thread
From: Gerd Hoffmann @ 2012-11-23 15:48 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/acpi_piix4.c | 23 ++++++++++++++++++++++-
1 files changed, 22 insertions(+), 1 deletions(-)
diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c
index cd876c8..a85c2d4 100644
--- a/hw/acpi_piix4.c
+++ b/hw/acpi_piix4.c
@@ -146,12 +146,33 @@ static void pm_io_space_update(PIIX4PMState *s)
}
}
+static void smbus_io_space_update(PIIX4PMState *s)
+{
+ if (s->smb.io.parent) {
+ memory_region_del_subregion(get_system_io(), &s->smb.io);
+ }
+ if (s->dev.config[0xd2] & 1) {
+ s->smb_io_base = le32_to_cpu(*(uint32_t *)(s->dev.config + 0x90));
+
+ /* XXX: need to improve memory and ioport allocation */
+ PIIX4_DPRINTF("smbus: mapping to 0x%x\n", s->smb_io_base);
+ memory_region_add_subregion(get_system_io(), s->smb_io_base,
+ &s->smb.io);
+ }
+}
+
static void pm_write_config(PCIDevice *d,
uint32_t address, uint32_t val, int len)
{
pci_default_write_config(d, address, val, len);
- if (range_covers_byte(address, len, 0x80))
+ if (range_covers_byte(address, len, 0x80) ||
+ ranges_overlap(address, len, 0x40, 4)) {
pm_io_space_update((PIIX4PMState *)d);
+ }
+ if (range_covers_byte(address, len, 0xd2) ||
+ ranges_overlap(address, len, 0x90, 4)) {
+ smbus_io_space_update((PIIX4PMState *)d);
+ }
}
static void vmstate_pci_status_pre_save(void *opaque)
--
1.7.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [Qemu-devel] [PATCH 17/20] apci: switch piix4 gpe to memory api
2012-11-23 15:48 [Qemu-devel] [PATCH 00/20] acpi: switch to memory api Gerd Hoffmann
` (15 preceding siblings ...)
2012-11-23 15:48 ` [Qemu-devel] [PATCH 16/20] acpi: fix piix4 smbus mapping Gerd Hoffmann
@ 2012-11-23 15:48 ` Gerd Hoffmann
2012-11-23 15:48 ` [Qemu-devel] [PATCH 18/20] acpi: remove acpi_gpe_blk Gerd Hoffmann
` (2 subsequent siblings)
19 siblings, 0 replies; 23+ messages in thread
From: Gerd Hoffmann @ 2012-11-23 15:48 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/acpi_piix4.c | 24 ++++++++++++++++++------
1 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c
index a85c2d4..b75be72 100644
--- a/hw/acpi_piix4.c
+++ b/hw/acpi_piix4.c
@@ -57,6 +57,7 @@ struct pci_status {
typedef struct PIIX4PMState {
PCIDevice dev;
MemoryRegion io;
+ MemoryRegion io_gpe;
ACPIREGS ar;
APMState apm;
@@ -504,7 +505,7 @@ static void piix4_pm_register_types(void)
type_init(piix4_pm_register_types)
-static uint32_t gpe_readb(void *opaque, uint32_t addr)
+static uint64_t gpe_readb(void *opaque, hwaddr addr, unsigned width)
{
PIIX4PMState *s = opaque;
uint32_t val = acpi_gpe_ioport_readb(&s->ar, addr);
@@ -513,7 +514,8 @@ static uint32_t gpe_readb(void *opaque, uint32_t addr)
return val;
}
-static void gpe_writeb(void *opaque, uint32_t addr, uint32_t val)
+static void gpe_writeb(void *opaque, hwaddr addr, uint64_t val,
+ unsigned width)
{
PIIX4PMState *s = opaque;
@@ -523,6 +525,16 @@ static void gpe_writeb(void *opaque, uint32_t addr, uint32_t val)
PIIX4_DPRINTF("gpe write %x <== %d\n", addr, val);
}
+static const MemoryRegionOps piix4_gpe_ops = {
+ .read = gpe_readb,
+ .write = gpe_writeb,
+ .valid.min_access_size = 1,
+ .valid.max_access_size = 4,
+ .impl.min_access_size = 1,
+ .impl.max_access_size = 1,
+ .endianness = DEVICE_LITTLE_ENDIAN,
+};
+
static uint32_t pci_up_read(void *opaque, uint32_t addr)
{
PIIX4PMState *s = opaque;
@@ -571,10 +583,10 @@ static int piix4_device_hotplug(DeviceState *qdev, PCIDevice *dev,
static void piix4_acpi_system_hot_add_init(PCIBus *bus, PIIX4PMState *s)
{
-
- register_ioport_write(GPE_BASE, GPE_LEN, 1, gpe_writeb, s);
- register_ioport_read(GPE_BASE, GPE_LEN, 1, gpe_readb, s);
- acpi_gpe_blk(&s->ar, GPE_BASE);
+ memory_region_init_io(&s->io_gpe, &piix4_gpe_ops, s, "apci-gpe0",
+ GPE_LEN);
+ memory_region_add_subregion(get_system_io(), GPE_BASE, &s->io_gpe);
+ acpi_gpe_blk(&s->ar, 0);
register_ioport_read(PCI_UP_BASE, 4, 4, pci_up_read, s);
register_ioport_read(PCI_DOWN_BASE, 4, 4, pci_down_read, s);
--
1.7.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [Qemu-devel] [PATCH 18/20] acpi: remove acpi_gpe_blk
2012-11-23 15:48 [Qemu-devel] [PATCH 00/20] acpi: switch to memory api Gerd Hoffmann
` (16 preceding siblings ...)
2012-11-23 15:48 ` [Qemu-devel] [PATCH 17/20] apci: switch piix4 gpe to memory api Gerd Hoffmann
@ 2012-11-23 15:48 ` 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
19 siblings, 0 replies; 23+ messages in thread
From: Gerd Hoffmann @ 2012-11-23 15:48 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
With gpe being switched to memory api this is no longer needed.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/acpi.c | 7 -------
hw/acpi.h | 2 --
hw/acpi_ich9.c | 1 -
hw/acpi_piix4.c | 1 -
4 files changed, 0 insertions(+), 11 deletions(-)
diff --git a/hw/acpi.c b/hw/acpi.c
index e58e45f..ae29a59 100644
--- a/hw/acpi.c
+++ b/hw/acpi.c
@@ -493,11 +493,6 @@ void acpi_gpe_init(ACPIREGS *ar, uint8_t len)
ar->gpe.en = g_malloc0(len / 2);
}
-void acpi_gpe_blk(ACPIREGS *ar, uint32_t blk)
-{
- ar->gpe.blk = blk;
-}
-
void acpi_gpe_reset(ACPIREGS *ar)
{
memset(ar->gpe.sts, 0, ar->gpe.len / 2);
@@ -523,7 +518,6 @@ void acpi_gpe_ioport_writeb(ACPIREGS *ar, uint32_t addr, uint32_t val)
{
uint8_t *cur;
- addr -= ar->gpe.blk;
cur = acpi_gpe_ioport_get_ptr(ar, addr);
if (addr < ar->gpe.len / 2) {
/* GPE_STS */
@@ -541,7 +535,6 @@ uint32_t acpi_gpe_ioport_readb(ACPIREGS *ar, uint32_t addr)
uint8_t *cur;
uint32_t val;
- addr -= ar->gpe.blk;
cur = acpi_gpe_ioport_get_ptr(ar, addr);
val = 0;
if (cur != NULL) {
diff --git a/hw/acpi.h b/hw/acpi.h
index 918d7f5..afda153 100644
--- a/hw/acpi.h
+++ b/hw/acpi.h
@@ -104,7 +104,6 @@ struct ACPIPM1CNT {
};
struct ACPIGPE {
- uint32_t blk;
uint8_t len;
uint8_t *sts;
@@ -150,7 +149,6 @@ void acpi_pm1_cnt_reset(ACPIREGS *ar);
/* GPE0 */
void acpi_gpe_init(ACPIREGS *ar, uint8_t len);
-void acpi_gpe_blk(ACPIREGS *ar, uint32_t blk);
void acpi_gpe_reset(ACPIREGS *ar);
void acpi_gpe_ioport_writeb(ACPIREGS *ar, uint32_t addr, uint32_t val);
diff --git a/hw/acpi_ich9.c b/hw/acpi_ich9.c
index 4faa18d..50b3585 100644
--- a/hw/acpi_ich9.c
+++ b/hw/acpi_ich9.c
@@ -215,7 +215,6 @@ void ich9_pm_init(ICH9LPCPMRegs *pm, qemu_irq sci_irq, qemu_irq cmos_s3)
acpi_pm1_cnt_init(&pm->acpi_regs, &pm->io);
acpi_gpe_init(&pm->acpi_regs, ICH9_PMIO_GPE0_LEN);
- acpi_gpe_blk(&pm->acpi_regs, 0);
memory_region_init_io(&pm->io_gpe, &ich9_gpe_ops, pm, "apci-gpe0",
ICH9_PMIO_GPE0_LEN);
memory_region_add_subregion(&pm->io, ICH9_PMIO_GPE0_STS, &pm->io_gpe);
diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c
index b75be72..d74fff9 100644
--- a/hw/acpi_piix4.c
+++ b/hw/acpi_piix4.c
@@ -586,7 +586,6 @@ static void piix4_acpi_system_hot_add_init(PCIBus *bus, PIIX4PMState *s)
memory_region_init_io(&s->io_gpe, &piix4_gpe_ops, s, "apci-gpe0",
GPE_LEN);
memory_region_add_subregion(get_system_io(), GPE_BASE, &s->io_gpe);
- acpi_gpe_blk(&s->ar, 0);
register_ioport_read(PCI_UP_BASE, 4, 4, pci_up_read, s);
register_ioport_read(PCI_DOWN_BASE, 4, 4, pci_down_read, s);
--
1.7.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [Qemu-devel] [PATCH 19/20] apci: switch piix4 pci hotplug to memory api
2012-11-23 15:48 [Qemu-devel] [PATCH 00/20] acpi: switch to memory api Gerd Hoffmann
` (17 preceding siblings ...)
2012-11-23 15:48 ` [Qemu-devel] [PATCH 18/20] acpi: remove acpi_gpe_blk Gerd Hoffmann
@ 2012-11-23 15:48 ` Gerd Hoffmann
2012-11-23 15:48 ` [Qemu-devel] [PATCH 20/20] q35: update lpc pci config space according to configured devices Gerd Hoffmann
19 siblings, 0 replies; 23+ messages in thread
From: Gerd Hoffmann @ 2012-11-23 15:48 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/acpi_piix4.c | 37 +++++++++++++++++++++++++++++--------
1 files changed, 29 insertions(+), 8 deletions(-)
diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c
index d74fff9..93aa319 100644
--- a/hw/acpi_piix4.c
+++ b/hw/acpi_piix4.c
@@ -42,6 +42,9 @@
#define GPE_BASE 0xafe0
#define GPE_LEN 4
+
+#define PCI_HOTPLUG_ADDR 0xae00
+#define PCI_HOTPLUG_SIZE 0x000f
#define PCI_UP_BASE 0xae00
#define PCI_DOWN_BASE 0xae04
#define PCI_EJ_BASE 0xae08
@@ -58,6 +61,7 @@ typedef struct PIIX4PMState {
PCIDevice dev;
MemoryRegion io;
MemoryRegion io_gpe;
+ MemoryRegion io_pci;
ACPIREGS ar;
APMState apm;
@@ -578,6 +582,27 @@ static uint32_t pcirmv_read(void *opaque, uint32_t addr)
return s->pci0_hotplug_enable;
}
+static const MemoryRegionOps piix4_pci_ops = {
+ .old_portio = (MemoryRegionPortio[]) {
+ {
+ .offset = PCI_UP_BASE - PCI_HOTPLUG_ADDR, .len = 4, .size = 4,
+ .read = pci_up_read,
+ },{
+ .offset = PCI_DOWN_BASE - PCI_HOTPLUG_ADDR, .len = 4, .size = 4,
+ .read = pci_down_read,
+ },{
+ .offset = PCI_EJ_BASE - PCI_HOTPLUG_ADDR, .len = 4, .size = 4,
+ .read = pci_features_read,
+ .write = pciej_write,
+ },{
+ .offset = PCI_RMV_BASE - PCI_HOTPLUG_ADDR, .len = 4, .size = 4,
+ .read = pcirmv_read,
+ },
+ PORTIO_END_OF_LIST()
+ },
+ .endianness = DEVICE_LITTLE_ENDIAN,
+};
+
static int piix4_device_hotplug(DeviceState *qdev, PCIDevice *dev,
PCIHotplugState state);
@@ -587,14 +612,10 @@ static void piix4_acpi_system_hot_add_init(PCIBus *bus, PIIX4PMState *s)
GPE_LEN);
memory_region_add_subregion(get_system_io(), GPE_BASE, &s->io_gpe);
- register_ioport_read(PCI_UP_BASE, 4, 4, pci_up_read, s);
- register_ioport_read(PCI_DOWN_BASE, 4, 4, pci_down_read, s);
-
- register_ioport_write(PCI_EJ_BASE, 4, 4, pciej_write, s);
- register_ioport_read(PCI_EJ_BASE, 4, 4, pci_features_read, s);
-
- register_ioport_read(PCI_RMV_BASE, 4, 4, pcirmv_read, s);
-
+ memory_region_init_io(&s->io_pci, &piix4_pci_ops, s, "apci-pci-hotplug",
+ PCI_HOTPLUG_SIZE);
+ memory_region_add_subregion(get_system_io(), PCI_HOTPLUG_ADDR,
+ &s->io_pci);
pci_bus_hotplug(bus, piix4_device_hotplug, &s->dev.qdev);
}
--
1.7.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [Qemu-devel] [PATCH 20/20] q35: update lpc pci config space according to configured devices
2012-11-23 15:48 [Qemu-devel] [PATCH 00/20] acpi: switch to memory api Gerd Hoffmann
` (18 preceding siblings ...)
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 ` Gerd Hoffmann
19 siblings, 0 replies; 23+ messages in thread
From: Gerd Hoffmann @ 2012-11-23 15:48 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/ich9.h | 1 +
hw/lpc_ich9.c | 29 +++++++++++++++++++++++++++++
hw/smbus_ich9.c | 12 ------------
3 files changed, 30 insertions(+), 12 deletions(-)
diff --git a/hw/ich9.h b/hw/ich9.h
index de49135..34e216f 100644
--- a/hw/ich9.h
+++ b/hw/ich9.h
@@ -51,6 +51,7 @@ typedef struct ICH9LPCState {
/* isa bus */
ISABus *isa_bus;
MemoryRegion rbca_mem;
+ Notifier machine_ready;
qemu_irq *pic;
qemu_irq *ioapic;
diff --git a/hw/lpc_ich9.c b/hw/lpc_ich9.c
index 2fc83a4..6585236 100644
--- a/hw/lpc_ich9.c
+++ b/hw/lpc_ich9.c
@@ -60,6 +60,7 @@
#include "pam.h"
#include "pci_internals.h"
#include "exec-memory.h"
+#include "sysemu.h"
static int ich9_lpc_sci_irq(ICH9LPCState *lpc);
@@ -456,6 +457,30 @@ static const MemoryRegionOps rbca_mmio_ops = {
.endianness = DEVICE_LITTLE_ENDIAN,
};
+static void ich9_lpc_machine_ready(Notifier *n, void *opaque)
+{
+ ICH9LPCState *s = container_of(n, ICH9LPCState, machine_ready);
+ uint8_t *pci_conf;
+
+ pci_conf = s->d.config;
+ if (isa_is_ioport_assigned(0x3f8)) {
+ /* com1 */
+ pci_conf[0x82] |= 0x01;
+ }
+ if (isa_is_ioport_assigned(0x2f8)) {
+ /* com2 */
+ pci_conf[0x82] |= 0x02;
+ }
+ if (isa_is_ioport_assigned(0x378)) {
+ /* lpt */
+ pci_conf[0x82] |= 0x04;
+ }
+ if (isa_is_ioport_assigned(0x3f0)) {
+ /* floppy */
+ pci_conf[0x82] |= 0x08;
+ }
+}
+
static int ich9_lpc_initfn(PCIDevice *d)
{
ICH9LPCState *lpc = ICH9_LPC_DEVICE(d);
@@ -473,6 +498,10 @@ static int ich9_lpc_initfn(PCIDevice *d)
ich9_cc_init(lpc);
apm_init(&lpc->apm, ich9_apm_ctrl_changed, lpc);
+
+ lpc->machine_ready.notify = ich9_lpc_machine_ready;
+ qemu_add_machine_init_done_notifier(&lpc->machine_ready);
+
return 0;
}
diff --git a/hw/smbus_ich9.c b/hw/smbus_ich9.c
index 54e7e12..4194785 100644
--- a/hw/smbus_ich9.c
+++ b/hw/smbus_ich9.c
@@ -78,18 +78,6 @@ static int ich9_smbus_initfn(PCIDevice *d)
pci_config_set_interrupt_pin(d->config, 0x01); /* interrupt pin 1 */
pci_set_byte(d->config + ICH9_SMB_HOSTC, 0);
-
- /*
- * update parameters based on
- * paralell_hds[0]
- * serial_hds[0]
- * serial_hds[0]
- * fdc
- *
- * Is there any OS that depends on them?
- */
-
- pci_set_byte(d->config + ICH9_SMB_HOSTC, 0);
/* TODO bar0, bar1: 64bit BAR support*/
pm_smbus_init(&d->qdev, &s->smb);
--
1.7.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [Qemu-devel] [PATCH 15/20] acpi: switch smbus to memory api
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
0 siblings, 1 reply; 23+ messages in thread
From: Andreas Färber @ 2012-11-26 15:18 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: Julien Grall, qemu-devel
Am 23.11.2012 16:48, schrieb Gerd Hoffmann:
> diff --git a/hw/pm_smbus.c b/hw/pm_smbus.c
> index 5d6046d..ea1380c 100644
> --- a/hw/pm_smbus.c
> +++ b/hw/pm_smbus.c
[...]
> @@ -170,7 +170,16 @@ uint32_t smb_ioport_readb(void *opaque, uint32_t addr)
> return val;
> }
>
> +static const MemoryRegionOps pm_smbus_ops = {
> + .read = smb_ioport_readb,
> + .write = smb_ioport_writeb,
> + .valid.min_access_size = 1,
> + .valid.max_access_size = 1,
> + .endianness = DEVICE_LITTLE_ENDIAN,
> +};
I notice that in comparison to Julien's patch, you are setting .valid
here where he used .impl.
Also a generic C question: When using C99-style struct initializers as
for the MemoryRegionOps, I understand that the fields not explicitly
assigned are zero-initialized. Does that also apply to .foo.bar = baz
notation or would it be advisable to use nested .foo = { .bar = baz }?
> +
> void pm_smbus_init(DeviceState *parent, PMSMBus *smb)
> {
> smb->smbus = i2c_init_bus(parent, "i2c");
> + memory_region_init_io(&smb->io, &pm_smbus_ops, smb, "pm-smbus", 64);
> }
> diff --git a/hw/pm_smbus.h b/hw/pm_smbus.h
> index 4750a40..e3069bf 100644
> --- a/hw/pm_smbus.h
> +++ b/hw/pm_smbus.h
> @@ -3,6 +3,7 @@
>
> typedef struct PMSMBus {
> i2c_bus *smbus;
> + MemoryRegion io;
>
> uint8_t smb_stat;
> uint8_t smb_ctl;
With a view to further QOM'ifying these devices, please keep the parent
field separated, i.e.
i2c_bus *smbus;
+ MemoryRegion io;
+
uint8_t ...
(Once macros and types are correctly used - as you do for ICH9 below -
smbus would also be renamed to parent_obj for clarity, cf. QOM PHB/IDE
series, and optionally excluded from gtk-doc documentation.)
Regards,
Andreas
> diff --git a/hw/smbus_ich9.c b/hw/smbus_ich9.c
> index 6940583..54e7e12 100644
> --- a/hw/smbus_ich9.c
> +++ b/hw/smbus_ich9.c
[...]
> @@ -54,42 +53,23 @@ static const VMStateDescription vmstate_ich9_smbus = {
> }
> };
>
> -static void ich9_smb_ioport_writeb(void *opaque, hwaddr addr,
> - uint64_t val, unsigned size)
> +static void ich9_smbus_write_config(PCIDevice *d, uint32_t address,
> + uint32_t val, int len)
> {
> - ICH9SMBState *s = opaque;
> - uint8_t hostc = s->dev.config[ICH9_SMB_HOSTC];
> + ICH9SMBState *s = ICH9_SMB_DEVICE(d);
[snip]
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [Qemu-devel] [PATCH 15/20] acpi: switch smbus to memory api
2012-11-26 15:18 ` Andreas Färber
@ 2012-11-27 8:47 ` Gerd Hoffmann
0 siblings, 0 replies; 23+ messages in thread
From: Gerd Hoffmann @ 2012-11-27 8:47 UTC (permalink / raw)
To: Andreas Färber; +Cc: Julien Grall, qemu-devel
On 11/26/12 16:18, Andreas Färber wrote:
> Am 23.11.2012 16:48, schrieb Gerd Hoffmann:
>> diff --git a/hw/pm_smbus.c b/hw/pm_smbus.c
>> index 5d6046d..ea1380c 100644
>> --- a/hw/pm_smbus.c
>> +++ b/hw/pm_smbus.c
> [...]
>> @@ -170,7 +170,16 @@ uint32_t smb_ioport_readb(void *opaque, uint32_t addr)
>> return val;
>> }
>>
>> +static const MemoryRegionOps pm_smbus_ops = {
>> + .read = smb_ioport_readb,
>> + .write = smb_ioport_writeb,
>> + .valid.min_access_size = 1,
>> + .valid.max_access_size = 1,
>> + .endianness = DEVICE_LITTLE_ENDIAN,
>> +};
>
> I notice that in comparison to Julien's patch, you are setting .valid
> here where he used .impl.
Setting .valid matches previous behavior (only byte handlers registered).
I'm not fully sure what the defaults for .valid are in case only .impl
is specified. I usually either set .valid only or explicitly specify
both if I want the memory api split dword writes into bytes for me.
> Also a generic C question: When using C99-style struct initializers as
> for the MemoryRegionOps, I understand that the fields not explicitly
> assigned are zero-initialized. Does that also apply to .foo.bar = baz
> notation or would it be advisable to use nested .foo = { .bar = baz }?
As far I know the whole (outer) struct is zero-initialized.
cheers,
Gerd
^ permalink raw reply [flat|nested] 23+ messages in thread
end of thread, other threads:[~2012-11-27 8:47 UTC | newest]
Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [Qemu-devel] [PATCH 06/20] apci: switch cnt to memory api Gerd Hoffmann
2012-11-23 15:48 ` [Qemu-devel] [PATCH 07/20] apci: switch cnt to memory api [ich9] 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
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).