From: Anthony Liguori <aliguori@us.ibm.com>
To: qemu-devel@nongnu.org
Cc: Michael Tsirkin <mstirkin@redhat.com>,
Anthony Liguori <aliguori@us.ibm.com>, Alex Graf <agraf@suse.de>
Subject: [Qemu-devel] [PATCH 08/15] es1370: convert to new pci interface
Date: Tue, 9 Feb 2010 16:01:32 -0600 [thread overview]
Message-ID: <1265752899-26980-9-git-send-email-aliguori@us.ibm.com> (raw)
In-Reply-To: <1265752899-26980-1-git-send-email-aliguori@us.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
hw/es1370.c | 64 ++++++++++++++++++++++++++++++++--------------------------
1 files changed, 35 insertions(+), 29 deletions(-)
diff --git a/hw/es1370.c b/hw/es1370.c
index 40cb48c..fdf63f1 100644
--- a/hw/es1370.c
+++ b/hw/es1370.c
@@ -157,9 +157,9 @@ static const unsigned dac1_samplerate[] = { 5512, 11025, 22050, 44100 };
#define ADC_CHANNEL 2
#define IO_READ_PROTO(n) \
-static uint32_t n (void *opaque, uint32_t addr)
+static uint32_t n (ES1370State *s, uint32_t addr)
#define IO_WRITE_PROTO(n) \
-static void n (void *opaque, uint32_t addr, uint32_t val)
+static void n (ES1370State *s, uint32_t addr, uint32_t val)
static void es1370_dac1_callback (void *opaque, int free);
static void es1370_dac2_callback (void *opaque, int free);
@@ -474,7 +474,6 @@ static inline uint32_t es1370_fixup (ES1370State *s, uint32_t addr)
IO_WRITE_PROTO (es1370_writeb)
{
- ES1370State *s = opaque;
uint32_t shift, mask;
addr = es1370_fixup (s, addr);
@@ -512,7 +511,6 @@ IO_WRITE_PROTO (es1370_writeb)
IO_WRITE_PROTO (es1370_writew)
{
- ES1370State *s = opaque;
addr = es1370_fixup (s, addr);
uint32_t shift, mask;
struct chan *d = &s->chan[0];
@@ -549,7 +547,6 @@ IO_WRITE_PROTO (es1370_writew)
IO_WRITE_PROTO (es1370_writel)
{
- ES1370State *s = opaque;
struct chan *d = &s->chan[0];
addr = es1370_fixup (s, addr);
@@ -613,9 +610,22 @@ IO_WRITE_PROTO (es1370_writel)
}
}
+static void es1370_write (PCIDevice *dev, pcibus_t addr, int size,
+ uint32_t value)
+{
+ ES1370State *s = DO_UPCAST (ES1370State, dev, dev);
+
+ if (size == 1) {
+ es1370_writeb (s, addr, value);
+ } else if (size == 2) {
+ es1370_writew (s, addr, value);
+ } else {
+ es1370_writel (s, addr, value);
+ }
+}
+
IO_READ_PROTO (es1370_readb)
{
- ES1370State *s = opaque;
uint32_t val;
addr = es1370_fixup (s, addr);
@@ -650,7 +660,6 @@ IO_READ_PROTO (es1370_readb)
IO_READ_PROTO (es1370_readw)
{
- ES1370State *s = opaque;
struct chan *d = &s->chan[0];
uint32_t val;
@@ -692,7 +701,6 @@ IO_READ_PROTO (es1370_readw)
IO_READ_PROTO (es1370_readl)
{
- ES1370State *s = opaque;
uint32_t val;
struct chan *d = &s->chan[0];
@@ -775,6 +783,21 @@ IO_READ_PROTO (es1370_readl)
return val;
}
+static uint32_t es1370_read (PCIDevice *dev, pcibus_t addr, int size)
+{
+ ES1370State *s = DO_UPCAST(ES1370State, dev, dev);
+ uint32_t val;
+
+ if (size == 1) {
+ val = es1370_readb (s, addr);
+ } else if (size == 2) {
+ val = es1370_readw (s, addr);
+ } else {
+ val = es1370_readl (s, addr);
+ }
+
+ return val;
+}
static void es1370_transfer_audio (ES1370State *s, struct chan *d, int loop_sel,
int max, int *irq)
@@ -802,7 +825,7 @@ static void es1370_transfer_audio (ES1370State *s, struct chan *d, int loop_sel,
if (!acquired)
break;
- cpu_physical_memory_write (addr, tmpbuf, acquired);
+ pci_memory_write (&s->dev, addr, tmpbuf, acquired);
temp -= acquired;
addr += acquired;
@@ -816,7 +839,7 @@ static void es1370_transfer_audio (ES1370State *s, struct chan *d, int loop_sel,
int copied, to_copy;
to_copy = audio_MIN ((size_t) temp, sizeof (tmpbuf));
- cpu_physical_memory_read (addr, tmpbuf, to_copy);
+ pci_memory_read (&s->dev, addr, tmpbuf, to_copy);
copied = AUD_write (voice, tmpbuf, to_copy);
if (!copied)
break;
@@ -906,24 +929,6 @@ 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);
-
- 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 VMStateDescription vmstate_es1370_channel = {
.name = "es1370_channel",
.version_id = 2,
@@ -1023,7 +1028,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);
+ pci_register_io_region (&s->dev, 0, 256, PCI_BASE_ADDRESS_SPACE_IO,
+ es1370_read, es1370_write);
qemu_register_reset (es1370_on_reset, s);
AUD_register_card ("es1370", &s->card);
--
1.6.5.2
next prev parent reply other threads:[~2010-02-09 22:02 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-09 22:01 [Qemu-devel] [PATCH 0/15][RFC] New PCI interfaces Anthony Liguori
2010-02-09 22:01 ` [Qemu-devel] [PATCH 01/15] pci: add new bus functions Anthony Liguori
2010-02-10 8:09 ` Isaku Yamahata
2010-02-10 8:57 ` [Qemu-devel] " Michael S. Tsirkin
2010-02-09 22:01 ` [Qemu-devel] [PATCH 02/15] rtl8139: convert to new PCI interfaces Anthony Liguori
2010-02-09 22:01 ` [Qemu-devel] [PATCH 03/15] lsi53c895a: convert to new pci interfaces Anthony Liguori
2010-02-09 22:01 ` [Qemu-devel] [PATCH 04/15] e1000: convert to new pci interface Anthony Liguori
2010-02-09 22:01 ` [Qemu-devel] [PATCH 05/15] wdt_i6300esb: fix io type leakage Anthony Liguori
2010-02-09 22:01 ` [Qemu-devel] [PATCH 06/15] wdt_i6300esb: convert to new pci inteface Anthony Liguori
2010-02-09 22:01 ` [Qemu-devel] [PATCH 07/15] ac97: convert to new PCI API Anthony Liguori
2010-02-09 22:45 ` malc
2010-02-09 22:52 ` Anthony Liguori
2010-02-09 23:06 ` malc
2010-02-09 23:10 ` Anthony Liguori
2010-02-09 23:36 ` malc
2010-02-09 23:52 ` Anthony Liguori
2010-02-10 0:24 ` malc
2010-02-11 14:20 ` Anthony Liguori
2010-02-09 22:01 ` Anthony Liguori [this message]
2010-02-09 22:01 ` [Qemu-devel] [PATCH 09/15] eepro100: convert to new pci interface Anthony Liguori
2010-02-10 6:32 ` Stefan Weil
2010-02-10 9:49 ` [Qemu-devel] " Michael S. Tsirkin
2010-02-10 10:43 ` Markus Armbruster
2010-02-10 10:48 ` Michael S. Tsirkin
2010-02-10 14:13 ` [Qemu-devel] " Anthony Liguori
2010-02-09 22:01 ` [Qemu-devel] [PATCH 10/15] virtio-pci: " Anthony Liguori
2010-02-09 22:01 ` [Qemu-devel] [PATCH 11/15] pci: add pci_register_msix_region Anthony Liguori
2010-02-09 22:01 ` [Qemu-devel] [PATCH 12/15] ne2000: convert to new pci interface Anthony Liguori
2010-02-09 22:01 ` [Qemu-devel] [PATCH 13/15] pcnet: " Anthony Liguori
2010-02-09 22:01 ` [Qemu-devel] [PATCH 14/15] usb-uhci: " Anthony Liguori
2010-02-09 22:01 ` [Qemu-devel] [PATCH 15/15] pci: byte swap as PCI interface layer Anthony Liguori
2010-02-10 9:31 ` [Qemu-devel] Re: [PATCH 0/15][RFC] New PCI interfaces Michael S. Tsirkin
2010-02-10 18:34 ` [Qemu-devel] " Blue Swirl
2010-02-10 19:29 ` Anthony Liguori
2010-02-10 20:41 ` Richard Henderson
2010-02-10 21:13 ` Anthony Liguori
2010-02-12 17:40 ` Blue Swirl
2010-03-01 2:51 ` Paul Brook
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=1265752899-26980-9-git-send-email-aliguori@us.ibm.com \
--to=aliguori@us.ibm.com \
--cc=agraf@suse.de \
--cc=mstirkin@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).