qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
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 16/38] es1370: convert to memory API
Date: Wed,  3 Aug 2011 14:55:46 +0300	[thread overview]
Message-ID: <1312372568-5215-17-git-send-email-avi@redhat.com> (raw)
In-Reply-To: <1312372568-5215-1-git-send-email-avi@redhat.com>

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
---
 hw/es1370.c |   43 +++++++++++++++++++++++++------------------
 1 files changed, 25 insertions(+), 18 deletions(-)

diff --git a/hw/es1370.c b/hw/es1370.c
index 1ed62b7..6a01797 100644
--- a/hw/es1370.c
+++ b/hw/es1370.c
@@ -268,6 +268,7 @@ struct chan {
 typedef struct ES1370State {
     PCIDevice dev;
     QEMUSoundCard card;
+    MemoryRegion io;
     struct chan chan[NB_CHANNELS];
     SWVoiceOut *dac_voice[2];
     SWVoiceIn *adc_voice;
@@ -775,7 +776,6 @@ IO_READ_PROTO (es1370_readl)
     return val;
 }
 
-
 static void es1370_transfer_audio (ES1370State *s, struct chan *d, int loop_sel,
                                    int max, int *irq)
 {
@@ -906,23 +906,20 @@ static void es1370_adc_callback (void *opaque, int avail)
     es1370_run_channel (s, ADC_CHANNEL, avail);
 }
 
-static void es1370_map (PCIDevice *pci_dev, int region_num,
-                        pcibus_t addr, pcibus_t size, int type)
-{
-    ES1370State *s = DO_UPCAST (ES1370State, dev, pci_dev);
-
-    (void) region_num;
-    (void) size;
-    (void) type;
-
-    register_ioport_write (addr, 0x40 * 4, 1, es1370_writeb, s);
-    register_ioport_write (addr, 0x40 * 2, 2, es1370_writew, s);
-    register_ioport_write (addr, 0x40, 4, es1370_writel, s);
+static const MemoryRegionPortio es1370_portio[] = {
+    { 0, 0x40 * 4, 1, .write = es1370_writeb, },
+    { 0, 0x40 * 2, 2, .write = es1370_writew, },
+    { 0, 0x40, 4, .write = es1370_writel, },
+    { 0, 0x40 * 4, 1, .read = es1370_readb, },
+    { 0, 0x40 * 2, 2, .read = es1370_readw, },
+    { 0, 0x40, 4, .read = es1370_readl, },
+    PORTIO_END
+};
 
-    register_ioport_read (addr, 0x40 * 4, 1, es1370_readb, s);
-    register_ioport_read (addr, 0x40 * 2, 2, es1370_readw, s);
-    register_ioport_read (addr, 0x40, 4, es1370_readl, s);
-}
+static const MemoryRegionOps es1370_io_ops = {
+    .old_portio = es1370_portio,
+    .endianness = DEVICE_LITTLE_ENDIAN,
+};
 
 static const VMStateDescription vmstate_es1370_channel = {
     .name = "es1370_channel",
@@ -1011,7 +1008,8 @@ static int es1370_initfn (PCIDevice *dev)
     c[PCI_MIN_GNT] = 0x0c;
     c[PCI_MAX_LAT] = 0x80;
 
-    pci_register_bar (&s->dev, 0, 256, PCI_BASE_ADDRESS_SPACE_IO, es1370_map);
+    memory_region_init_io(&s->io, &es1370_io_ops, s, "es1370", 256);
+    pci_register_bar_region(&s->dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &s->io);
     qemu_register_reset (es1370_on_reset, s);
 
     AUD_register_card ("es1370", &s->card);
@@ -1019,6 +1017,14 @@ static int es1370_initfn (PCIDevice *dev)
     return 0;
 }
 
+static int es1370_exitfn(PCIDevice *dev)
+{
+    ES1370State *s = DO_UPCAST (ES1370State, dev, dev);
+
+    memory_region_destroy(&s->io);
+    return 0;
+}
+
 int es1370_init (PCIBus *bus)
 {
     pci_create_simple (bus, -1, "ES1370");
@@ -1031,6 +1037,7 @@ static PCIDeviceInfo es1370_info = {
     .qdev.size    = sizeof (ES1370State),
     .qdev.vmsd    = &vmstate_es1370,
     .init         = es1370_initfn,
+    .exit         = es1370_exitfn,
     .vendor_id    = PCI_VENDOR_ID_ENSONIQ,
     .device_id    = PCI_DEVICE_ID_ENSONIQ_ES1370,
     .class_id     = PCI_CLASS_MULTIMEDIA_AUDIO,
-- 
1.7.5.3

  parent reply	other threads:[~2011-08-03 11:56 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-03 11:55 [Qemu-devel] [PATCH v2 00/38] Memory API, batch 2: PCI devices Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 01/38] pci: add API to get a BAR's mapped address Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 02/38] vmsvga: don't remember pci BAR address in callback any more Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 03/38] vga: convert vga and its derivatives to the memory API Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 04/38] cirrus: simplify mmio BAR access functions Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 05/38] cirrus: simplify bitblt " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 06/38] cirrus: simplify vga window mmio " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 07/38] vga: " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 08/38] cirrus: simplify linear framebuffer " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 09/38] Integrate I/O memory regions into qemu Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 10/38] pci: pass I/O address space to new PCI bus Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 11/38] pci: allow I/O BARs to be registered with pci_register_bar_region() Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 12/38] rtl8139: convert to memory API Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 13/38] ac97: " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 14/38] e1000: " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 15/38] eepro100: " Avi Kivity
2011-08-03 11:55 ` Avi Kivity [this message]
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 17/38] ide: " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 18/38] ivshmem: " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 19/38] virtio-pci: " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 20/38] ahci: " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 21/38] intel-hda: " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 22/38] lsi53c895a: " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 23/38] ppc: " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 24/38] ne2000: " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 25/38] pcnet: " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 26/38] i6300esb: " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 27/38] isa-mmio: concert " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 28/38] sun4u: convert " Avi Kivity
2011-08-03 11:55 ` [Qemu-devel] [PATCH v2 29/38] ehci: " Avi Kivity
2011-08-03 11:56 ` [Qemu-devel] [PATCH v2 30/38] uhci: " Avi Kivity
2011-08-03 11:56 ` [Qemu-devel] [PATCH v2 31/38] xen-platform: " Avi Kivity
2011-08-03 11:56 ` [Qemu-devel] [PATCH v2 32/38] msix: " Avi Kivity
2011-08-03 11:56 ` [Qemu-devel] [PATCH v2 33/38] pci: remove pci_register_bar_simple() Avi Kivity
2011-08-03 11:56 ` [Qemu-devel] [PATCH v2 34/38] pci: convert pci rom to memory API Avi Kivity
2011-08-03 11:56 ` [Qemu-devel] [PATCH v2 35/38] pci: remove pci_register_bar() Avi Kivity
2011-08-03 11:56 ` [Qemu-devel] [PATCH v2 36/38] pci: fold BAR mapping function into its caller Avi Kivity
2011-08-03 11:56 ` [Qemu-devel] [PATCH v2 37/38] pci: rename pci_register_bar_region() to pci_register_bar() Avi Kivity
2011-08-03 11:56 ` [Qemu-devel] [PATCH v2 38/38] pci: remove support for pre memory API BARs Avi Kivity

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=1312372568-5215-17-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).