From: "Benoît Canet" <benoit.canet@gmail.com>
To: qemu-devel@nongnu.org
Cc: "Benoît Canet" <benoit.canet@gmail.com>, avi@redhat.com
Subject: [Qemu-devel] [PATCH v3 03/11] mcf_fec: convert to memory API
Date: Tue, 22 Nov 2011 21:34:54 +0100 [thread overview]
Message-ID: <1321994102-28263-4-git-send-email-benoit.canet@gmail.com> (raw)
In-Reply-To: <1321994102-28263-1-git-send-email-benoit.canet@gmail.com>
Signed-off-by: Benoît Canet <benoit.canet@gmail.com>
---
hw/mcf.h | 3 ++-
hw/mcf5208.c | 3 ++-
hw/mcf_fec.c | 38 +++++++++++++++++++-------------------
3 files changed, 23 insertions(+), 21 deletions(-)
diff --git a/hw/mcf.h b/hw/mcf.h
index e2f6727..2f88ff0 100644
--- a/hw/mcf.h
+++ b/hw/mcf.h
@@ -18,7 +18,8 @@ void mcf_uart_mm_init(struct MemoryRegion *sysmem,
qemu_irq *mcf_intc_init(target_phys_addr_t base, CPUState *env);
/* mcf_fec.c */
-void mcf_fec_init(NICInfo *nd, target_phys_addr_t base, qemu_irq *irq);
+void mcf_fec_init(struct MemoryRegion *sysmem, NICInfo *nd,
+ target_phys_addr_t base, qemu_irq *irq);
/* mcf5206.c */
qemu_irq *mcf5206_init(struct MemoryRegion *sysmem,
diff --git a/hw/mcf5208.c b/hw/mcf5208.c
index 0119430..e03d80b 100644
--- a/hw/mcf5208.c
+++ b/hw/mcf5208.c
@@ -234,7 +234,8 @@ static void mcf5208evb_init(ram_addr_t ram_size,
exit(1);
}
if (nd_table[0].vlan)
- mcf_fec_init(&nd_table[0], 0xfc030000, pic + 36);
+ mcf_fec_init(address_space_mem, &nd_table[0],
+ 0xfc030000, pic + 36);
/* 0xfc000000 SCM. */
/* 0xfc004000 XBS. */
diff --git a/hw/mcf_fec.c b/hw/mcf_fec.c
index 42a5d77..ae37bef 100644
--- a/hw/mcf_fec.c
+++ b/hw/mcf_fec.c
@@ -10,6 +10,7 @@
#include "mcf.h"
/* For crc32 */
#include <zlib.h>
+#include "exec-memory.h"
//#define DEBUG_FEC 1
@@ -23,8 +24,9 @@ do { printf("mcf_fec: " fmt , ## __VA_ARGS__); } while (0)
#define FEC_MAX_FRAME_SIZE 2032
typedef struct {
+ MemoryRegion *sysmem;
+ MemoryRegion iomem;
qemu_irq *irq;
- int mmio_index;
NICState *nic;
NICConf conf;
uint32_t irq_state;
@@ -214,7 +216,8 @@ static void mcf_fec_reset(mcf_fec_state *s)
s->rfsr = 0x500;
}
-static uint32_t mcf_fec_read(void *opaque, target_phys_addr_t addr)
+static uint64_t mcf_fec_read(void *opaque, target_phys_addr_t addr,
+ unsigned size)
{
mcf_fec_state *s = (mcf_fec_state *)opaque;
switch (addr & 0x3ff) {
@@ -251,7 +254,8 @@ static uint32_t mcf_fec_read(void *opaque, target_phys_addr_t addr)
}
}
-static void mcf_fec_write(void *opaque, target_phys_addr_t addr, uint32_t value)
+static void mcf_fec_write(void *opaque, target_phys_addr_t addr,
+ uint64_t value, unsigned size)
{
mcf_fec_state *s = (mcf_fec_state *)opaque;
switch (addr & 0x3ff) {
@@ -429,23 +433,18 @@ static ssize_t mcf_fec_receive(VLANClientState *nc, const uint8_t *buf, size_t s
return size;
}
-static CPUReadMemoryFunc * const mcf_fec_readfn[] = {
- mcf_fec_read,
- mcf_fec_read,
- mcf_fec_read
-};
-
-static CPUWriteMemoryFunc * const mcf_fec_writefn[] = {
- mcf_fec_write,
- mcf_fec_write,
- mcf_fec_write
+static const MemoryRegionOps mcf_fec_ops = {
+ .read = mcf_fec_read,
+ .write = mcf_fec_write,
+ .endianness = DEVICE_NATIVE_ENDIAN,
};
static void mcf_fec_cleanup(VLANClientState *nc)
{
mcf_fec_state *s = DO_UPCAST(NICState, nc, nc)->opaque;
- cpu_unregister_io_memory(s->mmio_index);
+ memory_region_del_subregion(s->sysmem, &s->iomem);
+ memory_region_destroy(&s->iomem);
g_free(s);
}
@@ -458,18 +457,19 @@ static NetClientInfo net_mcf_fec_info = {
.cleanup = mcf_fec_cleanup,
};
-void mcf_fec_init(NICInfo *nd, target_phys_addr_t base, qemu_irq *irq)
+void mcf_fec_init(MemoryRegion *sysmem, NICInfo *nd,
+ target_phys_addr_t base, qemu_irq *irq)
{
mcf_fec_state *s;
qemu_check_nic_model(nd, "mcf_fec");
s = (mcf_fec_state *)g_malloc0(sizeof(mcf_fec_state));
+ s->sysmem = sysmem;
s->irq = irq;
- s->mmio_index = cpu_register_io_memory(mcf_fec_readfn,
- mcf_fec_writefn, s,
- DEVICE_NATIVE_ENDIAN);
- cpu_register_physical_memory(base, 0x400, s->mmio_index);
+
+ memory_region_init_io(&s->iomem, &mcf_fec_ops, s, "fec", 0x400);
+ memory_region_add_subregion(sysmem, base, &s->iomem);
s->conf.macaddr = nd->macaddr;
s->conf.vlan = nd->vlan;
--
1.7.7.3
next prev parent reply other threads:[~2011-11-22 20:35 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-22 20:34 [Qemu-devel] [PATCH v3 00/11] more memory API conversions Benoît Canet
2011-11-22 20:34 ` [Qemu-devel] [PATCH v3 01/11] mcf5206: convert to memory API Benoît Canet
2011-11-22 20:34 ` [Qemu-devel] [PATCH v3 02/11] mcf_uart: " Benoît Canet
2011-11-22 20:34 ` Benoît Canet [this message]
2011-11-22 20:34 ` [Qemu-devel] [PATCH v3 04/11] mcf_intc: " Benoît Canet
2011-11-22 20:34 ` [Qemu-devel] [PATCH v3 05/11] lm32_uart: " Benoît Canet
2011-11-22 20:34 ` [Qemu-devel] [PATCH v3 06/11] lm32_sys: " Benoît Canet
2011-11-22 20:34 ` [Qemu-devel] [PATCH v3 07/11] bonito: convert north bridge register mapping " Benoît Canet
2011-11-22 23:03 ` Peter Maydell
2011-11-23 17:55 ` Benoît Canet
2011-11-23 18:25 ` Peter Maydell
2011-11-24 8:40 ` Avi Kivity
2011-11-24 8:47 ` Benoît Canet
2011-11-22 20:34 ` [Qemu-devel] [PATCH v3 08/11] bonito: convert north bridge pci config " Benoît Canet
2011-11-22 20:35 ` [Qemu-devel] [PATCH v3 09/11] bonito: convert south " Benoît Canet
2011-11-22 20:35 ` [Qemu-devel] [PATCH v3 10/11] bonito: convert ldma " Benoît Canet
2011-11-22 20:35 ` [Qemu-devel] [PATCH v3 11/11] bonito: convert cop " Benoît Canet
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=1321994102-28263-4-git-send-email-benoit.canet@gmail.com \
--to=benoit.canet@gmail.com \
--cc=avi@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.