From: Avi Kivity <avi@redhat.com>
To: Anthony Liguori <anthony@codemonkey.ws>, qemu-devel@nongnu.org
Cc: kvm@vger.kernel.org
Subject: [Qemu-devel] [PATCH v2 01/24] apb_pci: convert to memory API
Date: Mon, 15 Aug 2011 17:17:15 +0300 [thread overview]
Message-ID: <1313417858-6454-2-git-send-email-avi@redhat.com> (raw)
In-Reply-To: <1313417858-6454-1-git-send-email-avi@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
---
hw/apb_pci.c | 84 +++++++++++++++++++++++++--------------------------------
1 files changed, 37 insertions(+), 47 deletions(-)
diff --git a/hw/apb_pci.c b/hw/apb_pci.c
index 1638226..6ee2068 100644
--- a/hw/apb_pci.c
+++ b/hw/apb_pci.c
@@ -31,7 +31,6 @@
#include "pci_host.h"
#include "pci_bridge.h"
#include "pci_internals.h"
-#include "rwhandler.h"
#include "apb_pci.h"
#include "sysemu.h"
#include "exec-memory.h"
@@ -70,7 +69,9 @@ do { printf("APB: " fmt , ## __VA_ARGS__); } while (0)
typedef struct APBState {
SysBusDevice busdev;
PCIBus *bus;
- ReadWriteHandler pci_config_handler;
+ MemoryRegion apb_config;
+ MemoryRegion pci_config;
+ MemoryRegion pci_ioport;
uint32_t iommu[4];
uint32_t pci_control[16];
uint32_t pci_irq_map[8];
@@ -81,7 +82,7 @@ typedef struct APBState {
} APBState;
static void apb_config_writel (void *opaque, target_phys_addr_t addr,
- uint32_t val)
+ uint64_t val, unsigned size)
{
APBState *s = opaque;
@@ -128,8 +129,8 @@ static void apb_config_writel (void *opaque, target_phys_addr_t addr,
}
}
-static uint32_t apb_config_readl (void *opaque,
- target_phys_addr_t addr)
+static uint64_t apb_config_readl (void *opaque,
+ target_phys_addr_t addr, unsigned size)
{
APBState *s = opaque;
uint32_t val;
@@ -176,33 +177,27 @@ static uint32_t apb_config_readl (void *opaque,
return val;
}
-static CPUWriteMemoryFunc * const apb_config_write[] = {
- &apb_config_writel,
- &apb_config_writel,
- &apb_config_writel,
+static const MemoryRegionOps apb_config_ops = {
+ .read = apb_config_readl,
+ .write = apb_config_writel,
+ .endianness = DEVICE_NATIVE_ENDIAN,
};
-static CPUReadMemoryFunc * const apb_config_read[] = {
- &apb_config_readl,
- &apb_config_readl,
- &apb_config_readl,
-};
-
-static void apb_pci_config_write(ReadWriteHandler *h, pcibus_t addr,
- uint32_t val, int size)
+static void apb_pci_config_write(void *opaque, target_phys_addr_t addr,
+ uint64_t val, unsigned size)
{
- APBState *s = container_of(h, APBState, pci_config_handler);
+ APBState *s = opaque;
val = qemu_bswap_len(val, size);
APB_DPRINTF("%s: addr " TARGET_FMT_lx " val %x\n", __func__, addr, val);
pci_data_write(s->bus, addr, val, size);
}
-static uint32_t apb_pci_config_read(ReadWriteHandler *h, pcibus_t addr,
- int size)
+static uint64_t apb_pci_config_read(void *opaque, target_phys_addr_t addr,
+ unsigned size)
{
uint32_t ret;
- APBState *s = container_of(h, APBState, pci_config_handler);
+ APBState *s = opaque;
ret = pci_data_read(s->bus, addr, size);
ret = qemu_bswap_len(ret, size);
@@ -252,16 +247,12 @@ static uint32_t pci_apb_ioreadl (void *opaque, target_phys_addr_t addr)
return val;
}
-static CPUWriteMemoryFunc * const pci_apb_iowrite[] = {
- &pci_apb_iowriteb,
- &pci_apb_iowritew,
- &pci_apb_iowritel,
-};
-
-static CPUReadMemoryFunc * const pci_apb_ioread[] = {
- &pci_apb_ioreadb,
- &pci_apb_ioreadw,
- &pci_apb_ioreadl,
+static const MemoryRegionOps pci_ioport_ops = {
+ .old_mmio = {
+ .read = { pci_apb_ioreadb, pci_apb_ioreadw, pci_apb_ioreadl },
+ .write = { pci_apb_iowriteb, pci_apb_iowritew, pci_apb_iowritel, },
+ },
+ .endianness = DEVICE_NATIVE_ENDIAN,
};
/* The APB host has an IRQ line for each IRQ line of each slot. */
@@ -393,10 +384,15 @@ static void pci_pbm_reset(DeviceState *d)
}
}
+static const MemoryRegionOps pci_config_ops = {
+ .read = apb_pci_config_read,
+ .write = apb_pci_config_write,
+ .endianness = DEVICE_NATIVE_ENDIAN,
+};
+
static int pci_pbm_init_device(SysBusDevice *dev)
{
APBState *s;
- int pci_config, apb_config, pci_ioport;
unsigned int i;
s = FROM_SYSBUS(APBState, dev);
@@ -408,27 +404,21 @@ static int pci_pbm_init_device(SysBusDevice *dev)
}
/* apb_config */
- apb_config = cpu_register_io_memory(apb_config_read,
- apb_config_write, s,
- DEVICE_NATIVE_ENDIAN);
+ memory_region_init_io(&s->apb_config, &apb_config_ops, s, "apb-config",
+ 0x10000);
/* at region 0 */
- sysbus_init_mmio(dev, 0x10000ULL, apb_config);
+ sysbus_init_mmio_region(dev, &s->apb_config);
- /* PCI configuration space */
- s->pci_config_handler.read = apb_pci_config_read;
- s->pci_config_handler.write = apb_pci_config_write;
- pci_config = cpu_register_io_memory_simple(&s->pci_config_handler,
- DEVICE_NATIVE_ENDIAN);
- assert(pci_config >= 0);
+ memory_region_init_io(&s->pci_config, &pci_config_ops, s, "apb-pci-config",
+ 0x1000000);
/* at region 1 */
- sysbus_init_mmio(dev, 0x1000000ULL, pci_config);
+ sysbus_init_mmio_region(dev, &s->pci_config);
/* pci_ioport */
- pci_ioport = cpu_register_io_memory(pci_apb_ioread,
- pci_apb_iowrite, s,
- DEVICE_NATIVE_ENDIAN);
+ memory_region_init_io(&s->pci_ioport, &pci_ioport_ops, s,
+ "apb-pci-ioport", 0x10000);
/* at region 2 */
- sysbus_init_mmio(dev, 0x10000ULL, pci_ioport);
+ sysbus_init_mmio_region(dev, &s->pci_ioport);
return 0;
}
--
1.7.5.3
next prev parent reply other threads:[~2011-08-15 14:17 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-15 14:17 [Qemu-devel] [PATCH v2 00/24] Memory API batch 4: more conversions Avi Kivity
2011-08-15 14:17 ` Avi Kivity [this message]
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 02/24] apic: convert to memory API Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 03/24] arm_gic: " Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 04/24] arm_sysctl: " Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 05/24] arm_timer: " Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 06/24] armv7m: " Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 07/24] gt64xxx.c: " Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 08/24] tusb6010: move declarations to new file tusb6010.h Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 09/24] omap_gpmc/nseries/tusb6010: convert to memory API Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 10/24] onenand: " Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 11/24] pcie_host: " Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 12/24] ppc405_uc: " Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 13/24] ppc4xx_sdram: " Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 14/24] stellaris_enet: " Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 15/24] sysbus: add a variant of sysbus_init_mmio_cb with an unmap callback Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 16/24] sh_pci: convert to memory API Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 17/24] arm11mpcore: use sysbus_init_mmio_cb2 Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 18/24] versatile_pci: convert to memory API Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 19/24] ppce500_pci: convert to sysbus_init_mmio_cb2() Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 20/24] sysbus: remove sysbus_init_mmio_cb() Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 21/24] isa: add isa_address_space() Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 22/24] pci: add pci_address_space() Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 23/24] vga: drop get_system_memory() from vga devices and derivatives Avi Kivity
2011-08-15 14:17 ` [Qemu-devel] [PATCH v2 24/24] 440fx: fix PAM, PCI holes Avi Kivity
2011-08-22 7:38 ` [Qemu-devel] [PATCH v2 00/24] Memory API batch 4: more conversions Avi Kivity
2011-08-22 16:33 ` 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=1313417858-6454-2-git-send-email-avi@redhat.com \
--to=avi@redhat.com \
--cc=anthony@codemonkey.ws \
--cc=kvm@vger.kernel.org \
--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).